Posted December 23, 20177 yr I've started a new mod, and right off the bat I'm having serious issues. I keep getting this warning for *every block I register*, and the item blocks aren't showing up in the creative tab (I'm assuming, for now, that these are both caused by the same issue): Quote Registry Block: The object Block{BLOCK_NAME_HERE} has been registered twice for the same name infernaltech:BLOCK_NAME_HERE (The BLOCK_NAME_HERE changes to the registry name of each block.) I'm sure I've just forgotten some tiny, simple thing, like an idiot, which is usually the case, but I've been looking for days now and can't find the issue. The weird thing is that I've never had this problem with any of my other mods, and I tend to use very similar skeleton code for them all for block registration, etc. (so much so that I've been considering breaking it out into a library). So the fact that this is happening now, but never has before, means I clearly did something differently than usual without realizing it, and I don't know what. I've even thrown in some console output in the block registration method, and I'm only getting a single registration output for each, so I don't know how it's acting like there are two of each... You can find the (very minimal) source code I'm working with at the (very tiny) repo here: https://github.com/IceMetalPunk/Infernal-Tech I hope someone can show me what I'm being stupid about so I can get back to making progress... Thanks. Edited December 24, 20177 yr by IceMetalPunk Fixed title. Whoops, copypasta. Whatever Minecraft needs, it is most likely not yet another tool tier.
December 23, 20177 yr CommonProxy subscribes to RegistryEvent.Register<Block> and calls BlockRegistry#register, which registers all of your Blocks. BlockRegistry also subscribes to RegistryEvent.Register<Block> and registers the same Blocks a second time, resulting in this warning. Also see Code Style Issue 1. Your registration code should be largely self-contained, the class that registers the Blocks and Items should be the same one that subscribes to RegistryEvent.Register; there's no reason to subscribe to it in one class and call methods in another class to do the actual registration. You can see how I handle Block and ItemBlock registration in my mod here. 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.
December 23, 20177 yr Author 12 minutes ago, Choonster said: CommonProxy subscribes to RegistryEvent.Register<Block> and calls BlockRegistry#register, which registers all of your Blocks. BlockRegistry also subscribes to RegistryEvent.Register<Block> and registers the same Blocks a second time, resulting in this warning. Also see Code Style Issue 1. My first thought was, "What? No, the registry doesn't subscribe to the event. That would be silly to have in both places..." Then I checked and obviously, you're right, it's there twice. You can bet I facepalmed. My only explanation for that is copypasta problems when reusing some code from an older mod of mine, though I can't explain at all how I continued not to see it during all my frustration with this warning... As for the coding style tip, yeah, I was just thinking about that earlier. I was looking at my ServerProxy class and thinking, "Have I *ever* used this? Wouldn't it make more sense to have only two proxy classes, not three?" It's just one of those bad habits I learned via tutorials very early on in my modding education (I think BedrockMiner's tutorials, specifically) and never broke. Seeing as how this mod is quite early in development, I'll definitely be refactoring that and trying to break the habit *A bit later* Okay, so I've refactored the code to organize things better and to remove the duplicate event subscriptions (and also to handle tile entity registration in a more loosely coupled way). It did, indeed, remove the warnings, so that's progress! However... the item blocks are still not showing up in the creative tab. They definitely exist, because I can /give myself the items, they're just not in the creative menu. If you follow the registration down, you'll see the BlockRegistry passes the InfernalTech.tab down into the smeltery block's constructor, which passes it up to its BasicBlock's super constructor, which uses it in this.itemBlock.setCreativeTab(tab). So why would it not show up in the creative menu tab? Whatever Minecraft needs, it is most likely not yet another tool tier.
December 23, 20177 yr If you look at ItemBlock#getCreativeTab, you'll see that it always uses the Block's creative tab and ignores the one set with Item#setCreativeTab. You need to use Block#setCreativeTab instead. 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.
December 24, 20177 yr Author 17 hours ago, Choonster said: If you look at ItemBlock#getCreativeTab, you'll see that it always uses the Block's creative tab and ignores the one set with Item#setCreativeTab. You need to use Block#setCreativeTab instead. Well... of course it'd be something silly like that, otherwise I might appear to be an actually competent coder Thank you! Everything is working fine now. Whatever Minecraft needs, it is most likely not yet another tool tier.
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.