Jump to content

[1.19] Custom registry not producing delegates


Recommended Posts

I'm running into a unexpected issue when trying to fetch delegates (`Holder.Reference` using `IForgeRegistry#getDelegate`).

For built in registries (like BLOCK) they seem to return a `Holder` for inbuilt and modded entries but as far as I can tell for custom registries always return an empty optional.

I've arugmented the ExampleMod to showcase the issue:


Is this a bug, incorrect usage or is there something additional I need to do for custom registries?

Link to comment
Share on other sites

Can you explain why you need this?

Vanilla's Holder objects are a way to reference objects that don't exist yet, e.g. a value that will be placed in a registry later by datapack loading, or resolving circular references.

Forge has this mechanism in the RegistryObject.

RegistryObject<T> extends Supplier<T>

e.g. if you want to an Item to reference a potion effect (which are registered after Items) you do something like (untested pseudo code):

public MyItem(Properties props, Supplier<MobEffect> potion) {
    // remember how to get the potion (not registered yet)
    this.potion = potion;

public void usePotion() {
    // Retrieve the potion at runtime (will exist)

RegistryObject<MobEffect> MY_POTION = ...;
// Pass the "supplier" to the constructor
RegistryObject<Item> MY_ITEM = ITEMS.register("my_item", () -> new MyItem(props, MY_POTION));



If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Link to comment
Share on other sites

Hi warjort thanks. My usecase is for a Map key that provides easy access to the key (ResourceLocation) & registered object (Item/Block/EntityType..).

Prior to 1.19 I used forge's `IRegistryDelegate` as keys in a long living Maps, as they stored a reference to the actual object as well as the resource location of that object in the registry. Using the delegate as a key was better as the equality of two registry items could be compared through the delegates using equals and you wouldn't need to store underlying object which could change and causing memory leaks. I'm not up to speed but perhaps this isn't want I need anymore. Using the resource location as a key and doing a look up in the relevant registry may be the way forward..

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.

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.


  • Create New...

Important Information

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