Jump to content

Radiophex

Members
  • Posts

    13
  • Joined

  • Last visited

Everything posted by Radiophex

  1. I'm kinda confused here. I am not sure what an ItemBlock is or how it works. Does it have to do with a block .json? Could I get a small example? My apologies
  2. I'm kinda confused here. I am not sure what an ItemBlock is or how it works. Does it have to do with a block .json? Could I get a small example? My apologies
  3. In the mod I am creating, I am attempting to register a block. However, the game seems to crash now that I have attempted to do so. I have my code and an error message that seems to be useful to display. Here they are: The blocks are registered under preInit() in FirstMod.java and the class that makes the blocks (BlockMaker.java) and the class with the Block registering methods (MyBlocks.java) are in the init package. What can I do to fix the crashing and be able to spawn in the block? If you need any more information, I would be more than happy to share it. [move]Thank you![/move]
  4. In the mod I am creating, I am attempting to register a block. However, the game seems to crash now that I have attempted to do so. I have my code and an error message that seems to be useful to display. Here they are: The blocks are registered under preInit() in FirstMod.java and the class that makes the blocks (BlockMaker.java) and the class with the Block registering methods (MyBlocks.java) are in the init package. What can I do to fix the crashing and be able to spawn in the block? If you need any more information, I would be more than happy to share it. [move]Thank you![/move]
  5. This worked, thank you!
  6. This worked, thank you!
  7. gladly! Here is the code for the class MyItems.java (which is where the registering takes place): package wes.firstmod.init; import wes.firstmod.FirstMod; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.item.Item; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.fml.common.registry.GameRegistry; public class MyItems { public static Item cheese; /*public static void preInit() { }*/ public static void register() { Item cheeseName = cheese.setRegistryName("cheese"); GameRegistry.register(cheeseName); } public static void init() { cheese = new Item().setUnlocalizedName("cheese"); } public static void registerRender(Item item) { ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(FirstMod.MODID + ":" + item.getRegistryName(), "inventory")); } public static void registerRenders() { registerRender(cheese); } } Also, in the class FirstMod.java, the registries are called (forgot to add this previously, my apologies): package wes.firstmod; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; 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 wes.firstmod.init.MyItems; @Mod(modid = FirstMod.MODID, version = FirstMod.VERSION) public class FirstMod { public static final String MODID = "firstmod"; public static final String VERSION = "1.0"; @EventHandler public void preInit(FMLPreInitializationEvent event) { MyRecipes.addRecipes(); MyItems.init(); MyItems.register(); } @EventHandler public void init(FMLInitializationEvent event) { MyRecipes.addRecipes(); MyItems.registerRenders(); } @EventHandler public void postInit(FMLPostInitializationEvent event) { } } Items are registered in preInit()
  8. gladly! Here is the code for the class MyItems.java (which is where the registering takes place): package wes.firstmod.init; import wes.firstmod.FirstMod; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.item.Item; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.fml.common.registry.GameRegistry; public class MyItems { public static Item cheese; /*public static void preInit() { }*/ public static void register() { Item cheeseName = cheese.setRegistryName("cheese"); GameRegistry.register(cheeseName); } public static void init() { cheese = new Item().setUnlocalizedName("cheese"); } public static void registerRender(Item item) { ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(FirstMod.MODID + ":" + item.getRegistryName(), "inventory")); } public static void registerRenders() { registerRender(cheese); } } Also, in the class FirstMod.java, the registries are called (forgot to add this previously, my apologies): package wes.firstmod; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; 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 wes.firstmod.init.MyItems; @Mod(modid = FirstMod.MODID, version = FirstMod.VERSION) public class FirstMod { public static final String MODID = "firstmod"; public static final String VERSION = "1.0"; @EventHandler public void preInit(FMLPreInitializationEvent event) { MyRecipes.addRecipes(); MyItems.init(); MyItems.register(); } @EventHandler public void init(FMLInitializationEvent event) { MyRecipes.addRecipes(); MyItems.registerRenders(); } @EventHandler public void postInit(FMLPostInitializationEvent event) { } } Items are registered in preInit()
  9. I am trying to load an item's model and .png using a .json file, but the item just loads as a pink and black block. here is my .json code: { "parent": "builtin/generated", "textures": { "layer0": "firstmod:items/cheese" }, "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] } } } I have also pinned some errors in the debug console that I think may help with this situation. Also, I have a picture of my package viewer if that is useful: So, how would I be able to render the object as the .png without it looking like a massive pink and blue block? If you need more information on the project (more code, images, etc.), I will be more than happy to provide it. Thank you!
  10. I am trying to load an item's model and .png using a .json file, but the item just loads as a pink and black block. here is my .json code: { "parent": "builtin/generated", "textures": { "layer0": "firstmod:items/cheese" }, "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] } } } I have also pinned some errors in the debug console that I think may help with this situation. Also, I have a picture of my package viewer if that is useful: So, how would I be able to render the object as the .png without it looking like a massive pink and blue block? If you need more information on the project (more code, images, etc.), I will be more than happy to provide it. Thank you!
  11. Alrighty, I think I got it all fixed up. Thanks again for the help! I also have another question, would there ever be a case when modding where I would need to use an unlocalized name? I just want to know for future reference.
  12. Alright, I changed the subject. I am using 1.9.4 I tried to do what you listed and it all worked! I may have gotten a bit confused and did something different, but I got it to work overall. I split the registering and items into two classes. MyItems.java: package wes.firstmod; import wes.firstmod.FirstMod; //import net.minecraft.client.Minecraft; //import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.item.Item; //import net.minecraft.util.ResourceLocation; //import net.minecraftforge.client.model.ModelLoader; //import net.minecraftforge.fml.common.registry.GameRegistry; public class MyItems { public static Item cheese; public static void init() { cheese = new Item().setUnlocalizedName("cheese"); } } and MyItemRegistry.java: package wes.firstmod; import wes.firstmod.FirstMod; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.item.Item; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.fml.common.registry.GameRegistry; public class MyItemRegistry { public static Item cheese = MyItems.cheese; public static void register() { Item cheeseName = cheese.setRegistryName("item_cheese"); GameRegistry.register(cheeseName); } public static void registerRender(Item item) { ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(FirstMod.MODID + ":" + item.getRegistryName(), "inventory")); } public static void registerRenders() { registerRender(MyItems.cheese); } } I just wanted to make sure this is what you were telling me, I tried my best to follow the list since my knowledge is limited. EDIT: I have a question, as well. What is the point of an unlocalized name? It doesn't look like there is a use to it, but I am probably very wrong Thanks a ton for helping! +1
  13. I am using a book that I got from a summer camp to make a mod step-by-step. I do have a basic knowledge of Java before attending this camp, but not of minecraft's source code. so, I have a class in my mod package that is supposed to register and render custom items. However, the import for ModelResourceLocation will not work correctly for me, as it is put into the code exactly as it is in the book. here is the class's code: package wes.firstmod; import wes.firstmod.FirstMod; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.item.Item; import net.minecraftforge.fml.common.registry.GameRegistry; public class MyItems { public static Item cheese; public static void init() { cheese = new Item().setUnlocalizedName("cheese"); } public static void register() { GameRegistry.registerItem(cheese, cheese.getUnlocalizedName().substring(5)); } public static void registerRender(Item item) { Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(FirstMod.MODID + ":" + item.getUnlocalizedName().substring(5), "inventory")); } public static void registerRenders() { registerRender(cheese); } } The import line for ModelResourceLocation has an error. import net.minecraft.client.resources.model.ModelResourceLocation; which causes this line to error as well: Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(FirstMod.MODID + ":" + item.getUnlocalizedName().substring(5), "inventory")); however, in the import line, the only part that seems to error is this part: "net.minecraft.client.resources.model" How would I be able to fix this? I am willing to give more information if required. Thanks!
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.