generated from FabricMC/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
src/main/java/xyz/hafemann/netheriteextras/mixin/TotemEnchantableMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} | ||
|
25 changes: 25 additions & 0 deletions
25
src/main/java/xyz/hafemann/netheriteextras/mixin/TotemUnbreakingEnchantableMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters