Search in sources :

Example 61 with NBTTagCompound

use of net.minecraft.server.v1_16_R2.NBTTagCompound in project WildLoaders by BG-Software-LLC.

the class NMSAdapter_v1_7_R4 method setTag.

@Override
public org.bukkit.inventory.ItemStack setTag(org.bukkit.inventory.ItemStack itemStack, String key, String value) {
    ItemStack nmsItem = CraftItemStack.asNMSCopy(itemStack);
    NBTTagCompound tagCompound = nmsItem.hasTag() ? nmsItem.getTag() : new NBTTagCompound();
    tagCompound.set(key, new NBTTagString(value));
    nmsItem.setTag(tagCompound);
    return CraftItemStack.asBukkitCopy(nmsItem);
}
Also used : NBTTagCompound(net.minecraft.server.v1_7_R4.NBTTagCompound) NBTTagString(net.minecraft.server.v1_7_R4.NBTTagString) ItemStack(net.minecraft.server.v1_7_R4.ItemStack) CraftItemStack(org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack)

Example 62 with NBTTagCompound

use of net.minecraft.server.v1_16_R2.NBTTagCompound in project WildLoaders by BG-Software-LLC.

the class NMSAdapter_v1_7_R4 method getTag.

@Override
public long getTag(org.bukkit.inventory.ItemStack itemStack, String key, long def) {
    ItemStack nmsItem = CraftItemStack.asNMSCopy(itemStack);
    NBTTagCompound tagCompound = nmsItem.hasTag() ? nmsItem.getTag() : new NBTTagCompound();
    if (!tagCompound.hasKeyOfType(key, 4))
        return def;
    return tagCompound.getLong(key);
}
Also used : NBTTagCompound(net.minecraft.server.v1_7_R4.NBTTagCompound) ItemStack(net.minecraft.server.v1_7_R4.ItemStack) CraftItemStack(org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack)

Example 63 with NBTTagCompound

use of net.minecraft.server.v1_16_R2.NBTTagCompound in project WildChests by BG-Software-LLC.

the class NMSAdapter_v1_16_R3 method deserialize.

private static InventoryHolder deserialize(NBTTagCompound tagCompound) {
    InventoryHolder inventory = new InventoryHolder(tagCompound.getInt("Size"), "Chest");
    NBTTagList itemsList = tagCompound.getList("Items", 10);
    for (int i = 0; i < itemsList.size(); i++) {
        NBTTagCompound nbtTagCompound = itemsList.getCompound(i);
        inventory.setItem(nbtTagCompound.getByte("Slot"), CraftItemStack.asBukkitCopy(ItemStack.a(nbtTagCompound)));
    }
    return inventory;
}
Also used : NBTTagList(net.minecraft.server.v1_16_R3.NBTTagList) NBTTagCompound(net.minecraft.server.v1_16_R3.NBTTagCompound) InventoryHolder(com.bgsoftware.wildchests.objects.inventory.InventoryHolder)

Example 64 with NBTTagCompound

use of net.minecraft.server.v1_16_R2.NBTTagCompound in project WildChests by BG-Software-LLC.

the class NMSAdapter_v1_16_R3 method getChestName.

@Override
public String getChestName(org.bukkit.inventory.ItemStack itemStack) {
    ItemStack nmsItem = CraftItemStack.asNMSCopy(itemStack);
    NBTTagCompound tagCompound = nmsItem.getTag();
    return tagCompound == null || !tagCompound.hasKey("chest-name") ? null : tagCompound.getString("chest-name");
}
Also used : NBTTagCompound(net.minecraft.server.v1_16_R3.NBTTagCompound) CraftItemStack(org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack) ItemStack(net.minecraft.server.v1_16_R3.ItemStack)

Example 65 with NBTTagCompound

use of net.minecraft.server.v1_16_R2.NBTTagCompound in project WildChests by BG-Software-LLC.

the class NMSAdapter_v1_16_R3 method setItemTag.

private org.bukkit.inventory.ItemStack setItemTag(org.bukkit.inventory.ItemStack itemStack, String key, String value) {
    ItemStack nmsItem = CraftItemStack.asNMSCopy(itemStack);
    NBTTagCompound tagCompound = nmsItem.getOrCreateTag();
    tagCompound.setString(key, value);
    return CraftItemStack.asCraftMirror(nmsItem);
}
Also used : NBTTagCompound(net.minecraft.server.v1_16_R3.NBTTagCompound) CraftItemStack(org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack) ItemStack(net.minecraft.server.v1_16_R3.ItemStack)

Aggregations

NBTTagCompound (net.minecraft.server.v1_12_R1.NBTTagCompound)87 ItemStack (org.bukkit.inventory.ItemStack)61 Map (java.util.Map)44 ArrayList (java.util.ArrayList)39 NBTTagCompound (net.minecraft.server.v1_16_R3.NBTTagCompound)39 NBTTagCompound (net.minecraft.server.v1_8_R3.NBTTagCompound)38 ItemMeta (org.bukkit.inventory.meta.ItemMeta)35 CraftItemStack (org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack)34 CompoundTag (com.wasteofplastic.org.jnbt.CompoundTag)30 ListTag (com.wasteofplastic.org.jnbt.ListTag)30 StringTag (com.wasteofplastic.org.jnbt.StringTag)30 Tag (com.wasteofplastic.org.jnbt.Tag)30 NBTTagList (net.minecraft.server.v1_12_R1.NBTTagList)24 NBTTagCompound (net.minecraft.server.v1_16_R2.NBTTagCompound)24 Nullable (javax.annotation.Nullable)21 NBTTagCompound (net.minecraft.server.v1_9_R2.NBTTagCompound)21 NBTTagCompound (net.minecraft.server.v1_10_R1.NBTTagCompound)20 NBTTagCompound (net.minecraft.server.v1_11_R1.NBTTagCompound)20 CraftItemStack (org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack)20 NBTTagCompound (net.minecraft.server.v1_15_R1.NBTTagCompound)18