BlockyPenguin Posted July 30, 2020 Posted July 30, 2020 (edited) So I have an array of blocks in my registry class: private static Block[] modBlocks = { ModBlocks.CAUTION_BLOCK, ModBlocks.WHITE_FLOOR_TILES, ModBlocks.GREY_FLOOR_TILES, ModBlocks.DARK_GREY_FLOOR_TILES, ... }; I then loop through it to register them all: @SubscribeEvent public static void blockRegistry(final RegistryEvent.Register<Block> e) { for(Block block : modBlocks) { e.getRegistry().register(block); } } I was wondering if there's a way to do this for tile entities, as they're a little more awkward. I'm using the @ObjectHolder to register things. Thanks! Edited August 10, 2020 by BlockyPenguin Quote Today (22/10/20) I reached 100 posts! I'm probably more excited than I should be for something so realistically minor...
Draco18s Posted July 30, 2020 Posted July 30, 2020 by the way, e.getRegistry.registerAll() exists. 27 minutes ago, BlockyPenguin said: I was wondering if there's a way to do this for tile entities, as they're a little more awkward Well, you don't register TEs, you register TE Types. So put those in an array. And yes, you'll probably need a helper function. Write a helper function and put its return value into the array. 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.
BlockyPenguin Posted July 30, 2020 Author Posted July 30, 2020 1 minute ago, Draco18s said: by the way, e.getRegistry.registerAll() exists. Ah, thanks! 1 minute ago, Draco18s said: Well, you don't register TEs, you register TE Types. Yeah, sorry, my bad. Typed the wrong thing. 2 minutes ago, Draco18s said: So put those in an array. And yes, you'll probably need a helper function. Write a helper function and put its return value into the array. Ok, cool! Will do! Thanks! Quote Today (22/10/20) I reached 100 posts! I'm probably more excited than I should be for something so realistically minor...
sciwhiz12 Posted July 30, 2020 Posted July 30, 2020 Are you creating your blocks in static fields in your `ModBlocks` class? Quote
BlockyPenguin Posted July 30, 2020 Author Posted July 30, 2020 Just now, sciwhiz12 said: Are you creating your blocks in static fields in your `ModBlocks` class? Yes Quote Today (22/10/20) I reached 100 posts! I'm probably more excited than I should be for something so realistically minor...
Draco18s Posted July 30, 2020 Posted July 30, 2020 Or use a DeferredRegister. 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.
sciwhiz12 Posted July 30, 2020 Posted July 30, 2020 See the documentation on registries and registering objects. Ignore the version difference, it's all the same in 1.15+ (except that its `DeferredRegister.create(...)`, not `new DeferredRegister(...)`) Quote
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.