Search in sources :

Example 36 with TagByte

use of de.keyle.knbt.TagByte in project MyPet by xXKeyleXx.

the class CommandOptionCreate method createInfo.

public static void createInfo(MyPetType petType, String[] args, TagCompound compound) {
    for (String arg : args) {
        if (arg.equalsIgnoreCase("baby")) {
            compound.getCompoundData().put("Baby", new TagByte(true));
        } else if (arg.equalsIgnoreCase("fire")) {
            compound.getCompoundData().put("Fire", new TagByte(true));
        } else if (arg.equalsIgnoreCase("powered")) {
            compound.getCompoundData().put("Powered", new TagByte(true));
        } else if (arg.equalsIgnoreCase("saddle")) {
            compound.getCompoundData().put("Saddle", new TagByte(true));
        } else if (arg.equalsIgnoreCase("sheared")) {
            compound.getCompoundData().put("Sheared", new TagByte(true));
        } else if (arg.equalsIgnoreCase("wither")) {
            compound.getCompoundData().put("Type", new TagInt(1));
        } else if (arg.equalsIgnoreCase("stray")) {
            compound.getCompoundData().put("Type", new TagInt(2));
        } else if (arg.equalsIgnoreCase("husk")) {
            compound.getCompoundData().put("Type", new TagInt(6));
        } else if (arg.equalsIgnoreCase("tamed")) {
            compound.getCompoundData().put("Tamed", new TagByte(true));
        } else if (arg.equalsIgnoreCase("angry")) {
            compound.getCompoundData().put("Angry", new TagByte(true));
        } else if (arg.equalsIgnoreCase("villager")) {
            compound.getCompoundData().put("Villager", new TagByte(true));
        } else if (arg.equalsIgnoreCase("chest")) {
            compound.getCompoundData().put("Chest", new TagByte(true));
        } else if (arg.equalsIgnoreCase("elder")) {
            compound.getCompoundData().put("Elder", new TagByte(true));
        } else if (arg.equalsIgnoreCase("donkey")) {
            compound.getCompoundData().put("Type", new TagByte((byte) 1));
        } else if (arg.equalsIgnoreCase("mule")) {
            compound.getCompoundData().put("Type", new TagByte((byte) 2));
        } else if (arg.equalsIgnoreCase("zombie")) {
            compound.getCompoundData().put("Type", new TagByte((byte) 3));
        } else if (arg.equalsIgnoreCase("skeleton")) {
            compound.getCompoundData().put("Type", new TagByte((byte) 4));
        } else if (arg.equalsIgnoreCase("glowing")) {
            compound.getCompoundData().put("Glowing", new TagByte(true));
        } else if (arg.startsWith("size:")) {
            String size = arg.replace("size:", "");
            if (Util.isInt(size)) {
                compound.getCompoundData().put("Size", new TagInt(Integer.parseInt(size)));
            }
        } else if (arg.startsWith("horse:")) {
            String horseTypeString = arg.replace("horse:", "");
            if (Util.isByte(horseTypeString)) {
                int horseType = Integer.parseInt(horseTypeString);
                horseType = Math.min(Math.max(0, horseType), 4);
                compound.getCompoundData().put("Type", new TagByte((byte) horseType));
            }
        } else if (arg.startsWith("variant:")) {
            String variantString = arg.replace("variant:", "");
            if (Util.isInt(variantString)) {
                int variant = Integer.parseInt(variantString);
                if (petType == MyPetType.Horse) {
                    variant = Math.min(Math.max(0, variant), 1030);
                    compound.getCompoundData().put("Variant", new TagInt(variant));
                } else if (petType == MyPetType.Rabbit) {
                    if (variant != 99 && (variant > 5 || variant < 0)) {
                        variant = 0;
                    }
                    compound.getCompoundData().put("Variant", new TagByte(variant));
                } else if (petType == MyPetType.Llama) {
                    if (variant > 3 || variant < 0) {
                        variant = 0;
                    }
                    compound.getCompoundData().put("Variant", new TagInt(variant));
                } else if (petType == MyPetType.Parrot) {
                    compound.getCompoundData().put("Variant", new TagInt(variant));
                }
            }
        } else if (arg.startsWith("cat:")) {
            String catTypeString = arg.replace("cat:", "");
            if (Util.isInt(catTypeString)) {
                int catType = Integer.parseInt(catTypeString);
                catType = Math.min(Math.max(0, catType), 3);
                compound.getCompoundData().put("CatType", new TagInt(catType));
            }
        } else if (arg.startsWith("profession:")) {
            String professionString = arg.replace("profession:", "");
            if (Util.isInt(professionString)) {
                int profession = Integer.parseInt(professionString);
                profession = Math.min(Math.max(0, profession), 5);
                if (petType == MyPetType.Villager) {
                    compound.getCompoundData().put("Profession", new TagInt(profession));
                } else if (petType == MyPetType.Zombie) {
                    compound.getCompoundData().put("Villager", new TagByte(true));
                    compound.getCompoundData().put("Profession", new TagInt(profession));
                }
            }
        } else if (arg.startsWith("color:")) {
            String colorString = arg.replace("color:", "");
            if (Util.isByte(colorString)) {
                byte color = Byte.parseByte(colorString);
                color = color > 15 ? 15 : color < 0 ? 0 : color;
                compound.getCompoundData().put("Color", new TagByte(color));
            }
        } else if (arg.startsWith("collar:")) {
            String colorString = arg.replace("collar:", "");
            if (Util.isByte(colorString)) {
                byte color = Byte.parseByte(colorString);
                color = color > 15 ? 15 : color < 0 ? 0 : color;
                compound.getCompoundData().put("CollarColor", new TagByte(color));
            }
        } else if (arg.startsWith("block:")) {
            String blocks = arg.replace("block:", "");
            String[] blockInfo = blocks.split(":");
            if (blockInfo.length >= 1 && Util.isInt(blockInfo[0]) && MyPetApi.getPlatformHelper().isValidMaterial(Integer.parseInt(blockInfo[0]))) {
                compound.getCompoundData().put("BlockID", new TagInt(Integer.parseInt(blockInfo[0])));
            }
            if (blockInfo.length >= 2 && Util.isInt(blockInfo[1])) {
                int blockData = Integer.parseInt(blockInfo[1]);
                blockData = Math.min(Math.max(0, blockData), 15);
                compound.getCompoundData().put("BlockData", new TagInt(blockData));
            }
        }
    }
}
Also used : TagInt(de.keyle.knbt.TagInt) TagByte(de.keyle.knbt.TagByte)

Example 37 with TagByte

use of de.keyle.knbt.TagByte in project MyPet by xXKeyleXx.

the class Pickup method save.

public TagCompound save() {
    TagCompound nbtTagCompound = new TagCompound();
    nbtTagCompound.getCompoundData().put("Active", new TagByte(pickup));
    return nbtTagCompound;
}
Also used : TagCompound(de.keyle.knbt.TagCompound) TagByte(de.keyle.knbt.TagByte)

Example 38 with TagByte

use of de.keyle.knbt.TagByte in project MyPet by xXKeyleXx.

the class Inventory method save.

@Override
public void save(TagCompound tagCompound) {
    tagCompound.getCompoundData().put("add", new TagInt(Integer.parseInt(rowsInput.getText())));
    tagCompound.getCompoundData().put("drop", new TagByte(dropContentCheckBox.isSelected()));
}
Also used : TagInt(de.keyle.knbt.TagInt) TagByte(de.keyle.knbt.TagByte)

Example 39 with TagByte

use of de.keyle.knbt.TagByte in project MyPet by xXKeyleXx.

the class Pickup method save.

@Override
public void save(TagCompound tagCompound) {
    tagCompound.getCompoundData().put("addset_range", new TagString(addRangeRadioButton.isSelected() ? "add" : "set"));
    tagCompound.getCompoundData().put("range", new TagDouble(Double.parseDouble(rangeInput.getText())));
    tagCompound.getCompoundData().put("exp_pickup", new TagByte(expPickupCheckBox.isSelected()));
}
Also used : TagString(de.keyle.knbt.TagString) TagByte(de.keyle.knbt.TagByte) TagDouble(de.keyle.knbt.TagDouble)

Example 40 with TagByte

use of de.keyle.knbt.TagByte in project MyPet by xXKeyleXx.

the class EntityConverterService method convertWolf.

public void convertWolf(Wolf wolf, TagCompound properties) {
    properties.getCompoundData().put("Sitting", new TagByte(wolf.isSitting()));
    properties.getCompoundData().put("Tamed", new TagByte(wolf.isTamed()));
    properties.getCompoundData().put("CollarColor", new TagByte(wolf.getCollarColor().getWoolData()));
}
Also used : TagByte(de.keyle.knbt.TagByte)

Aggregations

TagByte (de.keyle.knbt.TagByte)75 TagCompound (de.keyle.knbt.TagCompound)43 TagInt (de.keyle.knbt.TagInt)36 TagList (de.keyle.knbt.TagList)13 ArrayList (java.util.ArrayList)13 ItemStack (org.bukkit.inventory.ItemStack)7 EquipmentSlot (de.Keyle.MyPet.api.entity.EquipmentSlot)4 TagDouble (de.keyle.knbt.TagDouble)1 TagString (de.keyle.knbt.TagString)1 CraftItemStack (org.bukkit.craftbukkit.v1_10_R1.inventory.CraftItemStack)1 CraftItemStack (org.bukkit.craftbukkit.v1_11_R1.inventory.CraftItemStack)1 CraftItemStack (org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack)1 CraftItemStack (org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack)1 CraftItemStack (org.bukkit.craftbukkit.v1_8_R1.inventory.CraftItemStack)1 CraftItemStack (org.bukkit.craftbukkit.v1_8_R2.inventory.CraftItemStack)1 CraftItemStack (org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack)1 CraftItemStack (org.bukkit.craftbukkit.v1_9_R1.inventory.CraftItemStack)1 CraftItemStack (org.bukkit.craftbukkit.v1_9_R2.inventory.CraftItemStack)1