More Item Attribute Things

This commit is contained in:
Kam committed 2025-02-26 22:49:26 -05:00
1 parent 9b7af03de3
commit 50977543c0
13 files changed
+312 -162

No files matched your search

@@ -0,0 +1,35 @@
package noppes.npcs.mixin;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.attribute.ItemAttributeHelper;
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.CallbackInfoReturnable;
import java.util.List;
import static noppes.npcs.attribute.ItemAttributeHelper.RPGItemAttributes;
@Mixin(ItemStack.class)
public abstract class MixinItemStack {
@Shadow
public abstract boolean hasTagCompound();
@Shadow
public abstract NBTTagCompound getTagCompound();
@Shadow
public NBTTagCompound stackTagCompound;
@Inject(method = "getTooltip", at = @At("TAIL"), cancellable = true)
public void getAttributeTooltip(EntityPlayer player, boolean advanced, CallbackInfoReturnable<List<String>> cir) {
List<String> tooltip = cir.getReturnValue();
if (hasTagCompound() && getTagCompound().hasKey(RPGItemAttributes)) {
cir.setReturnValue(ItemAttributeHelper.getToolTip(tooltip, getTagCompound()));
}
}
}