Jump to content

Recommended Posts

Posted
2 minutes ago, Doublecaster said:

I believe that the JSON file names are case sensitive. Try renaming itemvapestick.json to ItemVapeStick.json

Nope, that didn´t help.

Posted

Items and other IForgeRegistryEntry implementations must be registered in RegistryEvent.Register<> event.
Models must be registered with ModelLoader in ModelRegistryEvent event client-side.

Documentation on events here.
Documentation on 'registering things' here.
A proper way to register a model of an item is

ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory"));


Please share this message to similar threads so people don't waste their time writing it over and over again.

  • Like 1
Posted (edited)

Found your problem. You're assigning "ItemVapeStick" as a registry name. Everything related to resources must be lowercase.

In order for models to function properly in IDE, you might need to have pack format set to 3.
Create pack.mcmeta file in resources directory with the following content:

{
    "pack": {
        "description": "Mod's resources",
        "pack_format": 3
    }
}



By the way, what the pokemon is VapeItems enum in Reference.java? I kinda understand what it's for, but it only makes code hard to read and confuses everyone.

Edited by MrBendelScrolls
Sneaky 8-length tab
  • Like 1
Posted

So...

I tried to fix the ModItems.java but I feel like I just more screwed it up... Here is a result:

public class ModItems {
    
    public static Item vapestick;
    
    public static void init() {
        
        vapestick = new ItemVapeStick();
    }
    
    public static void register() {
        GameRegistry.register(vapestick);
    }
    
    public static void registerRenders() {
        registerRender(vapestick);
    }
    
    private static void registerRender(Item item) {
        System.out.println(item.getRegistryName());
        ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory"));
    }

    public class EventHandler {
        @SubscribeEvent
        public void pickupItem(EntityItemPickupEvent event) {
            System.out.println("Item picked up!");
        }
            public void registerBlocks(RegistryEvent.Register<Block> event) {
                event.getRegistry().registerAll();
        }
    }

}
 

 

Then in resources, there was pack.mcmeta file already so I edited it (in nope pad) and NoBrainly changed the code to that one you wrote above and lost the original code. After that, I couldn´t run the game, so I was forced to delete the file.

 

I am a real beginner in MC modding and I just feel like I´m not able to do it. Would you be so kind and explain to me how to Register that item. I´m super confused off that article. I just wanted to learn something new. :)

 

Posted

This is a good example of using registry events.
One note: client-side ModelLoader can crash a server and shouldn't be used in common code. Solve it your way, just a call to proxy is ok.

 

18 minutes ago, Rasdek11 said:

Then in resources, there was pack.mcmeta file already so I edited it (in nope pad) and NoBrainly changed the code to that one you wrote above and lost the original code. After that, I couldn´t run the game, so I was forced to delete the file.

My fault, sorry. I gave you invalid code, there must be description field.

{
    "pack": {
        "description": "Mod's resources",
        "pack_format": 3
    }
}
Posted
11 hours ago, diesieben07 said:

It's one of the many MrCrayfish abominations that everyone blindly copies.

So what should I do then... Do you know any other tutorials with updated codes?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.