Posted September 27, 20159 yr hey guys really stuck here, Can't figure out why my texture rendering isn't working. I THINK it is a path issue. I am using the forge eclipse environment. main class: package statslevelmod; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.relauncher.Side; @Mod(modid = Level.MODID, name = Level.MODNAME, version = Level.VERSION) public class Level { public static final String MODID = "statslevelmod"; public static final String MODNAME = "Level"; public static final String VERSION = "1.0.1"; public static Item sharpstick; @EventHandler public void preInit (FMLPreInitializationEvent event) { System.out.println("Loading " + MODNAME + "!"); System.out.println("Version " + VERSION + "!"); sharpstick = new SharpStick(); MinecraftForge.EVENT_BUS.register(new LevelEventHandler()); GameRegistry.addRecipe(new ItemStack(sharpstick), "A ", " A", 'A', Items.stick); } @EventHandler public void init(FMLInitializationEvent event) { if (event.getSide() == Side.CLIENT) { regTexture(sharpstick); } } @EventHandler public void postInt (FMLPostInitializationEvent event) { System.out.println(MODID + " loaded successfuly!"); } public static void regTexture(Item item) { Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(MODID + ":" + item.getUnlocalizedName().substring(5), "inventory")); <----- where the error occurs. } } My Event Handler Class: package statslevelmod; import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityItem; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class LevelEventHandler { @SubscribeEvent public void onPlayerMineEvent(PlayerEvent.BreakSpeed event) { if (event.state.getBlock() == Blocks.log) { event.newSpeed = -1; } else { event.newSpeed = -1; } } @SubscribeEvent public void onPlayerClickEvent(PlayerInteractEvent event) { if (event.action == Action.RIGHT_CLICK_BLOCK) { if (event.entityPlayer.getCurrentEquippedItem() == null) { if (event.world.getBlockState(event.pos).getBlock() == Blocks.grass && event.face == event.face.UP) { if (!event.world.isRemote) { event.world.setBlockState(event.pos, Blocks.dirt.getDefaultState()); Block.spawnAsEntity(event.world, event.pos, new ItemStack(Level.sharpstick)); } } } } } } My Item Class package statslevelmod; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraftforge.fml.common.registry.GameRegistry; public class SharpStick extends Item { private final String name = "sharpStick"; public SharpStick() { super(); GameRegistry.registerItem(this, name); setCreativeTab(CreativeTabs.tabMisc); setUnlocalizedName(name); setMaxStackSize(64); } } My Item JSON file: { "parent":"builtin/generated", "textures": { "layer0":"statslevelmod:items/sharpStick" }, "display": { "thirdperson": { "rotation": [ -90, 0, 0 ], "translation": [ 0, 1, -3 ], "scale": [ 0.55, 0.55, 0.55 ] }, "firstperson": { "rotation": [ 0, -135, 25 ], "translation": [ 0, 4, 2 ], "scale": [ 1.7, 1.7, 1.7 ] } } } This is a screenshot of my Package Explorer: http://i.imgur.com/Vnhc4zX.png Any help is greatly appreciated, thanks
September 27, 20159 yr Author Textures must be registered in init, not preInit. Thanks! that fixed the crash but the item has no texture, so probably I have a pathing problem also.
September 27, 20159 yr Author FIXED IT! Basically I copied and pasted my asset folder and subfolders everywhere, found it worked, so deleted one at a time to find the right one
September 27, 20159 yr Textures must be registered in init, not preInit. This is the case if you're using the vanilla ItemModelMesher#register methods (like the OP is), but Forge's ModelLoader#setCustomModelResourceLocation and ModelLoader.setCustomMeshDefinition methods (which do the same thing as the vanilla methods) need to be called in preInit rather than init. 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.