The 32767 did the trick. I did manage, however, to screw SOMETHING up, and now my names are all item.soup.c.name and so on. Additionally, I've been following a tutorial for custom blocks; I did the updates from 1.11 to 1.12, but the block has yet to show up anywhere. My code has been updated at https://github.com/TheWebExpert1/davidblocks.
I had followed mcjty's example, but hadn't combined that with your note on refining the code. Now, as mcjty promised, I have a basic block with no texture - and with no "friendly" name. I've been poking around looking to find out how to fix both issues, but have come up dry. I've posted the current code at https://github.com/TheWebExpert1/davidblocks.
I have problems with mcjty. First, his examples are themselves incomplete (they even say so). A block with no texture isn't much of a block. Second, if you download his code, it has errors in the DataBlock module; once you eliminate all references to that, everything ELSE should work... but NONE of it does. Not a single block gets registered.
I was actually successful in creating a custom mob with his code - it works exactly as specified - but I really, REALLY need my blocks right!
If I eliminate the line in registerBlocks, the block doesn't get registered. If I eliminate the line in registerModels, the block doesn't get registered. Only with both there does it actually show up, albeit with the default texture.
I fixed the registry name, the path to the parent file, and the texture aspect ratios. I'm still not getting the texture, and the image is still displaying "newmod:tutorial_ore#inventory" over the texture. The updated code has been posted.
This duplicates what's happening in ItemInit for the items. Now, the block exists - yet it still has no texture, and is still showing the text over the default texture. The NAME is right, the block is there, but still no texture.
public static BlockTutorialOre tutorial_ore = (BlockTutorialOre) new BlockTutorialOre("tutorial_ore", 2.0F, 4.0F, 2).setRegistryName("tutorial_ore").setUnlocalizedName("tutorial_ore");
public static final Item tutorial_oreitem = new ItemBlock(tutorial_ore).setRegistryName("tutorial_ore").setUnlocalizedName("tutorial_oreitem");
@SubscribeEvent
public static void registerBlocks(RegistryEvent.Register<Block> event)
{
event.getRegistry().register(tutorial_ore);
}
@SubscribeEvent
public static void registerItems(RegistryEvent.Register<Item> event)
{
event.getRegistry().register(tutorial_oreitem);
}
@SubscribeEvent
@SideOnly(Side.CLIENT)
public static void registerModels(ModelRegistryEvent event)
{
registerEverything(tutorial_ore);
}
private static void registerItem(Item item)
{
ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory"));
}
public static void registerEverything(Block block)
{
ForgeRegistries.BLOCKS.register(block);
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), 0, new ModelResourceLocation(block.getRegistryName(), "inventory"));
}
You said that the ItemBlock was being created in the wrong place, but not what the RIGHT place was. Beyond what I've posted here, I really don't understand what I've missed. I copied everything relevant from ItemBlock... I get the block, with the correct friendly name, but no texture, and the text written on it.
public static BlockTutorialOre tutorial_ore = (BlockTutorialOre) new BlockTutorialOre("tutorial_ore", 2.0F, 4.0F, 2).setRegistryName("tutorial_ore").setUnlocalizedName("tutorial_ore");
public static final Item tutorial_oreitem = new ItemBlock(tutorial_ore).setRegistryName("tutorial_ore").setUnlocalizedName("tutorial_oreitem");
@SubscribeEvent
public static void registerBlocks(RegistryEvent.Register<Block> event)
{
event.getRegistry().register(tutorial_ore);
}
@SubscribeEvent
public static void registerItems(RegistryEvent.Register<Item> event)
{
event.getRegistry().register(tutorial_oreitem);
//ForgeRegistries.ITEMS.register(tutorial_oreitem.setRegistryName(tutorial_oreitem.getRegistryName()));
}
@SubscribeEvent
@SideOnly(Side.CLIENT)
public static void registerModels(ModelRegistryEvent event)
{
registerModel(tutorial_ore);
}
public static void registerModel(Block block)
{
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), 0, new ModelResourceLocation(block.getRegistryName(), "inventory"));
}
I removed the ForgeRegistries.BLOCKS.register, and renamed the function registerModel. I also got rid of the registerItem method. I tried adding the remarked out line in registeredItems, but it causes the game to crash. Additionally, I don't understand what you mean by "repoint the Item model to the parent Block model by changing it's path[/i]" or where the path in the Block model is.
I really wish I understood what you were talking about. I fixed the texture paths; I don't have any idea how to "pass it into event.getRegistry" as you've specified. I did this:
public static BlockTutorialOre tutorial_ore = (BlockTutorialOre) new BlockTutorialOre("tutorial_ore", 2.0F, 4.0F, 2).setRegistryName("tutorial_ore").setUnlocalizedName("tutorial_ore");
public static final Item tutorial_oreitem = new ItemBlock(tutorial_ore).setRegistryName("tutorial_ore").setUnlocalizedName("tutorial_oreitem");
@SubscribeEvent
public static void registerBlocks(RegistryEvent.Register<Block> event)
{
event.getRegistry().register(tutorial_ore);
}
@SubscribeEvent
public static void registerItems(RegistryEvent.Register<Item> event)
{
event.getRegistry().register(tutorial_oreitem);
}
@SubscribeEvent
@SideOnly(Side.CLIENT)
public static void registerModels(ModelRegistryEvent event)
{
registerModel(tutorial_ore);
}
public static void registerModel(Block block)
{
ForgeRegistries.ITEMS.register(tutorial_oreitem.setRegistryName(tutorial_oreitem.getRegistryName()));
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), 0, new ModelResourceLocation(block.getRegistryName(), "inventory"));
}
However, the game crashes. The original line "ForgeRegistries.ITEMS.register(new ItemBlock(block).setRegistryName(block.getRegistryName()));" also crashes the game. I really, REALLY want to understand what I'm doing wrong so that I won't repeat the mistakes, but I'm having trouble figuring out exactly what it is you want me to do.
Thank you. I understand what a field is, but I wasn't sure where to put it in this code. I also understand about passing parameters; again, I wasn't sure where or how, in this instance. This is different from the Java code I've done before, or at least it seems to be. I'll keep studying anyway.
I just finished following a custom armor and custom tool tutorial by Harry's Tech Reviews (). I even downloaded HIS code and ran THAT. Well, his code (and the code I've posted at https://github.com/TheWebExpert1/davidblocks) both have the same problem: The tools & armor in the inventory (and in your hand) have no texture. The armor on you (or on the armor stand) is right, but not in hand or in the GUI. I've asked him for help, but since his own code isn't working, I'm not sure what to do.
Yes, I know there are probably some better ways to code this than what he's done, and I'm open to constructive suggestions. For instance, since I have three separate sets of armor (& tools), I thought maybe I could create a set of Enums and use those, rather than calling each separately, as I'm currently doing, but I'm not sure how to do it.
Also: I don't understand how my Items & Blocks don't need a call to .register & .init in the RegistryHandler class to get onto the inventory, but the armor and tools do. There's something different happening, and I'm trying to understand what it is, so I can clean up the code.
I've got to really, REALLY thank you, CSB... you've been very, very patient with me. I saw you getting a bit hot under the collar in a couple of posts, because I wasn't seeing the forest for the trees, but this particular post was OVERWHELMINGLY helpful.
First, I essentially duplicated the procedures from the ItemInit class into my ToolInit class. I moved the declarations of the items outside of the Init function, and deleted the Init function. I also eliminated the contents of the proxy classes, and deleted the RegistryHandler class. Once I got the @EventBusSubscriber and RegistryEvents in place, my pickaxe and helmet FINALLY showed up, complete with texture, but in the inventory and in hand. (I just did the pickaxe and helmet until I was sure the code worked).
I just KNEW there was something "off" about the tutorial I was following (although it worked for HIM), because even his own code didn't run properly; I'm guessing it's a version difference, that MC 1.12 handles things slightly differently than from the version he was apparently coding for.
The documents you linked to are great; I'm afraid I'll have to re-read them several times before I fully understand everything there. I get the basic concepts; but there's a lot more there than just the basic concepts. I'm sure I'll need to know more than that as I proceed.
Right now, all my blocks are identical, my food is identical, and my armor & tool values are identical. Eventually, I'll change the values to ones that make sense for what I'm creating, plus add custom sounds. Right now, it's enough that they're appearing. All of the "extra" stuff can wait; I'm just focusing on creating them, plus the relevant crafting recipes & smelting recipes, and making sure all THAT works -- BEFORE delving further into the other areas.
Once again, I thank you from the bottom of my heart. You've made it possible for me to continue what I'm doing. I have a few complex ideas in mind (yeah, biting off more than I can chew, I know), but I knew I had to start with the "simple" things first. Now, on with the coding...
Well, it's a minor thing (get it minor? miner? lols!)...
But the armor stands are holding my custom swords strangely (picture attached).
I know it's a little nit-picky, but there's no reason (that I know of) that the custom swords should be held any differently from a standard one. I've added the code from the original sword into my code, but that didn't seem to help. Got any ideas?
I have a couple of interesting problem,s which I've been banging my head against the wall with for the last hour or two; you could probably solve them in .05 seconds.
1st: I've created a new block, CeramicBlock, but the texture doesn't show up in the inventory. I've checked everything (I think), and everything LOOKS good, but no texture.
2nd: I have a block called CompressorBlock, which is currently just a furnace with a new face. The block places properly (including facing) and gives the furnace GUI. I'll eventually replace that with my own. The main problem is that its texture isn't showing up in inventory, either.
3rd: I've tried to create a Block with subtypes; I registered it the same way I'm registering my Items with subtypes... but it's not registering properly. Not only do I not get the texture, I get the name across the default texture, and it's not showing me the subtypes at all. I'm sure there's a way to do it, but I'm missing something fundamental here.
I see that CJ has a couple of tutorials on GUIS & containers, plus a couple of others I'm interested in, so I'll be watching those. I know I've missed something simple here, but I just can't see what it is. I've posted the new code at https://github.com/TheWebExpert1/davidblocks.
I guess it's just too long staring at the code. I have no idea how I missed the registration. The mismatched names wasn't blatantly obvious, until I really started looking for it.
My 3rd problem still persists, and is the only error showing in the console. It's trying to access "blok", rather than "blokc" and "bloks", which should be the proper subtypes. Since it's being done the same way as InitItem in InitBlock, I have no idea what's wrong; in hand, it defaults to the copper texture (I got THAT part), but has no texture on the ground, and the 2nd block isn't anywhere. I gather that they're not being registered properly, but I'm just not sure what I'm doing wrong.
Finally, there's the danged furnace (compressor). I am aware that it's not just a simple "copy pasta" (more like "copy filet mignon"), but I've copied over, virtually unchanged, everything from the furnace class. Theoretically, when you load the "compressor," it should change the texture to the compressoron texture... but it's changing to the FURNACE_ON texture instead, and spitting out the contents. I'm not sure what the problem is at this point; I'm still looking through the code for clues.
I copied it from the forgeSrc-1.12-14.21.1.2443.jar, under net.minecraft.tileentity.TileEntityFurnace class; I needed my own version of this; however, I've been unsuccessful in getting rid of all the prior instances of TileEntityFurnace, such as:
If I try to change it to TileEntityFurnace, it throws a conniption fit. Perhaps there's something missing in this code? I wouldn't think so, offhand, as this is the latest version of forge.
The 32767 did the trick. I did manage, however, to screw SOMETHING up, and now my names are all item.soup.c.name and so on. Additionally, I've been following a tutorial for custom blocks; I did the updates from 1.11 to 1.12, but the block has yet to show up anywhere. My code has been updated at https://github.com/TheWebExpert1/davidblocks.
I had followed mcjty's example, but hadn't combined that with your note on refining the code. Now, as mcjty promised, I have a basic block with no texture - and with no "friendly" name. I've been poking around looking to find out how to fix both issues, but have come up dry. I've posted the current code at https://github.com/TheWebExpert1/davidblocks.
I have problems with mcjty. First, his examples are themselves incomplete (they even say so). A block with no texture isn't much of a block. Second, if you download his code, it has errors in the DataBlock module; once you eliminate all references to that, everything ELSE should work... but NONE of it does. Not a single block gets registered.
I was actually successful in creating a custom mob with his code - it works exactly as specified - but I really, REALLY need my blocks right!
If I eliminate the line in registerBlocks, the block doesn't get registered. If I eliminate the line in registerModels, the block doesn't get registered. Only with both there does it actually show up, albeit with the default texture.
I fixed the registry name, the path to the parent file, and the texture aspect ratios. I'm still not getting the texture, and the image is still displaying "newmod:tutorial_ore#inventory" over the texture. The updated code has been posted.
I think I *FINALLY* understand what you're talking about. I've modified my BlockInit class, as follows:
This duplicates what's happening in ItemInit for the items. Now, the block exists - yet it still has no texture, and is still showing the text over the default texture. The NAME is right, the block is there, but still no texture.
The previous post has the code for registering the ItemBLock.
Here is my updated code:
You said that the ItemBlock was being created in the wrong place, but not what the RIGHT place was. Beyond what I've posted here, I really don't understand what I've missed. I copied everything relevant from ItemBlock... I get the block, with the correct friendly name, but no texture, and the text written on it.
I'm still at a loss to understand.
I removed the ForgeRegistries.BLOCKS.register, and renamed the function registerModel. I also got rid of the registerItem method. I tried adding the remarked out line in registeredItems, but it causes the game to crash. Additionally, I don't understand what you mean by "repoint the Item model to the parent Block model by changing it's path[/i]" or where the path in the Block model is.
I really wish I understood what you were talking about. I fixed the texture paths; I don't have any idea how to "pass it into event.getRegistry" as you've specified. I did this:
However, the game crashes. The original line "ForgeRegistries.ITEMS.register(new ItemBlock(block).setRegistryName(block.getRegistryName()));" also crashes the game. I really, REALLY want to understand what I'm doing wrong so that I won't repeat the mistakes, but I'm having trouble figuring out exactly what it is you want me to do.
Thank you. I understand what a field is, but I wasn't sure where to put it in this code. I also understand about passing parameters; again, I wasn't sure where or how, in this instance. This is different from the Java code I've done before, or at least it seems to be. I'll keep studying anyway.
I just finished following a custom armor and custom tool tutorial by Harry's Tech Reviews (). I even downloaded HIS code and ran THAT. Well, his code (and the code I've posted at https://github.com/TheWebExpert1/davidblocks) both have the same problem: The tools & armor in the inventory (and in your hand) have no texture. The armor on you (or on the armor stand) is right, but not in hand or in the GUI. I've asked him for help, but since his own code isn't working, I'm not sure what to do.
Yes, I know there are probably some better ways to code this than what he's done, and I'm open to constructive suggestions. For instance, since I have three separate sets of armor (& tools), I thought maybe I could create a set of Enums and use those, rather than calling each separately, as I'm currently doing, but I'm not sure how to do it.
Also: I don't understand how my Items & Blocks don't need a call to .register & .init in the RegistryHandler class to get onto the inventory, but the armor and tools do. There's something different happening, and I'm trying to understand what it is, so I can clean up the code.
I've got to really, REALLY thank you, CSB... you've been very, very patient with me. I saw you getting a bit hot under the collar in a couple of posts, because I wasn't seeing the forest for the trees, but this particular post was OVERWHELMINGLY helpful.
First, I essentially duplicated the procedures from the ItemInit class into my ToolInit class. I moved the declarations of the items outside of the Init function, and deleted the Init function. I also eliminated the contents of the proxy classes, and deleted the RegistryHandler class. Once I got the @EventBusSubscriber and RegistryEvents in place, my pickaxe and helmet FINALLY showed up, complete with texture, but in the inventory and in hand. (I just did the pickaxe and helmet until I was sure the code worked).
I just KNEW there was something "off" about the tutorial I was following (although it worked for HIM), because even his own code didn't run properly; I'm guessing it's a version difference, that MC 1.12 handles things slightly differently than from the version he was apparently coding for.
The documents you linked to are great; I'm afraid I'll have to re-read them several times before I fully understand everything there. I get the basic concepts; but there's a lot more there than just the basic concepts. I'm sure I'll need to know more than that as I proceed.
Right now, all my blocks are identical, my food is identical, and my armor & tool values are identical. Eventually, I'll change the values to ones that make sense for what I'm creating, plus add custom sounds. Right now, it's enough that they're appearing. All of the "extra" stuff can wait; I'm just focusing on creating them, plus the relevant crafting recipes & smelting recipes, and making sure all THAT works -- BEFORE delving further into the other areas.
Once again, I thank you from the bottom of my heart. You've made it possible for me to continue what I'm doing. I have a few complex ideas in mind (yeah, biting off more than I can chew, I know), but I knew I had to start with the "simple" things first. Now, on with the coding...
Well, it's a minor thing (get it minor? miner? lols!)...
But the armor stands are holding my custom swords strangely (picture attached).
I know it's a little nit-picky, but there's no reason (that I know of) that the custom swords should be held any differently from a standard one. I've added the code from the original sword into my code, but that didn't seem to help. Got any ideas?
You're a genius.
It is, indeed, handheld, rather than generated. Who knew that such a simple thing could do that??
Thanks again!
I have a couple of interesting problem,s which I've been banging my head against the wall with for the last hour or two; you could probably solve them in .05 seconds.
1st: I've created a new block, CeramicBlock, but the texture doesn't show up in the inventory. I've checked everything (I think), and everything LOOKS good, but no texture.
2nd: I have a block called CompressorBlock, which is currently just a furnace with a new face. The block places properly (including facing) and gives the furnace GUI. I'll eventually replace that with my own. The main problem is that its texture isn't showing up in inventory, either.
3rd: I've tried to create a Block with subtypes; I registered it the same way I'm registering my Items with subtypes... but it's not registering properly. Not only do I not get the texture, I get the name across the default texture, and it's not showing me the subtypes at all. I'm sure there's a way to do it, but I'm missing something fundamental here.
I see that CJ has a couple of tutorials on GUIS & containers, plus a couple of others I'm interested in, so I'll be watching those. I know I've missed something simple here, but I just can't see what it is. I've posted the new code at https://github.com/TheWebExpert1/davidblocks.
I guess it's just too long staring at the code. I have no idea how I missed the registration. The mismatched names wasn't blatantly obvious, until I really started looking for it.
My 3rd problem still persists, and is the only error showing in the console. It's trying to access "blok", rather than "blokc" and "bloks", which should be the proper subtypes. Since it's being done the same way as InitItem in InitBlock, I have no idea what's wrong; in hand, it defaults to the copper texture (I got THAT part), but has no texture on the ground, and the 2nd block isn't anywhere. I gather that they're not being registered properly, but I'm just not sure what I'm doing wrong.
Finally, there's the danged furnace (compressor). I am aware that it's not just a simple "copy pasta" (more like "copy filet mignon"), but I've copied over, virtually unchanged, everything from the furnace class. Theoretically, when you load the "compressor," it should change the texture to the compressoron texture... but it's changing to the FURNACE_ON texture instead, and spitting out the contents. I'm not sure what the problem is at this point; I'm still looking through the code for clues.
I copied it from the forgeSrc-1.12-14.21.1.2443.jar, under net.minecraft.tileentity.TileEntityFurnace class; I needed my own version of this; however, I've been unsuccessful in getting rid of all the prior instances of TileEntityFurnace, such as:
If I try to change it to TileEntityFurnace, it throws a conniption fit. Perhaps there's something missing in this code? I wouldn't think so, offhand, as this is the latest version of forge.
Ok, so what about the blok problem?