Search in sources :

Example 46 with CompoundTag

use of com.wasteofplastic.org.jnbt.CompoundTag in project acidisland by tastybento.

the class BannerBlock method prep.

@SuppressWarnings("deprecation")
public boolean prep(Map<String, Tag> tileData) {
    // x = Int
    try {
        // Do the base color
        int baseColor = 15 - ((IntTag) tileData.get("Base")).getValue();
        // //ASkyBlock.getPlugin().getLogger().info("Base value = " +
        // baseColor);
        // baseColor green = 10
        bannerBaseColor = DyeColor.getByDyeData((byte) baseColor);
        // Do the patterns (no idea if this will work or not)
        bannerPattern = new ArrayList<Pattern>();
        ListTag patterns = (ListTag) tileData.get("Patterns");
        if (patterns != null) {
            for (Tag pattern : patterns.getValue()) {
                // Translate pattern to PatternType
                if (pattern instanceof CompoundTag) {
                    CompoundTag patternColor = (CompoundTag) pattern;
                    // The tag is made up of pattern (String) and color
                    // (int)
                    Map<String, Tag> patternValue = patternColor.getValue();
                    StringTag mark = (StringTag) patternValue.get("Pattern");
                    Integer markColor = 15 - ((IntTag) patternValue.get("Color")).getValue();
                    // ASkyBlock.getPlugin().getLogger().info("mark = " +
                    // mark.getValue());
                    // ASkyBlock.getPlugin().getLogger().info("color = " +
                    // markColor);
                    DyeColor dColor = DyeColor.getByDyeData(markColor.byteValue());
                    // + dColor.toString());
                    if (patternKey.containsKey(mark.getValue())) {
                        Pattern newPattern = new Pattern(dColor, patternKey.get(mark.getValue()));
                        bannerPattern.add(newPattern);
                    }
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return true;
}
Also used : StringTag(com.wasteofplastic.org.jnbt.StringTag) Pattern(org.bukkit.block.banner.Pattern) ListTag(com.wasteofplastic.org.jnbt.ListTag) StringTag(com.wasteofplastic.org.jnbt.StringTag) CompoundTag(com.wasteofplastic.org.jnbt.CompoundTag) IntTag(com.wasteofplastic.org.jnbt.IntTag) Tag(com.wasteofplastic.org.jnbt.Tag) DyeColor(org.bukkit.DyeColor) ListTag(com.wasteofplastic.org.jnbt.ListTag) CompoundTag(com.wasteofplastic.org.jnbt.CompoundTag)

Aggregations

CompoundTag (com.wasteofplastic.org.jnbt.CompoundTag)46 StringTag (com.wasteofplastic.org.jnbt.StringTag)46 Tag (com.wasteofplastic.org.jnbt.Tag)46 ListTag (com.wasteofplastic.org.jnbt.ListTag)44 Map (java.util.Map)42 ItemStack (org.bukkit.inventory.ItemStack)22 ArrayList (java.util.ArrayList)20 ItemMeta (org.bukkit.inventory.meta.ItemMeta)20 Potion (org.bukkit.potion.Potion)12 PotionType (org.bukkit.potion.PotionType)12 HashMap (java.util.HashMap)8 NBTTagCompound (net.minecraft.server.v1_10_R1.NBTTagCompound)4 NBTTagString (net.minecraft.server.v1_10_R1.NBTTagString)4 NBTTagCompound (net.minecraft.server.v1_11_R1.NBTTagCompound)4 NBTTagString (net.minecraft.server.v1_11_R1.NBTTagString)4 NBTTagCompound (net.minecraft.server.v1_12_R1.NBTTagCompound)4 NBTTagString (net.minecraft.server.v1_12_R1.NBTTagString)4 NBTTagString (net.minecraft.server.v1_7_R3.NBTTagString)4 NBTTagString (net.minecraft.server.v1_7_R4.NBTTagString)4 NBTTagString (net.minecraft.server.v1_8_R1.NBTTagString)4