Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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);
    }

}

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.