Search in sources :

Example 21 with TagInt

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

the class Ranged method save.

@Override
public void save(TagCompound tagCompound) {
    tagCompound.getCompoundData().put("projectile", new TagString(((String) projectileComboBox.getSelectedItem()).replace(" ", "")));
    tagCompound.getCompoundData().put("addset_damage", new TagString(addDamageRadioButton.isSelected() ? "add" : "set"));
    tagCompound.getCompoundData().put("damage_double", new TagDouble(Double.parseDouble(damageInput.getText())));
    tagCompound.getCompoundData().put("addset_rateoffire", new TagString(addRateOfFireRadioButton.isSelected() ? "add" : "set"));
    tagCompound.getCompoundData().put("rateoffire", new TagInt(Integer.parseInt(rateOfFireInput.getText())));
}
Also used : TagInt(de.keyle.knbt.TagInt) TagString(de.keyle.knbt.TagString) TagString(de.keyle.knbt.TagString) TagDouble(de.keyle.knbt.TagDouble)

Example 22 with TagInt

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

the class Slow method save.

@Override
public void save(TagCompound tagCompound) {
    tagCompound.getCompoundData().put("addset_chance", new TagString(addChanceRadioButton.isSelected() ? "add" : "set"));
    tagCompound.getCompoundData().put("chance", new TagInt(Integer.parseInt(chanceInput.getText())));
    tagCompound.getCompoundData().put("addset_duration", new TagString(addTimeRadioButton.isSelected() ? "add" : "set"));
    tagCompound.getCompoundData().put("duration", new TagInt(Integer.parseInt(timeInput.getText())));
}
Also used : TagInt(de.keyle.knbt.TagInt) TagString(de.keyle.knbt.TagString)

Example 23 with TagInt

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

the class Stomp method save.

@Override
public void save(TagCompound tagCompound) {
    tagCompound.getCompoundData().put("addset_chance", new TagString(addChanceRadioButton.isSelected() ? "add" : "set"));
    tagCompound.getCompoundData().put("chance", new TagInt(Integer.parseInt(chanceInput.getText())));
    tagCompound.getCompoundData().put("addset_damage", new TagString(addDamageRadioButton.isSelected() ? "add" : "set"));
    tagCompound.getCompoundData().put("damage", new TagDouble(Double.parseDouble(damageInput.getText())));
}
Also used : TagInt(de.keyle.knbt.TagInt) TagString(de.keyle.knbt.TagString) TagDouble(de.keyle.knbt.TagDouble)

Example 24 with TagInt

use of de.keyle.knbt.TagInt 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("screaming")) {
            compound.getCompoundData().put("Screaming", 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.equalsIgnoreCase("rainbow")) {
            compound.getCompoundData().put("Rainbow", new TagByte(true));
        } else if (arg.equalsIgnoreCase("has-stung")) {
            compound.getCompoundData().put("HasStung", new TagByte(true));
        } else if (arg.equalsIgnoreCase("has-nectar")) {
            compound.getCompoundData().put("HasNectar", 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 || petType == MyPetType.TraderLlama) {
                    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 (petType == MyPetType.Axolotl) {
                    compound.getCompoundData().put("Variant", new TagInt(variant));
                } else if (petType == MyPetType.TropicalFish) {
                    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), MyPetApi.getCompatUtil().isCompatible("1.14") ? 15 : 5);
                if (petType == MyPetType.Villager) {
                    compound.getCompoundData().put("Profession", new TagInt(profession));
                    if (!compound.getCompoundData().containsKey("VillagerLevel")) {
                        compound.getCompoundData().put("VillagerLevel", new TagInt(1));
                    }
                } else if (petType == MyPetType.Zombie || petType == MyPetType.ZombieVillager) {
                    compound.getCompoundData().put("Villager", new TagByte(true));
                    compound.getCompoundData().put("Profession", new TagInt(profession));
                    if (!compound.getCompoundData().containsKey("TradingLevel")) {
                        compound.getCompoundData().put("TradingLevel", new TagInt(1));
                    }
                }
            }
        } 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 block = arg.replace("block:", "");
            ItemDatabase itemDatabase = MyPetApi.getServiceManager().getService(ItemDatabase.class).get();
            MaterialHolder materialHolder = itemDatabase.getByID(block.toLowerCase());
            if (materialHolder != null) {
                compound.getCompoundData().put("BlockName", new TagString(materialHolder.getId()));
            }
        } else if (arg.startsWith("puff:")) {
            switch(arg) {
                case "puff:none":
                    compound.getCompoundData().put("PuffState", new TagInt(0));
                    break;
                case "puff:semi":
                    compound.getCompoundData().put("PuffState", new TagInt(1));
                    break;
                case "puff:fully":
                    compound.getCompoundData().put("PuffState", new TagInt(2));
                    break;
            }
        } else if (arg.startsWith("main-gene:") || arg.startsWith("hidden-gene:")) {
            String gene;
            String key;
            if (arg.startsWith("main-gene:")) {
                key = "MainGene";
                gene = arg.substring(10);
            } else {
                key = "HiddenGene";
                gene = arg.substring(12);
            }
            switch(gene.toLowerCase()) {
                case "normal":
                    compound.getCompoundData().put(key, new TagInt(0));
                    break;
                case "lazy":
                    compound.getCompoundData().put(key, new TagInt(1));
                    break;
                case "worried":
                    compound.getCompoundData().put(key, new TagInt(2));
                    break;
                case "playful":
                    compound.getCompoundData().put(key, new TagInt(3));
                    break;
                case "brown":
                    compound.getCompoundData().put(key, new TagInt(4));
                    break;
                case "weak":
                    compound.getCompoundData().put(key, new TagInt(5));
                    break;
                case "aggressive":
                    compound.getCompoundData().put(key, new TagInt(6));
                    break;
            }
        } else if (arg.startsWith("type:")) {
            switch(petType) {
                case Fox:
                    switch(arg) {
                        case "type:white":
                            compound.getCompoundData().put("FoxType", new TagInt(1));
                            break;
                        case "type:red":
                        default:
                            compound.getCompoundData().put("FoxType", new TagInt(0));
                            break;
                    }
                    break;
                case Mooshroom:
                    switch(arg) {
                        case "type:brown":
                            compound.getCompoundData().put("CowType", new TagInt(1));
                            break;
                        case "type:red":
                        default:
                            compound.getCompoundData().put("CowType", new TagInt(0));
                            break;
                    }
                    break;
                case Cat:
                    String catTypeString = arg.replace("type:", "");
                    if (Util.isInt(catTypeString)) {
                        int catType = Integer.parseInt(catTypeString);
                        catType = Util.clamp(catType, 0, 10);
                        compound.getCompoundData().put("CatType", new TagInt(catType));
                    }
                    break;
                case Villager:
                case ZombieVillager:
                    String villagerTypeString = arg.replace("type:", "");
                    if (Util.isInt(villagerTypeString)) {
                        int villagerType = Integer.parseInt(villagerTypeString);
                        villagerType = Util.clamp(villagerType, 0, 6);
                        compound.getCompoundData().put("VillagerType", new TagInt(villagerType));
                    }
                    break;
            }
        }
    }
}
Also used : ItemDatabase(de.Keyle.MyPet.api.util.inventory.material.ItemDatabase) TagInt(de.keyle.knbt.TagInt) TagString(de.keyle.knbt.TagString) MaterialHolder(de.Keyle.MyPet.api.util.inventory.material.MaterialHolder) TagString(de.keyle.knbt.TagString) TagByte(de.keyle.knbt.TagByte)

Example 25 with TagInt

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

the class MyMagmaCube method writeExtendedInfo.

@Override
public TagCompound writeExtendedInfo() {
    TagCompound info = super.writeExtendedInfo();
    info.getCompoundData().put("Size", new TagInt(getSize()));
    return info;
}
Also used : TagInt(de.keyle.knbt.TagInt) TagCompound(de.keyle.knbt.TagCompound)

Aggregations

TagInt (de.keyle.knbt.TagInt)98 TagCompound (de.keyle.knbt.TagCompound)57 TagByte (de.keyle.knbt.TagByte)43 ItemStack (org.bukkit.inventory.ItemStack)24 TagList (de.keyle.knbt.TagList)16 TagString (de.keyle.knbt.TagString)13 ArrayList (java.util.ArrayList)10 HashSet (java.util.HashSet)7 TagDouble (de.keyle.knbt.TagDouble)6 EquipmentSlot (de.Keyle.MyPet.api.entity.EquipmentSlot)3 TagByteArray (de.keyle.knbt.TagByteArray)2 TagFloat (de.keyle.knbt.TagFloat)2 TagIntArray (de.keyle.knbt.TagIntArray)2 TagLong (de.keyle.knbt.TagLong)2 TagShort (de.keyle.knbt.TagShort)2 List (java.util.List)2 ByteArrayTag (net.minecraft.nbt.ByteArrayTag)2 ByteTag (net.minecraft.nbt.ByteTag)2 CompoundTag (net.minecraft.nbt.CompoundTag)2 DoubleTag (net.minecraft.nbt.DoubleTag)2