Search in sources :

Example 31 with NBTTagList

use of net.minecraft.server.v1_16_R2.NBTTagList in project PaperDev by Kamillaova.

the class CraftMetaBanner method applyToItem.

@Override
void applyToItem(NBTTagCompound tag) {
    super.applyToItem(tag);
    NBTTagCompound entityTag = new NBTTagCompound();
    if (base != null) {
        entityTag.setInt(BASE.NBT, base.getDyeData());
    }
    NBTTagList newPatterns = new NBTTagList();
    for (Pattern p : patterns) {
        NBTTagCompound compound = new NBTTagCompound();
        compound.setInt(COLOR.NBT, p.getColor().getDyeData());
        compound.setString(PATTERN.NBT, p.getPattern().getIdentifier());
        newPatterns.add(compound);
    }
    entityTag.set(PATTERNS.NBT, newPatterns);
    tag.set("BlockEntityTag", entityTag);
}
Also used : NBTTagList(net.minecraft.server.v1_12_R1.NBTTagList) Pattern(org.bukkit.block.banner.Pattern) NBTTagCompound(net.minecraft.server.v1_12_R1.NBTTagCompound)

Example 32 with NBTTagList

use of net.minecraft.server.v1_16_R2.NBTTagList in project PaperDev by Kamillaova.

the class CraftMetaBook method applyToItem.

void applyToItem(NBTTagCompound itemData, boolean handlePages) {
    super.applyToItem(itemData);
    if (hasTitle()) {
        itemData.setString(BOOK_TITLE.NBT, this.title);
    }
    if (hasAuthor()) {
        itemData.setString(BOOK_AUTHOR.NBT, this.author);
    }
    if (handlePages) {
        if (hasPages()) {
            NBTTagList list = new NBTTagList();
            for (IChatBaseComponent page : pages) {
                list.add(new NBTTagString(CraftChatMessage.fromComponent(page)));
            }
            itemData.set(BOOK_PAGES.NBT, list);
        }
        itemData.remove(RESOLVED.NBT);
    }
    if (generation != null) {
        itemData.setInt(GENERATION.NBT, generation);
    }
}
Also used : NBTTagList(net.minecraft.server.v1_12_R1.NBTTagList) NBTTagString(net.minecraft.server.v1_12_R1.NBTTagString) IChatBaseComponent(net.minecraft.server.v1_12_R1.IChatBaseComponent)

Example 33 with NBTTagList

use of net.minecraft.server.v1_16_R2.NBTTagList in project PaperDev by Kamillaova.

the class CraftMetaBookSigned method applyToItem.

@Override
void applyToItem(NBTTagCompound itemData) {
    super.applyToItem(itemData, false);
    if (hasTitle()) {
        itemData.setString(BOOK_TITLE.NBT, this.title);
    } else {
        itemData.setString(BOOK_TITLE.NBT, " ");
    }
    if (hasAuthor()) {
        itemData.setString(BOOK_AUTHOR.NBT, this.author);
    } else {
        itemData.setString(BOOK_AUTHOR.NBT, " ");
    }
    if (hasPages()) {
        NBTTagList list = new NBTTagList();
        for (IChatBaseComponent page : pages) {
            list.add(new NBTTagString(ChatSerializer.a(page)));
        }
        itemData.set(BOOK_PAGES.NBT, list);
    }
    itemData.setBoolean(RESOLVED.NBT, true);
    if (generation != null) {
        itemData.setInt(GENERATION.NBT, generation);
    } else {
        itemData.setInt(GENERATION.NBT, 0);
    }
}
Also used : NBTTagList(net.minecraft.server.v1_12_R1.NBTTagList) NBTTagString(net.minecraft.server.v1_12_R1.NBTTagString) IChatBaseComponent(net.minecraft.server.v1_12_R1.IChatBaseComponent)

Example 34 with NBTTagList

use of net.minecraft.server.v1_16_R2.NBTTagList in project PaperDev by Kamillaova.

the class CraftMetaFirework method applyToItem.

@Override
void applyToItem(NBTTagCompound itemTag) {
    super.applyToItem(itemTag);
    if (isFireworkEmpty()) {
        return;
    }
    NBTTagCompound fireworks = itemTag.getCompound(FIREWORKS.NBT);
    itemTag.set(FIREWORKS.NBT, fireworks);
    if (hasEffects()) {
        NBTTagList effects = new NBTTagList();
        for (FireworkEffect effect : this.effects) {
            effects.add(getExplosion(effect));
        }
        if (effects.size() > 0) {
            fireworks.set(EXPLOSIONS.NBT, effects);
        }
    }
    if (hasPower()) {
        fireworks.setByte(FLIGHT.NBT, (byte) power);
    }
}
Also used : NBTTagList(net.minecraft.server.v1_12_R1.NBTTagList) NBTTagCompound(net.minecraft.server.v1_12_R1.NBTTagCompound) FireworkEffect(org.bukkit.FireworkEffect)

Example 35 with NBTTagList

use of net.minecraft.server.v1_16_R2.NBTTagList in project PaperDev by Kamillaova.

the class CraftMetaItem method applyEnchantments.

static void applyEnchantments(Map<Enchantment, Integer> enchantments, NBTTagCompound tag, ItemMetaKey key) {
    if (enchantments == null) /*|| enchantments.size() == 0*/
    {
        // Spigot - remove size check
        return;
    }
    NBTTagList list = new NBTTagList();
    for (Map.Entry<Enchantment, Integer> entry : enchantments.entrySet()) {
        NBTTagCompound subtag = new NBTTagCompound();
        subtag.setShort(ENCHANTMENTS_ID.NBT, (short) entry.getKey().getId());
        subtag.setShort(ENCHANTMENTS_LVL.NBT, entry.getValue().shortValue());
        list.add(subtag);
    }
    tag.set(key.NBT, list);
}
Also used : NBTTagList(net.minecraft.server.v1_12_R1.NBTTagList) NBTTagCompound(net.minecraft.server.v1_12_R1.NBTTagCompound) Enchantment(org.bukkit.enchantments.Enchantment) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) HashMap(java.util.HashMap) ImmutableSortedMap(com.google.common.collect.ImmutableSortedMap) TreeMap(java.util.TreeMap)

Aggregations

NBTTagList (net.minecraft.server.v1_12_R1.NBTTagList)27 ItemStack (org.bukkit.inventory.ItemStack)23 ArrayList (java.util.ArrayList)22 NBTTagCompound (net.minecraft.server.v1_12_R1.NBTTagCompound)22 ItemMeta (org.bukkit.inventory.meta.ItemMeta)22 Map (java.util.Map)21 CompoundTag (com.wasteofplastic.org.jnbt.CompoundTag)20 ListTag (com.wasteofplastic.org.jnbt.ListTag)20 StringTag (com.wasteofplastic.org.jnbt.StringTag)20 Tag (com.wasteofplastic.org.jnbt.Tag)20 TagCompound (de.keyle.knbt.TagCompound)9 InvocationTargetException (java.lang.reflect.InvocationTargetException)9 NBTTagString (net.minecraft.server.v1_12_R1.NBTTagString)9 CraftItemStack (org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack)8 NBTTagCompound (net.minecraft.server.v1_8_R3.NBTTagCompound)6 NBTTagList (net.minecraft.server.v1_8_R3.NBTTagList)6 NBTTagCompound (net.minecraft.server.v1_16_R3.NBTTagCompound)5 NBTTagList (net.minecraft.server.v1_16_R3.NBTTagList)5 NBTTagCompound (net.minecraft.server.v1_9_R2.NBTTagCompound)5 NBTTagList (net.minecraft.server.v1_9_R2.NBTTagList)5