Skip to content

Commit

Permalink
Fix Totem being enchantable
Browse files Browse the repository at this point in the history
  • Loading branch information
SLH335 committed Feb 14, 2024
1 parent e44baed commit 01f6817
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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<Boolean> cir) {
if (stack.isOf(ModItems.TOTEM_OF_NEVERDYING)) {
cir.setReturnValue(false);
}
}
}

Original file line number Diff line number Diff line change
@@ -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<Boolean> cir) {
if (stack.isOf(ModItems.TOTEM_OF_NEVERDYING)) {
cir.setReturnValue(false);
}
}
}
2 changes: 2 additions & 0 deletions src/main/resources/netheriteextras.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"package": "xyz.hafemann.netheriteextras.mixin",
"compatibilityLevel": "JAVA_17",
"mixins": [
"TotemUnbreakingEnchantableMixin",
"TotemEnchantableMixin",
"NetheriteHorseArmorHorseEntityMixin",
"NetheriteNuggetArmorMixin",
"NetheriteNuggetToolMixin"
Expand Down

0 comments on commit 01f6817

Please sign in to comment.