Search in sources :

Example 11 with TagDouble

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

the class Life method upgrade.

public void upgrade(SkillInfo upgrade, boolean quiet) {
    if (upgrade instanceof LifeInfo) {
        if (upgrade.getProperties().getCompoundData().containsKey("hp")) {
            int hp = upgrade.getProperties().getAs("hp", TagInt.class).getIntData();
            upgrade.getProperties().getCompoundData().remove("hp");
            TagDouble TagDouble = new TagDouble(hp);
            upgrade.getProperties().getCompoundData().put("hp_double", TagDouble);
        }
        if (upgrade.getProperties().getCompoundData().containsKey("hp_double")) {
            if (!upgrade.getProperties().getCompoundData().containsKey("addset_hp") || upgrade.getProperties().getAs("addset_hp", TagString.class).getStringData().equals("add")) {
                hpIncrease += upgrade.getProperties().getAs("hp_double", TagDouble.class).getDoubleData();
            } else {
                hpIncrease = upgrade.getProperties().getAs("hp_double", TagDouble.class).getDoubleData();
            }
            if (getMyPet().getStatus() == PetState.Here) {
                getMyPet().getEntity().get().setMaxHealth(getMyPet().getMaxHealth());
            }
            if (!quiet) {
                myPet.getOwner().sendMessage(Util.formatText(Translation.getString("Message.Skill.Hp.Upgrade", myPet.getOwner().getLanguage()), myPet.getPetName(), myPet.getMaxHealth()));
            }
        }
    }
}
Also used : LifeInfo(de.Keyle.MyPet.api.skill.skills.LifeInfo) TagInt(de.keyle.knbt.TagInt) TagString(de.keyle.knbt.TagString) TagDouble(de.keyle.knbt.TagDouble)

Example 12 with TagDouble

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

the class Ranged method upgrade.

public void upgrade(SkillInfo upgrade, boolean quiet) {
    if (upgrade instanceof RangedInfo) {
        boolean isPassive = damage <= 0;
        if (upgrade.getProperties().getCompoundData().containsKey("damage")) {
            int damage = upgrade.getProperties().getAs("damage", TagInt.class).getIntData();
            upgrade.getProperties().getCompoundData().remove("damage");
            TagDouble TagDouble = new TagDouble(damage);
            upgrade.getProperties().getCompoundData().put("damage_double", TagDouble);
        }
        if (upgrade.getProperties().getCompoundData().containsKey("damage_double")) {
            if (!upgrade.getProperties().getCompoundData().containsKey("addset_damage") || upgrade.getProperties().getAs("addset_damage", TagString.class).getStringData().equals("add")) {
                damage += upgrade.getProperties().getAs("damage_double", TagDouble.class).getDoubleData();
            } else {
                damage = upgrade.getProperties().getAs("damage_double", TagDouble.class).getDoubleData();
            }
        }
        if (upgrade.getProperties().getCompoundData().containsKey("projectile")) {
            String projectileName = upgrade.getProperties().getAs("projectile", TagString.class).getStringData();
            for (Projectiles projectile : Projectiles.values()) {
                if (projectile.name().equalsIgnoreCase(projectileName)) {
                    selectedProjectile = projectile;
                }
            }
        }
        if (upgrade.getProperties().getCompoundData().containsKey("rateoffire")) {
            if (!upgrade.getProperties().getCompoundData().containsKey("addset_rateoffire") || upgrade.getProperties().getAs("addset_rateoffire", TagString.class).getStringData().equals("add")) {
                rateOfFire += upgrade.getProperties().getAs("rateoffire", TagInt.class).getIntData();
            } else {
                rateOfFire = upgrade.getProperties().getAs("rateoffire", TagInt.class).getIntData();
            }
        }
        if (!quiet) {
            myPet.getOwner().sendMessage(Util.formatText(Translation.getString("Message.Skill.Ranged.Upgrade", myPet.getOwner()), myPet.getPetName(), Translation.getString("Name." + getProjectile().name(), myPet.getOwner()), damage, String.format("%1.2f", (1. / ((getRateOfFire() * 50.) / 1000.)) * 60.)));
        }
        if (isPassive != (damage <= 0)) {
            if (myPet.getStatus() == PetState.Here) {
                getMyPet().getEntity().get().getHandle().getPathfinder().clearGoals();
                getMyPet().getEntity().get().getHandle().getTargetSelector().clearGoals();
                getMyPet().getEntity().get().getHandle().setPathfinder();
                if (damage == 0) {
                    getMyPet().getEntity().get().setTarget(null);
                }
            }
        }
    }
}
Also used : RangedInfo(de.Keyle.MyPet.api.skill.skills.RangedInfo) TagInt(de.keyle.knbt.TagInt) TagString(de.keyle.knbt.TagString) TagString(de.keyle.knbt.TagString) TagDouble(de.keyle.knbt.TagDouble)

Example 13 with TagDouble

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

the class Damage method save.

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

Example 14 with TagDouble

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

the class Damage method load.

@Override
public void load(TagCompound TagCompound) {
    if (!TagCompound.getCompoundData().containsKey("addset_damage") || TagCompound.getAs("addset_damage", TagString.class).getStringData().equals("add")) {
        addDamageRadioButton.setSelected(true);
    } else {
        setdamageRadioButton.setSelected(true);
    }
    if (TagCompound.getCompoundData().containsKey("damage")) {
        TagCompound.getCompoundData().put("damage_double", new TagDouble(TagCompound.getAs("damage", TagInt.class).getIntData()));
        TagCompound.getCompoundData().remove("damage");
    }
    if (TagCompound.getCompoundData().containsKey("damage_double")) {
        damageInput.setText("" + TagCompound.getAs("damage_double", TagDouble.class).getDoubleData());
    }
}
Also used : TagInt(de.keyle.knbt.TagInt) TagString(de.keyle.knbt.TagString) TagDouble(de.keyle.knbt.TagDouble)

Example 15 with TagDouble

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

the class Lightning method load.

@Override
public void load(TagCompound TagCompound) {
    if (!TagCompound.getCompoundData().containsKey("addset_chance") || TagCompound.getAs("addset_chance", TagString.class).getStringData().equals("add")) {
        addChanceRadioButton.setSelected(true);
    } else {
        setChanceRadioButton.setSelected(true);
    }
    if (TagCompound.getCompoundData().containsKey("chance")) {
        chanceInput.setText("" + TagCompound.getAs("chance", TagInt.class).getIntData());
    }
    if (!TagCompound.getCompoundData().containsKey("addset_damage") || TagCompound.getAs("addset_damage", TagString.class).getStringData().equals("add")) {
        addDamageRadioButton.setSelected(true);
    } else {
        setDamageRadioButton.setSelected(true);
    }
    if (TagCompound.getCompoundData().containsKey("damage")) {
        TagCompound.getCompoundData().put("damage_double", new TagDouble(TagCompound.getAs("damage", TagInt.class).getIntData()));
        TagCompound.getCompoundData().remove("damage");
    }
    if (TagCompound.getCompoundData().containsKey("damage_double")) {
        damageInput.setText("" + TagCompound.getAs("damage_double", TagDouble.class).getDoubleData());
    }
}
Also used : TagInt(de.keyle.knbt.TagInt) TagString(de.keyle.knbt.TagString) TagDouble(de.keyle.knbt.TagDouble)

Aggregations

TagDouble (de.keyle.knbt.TagDouble)17 TagString (de.keyle.knbt.TagString)17 TagInt (de.keyle.knbt.TagInt)14 DamageInfo (de.Keyle.MyPet.api.skill.skills.DamageInfo)1 HealInfo (de.Keyle.MyPet.api.skill.skills.HealInfo)1 LifeInfo (de.Keyle.MyPet.api.skill.skills.LifeInfo)1 LightningInfo (de.Keyle.MyPet.api.skill.skills.LightningInfo)1 RangedInfo (de.Keyle.MyPet.api.skill.skills.RangedInfo)1 TagByte (de.keyle.knbt.TagByte)1