From 1b76b147b12ec7be8d0eff1f046c5170636ae8d7 Mon Sep 17 00:00:00 2001 From: PepperCode1 <44146161+PepperCode1@users.noreply.github.com> Date: Tue, 16 May 2023 07:12:08 -0700 Subject: [PATCH] 1.19 is enchanting - Remove EnchantmentHelperMixin and use 1.19 enchantment extensions instead - Bump minimum Forge requirement to 43.2.3 --- .../curiosities/armor/DivingHelmetItem.java | 17 ++++++++++++++ .../mixin/EnchantmentHelperMixin.java | 23 ------------------- src/main/resources/META-INF/mods.toml | 2 +- src/main/resources/create.mixins.json | 1 - 4 files changed, 18 insertions(+), 25 deletions(-) delete mode 100644 src/main/java/com/simibubi/create/foundation/mixin/EnchantmentHelperMixin.java diff --git a/src/main/java/com/simibubi/create/content/curiosities/armor/DivingHelmetItem.java b/src/main/java/com/simibubi/create/content/curiosities/armor/DivingHelmetItem.java index 5bda149ae..f827996ae 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/armor/DivingHelmetItem.java +++ b/src/main/java/com/simibubi/create/content/curiosities/armor/DivingHelmetItem.java @@ -1,5 +1,7 @@ package com.simibubi.create.content.curiosities.armor; +import java.util.Map; + import org.jetbrains.annotations.Nullable; import com.simibubi.create.foundation.advancement.AllAdvancements; @@ -38,6 +40,21 @@ public class DivingHelmetItem extends BaseArmorItem { return super.canApplyAtEnchantingTable(stack, enchantment); } + @Override + public int getEnchantmentLevel(ItemStack stack, Enchantment enchantment) { + if (enchantment == Enchantments.AQUA_AFFINITY) { + return 1; + } + return super.getEnchantmentLevel(stack, enchantment); + } + + @Override + public Map getAllEnchantments(ItemStack stack) { + Map map = super.getAllEnchantments(stack); + map.put(Enchantments.AQUA_AFFINITY, 1); + return map; + } + public static boolean isWornBy(Entity entity, boolean fireproof) { ItemStack stack = getWornItem(entity); if (stack == null) diff --git a/src/main/java/com/simibubi/create/foundation/mixin/EnchantmentHelperMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/EnchantmentHelperMixin.java deleted file mode 100644 index 46c6eb12f..000000000 --- a/src/main/java/com/simibubi/create/foundation/mixin/EnchantmentHelperMixin.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.simibubi.create.foundation.mixin; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import com.simibubi.create.content.curiosities.armor.DivingHelmetItem; - -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.enchantment.Enchantment; -import net.minecraft.world.item.enchantment.EnchantmentHelper; -import net.minecraft.world.item.enchantment.Enchantments; - -@Mixin(EnchantmentHelper.class) -public class EnchantmentHelperMixin { - @Inject(method = "getItemEnchantmentLevel(Lnet/minecraft/world/item/enchantment/Enchantment;Lnet/minecraft/world/item/ItemStack;)I", at = @At("HEAD"), cancellable = true) - private static void create$onGetItemEnchantmentLevel(Enchantment enchantment, ItemStack stack, CallbackInfoReturnable cir) { - if (enchantment == Enchantments.AQUA_AFFINITY && stack.getItem() instanceof DivingHelmetItem) { - cir.setReturnValue(1); - } - } -} diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index bbfd85ead..51173d415 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -19,7 +19,7 @@ Technology that empowers the player.''' [[dependencies.create]] modId="forge" mandatory=true - versionRange="[43.0.0,)" + versionRange="[43.2.3,)" ordering="NONE" side="BOTH" diff --git a/src/main/resources/create.mixins.json b/src/main/resources/create.mixins.json index 37bdb0006..9a85238fc 100644 --- a/src/main/resources/create.mixins.json +++ b/src/main/resources/create.mixins.json @@ -9,7 +9,6 @@ "ContraptionDriverInteractMixin", "WaterWheelFluidSpreadMixin", "CustomItemUseEffectsMixin", - "EnchantmentHelperMixin", "EntityMixin", "LavaSwimmingMixin", "MainMixin",