New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[1.20.6] DeferredRegister for ArmorMaterial is broken #9961
Comments
While this gets fixed, you can try doing something like this:
It's not the best solution but at least it works for now. Of course when this will get patched I recommend switching to the DeferredRegister methods and using the proper RegistryObjects |
So, it is an issue with the way I sort the registry fire events. Currently it's being sorted by the first time register is called. For now i've made a solution that works for this simple test case: private static final DeferredRegister<ArmorMaterial> ARMORS = deferred(Registries.ARMOR_MATERIAL);
private static final RegistryObject<ArmorMaterial> ARMOR = ARMORS.register("test", () -> {
return new ArmorMaterial(
Collections.emptyMap(),
1,
SoundEvents.ARMOR_EQUIP_CHAIN,
() -> Ingredient.of(Items.IRON_INGOT),
Collections.emptyList(),
1.0f, 1.0f
);
});
private static final DeferredRegister<Item> ITEMS = deferred(Registries.ITEM);
private static final RegistryObject<Item> ARMOR_CHEST = ITEMS.register("test_chest", () -> {
return new ArmorItem(
ARMOR.getHolder().orElseThrow(),
ArmorItem.Type.CHESTPLATE,
new Item.Properties().durability(ArmorItem.Type.CHESTPLATE.getDurability(15))
);
});
Eventually I need to go in and simplify the registry system yet again. I really wish Mojang would get their crap together and solve the few minor things that make all our registry hooks necessary. Namely, ID syncing between network and saves for non-data driven registries. |
Minecraft Version: 1.20.6
Forge Version: 50.0.5
Logs: No crash
Description of issue:
Since 1.20.6 ArmorItem has only one constructor:
It requires Holder<> of ArmorMaterial. Forge uses RegistryObject for deferred registering, so when I use deferred registration for the new ArmorMaterial, it returns not the Holder<>. But the armor constructor requires Holder<>.
I can try to get Holder<> from RegistryObject, using
getHolder().orElseThrow()
:But Holder<> is null in this time (items are registered via DeferredRegister, armor materials too, looks like new item constructor is called during the stage, when Holders are not created yet), so there is an Exception.
So now the only way to add and use new ArmorMaterial is to write fabric-styled code, that looks strange among forge deferred registration files.
The text was updated successfully, but these errors were encountered: