Posted September 1, 20205 yr Here is most of my mod class: public class Circuitry { public static final String MODID = "circuitry"; private static final DeferredRegister<Block> BLOCKS = new DeferredRegister<>(ForgeRegistries.BLOCKS, MODID); public static final RegistryObject<Block> IN_NODE = BLOCKS.register("in_node", InNodeBlock::new), OUT_NODE = BLOCKS.register("out_node", OutNodeBlock::new); public Circuitry() { DeferredRegister<Item> items = new DeferredRegister<>(ForgeRegistries.ITEMS, MODID); BLOCKS.getEntries().forEach(block -> items.register(block.getId().getPath(), () -> new BlockItem(block.get(), new Properties().group(ItemGroup.REDSTONE)))); IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus(); bus.register(BLOCKS); bus.register(items); } } I have the Item DeferredRegister and RegistryObjects in the constructor rather than statically declaring it because I never need to retrieve the Item objects anywhere else in my code. However, upon loading a world, I am unable to find any of the added Blocks in the Redstone tab of the creative menu. The following commands don't work either: /give Dev circuitry:in_node /give Dev circuitry:out_node Declaring the Item DeferredRegister and RegistryObjects statically doesn't seem to fix the problem either. Printing the Item DeferredRegistry shows two entries with the correct names. No error messages are thrown and I can't determine why this is occurring.
September 1, 20205 yr https://mcforge.readthedocs.io/en/latest/concepts/registries/#deferredregister You registered them in the wrong way.
September 1, 20205 yr 8 hours ago, Caffeinated Pinkie said: No error messages are thrown and I can't determine why this is occurring. Because when this line runs: 8 hours ago, Caffeinated Pinkie said: BLOCKS.getEntries().forEach(block -> items.register(block.getId().getPath(), () -> new BlockItem(block.get(), new Properties().group(ItemGroup.REDSTONE)))); Your BLOCKS contains no entries because block registration hasn't happened yet. Register your stuff properly. 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.
September 1, 20205 yr Author 3 hours ago, Draco18s said: Because when this line runs: Your BLOCKS contains no entries because block registration hasn't happened yet. Register your stuff properly. Well, when I iterate through the BLOCKS entries, it shows two RegistryObjects in it. After running the command to create items as I did, there are two RegistryObjects in the items entries. They all have the correct names as well. It seems functionally identical to defining them as so: public Circuitry() { DeferredRegister<Item> items = new DeferredRegister<>(ForgeRegistries.ITEMS, MODID); items.register("in_node", () -> new BlockItem(IN_NODE.get(), new Properties().group(ItemGroup.REDSTONE))); items.register("out_node", () -> new BlockItem(OUT_NODE.get(), new Properties().group(ItemGroup.REDSTONE))); IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus(); bus.register(BLOCKS); bus.register(items); } and even doing this statically like so: public class Circuitry { private static final DeferredRegister<Block> BLOCKS = new DeferredRegister<>(ForgeRegistries.BLOCKS, MODID); private static final DeferredRegister<Item> ITEMS = new DeferredRegister<>(ForgeRegistries.ITEMS, MODID); public static final RegistryObject<Block> IN_NODE = BLOCKS.register("in_node", InNodeBlock::new), OUT_NODE = BLOCKS.register("out_node", OutNodeBlock::new); static { ITEMS.register("in_node", () -> new BlockItem(IN_NODE.get(), new Properties().group(ItemGroup.REDSTONE))); ITEMS.register("out_node", () -> new BlockItem(OUT_NODE.get(), new Properties().group(ItemGroup.REDSTONE))); } public Circuitry() { IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus(); bus.register(BLOCKS); bus.register(ITEMS); } } Even writing it identical to how the documentation does it doesn't help: public class Circuitry { private static final DeferredRegister<Block> BLOCKS = new DeferredRegister<>(ForgeRegistries.BLOCKS, MODID); private static final DeferredRegister<Item> ITEMS = new DeferredRegister<>(ForgeRegistries.ITEMS, MODID); public static final RegistryObject<Block> IN_NODE_BLOCK = BLOCKS.register("in_node", InNodeBlock::new), OUT_NODE_BLOCK = BLOCKS.register("out_node", OutNodeBlock::new); public static final RegistryObject<Item> IN_NODE_ITEM = ITEMS.register("in_node", () -> new BlockItem(IN_NODE_BLOCK.get(), new Properties().group(ItemGroup.REDSTONE))), OUT_NODE_ITEM = ITEMS.register("out_node", () -> new BlockItem(OUT_NODE_BLOCK.get(), new Properties().group(ItemGroup.REDSTONE))); public Circuitry() { IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus(); bus.register(BLOCKS); bus.register(ITEMS); } }
September 1, 20205 yr 3 minutes ago, Caffeinated Pinkie said: It seems functionally identical to defining them as so: It is not. This: Runs immediately. This: Runs at a deferred time. 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.
September 1, 20205 yr Author 5 minutes ago, Draco18s said: It is not. This: Runs immediately. This: Runs at a deferred time. Alright. But that still doesn't help because none of the methods I tried work.
September 1, 20205 yr Author 1 minute ago, diesieben07 said: This is the answer. This is not how your register a DefferedRegister to the event bus. Oh jeez, that was a stupid mistake. I should not have been writing late t night. Thank you.
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.