Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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.

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.

  • 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);
    }
}

 

3 minutes ago, Caffeinated Pinkie said:

It seems functionally identical to defining them as so:

It is not.

 

This:

image.png.9864634970c01cb9e2abb4367cb2a75d.png

Runs immediately.

 

This:

image.png.68c82e1350d10ee8163320bac176daa4.png

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.

  • Author
5 minutes ago, Draco18s said:

It is not.

 

This:

image.png.9864634970c01cb9e2abb4367cb2a75d.png

Runs immediately.

 

This:

image.png.68c82e1350d10ee8163320bac176daa4.png

Runs at a deferred time.

Alright. But that still doesn't help because none of the methods I tried work.

  • 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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.