devguydan Posted March 13, 2019 Share Posted March 13, 2019 (edited) I am working my way through the docs and I find this: https://mcforge.readthedocs.io/en/latest/blocks/blocks/#basic-blocks I think this is a great place to start and so I decide I want to create a rock-type class that breaks easily. Simple enough right? Well not for me rn. I start with a base project: https://github.com/djpeach/ExampleMod/tree/baseStructure I start trying to work with what I can figure out and try: @SubscribeEvent public static void addBlocks(RegistryEvent.Register<Block> event) { Block myRock = new Block(Material.ROCK); myRock.setHardness(0.1f); event.getRegistry().register(myRock); } I guess perhaps this is registering, but I cannot see it in my creative tabs so I try: myRock.setCreativeTab(CreativeTabs.MATERIALS); Still nothing. I don't know quite what to try next. My gut tells me it has something to do with registries, which is where I am most confused. I figure it might have to do with https://mcforge.readthedocs.io/en/latest/concepts/registries/#creating-registries, more specifically the ObjectHolder stuff. I can't seem to work out its purpose however. If someone could nudge me down the right path here, that would be great. Going to move on to Items for now. Hopefully they are easier Edited February 10, 2020 by devguydan Solved/outdated Quote I hate signatures, they're too distracting Link to comment Share on other sites More sharing options...
DavidM Posted March 13, 2019 Share Posted March 13, 2019 1. Remember to set the block's registry name with Block#setRegistryName. 2. If you want to have an item representation of your block, you also need to register an ItemBlock of it (in RegistryEvent.Register<Item>): itemRegistry.register(new ItemBlock(myBlock)); . Quote Some tips: Spoiler Modder Support: Spoiler 1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code. 2. Always post your code. 3. Never copy and paste code. You won't learn anything from doing that. 4. Quote Programming via Eclipse's hotfixes will get you nowhere 5. Learn to use your IDE, especially the debugger. 6. Quote The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it. Support & Bug Reports: Spoiler 1. Read the EAQ before asking for help. Remember to provide the appropriate log(s). 2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support. Link to comment Share on other sites More sharing options...
devguydan Posted March 13, 2019 Author Share Posted March 13, 2019 (edited) What exactly does the registryName do for us? I have read that page 5+ times and it doesn't really say why. But I did it and I registered an ItemBlock with it. Still not working I know I could get this working if I followed all these examples with external classes, but the docs very clearly say that is not necessary for the basics. And I want to be able to understand what is going on at a lower level before moving into more abstract designs. Edited March 13, 2019 by devguydan Added why I am doing it this way Quote I hate signatures, they're too distracting Link to comment Share on other sites More sharing options...
DavidM Posted March 13, 2019 Share Posted March 13, 2019 (edited) 1. A registry name is like the unique identifier for a block/item. 2. Push your repo. I cannot find your code for your block in all 4 branches. Edited March 13, 2019 by DavidM Quote Some tips: Spoiler Modder Support: Spoiler 1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code. 2. Always post your code. 3. Never copy and paste code. You won't learn anything from doing that. 4. Quote Programming via Eclipse's hotfixes will get you nowhere 5. Learn to use your IDE, especially the debugger. 6. Quote The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it. Support & Bug Reports: Spoiler 1. Read the EAQ before asking for help. Remember to provide the appropriate log(s). 2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support. Link to comment Share on other sites More sharing options...
devguydan Posted March 13, 2019 Author Share Posted March 13, 2019 pushed Where is that unique id used? The resources and textures? I can't even get it to tell me it can't find the resources Quote I hate signatures, they're too distracting Link to comment Share on other sites More sharing options...
devguydan Posted March 13, 2019 Author Share Posted March 13, 2019 Makes sense. I'm just so far from that rn. I want to register and see an [unrendered] block. And I want to do it at a VERY basic level. I don't want to extend the Block class or anything. The docs make it seem this is very possible, so idk what step in this I am missing. This is what I expect to see: Quote I hate signatures, they're too distracting Link to comment Share on other sites More sharing options...
devguydan Posted March 13, 2019 Author Share Posted March 13, 2019 And it would be nice to learn (along the same lines) how to modify the hardnes/other properties of existing blocks. Say for example, make dirt hard as obsidian. Quote I hate signatures, they're too distracting Link to comment Share on other sites More sharing options...
devguydan Posted March 13, 2019 Author Share Posted March 13, 2019 One thing I am noticing in other code that I don't have is ModelRegistryEvent and ModelLoader.setCustomModelResourceLocation() Is this the step I am missing? I cannot find anything about registering models or setting the resource location in the docs. Are there more in-depth docs somewhere? Or do I need to start diving into source code and reading comments? Quote I hate signatures, they're too distracting Link to comment Share on other sites More sharing options...
devguydan Posted March 13, 2019 Author Share Posted March 13, 2019 This should be simple right? Quote I hate signatures, they're too distracting Link to comment Share on other sites More sharing options...
devguydan Posted March 13, 2019 Author Share Posted March 13, 2019 Ok I lowercase and matched my registry names. I made the @ObjectHolder variable final, and created the Block when registering it? Not sure how to do this part @SubscribeEvent public static void addBlocks(RegistryEvent.Register<Block> event) { Blocks.myRock.setHardness(0.1f); Blocks.myRock.setCreativeTab(CreativeTabs.MATERIALS); Blocks.myRock.setRegistryName(MOD_ID,"myrock"); event.getRegistry().register(new Block(Material.ROCK)); } Quote I hate signatures, they're too distracting Link to comment Share on other sites More sharing options...
devguydan Posted March 13, 2019 Author Share Posted March 13, 2019 Just got to models https://mcforge.readthedocs.io/en/latest/models/introduction/ this has to be it Quote I hate signatures, they're too distracting Link to comment Share on other sites More sharing options...
devguydan Posted March 13, 2019 Author Share Posted March 13, 2019 2 minutes ago, diesieben07 said: You cannot access Blocks.myRock there. Object holders are initialized after all registry events. Use a local variable, apply all properties to it, then register it. Blocks.myRock will then be filled properly by @ObjectHolder. Ok I totally misunderstood their purpose then. So I know they are refreshed after block, item, and then all other registry events. What does "refreshed" do to them and why? What do they get used for down the line? Quote I hate signatures, they're too distracting Link to comment Share on other sites More sharing options...
devguydan Posted February 8, 2020 Author Share Posted February 8, 2020 (edited) It’s funny seeing how much stuff I did not know back then. I understand all this now, and am lost and confused on completely different things now, yay! And I can’t believe this was less than a year ago. I don’t remember it at all. Edited February 10, 2020 by devguydan Timeline wow Quote I hate signatures, they're too distracting Link to comment Share on other sites More sharing options...
Cadiboo Posted February 10, 2020 Share Posted February 10, 2020 Btw, DeferredRegister is the best way to do stuff now. Quote About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme) Link to comment Share on other sites More sharing options...
devguydan Posted February 10, 2020 Author Share Posted February 10, 2020 3 hours ago, Cadiboo said: Btw, DeferredRegister is the best way to do stuff now. Yes! I was trying to get Deferred registers to work based on what I saw in your example mod, but was getting issues with a null registry. I got it all working without deferred registries now, so I plan to revisit it again next time I get a chance to look at it. Also just curious, what are the benefits of the deferred registries over the event hooks? Sounds like they both register things at the correct time. Quote I hate signatures, they're too distracting Link to comment Share on other sites More sharing options...
Cadiboo Posted February 13, 2020 Share Posted February 13, 2020 (edited) On 2/11/2020 at 1:49 AM, devguydan said: what are the benefits of the deferred registries over the event hooks? DeferredRegister uses the event hooks. They just have much simpler and cleaner syntax. They also take care of ensuring your object references stay up to date and also support registry overrides. Edited February 17, 2020 by Cadiboo 1 Quote About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme) Link to comment Share on other sites More sharing options...
Draco18s Posted February 13, 2020 Share Posted February 13, 2020 1 hour ago, Cadiboo said: ensuring your object references stay out of date I am pretty sure this is not what you meant. 1 1 Quote 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. Link to comment Share on other sites More sharing options...
Recommended Posts
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.