diff options
Diffstat (limited to 'src/main/java/com/dulkirfabric/mixin/ItemStackMixin.java')
-rw-r--r-- | src/main/java/com/dulkirfabric/mixin/ItemStackMixin.java | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/main/java/com/dulkirfabric/mixin/ItemStackMixin.java b/src/main/java/com/dulkirfabric/mixin/ItemStackMixin.java new file mode 100644 index 0000000..5fdd7f5 --- /dev/null +++ b/src/main/java/com/dulkirfabric/mixin/ItemStackMixin.java @@ -0,0 +1,27 @@ +package com.dulkirfabric.mixin; + +import com.dulkirfabric.util.ItemChangeHandler; +import net.minecraft.client.item.TooltipContext; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.text.Text; +import org.jetbrains.annotations.Nullable; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import java.util.List; + +@Mixin(ItemStack.class) +public abstract class ItemStackMixin { + @Shadow public abstract Item getItem(); + + @Inject(method = "getTooltip", at = @At("HEAD")) + private void onGetTooltip(@Nullable PlayerEntity player, TooltipContext context, CallbackInfoReturnable<List<Text>> cir) { + ItemChangeHandler.INSTANCE.handle(this.getItem().getName().getString()); + } +} |