Posted October 17, 20168 yr Ok i want to set a texture to my item but how? code of item: package item; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import reference.Reference; public class itemXelaMod extends Item { public itemXelaMod() { super(); } @Override public String getUnlocalizedName() { return String.format("item.%s%s", Reference.MOD_ID.toLowerCase() + ":", getUnwrappedUnlocalizedName(super.getUnlocalizedName())); } @Override public String getUnlocalizedName(ItemStack itemstack) { return String.format("item.%s%s", Reference.MOD_ID.toLowerCase() + ":", getUnwrappedUnlocalizedName(super.getUnlocalizedName())); } private Object getUnwrappedUnlocalizedName(String unlocalizedName) { return unlocalizedName.substring(unlocalizedName.indexOf(".")+ 1); } } package item; public class itemHoja extends itemXelaMod { public itemHoja() { super(); this.setUnlocalizedName("Hoja"); } } register the item package init; import item.itemHoja; import item.itemXelaMod; import net.minecraftforge.fml.common.registry.GameRegistry; public class ModItems { public static final itemXelaMod hoja = new itemHoja(); public static void init() { GameRegistry.registerItem(hoja, "Hoja"); } } In my Main class public void preInit(FMLPreInitializationEvent e) { ModItems.init(); }
October 17, 20168 yr First off you probably should look at a tutorial first. Here a 1.8 tutorial set that is in 1.8.9 but most of the concepts will apply to 1.10.2 http://bedrockminer.jimdo.com/modding-tutorials/basic-modding-1-8/ Here is also the official documentation for forge https://mcforge.readthedocs.io/en/latest/ . Once you read these you'll be able to do anything with MC well programming wise.
October 17, 20168 yr Author i followed exactrly this tutorial: http://bedrockminer.jimdo.com/modding-tutorials/basic-modding-1-8/first-item/ but dont work i mean i have an error loading model model of my item: { "parent":"xelamod:item/firstItem", "textures": { "layer0":"xelamod:items/itemHoja" } } model of standart item: { "parent":"builtin/generated", "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 ] } } } my packcages: subir imagen
October 17, 20168 yr 1) Do not use GameRegistry.registerItem() , just simply use GameRegistry.register() . The registration was streamlined some time ago. 2) You are never setting a RegistryName for this item, as fas as I can see. 3) Please dear god of any religion, burn the tutorials that use Minecraft::register() . You need to use ModelLoader instead. Minecraft::register is VERY prone to cause issues, which is why forge provides its own rendering registration. 4) Don't extend builtin/generated. I believe you should extend item/generated instead. Not at my pc so cannot check the exact name. 5) If you get an error in your console, then -please- post that error here. We cannot know the full issue without the cause. I have a very simple tutorial on how to register and render items here. It demonstrates looped registration vs. monotonous retyping the same lines over and over, so do carry that in mind. Stick to either the simple or looped files Also previously known as eAndPi. "Pi, is there a station coming up where we can board your train of thought?" -Kronnn Published Mods: Underworld Handy links: Vic_'s Forge events Own WIP Tutorials.
October 17, 20168 yr Author Error: [15:40:40] [Client thread/ERROR] [FML]: Exception loading model for variant xelamod:Hoja#inventory for item "xelamod:Hoja", normal location exception: net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model xelamod:item/Hoja with loader VanillaLoader.INSTANCE, skipping at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:153) ~[ModelLoaderRegistry.class:?] at net.minecraftforge.client.model.ModelLoader.loadItemModels(ModelLoader.java:317) ~[ModelLoader.class:?] at net.minecraft.client.renderer.block.model.ModelBakery.loadVariantItemModels(ModelBakery.java:170) ~[ModelBakery.class:?] at net.minecraftforge.client.model.ModelLoader.setupModelRegistry(ModelLoader.java:147) ~[ModelLoader.class:?] at net.minecraft.client.renderer.block.model.ModelManager.onResourceManagerReload(ModelManager.java:28) [ModelManager.class:?] at net.minecraft.client.resources.SimpleReloadableResourceManager.registerReloadListener(SimpleReloadableResourceManager.java:122) [simpleReloadableResourceManager.class:?] at net.minecraft.client.Minecraft.startGame(Minecraft.java:540) [Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:386) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_60] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_60] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_60] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_60] at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_60] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_60] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_60] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_60] at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?] at GradleStart.main(GradleStart.java:26) [start/:?] Caused by: java.io.FileNotFoundException: xelamod:models/item/Hoja.json at net.minecraft.client.resources.FallbackResourceManager.getResource(FallbackResourceManager.java:68) ~[FallbackResourceManager.class:?] at net.minecraft.client.resources.SimpleReloadableResourceManager.getResource(SimpleReloadableResourceManager.java:65) ~[simpleReloadableResourceManager.class:?] at net.minecraft.client.renderer.block.model.ModelBakery.loadModel(ModelBakery.java:311) ~[ModelBakery.class:?] at net.minecraftforge.client.model.ModelLoader.access$1100(ModelLoader.java:118) ~[ModelLoader.class:?] at net.minecraftforge.client.model.ModelLoader$VanillaLoader.loadModel(ModelLoader.java:868) ~[ModelLoader$VanillaLoader.class:?] at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:149) ~[ModelLoaderRegistry.class:?] ... 20 more [15:40:40] [Client thread/ERROR] [FML]: Exception loading model for variant xelamod:Hoja#inventory for item "xelamod:Hoja", blockstate location exception: net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model xelamod:Hoja#inventory with loader VariantLoader.INSTANCE, skipping at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:153) ~[ModelLoaderRegistry.class:?] at net.minecraftforge.client.model.ModelLoader.loadItemModels(ModelLoader.java:325) ~[ModelLoader.class:?] at net.minecraft.client.renderer.block.model.ModelBakery.loadVariantItemModels(ModelBakery.java:170) ~[ModelBakery.class:?] at net.minecraftforge.client.model.ModelLoader.setupModelRegistry(ModelLoader.java:147) ~[ModelLoader.class:?] at net.minecraft.client.renderer.block.model.ModelManager.onResourceManagerReload(ModelManager.java:28) [ModelManager.class:?] at net.minecraft.client.resources.SimpleReloadableResourceManager.registerReloadListener(SimpleReloadableResourceManager.java:122) [simpleReloadableResourceManager.class:?] at net.minecraft.client.Minecraft.startGame(Minecraft.java:540) [Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:386) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_60] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_60] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_60] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_60] at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_60] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_60] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_60] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_60] at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?] at GradleStart.main(GradleStart.java:26) [start/:?] Caused by: net.minecraft.client.renderer.block.model.ModelBlockDefinition$MissingVariantException at net.minecraft.client.renderer.block.model.ModelBlockDefinition.getVariant(ModelBlockDefinition.java:78) ~[ModelBlockDefinition.class:?] at net.minecraftforge.client.model.ModelLoader$VariantLoader.loadModel(ModelLoader.java:1184) ~[ModelLoader$VariantLoader.class:?] at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:149) ~[ModelLoaderRegistry.class:?] ... 20 more commonProxy package com.xelatercero.xelamod; import com.xelatercero.xelamod.items.ModItems; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; public class CommonProxy { public void preInit(FMLPreInitializationEvent e) { ModItems.createItems(); } public void init(FMLInitializationEvent e) { } public void postInit(FMLPostInitializationEvent e) { } } ClientProxy package com.xelatercero.xelamod; import com.xelatercero.xelamod.client.render.items.ItemRenderRegister; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; public class ClientProxy extends CommonProxy { @Override public void preInit(FMLPreInitializationEvent e) { super.preInit(e); } @Override public void init(FMLInitializationEvent e) { super.init(e); ItemRenderRegister.registerItemRenderer(); } @Override public void postInit(FMLPostInitializationEvent e) { super.postInit(e); } } ModItems package com.xelatercero.xelamod.items; import net.minecraft.item.Item; import net.minecraftforge.fml.common.registry.GameRegistry; public final class ModItems { public static Item itemHoja; public static void createItems() { GameRegistry.registerItem(itemHoja = new BasicItem("Hoja"), "Hoja"); } } BasicITEM class package com.xelatercero.xelamod.items; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; public class BasicItem extends Item { public BasicItem(String unlocalizedName) { super(); this.setUnlocalizedName(unlocalizedName); this.setCreativeTab(CreativeTabs.MATERIALS); } } ItemRenderRegister package com.xelatercero.xelamod.client.render.items; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.item.Item; import com.xelatercero.xelamod.items.ModItems; import Reference.Reference;; public class ItemRenderRegister { public static String modid = Reference.MOD_ID; public static void registerItemRenderer() { reg(ModItems.itemHoja); } public static void reg(Item item) { Minecraft.getMinecraft().getRenderItem().getItemModelMesher() .register(item, 0, new ModelResourceLocation(modid + ":" + item.getUnlocalizedName().substring(5), "inventory")); } } ok i am very new at this, so i will apreciate you to explain me what i done wrong
October 17, 20168 yr setRegistryName(unlocalizedName) without this it won't know what the item is cause Forge doesn't use numbers for block/item ids anymore but instead uses the registry name. also models get loaded in @Sided(Side.Client) only while the rest of the code is loaded in common In my mod I separated model loading which is in ModelHandler for items and blocks from blocks ModBlocks and items ModItems and recipes ModRecipes. Also EVERY block needs to have: 1. a blockstate 2. item block + item block model that has parent your mod block 3. block model . Disclaimer: I been told to keep my opinions to myself, to shut up and that I am spreading lies and misinformation or even that my methods are unorthodox and or too irregular. Here are my suggestions take it or leave it.
October 17, 20168 yr No. Never set the RegistryName FROM the UnlocalizedName. If anything, it is supposed to be the other way around. Unlocalized name can change at any time. RegistryName should NOT change, as that will erase any crafted/placed items/blocks in any map with the old RegistryName. And either in your item/blocks constructor, or when you are registering it. Also previously known as eAndPi. "Pi, is there a station coming up where we can board your train of thought?" -Kronnn Published Mods: Underworld Handy links: Vic_'s Forge events Own WIP Tutorials.
October 17, 20168 yr Author ok i will keep in mind but can anyone tell me how do i fix my problem i mean look to my error and tell me what can i do or what i did wrong
October 17, 20168 yr Author ok nvm i will go to learn some ordinary java because this is too much for me i dont understant almost nothing
October 17, 20168 yr The issue is caused by a missing file. Caused by: java.io.FileNotFoundException: xelamod:models/item/Hoja.json It is looking for a file in src/main/resources/assets/xelamod/models/item, which is called Hoja.json. Also previously known as eAndPi. "Pi, is there a station coming up where we can board your train of thought?" -Kronnn Published Mods: Underworld Handy links: Vic_'s Forge events Own WIP Tutorials.
October 17, 20168 yr No. Never set the RegistryName FROM the UnlocalizedName. If anything, it is supposed to be the other way around. Unlocalized name can change at any time. RegistryName should NOT change, as that will erase any crafted/placed items/blocks in any map with the old RegistryName. And either in your item/blocks constructor, or when you are registering it. That's complete BS. Unlocalized name does not change only your lang file changes Registry name is the name of your block/item A block called "BIG_BLOCK" with the unlocalizedName "bigBlock" and registry name "bigBlock" in lang file you can translate in various language say French tile.bigBlock.name=Bloque Grande how did the unlocalized name change? What can make unlocalized name change? Not sure where you got that information that unlocalizedName can change any time but is incorrect. At least no longer in 1.10.2+ .As far as i know you can have multiple unlocalized names based on meta/blockstate for one block/item but they will ALWAYS stay the same unless you change them manually in code. Unlocalized name can always change if YOU change it. Disclaimer: I been told to keep my opinions to myself, to shut up and that I am spreading lies and misinformation or even that my methods are unorthodox and or too irregular. Here are my suggestions take it or leave it.
October 17, 20168 yr Here is what my BaseBlock class looks like public class BaseBlock extends Block { public BaseBlock(String name, Material materialIn, MapColor mapcolorIn) { super(materialIn, mapcolorIn); this.setUnlocalizedName(name); this.setRegistryName(name); this.setCreativeTab(ModData.CREATIVE_TAB); } } I don't know what the user above is saying but my unlocalized name has never randomly changed EVER. This makes it easy because I know my unlocalized name in lang is same as png file name and same as registry name for the block. steamBoiler.png steamBoiler (block) tile.steamBoiler.name=SteamBoiler life is easy Disclaimer: I been told to keep my opinions to myself, to shut up and that I am spreading lies and misinformation or even that my methods are unorthodox and or too irregular. Here are my suggestions take it or leave it.
October 17, 20168 yr Author Its strange because i al 100℅ sure that existe Hoja.json un src/main/resources/assets/models/items/Hoja.json
October 17, 20168 yr how did the unlocalized name change? What can make unlocalized name change? Item Variants. Duh. Did you really think that all 16 wool colors had the same unlocalized name? No, they don't. Also, setUnlocalizedName will not throw an error if an unlocalized name has already been set. setRegistryName absolutely will. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
October 17, 20168 yr Its strange because i al 100℅ sure that existe Hoja.json un src/main/resources/assets/models/items/Hoja.json You forgot your modid between assets and models: (.../assets/modid/models/...). Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
October 17, 20168 yr Author oh sorry i forgot o write that but yes i have my mod id : C:\Users\alex\Desktop\modwork\mods\1.7\xelamod\src\main\resources\assets\xelamod\models\item
October 17, 20168 yr make sure your file and folder names are in all lower case. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
October 17, 20168 yr Author yes my folders are in lower case you can see it in my last reply, and i changed the name of the json file to lower case, but nothing, but one question why he is searching Hoja.json i have hoja.json but if i change it to Hoja.json same error
October 17, 20168 yr why he is searching Hoja.json Its because you set your item's registry name as "Hoja" with a capital (go look at your code). Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
October 17, 20168 yr Author no its in lower case GameRegistry.registerItem(itemHoja = new BasicItem("hoja"), "hoja");
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.