Sunday, 24 May 2015

Common Mistakes with Item Models

The diagram below shows some of the typical files needed to render a simple item (ItemMT01) with an autogenerated model based on a texture.  The most common errors are highlighted. 

For the list of symptoms that these errors produce, see here.

For common mistakes in Blocks, Items which are based on Blocks, or Items with more complicated models, see here.

For Items with subtypes (this.setHasSubtypes(true);), you need to register the subtype names properly using ModelBakery.  If your item has subtypes but you want the registry to ignore metadata, use the "anonymous class" technique below instead
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(itemVariants, 
  new ItemMeshDefinition()     {
      public ModelResourceLocation getModelLocation(ItemStack stack) {
        return new ModelResourceLocation("spawn_egg", "inventory");
      }
    });

A useful breakpoint to solve registration problems is to set a breakpoint at

ItemModelMesher::
public IBakedModel getItemModel(ItemStack stack)
{
    Item item = stack.getItem();
    IBakedModel ibakedmodel = this.getItemModel(item, this.getMetadata(stack));
}

You can then trace in, to compare 1) the model that your item is looking for, against 2) the contents of the registry.  Where they don't match, you can usually see why immediately.





1 comment:

  1. Nice! I just got a Minecraft card code for FREE! :D http://freeminecraftgiftcode.net

    ReplyDelete