Posted July 30, 20178 yr I'm currently trying to have an ItemBlock change models depending on its variant which is set in the item's NBT data. Currently This is what I have: Registry: public class RegisterUtil { public static void registerAll (FMLPreInitializationEvent event) { registerArcadeMachine(event, ArcadeBlocks.arcadeMachine); } private static void registerBlockWavefrontMeshDefinition (Item item, Block block) { registerItemBlock(item, block); OBJLoader.INSTANCE.addDomain(Reference.MODID); if (item instanceof IItemMeshDefinition) { ModelLoader.setCustomMeshDefinition(item, ((IItemMeshDefinition)item).getMeshDefinition()); for (EnumGame g : EnumGame.values()) { ModelBakery.registerItemVariants(item, new ModelResourceLocation(block.getRegistryName(), "game=" + g.getName())); // Gives me missing model error //ModelBakery.registerItemVariants(item, new ModelResourceLocation(block.getRegistryName().toString() + "_" + g.getName(), "inventory")); // Says parent can't have non-vanilla model (or something along those lines) } //ModelBakery.registerItemVariants(item, new ModelResourceLocation(block.getRegistryName(), "game")); // Gives me missing model error //ModelBakery.registerItemVariants(item, new ModelResourceLocation(block.getRegistryName(), "inventory")); // No error, no model/textures } } @Deprecated private static void registerArcadeMachine (FMLPreInitializationEvent event, Block block) { final ItemBlockArcade item = new ItemBlockArcade(block); if (event.getSide() == Side.CLIENT) registerBlockWavefrontMeshDefinition(item, block); } private static void registerBlock (Block block) { GameRegistry.register(block.setUnlocalizedName(block.getRegistryName().toString())); } private static void registerItemBlock (Item item, Block block) { registerBlock(block); GameRegistry.register(item, block.getRegistryName()); } } ItemBlock: public class ItemBlockArcade extends ItemBlock implements IItemMeshDefinition { public ItemBlockArcade (Block block) { super(block); setMaxDamage(0); setHasSubtypes(true); } public int getMetadata (int damage) { return damage; } // Not really sure how to use ItemMeshDefinition @Override @SideOnly(Side.CLIENT) public ItemMeshDefinition getMeshDefinition () { return new ItemMeshDefinition() { @Override public ModelResourceLocation getModelLocation(ItemStack stack) { //if (stack.hasTagCompound()) return new ModelResourceLocation(Reference.MODID + ":arcade_machine_" + EnumMob.getName(stack.getTagCompound().getInteger("Game")), "inventory"); //else return new ModelResourceLocation(Reference.MODID + ":arcade_machine_snake", "inventory"); if (stack.hasTagCompound()) return new ModelResourceLocation(Reference.MODID + ":arcade_machine", "game=" + EnumMob.getName(stack.getTagCompound().getInteger("Game"))); else return new ModelResourceLocation(Reference.MODID + ":arcade_machine", "game=snake"); } }; } } Blockstate Json { "forge_marker": 1, "defaults": { "model": "arcademod:arcade_machine.obj", "transform": "forge:default-block" }, "variants": { "inventory": [{ "model": "arcademod:arcade_machine.obj", "textures": { "#all": "arcademod:blocks/snake/bottom" } }], "game": { "snake": { "textures": { "#all": "arcademod:blocks/snake/bottom" } }, "tetrominoes": { "textures": { "#all": "arcademod:blocks/tetrominoes/back_panel" } } }, "facing": { "south": { "y": 0 }, "west": { "y": 90 }, "north": { "y": 180 }, "east": { "y": 270 } } } } All the ways I tried so far have just given me a purple/black texture and loaded no model. I'm pretty sure I'm doing something super simple incorrectly. Edited July 30, 20178 yr by SuperHB MobDrops http://www.planetminecraft.com/mod/125-mobdrops/
July 30, 20178 yr Your blockstates file has two properties (game and facing), but the ModelResourceLocation you return from the ItemMeshDefinition only includes one of them. It needs to include both, in alphabetical order. You should also call ModelBakery.registerItemVariants with every possible ModelResourceLocation that can be returned by the ItemMeshDefinition to ensure that they're loaded by Minecraft. 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.
July 30, 20178 yr Author 2 hours ago, Choonster said: Your blockstates file has two properties (game and facing), but the ModelResourceLocation you return from the ItemMeshDefinition only includes one of them. It needs to include both, in alphabetical order. You should also call ModelBakery.registerItemVariants with every possible ModelResourceLocation that can be returned by the ItemMeshDefinition to ensure that they're loaded by Minecraft. Thank you! That fixed everything. MobDrops http://www.planetminecraft.com/mod/125-mobdrops/
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.