Jump to content

Quick Clarifying Question about DeferredRegistries


Syric

Recommended Posts

From my understanding, all of my blocks, items, and whatnot should be registered like this:

    public static final RegistryObject<Block> CRASH_PAD = registry.BLOCKS.register("crash_pad", () -> new CrashPadBlock(AbstractBlock.Properties.of(Material.CLAY, MaterialColor.GRASS).friction(0.8F).sound(SoundType.SLIME_BLOCK).noOcclusion()));
    public static final RegistryObject<Item> ALCHEMICAL_FLASK = registry.ITEMS.register("alchemical_flask", () -> new Item(new Item.Properties().tab(ItemGroup.TAB_MATERIALS)));

If I then wished to refer to the crash_pad Block, or the alchemical_flask Item, do I have to refer to them as 'registry.CRASH_PAD.get()' and 'registry.ALCHEMICAL_FLASK.get()'? This seems a bit roundabout. Can I define the blocks as Blocks and the items as Items before creating and registering RegistryObject<T>s from them, or do I have to always get the blocks and items from their RegistryObjects?

Link to comment
Share on other sites

Okay, thanks for the help! A few questions.

  1. BLOCKS and ITEMS are in the same class as each other- it's called 'registry'. (forgot to capitalize, oops- I'll fix that momentarily.) What exactly shouldn't be in separate classes? Are you saying that my actual RegistryObjects (the individual blocks, items, etc.) should all be in the same class? Or that the DeferredRegisters should all be in the same class? Or that all the RegistryObject<Block>s should be in the same class as the DeferredRegister<Block>, and the RegistryObject<Item>s should be in the same class as the DeferredRegister<Item>, but those two classes don't necessarily have to be the same?
  2. What is @ObjectHolder, what does it do, and where can I go to learn more? (That is, assuming it's a Forge thing. If it's a Java thing I don't know, say so and I'll go research it elsewhere- I understand and respect that this forum isn't a place to look for Java help.)
Link to comment
Share on other sites

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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