Posted July 30, 20205 yr 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, 20205 yr by BlockyPenguin Today (22/10/20) I reached 100 posts! I'm probably more excited than I should be for something so realistically minor...
July 30, 20205 yr 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. 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.
July 30, 20205 yr Author 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! Today (22/10/20) I reached 100 posts! I'm probably more excited than I should be for something so realistically minor...
July 30, 20205 yr Author Just now, sciwhiz12 said: Are you creating your blocks in static fields in your `ModBlocks` class? Yes Today (22/10/20) I reached 100 posts! I'm probably more excited than I should be for something so realistically minor...
July 30, 20205 yr Or use a DeferredRegister. 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.
July 30, 20205 yr 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(...)`)
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.