is.setTag(new NBTTagCompound()); is.getTag().set("AttributeModifiers", emptyList); is.getTag().set("ench", emptyList); } else { is.getTag().remove("ench"); if (is.getTag().hasKey("display")) { display = is.getTag().getCompound("display"); } else { display = new NBTTagCompound(); is.getTag().set("display", display); display.setString("Name", icon.getTitle()); display.set("Lore", loreTag); for (String loreLine : icon.getLore()) { loreTag.add(new NBTTagString(loreLine)); icon.getMeta().applyTo(tag); NBTTagCompound vanillaTag = (NBTTagCompound) ItemStackNBTConverter.compoundToVanillaCompound(tag); for (Object key : vanillaTag.c()) { is.getTag().set(key.toString(), vanillaTag.get(key.toString()));
public ItemStack splitStack(int slot, int subtract) { if (slot < size && items.get(slot) != null) { if (items.get(slot).count <= subtract) { ItemStack itemStack = items.get(slot); items.set(slot, null); return itemStack; } else { ItemStack itemStack = items.get(slot); ItemStack splittedStack = new ItemStack(itemStack.getItem(), subtract, itemStack.getData()); if (itemStack.getTag() != null) { splittedStack.setTag(((NBTTagCompound) itemStack.getTag().clone())); } itemStack.count -= subtract; if (items.get(slot).count == 0) { items.set(slot, null); } return splittedStack; } } return null; }
@Override public boolean c(NBTTagCompound nbttagcompound) { if (this.controller.getEntity().isDead()) { return false; } else { nbttagcompound.setString("id", getSavedName()); this.controller.getEntity().getHandle(Entity.class).e(nbttagcompound); return true; } }
/** * Sets the current display name of an Item * * @param stack to set the display name of * @param displayName to set to, null to reset to the default */ public static void setDisplayName(org.bukkit.inventory.ItemStack stack, String displayName) { if (displayName != null) { CommonNMS.getNative(stack).c(displayName); } else if (hasDisplayName(stack)) { CommonNMS.getNative(stack).tag.remove("display"); } } }
case Compound: TagCompound TagCompound = (TagCompound) tag; NBTTagCompound tagCompound = new NBTTagCompound(); for (String name : TagCompound.getCompoundData().keySet()) { tagCompound.set(name, compoundToVanillaCompound(TagCompound.getCompoundData().get(name)));
public static boolean compareTagData(ItemStack i1, ItemStack i2) { if (i1.hasItemMeta() && i2.hasItemMeta()) { NBTTagCompound tag1 = CraftItemStack.asNMSCopy(i1).getTag(); NBTTagCompound tag2 = CraftItemStack.asNMSCopy(i2).getTag(); return tag1 != null && tag1.equals(tag2); } return i1.hasItemMeta() == i2.hasItemMeta(); } }
@Override public TagCompound entityToTag(Entity bukkitEntity) { net.minecraft.server.v1_7_R4.Entity entity = ((CraftEntity) bukkitEntity).getHandle(); NBTTagCompound vanillaNBT = new NBTTagCompound(); entity.e(vanillaNBT); return (TagCompound) ItemStackNBTConverter.vanillaCompoundToCompound(vanillaNBT); }
@Override public boolean d(NBTTagCompound nbttagcompound) { if (this.controller.getEntity().isDead() || (this.controller.getEntity().hasPlayerPassenger() && controller.isPlayerTakable())) { return false; } else { nbttagcompound.setString("id", getSavedName()); this.controller.getEntity().getHandle(Entity.class).e(nbttagcompound); return true; } }
return CraftItemStack.asNMSCopy(item).getTag().equals(compareItem.getTag());