diff --git a/src/main/java/xyz/hafemann/netheriteextras/mixin/TotemEnchantableMixin.java b/src/main/java/xyz/hafemann/netheriteextras/mixin/TotemEnchantableMixin.java new file mode 100644 index 0000000..4dffea3 --- /dev/null +++ b/src/main/java/xyz/hafemann/netheriteextras/mixin/TotemEnchantableMixin.java @@ -0,0 +1,26 @@ +package xyz.hafemann.netheriteextras.mixin; + +import net.minecraft.enchantment.Enchantment; +import net.minecraft.item.ItemStack; +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 xyz.hafemann.netheriteextras.item.ModItems; + +@Mixin(Enchantment.class) +public class TotemEnchantableMixin { + public TotemEnchantableMixin() {} + + @Inject( + method = "isAcceptableItem", + at = @At("HEAD"), + cancellable = true + ) + private void onIsAcceptableItem(ItemStack stack, CallbackInfoReturnable cir) { + if (stack.isOf(ModItems.TOTEM_OF_NEVERDYING)) { + cir.setReturnValue(false); + } + } +} + diff --git a/src/main/java/xyz/hafemann/netheriteextras/mixin/TotemUnbreakingEnchantableMixin.java b/src/main/java/xyz/hafemann/netheriteextras/mixin/TotemUnbreakingEnchantableMixin.java new file mode 100644 index 0000000..84838c8 --- /dev/null +++ b/src/main/java/xyz/hafemann/netheriteextras/mixin/TotemUnbreakingEnchantableMixin.java @@ -0,0 +1,25 @@ +package xyz.hafemann.netheriteextras.mixin; + +import net.minecraft.enchantment.UnbreakingEnchantment; +import net.minecraft.item.ItemStack; +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 xyz.hafemann.netheriteextras.item.ModItems; + +@Mixin(UnbreakingEnchantment.class) +public class TotemUnbreakingEnchantableMixin { + public TotemUnbreakingEnchantableMixin() {} + + @Inject( + method = "isAcceptableItem", + at = @At("HEAD"), + cancellable = true + ) + private void onIsAcceptableItem(ItemStack stack, CallbackInfoReturnable cir) { + if (stack.isOf(ModItems.TOTEM_OF_NEVERDYING)) { + cir.setReturnValue(false); + } + } +} diff --git a/src/main/resources/netheriteextras.mixins.json b/src/main/resources/netheriteextras.mixins.json index a0895ba..58c061b 100644 --- a/src/main/resources/netheriteextras.mixins.json +++ b/src/main/resources/netheriteextras.mixins.json @@ -4,6 +4,8 @@ "package": "xyz.hafemann.netheriteextras.mixin", "compatibilityLevel": "JAVA_17", "mixins": [ + "TotemUnbreakingEnchantableMixin", + "TotemEnchantableMixin", "NetheriteHorseArmorHorseEntityMixin", "NetheriteNuggetArmorMixin", "NetheriteNuggetToolMixin"