Search in sources :

Example 1 with DamageInfo

use of de.Keyle.MyPet.api.skill.skills.DamageInfo in project MyPet by xXKeyleXx.

the class Damage method upgrade.

public void upgrade(SkillInfo upgrade, boolean quiet) {
    if (upgrade instanceof DamageInfo) {
        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 (!quiet) {
                myPet.getOwner().sendMessage(Util.formatText(Translation.getString("Message.Skill.Damage.Upgrade", myPet.getOwner().getLanguage()), myPet.getPetName(), damage));
            }
        }
        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 : TagInt(de.keyle.knbt.TagInt) TagString(de.keyle.knbt.TagString) DamageInfo(de.Keyle.MyPet.api.skill.skills.DamageInfo) TagDouble(de.keyle.knbt.TagDouble)

Aggregations

DamageInfo (de.Keyle.MyPet.api.skill.skills.DamageInfo)1 TagDouble (de.keyle.knbt.TagDouble)1 TagInt (de.keyle.knbt.TagInt)1 TagString (de.keyle.knbt.TagString)1