Jump to content

[1.8.9-11.15.0.1705] Item renders as black and purple cube


Recommended Posts

Posted

Trying to get back into modding, and the new rendering system doesn't seem to complicated, except I can't get it to work. The item renders as a black and purple cube in my inventory.

 

ead408d004.png

 

Here's the console output: http://pastebin.com/BjWcKWkG

 

And here's the code:

 

 

Inside main mod class

    @Mod.EventHandler
    public void onPreInitialization(FMLPreInitializationEvent event) {
        FMLLog.info("Currently initializing %s version %s,", Reference.MOD_ID, Reference.VERSION);
        ConfigurationHandler.init(event.getSuggestedConfigurationFile());

        ModItems.init();
        proxy.onPreInitialization(event);
    }

    @Mod.EventHandler
    public void onInitialization(FMLInitializationEvent event) {

        proxy.onInitialization(event);
    }

    @Mod.EventHandler
    public void onPostInitializing(FMLPostInitializationEvent event) {
        proxy.onPostInitializationEvent(event);
        FMLLog.info("Finished initializing.");
    }

 

Inside the ClientProxy class

    @Override
    public void onPreInitialization(FMLPreInitializationEvent event) {
        // register key bindings
    }

    @Override
    public void onInitialization(FMLInitializationEvent event) {
        ResourceLocationHelper.registerItemRenderer(ModItems.denseMatterVessel);
    }

 

Inside ResourceLocationHelper

    public static void registerItemRenderer(ItemQSBase item) {
        Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(
                item,
                0,
                new ModelResourceLocation(
                        Reference.UNIVERSAL_PREFIX + Reference.MOD_ID_LOWERCASE + item.getUnwrappedUnlocalizedName(),
                        "inventory"
                )
        );
    }

 

Inside the ModItems class

    public static ItemDenseMatterVessel denseMatterVessel;

    public static void init() {
        GameRegistry.registerItem(denseMatterVessel = new ItemDenseMatterVessel(), "denseMatterVessel");

        denseMatterVessel.setCreativeTab(CreativeTabQuantumStorage.INSTANCE);
    }

 

Inside the ItemDenseMatterVessel class

    public class ItemDenseMatterVessel extends Item {

    public ItemDenseMatterVessel() {
        // UNIVERSAL_PREFIX is "quantumstorage:"
        setUnlocalizedName(Reference.UNIVERSAL_PREFIX + unlocalizedNameBase);
    }

}

Posted

Minecraft only loads one model per item by default, the name of this model is the item's registry name (the name passed to

GameRegistry.registerItem

or

Item#setRegistryName

). If you want to load a different model or multiple models, you need to call

ModelBakery.registerItemVariants

with the locations of those models.

 

I would highly recommend using Forge's

ModelLoader.setCustomModelResourceLocation

and

ModelLoader.setCustomMeshDefinition

methods in preInit instead of the vanilla

ItemModelMesher#register

overloads in init.

ModelLoader.setCustomModelResourceLocation

will call

ModelBakery.registerItemVariants

with the model location for you.

 

I would also recommend setting the registry names of your items with

Item#setRegistryName

and registering them with

GameRegistry.registerItem(Item)

. You can get an item's registry name in the

"modid:name"

format from

Item#getRegistryName

. This also applies to blocks.

 

I have a whole bunch of model registration code for my item models here. I use Forge's blockstates format and Java 8 features quite a lot in my mod.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

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.