Jump to content

[1.19] How to override vanilla enchantments?


Recommended Posts

Hello. I'm currently updating my mod to 1.19 and have trouble with overriding vanilla enchantments by registering my own enchantment with the same ResourceLocation as the vanilla one. Previously I was using

    public static void registerEnchantments(Register<Enchantment> event) {
        // overwriting of vanilla enchantments
        ElementalCombat.LOGGER.info("Expected overrides");
                new ElementalResistanceEnchantment(ElementalResistanceEnchantment.Type.FIRE).setRegistryName(Enchantments.FIRE_PROTECTION.getRegistryName()));
            .register(new StyleResistanceEnchantment(StyleResistanceEnchantment.Type.PROJECTILE)
                new StyleResistanceEnchantment(StyleResistanceEnchantment.Type.EXPLOSION).setRegistryName(Enchantments.BLAST_PROTECTION.getRegistryName()));

but apparently this event was removed. I found the a general RegisterEvent class, but I'm not sure how to properly use it. Also the method Enchantment#getRegistryName from the vanilla class seems to be removed, so I won't get the correct ResourceLocation from it anymore... Can someone help me please?

Link to comment
Share on other sites

Nevermind. Someone on discord helped me out.

The Solution is to use a DerefferdRegister, that uses the minecraft namespace

    public static final DeferredRegister<Enchantment> VANILLA_ENCHANTMENTS = DeferredRegister.create(ForgeRegistries.ENCHANTMENTS, "minecraft");
    public static final RegistryObject<Enchantment> FIRE_PROTECTION = VANILLA_ENCHANTMENTS.register("fire_protection",
        () -> new ElementalResistanceEnchantment(ElementalResistanceEnchantment.Type.FIRE));
    public static final RegistryObject<Enchantment> PROJECTILE_PROTECTION = VANILLA_ENCHANTMENTS.register("projectile_protection",
        () -> new StyleResistanceEnchantment(StyleResistanceEnchantment.Type.PROJECTILE));
    public static final RegistryObject<Enchantment> BLAST_PROTECTION = VANILLA_ENCHANTMENTS.register("blast_protection",
        () -> new StyleResistanceEnchantment(StyleResistanceEnchantment.Type.EXPLOSION));


Edited by Tavi007
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.