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

I'm trying to make a mod that changes vanilla item model based off of its name or lore. But before I get to that, I'm trying to get it to even change the model in the first place! Nothing seems to happen. Am I missing anything?

 

Main mod file:

http://pastebin.com/KKhrD2bC

 

CustomItemModel:

http://pastebin.com/sEXEffZ9

 

TestDiamondSwordModel:

http://pastebin.com/hbjSJsaN

  • Author

Also, I noticed that MinecraftForgeClient.registerItemRenderer is not a thing in 1.9. Any reason for this?

  • Author

I'm sorry, I tried reading it, but I can't quite understand what exactly I need to do. Could you please explain to me?

Make a class that implements

ICustomModelLoader

. In

accepts

return true if it is the RL for your Item. In loadModel return a new IModel. In the IModel:

bake

: return a new instance of your ISmartItemModel.

getDependencies

/

getTextures

: Return ImmutableList.of() (the empty list).

getDefaultState

: Return TRSRTransformation.identiy.

 

Then register your loader using

ModelLoaderRegistry.registerLoader

in preInit. You now no longer need the bake event handler.

The difference for you is that you have a texture to return and you will probably be using IBakedModle instead of ISmartItemModel

Current Project: Armerger 

Planned mods: Light Drafter  | Ore Swords

Looking for help getting a mod off the ground? Coding  | Textures

  • Author

Wouldn't an IBakedModel require me to model it in Techne? I want to use it with Minecraft json models, supplied by the resource pack.

  • Author

I figured out that you can use ItemOverrideList and handleItemState to get the itemstack info, but now I need to know how to generate a baked model from a model json file.

I haven't done that myself but minecrafts model loader also implements ICustomModelLoader so if you look around through that you should be able to see how they do it.

 

In case you don't know:

right click -> the 3 opens are a great way to trace through classes and method calls.

 

Current Project: Armerger 

Planned mods: Light Drafter  | Ore Swords

Looking for help getting a mod off the ground? Coding  | Textures

  • Author

It seems the problem with ItemMeshDefinition is that getModelLocation() is never called. I can't figure out why.

  • Author

I discovered in ItemModelMesher:

 

public IBakedModel getItemModel(ItemStack stack)

    {

        Item item = stack.getItem();

        IBakedModel ibakedmodel = this.getItemModel(item, this.getMetadata(stack));

 

        if (ibakedmodel == null)

        {

            ItemMeshDefinition itemmeshdefinition = (ItemMeshDefinition)this.shapers.get(item);

 

            if (itemmeshdefinition != null)

            {

                ibakedmodel = this.modelManager.getModel(itemmeshdefinition.getModelLocation(stack));

            }

        }

 

        if (ibakedmodel == null)

        {

            ibakedmodel = this.modelManager.getMissingModel();

        }

 

        return ibakedmodel;

    }

 

Does that mean that it's only called for nonexistent meshes? (It checks if baked mesh is null first)

  • Author

@SuppressWarnings("unchecked")

private void removeItemFromMesher(Item item, int meta) {

try {

Field field1 = ItemModelMesher.class.getDeclaredField("simpleShapesCache");

field1.setAccessible(true);

Map<Integer, IBakedModel> simpleShapesCache = (Map<Integer, IBakedModel>) field1.get(getMesher());

simpleShapesCache.remove(getIndex(item, meta));

field1.set(getMesher(), simpleShapesCache);

Field field2 = ItemModelMesher.class.getDeclaredField("simpleShapes");

field2.setAccessible(true);

Map<Integer, ModelResourceLocation> simpleShapes = (Map<Integer, ModelResourceLocation>) field2.get(getMesher());

simpleShapes.remove(getIndex(item, meta));

field2.set(getMesher(), simpleShapes);

} catch (NoSuchFieldException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (SecurityException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (IllegalArgumentException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (IllegalAccessException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

 

 

I tried doing this on postinit, but it did nothing.

  • Author

I GOT IT TO WORK WITH ICUSTOMMODELLOADER! :D

 

It now looks like a potato unless it is named Apple, in which case it looks like an apple. It works as expected :)

 

My new code: http://pastebin.com/bQAWSUVx

 

Now that I know how, I can use that same concept to make an actual system for it. (Code is very hacky, so anyone reading this shouldn't copy and paste ;))

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.