mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-28 09:05:38 +00:00
More Item Attribute Things
This commit is contained in:
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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user