Posted February 19, 20232 yr 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 @SubscribeEvent public static void registerEnchantments(Register<Enchantment> event) { // overwriting of vanilla enchantments ElementalCombat.LOGGER.info("Expected overrides"); event.getRegistry() .register( new ElementalResistanceEnchantment(ElementalResistanceEnchantment.Type.FIRE).setRegistryName(Enchantments.FIRE_PROTECTION.getRegistryName())); event.getRegistry() .register(new StyleResistanceEnchantment(StyleResistanceEnchantment.Type.PROJECTILE) .setRegistryName(Enchantments.PROJECTILE_PROTECTION.getRegistryName())); event.getRegistry() .register( 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?
February 19, 20232 yr Author 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 February 19, 20232 yr by Tavi007
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.