Java Code Examples for org.bukkit.DyeColor#getByDyeData()

The following examples show how to use org.bukkit.DyeColor#getByDyeData() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CraftMetaBanner.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
CraftMetaBanner(NBTTagCompound tag) {
    super(tag);

    if (!tag.hasKey("BlockEntityTag")) {
        return;
    }

    NBTTagCompound entityTag = tag.getCompoundTag("BlockEntityTag");

    base = entityTag.hasKey(BASE.NBT) ? DyeColor.getByDyeData((byte) entityTag.getInteger(BASE.NBT)) : null;

    if (entityTag.hasKey(PATTERNS.NBT)) {
        NBTTagList patterns = entityTag.getTagList(PATTERNS.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND);
        for (int i = 0; i < Math.min(patterns.tagCount(), 20); i++) {
            NBTTagCompound p = patterns.getCompoundTagAt(i);
            this.patterns.add(new Pattern(DyeColor.getByDyeData((byte) p.getInteger(COLOR.NBT)), PatternType.getByIdentifier(p.getString(PATTERN.NBT))));
        }
    }
}
 
Example 2
Source File: CraftBanner.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void load(TileEntityBanner banner) {
    super.load(banner);

    base = DyeColor.getByDyeData((byte) banner.baseColor.getDyeDamage());
    patterns = new ArrayList<Pattern>();

    if (banner.patterns != null) {
        for (int i = 0; i < banner.patterns.tagCount(); i++) {
            NBTTagCompound p = (NBTTagCompound) banner.patterns.get(i);
            patterns.add(new Pattern(DyeColor.getByDyeData((byte) p.getInteger("Color")), PatternType.getByIdentifier(p.getString("Pattern"))));
        }
    }
}
 
Example 3
Source File: DyeItemData.java    From SonarPet with GNU General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
public DyeColor getColor() {
    return DyeColor.getByDyeData(getRawData());
}
 
Example 4
Source File: BannerBlock.java    From askyblock with GNU General Public License v2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
public boolean prep(Map<String, Tag> tileData) {
    // Format for banner is:
    // Patterns = List of patterns
    // id = String "BannerBlock"
    // Base = Int color
    // Then the location
    // z = Int
    // y = Int
    // 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()) {
                // ASkyBlock.getPlugin().getLogger().info("pattern = " +
                // pattern);
                // 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());
                    // ASkyBlock.getPlugin().getLogger().info(" dye color = "
                    // + 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;
}
 
Example 5
Source File: SlotLapis.java    From Carbon with GNU Lesser General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public boolean isAllowed(ItemStack itemStack) {
	return itemStack.getItem() == Items.INK_SACK && DyeColor.getByDyeData((byte) itemStack.getData()) == DyeColor.BLUE;
}
 
Example 6
Source File: Dye.java    From Kettle with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Gets the current color of this dye
 *
 * @return DyeColor of this dye
 */
public DyeColor getColor() {
    return DyeColor.getByDyeData(getData());
}