Search in sources :

Example 1 with EntityTameableAnimal

use of net.minecraft.server.v1_9_R2.EntityTameableAnimal in project MyPet by xXKeyleXx.

the class ControlTarget method shouldStart.

@Override
public boolean shouldStart() {
    if (controlPathfinderGoal == null) {
        if (petEntity.getPathfinder().hasGoal("Control")) {
            controlPathfinderGoal = (Control) petEntity.getPathfinder().getGoal("Control");
        }
    }
    if (controlPathfinderGoal == null) {
        return false;
    }
    if (myPet.getDamage() <= 0 && myPet.getRangedDamage() <= 0) {
        return false;
    }
    if (controlPathfinderGoal.moveTo != null && petEntity.canMove()) {
        Behavior behaviorSkill = null;
        if (myPet.getSkills().isSkillActive(Behavior.class)) {
            behaviorSkill = myPet.getSkills().getSkill(Behavior.class).get();
            if (behaviorSkill.getBehavior() == Behavior.BehaviorState.Friendly) {
                return false;
            }
        }
        for (Object entityObj : this.petEntity.world.a(EntityLiving.class, this.petEntity.boundingBox.grow((double) this.range, 4.0D, (double) this.range))) {
            EntityLiving entityLiving = (EntityLiving) entityObj;
            if (entityLiving != petEntity) {
                if (entityLiving instanceof EntityPlayer) {
                    Player targetPlayer = (Player) entityLiving.getBukkitEntity();
                    if (myPet.getOwner().equals(targetPlayer)) {
                        continue;
                    } else if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), targetPlayer, true)) {
                        continue;
                    }
                } else if (entityLiving instanceof EntityTameableAnimal) {
                    EntityTameableAnimal tameable = (EntityTameableAnimal) entityLiving;
                    if (tameable.isTamed() && tameable.getOwner() != null) {
                        Player tameableOwner = (Player) tameable.getOwner().getBukkitEntity();
                        if (myPet.getOwner().equals(tameableOwner)) {
                            continue;
                        } else if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), tameableOwner, true)) {
                            continue;
                        }
                    }
                } else if (entityLiving instanceof EntityMyPet) {
                    MyPet targetMyPet = ((EntityMyPet) entityLiving).getMyPet();
                    if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), targetMyPet.getOwner().getPlayer(), true)) {
                        continue;
                    }
                }
                if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), entityLiving.getBukkitEntity())) {
                    continue;
                }
                if (behaviorSkill != null) {
                    if (behaviorSkill.getBehavior() == BehaviorState.Raid) {
                        if (entityLiving instanceof EntityTameableAnimal) {
                            continue;
                        } else if (entityLiving instanceof EntityMyPet) {
                            continue;
                        } else if (entityLiving instanceof EntityPlayer) {
                            continue;
                        }
                    }
                }
                controlPathfinderGoal.stopControl();
                this.target = entityLiving;
                return true;
            }
        }
    }
    return false;
}
Also used : EntityPlayer(net.minecraft.server.v1_7_R4.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer) Player(org.bukkit.entity.Player) EntityMyPet(de.Keyle.MyPet.compat.v1_7_R4.entity.EntityMyPet) EntityLiving(net.minecraft.server.v1_7_R4.EntityLiving) MyPet(de.Keyle.MyPet.api.entity.MyPet) EntityMyPet(de.Keyle.MyPet.compat.v1_7_R4.entity.EntityMyPet) EntityPlayer(net.minecraft.server.v1_7_R4.EntityPlayer) EntityTameableAnimal(net.minecraft.server.v1_7_R4.EntityTameableAnimal) Behavior(de.Keyle.MyPet.skill.skills.Behavior)

Example 2 with EntityTameableAnimal

use of net.minecraft.server.v1_9_R2.EntityTameableAnimal in project MyPet by xXKeyleXx.

the class ControlTarget method shouldStart.

@Override
public boolean shouldStart() {
    if (controlPathfinderGoal == null) {
        if (petEntity.getPathfinder().hasGoal("Control")) {
            controlPathfinderGoal = (Control) petEntity.getPathfinder().getGoal("Control");
        }
    }
    if (controlPathfinderGoal == null) {
        return false;
    }
    if (myPet.getDamage() <= 0 && myPet.getRangedDamage() <= 0) {
        return false;
    }
    if (controlPathfinderGoal.moveTo != null && petEntity.canMove()) {
        Behavior behaviorSkill = null;
        if (myPet.getSkills().isSkillActive(Behavior.class)) {
            behaviorSkill = myPet.getSkills().getSkill(Behavior.class).get();
            if (behaviorSkill.getBehavior() == Behavior.BehaviorState.Friendly) {
                return false;
            }
        }
        for (Object entityObj : this.petEntity.world.a(EntityLiving.class, this.petEntity.getBoundingBox().grow((double) this.range, 4.0D, (double) this.range))) {
            EntityLiving entityLiving = (EntityLiving) entityObj;
            if (entityLiving != petEntity && !(entityLiving instanceof EntityArmorStand)) {
                if (entityLiving instanceof EntityPlayer) {
                    Player targetPlayer = (Player) entityLiving.getBukkitEntity();
                    if (myPet.getOwner().equals(targetPlayer)) {
                        continue;
                    } else if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), targetPlayer, true)) {
                        continue;
                    }
                } else if (entityLiving instanceof EntityTameableAnimal) {
                    EntityTameableAnimal tameable = (EntityTameableAnimal) entityLiving;
                    if (tameable.isTamed() && tameable.getOwner() != null) {
                        Player tameableOwner = (Player) tameable.getOwner().getBukkitEntity();
                        if (myPet.getOwner().equals(tameableOwner)) {
                            continue;
                        } else if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), tameableOwner, true)) {
                            continue;
                        }
                    }
                } else if (entityLiving instanceof EntityMyPet) {
                    MyPet targetMyPet = ((EntityMyPet) entityLiving).getMyPet();
                    if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), targetMyPet.getOwner().getPlayer(), true)) {
                        continue;
                    }
                }
                if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), entityLiving.getBukkitEntity())) {
                    continue;
                }
                if (behaviorSkill != null) {
                    if (behaviorSkill.getBehavior() == BehaviorState.Raid) {
                        if (entityLiving instanceof EntityTameableAnimal) {
                            continue;
                        } else if (entityLiving instanceof EntityMyPet) {
                            continue;
                        } else if (entityLiving instanceof EntityPlayer) {
                            continue;
                        }
                    }
                }
                controlPathfinderGoal.stopControl();
                this.target = entityLiving;
                return true;
            }
        }
    }
    return false;
}
Also used : EntityPlayer(net.minecraft.server.v1_8_R2.EntityPlayer) Player(org.bukkit.entity.Player) CraftPlayer(org.bukkit.craftbukkit.v1_8_R2.entity.CraftPlayer) EntityMyPet(de.Keyle.MyPet.compat.v1_8_R2.entity.EntityMyPet) EntityLiving(net.minecraft.server.v1_8_R2.EntityLiving) MyPet(de.Keyle.MyPet.api.entity.MyPet) EntityMyPet(de.Keyle.MyPet.compat.v1_8_R2.entity.EntityMyPet) EntityPlayer(net.minecraft.server.v1_8_R2.EntityPlayer) EntityTameableAnimal(net.minecraft.server.v1_8_R2.EntityTameableAnimal) EntityArmorStand(net.minecraft.server.v1_8_R2.EntityArmorStand) Behavior(de.Keyle.MyPet.skill.skills.Behavior)

Example 3 with EntityTameableAnimal

use of net.minecraft.server.v1_9_R2.EntityTameableAnimal in project MyPet by xXKeyleXx.

the class ControlTarget method shouldStart.

@Override
public boolean shouldStart() {
    if (controlPathfinderGoal == null) {
        if (petEntity.getPathfinder().hasGoal("Control")) {
            controlPathfinderGoal = (Control) petEntity.getPathfinder().getGoal("Control");
        }
    }
    if (controlPathfinderGoal == null) {
        return false;
    }
    if (myPet.getDamage() <= 0 && myPet.getRangedDamage() <= 0) {
        return false;
    }
    if (controlPathfinderGoal.moveTo != null && petEntity.canMove()) {
        Behavior behaviorSkill = null;
        if (myPet.getSkills().isSkillActive(Behavior.class)) {
            behaviorSkill = myPet.getSkills().getSkill(Behavior.class).get();
            if (behaviorSkill.getBehavior() == Behavior.BehaviorState.Friendly) {
                return false;
            }
        }
        for (Object entityObj : this.petEntity.world.a(EntityLiving.class, this.petEntity.getBoundingBox().grow((double) this.range, 4.0D, (double) this.range))) {
            EntityLiving entityLiving = (EntityLiving) entityObj;
            if (entityLiving != petEntity && !(entityLiving instanceof EntityArmorStand)) {
                if (entityLiving instanceof EntityPlayer) {
                    Player targetPlayer = (Player) entityLiving.getBukkitEntity();
                    if (myPet.getOwner().equals(targetPlayer)) {
                        continue;
                    } else if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), targetPlayer, true)) {
                        continue;
                    }
                } else if (entityLiving instanceof EntityTameableAnimal) {
                    EntityTameableAnimal tameable = (EntityTameableAnimal) entityLiving;
                    if (tameable.isTamed() && tameable.getOwner() != null) {
                        Player tameableOwner = (Player) tameable.getOwner().getBukkitEntity();
                        if (myPet.getOwner().equals(tameableOwner)) {
                            continue;
                        } else if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), tameableOwner, true)) {
                            continue;
                        }
                    }
                } else if (entityLiving instanceof EntityMyPet) {
                    MyPet targetMyPet = ((EntityMyPet) entityLiving).getMyPet();
                    if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), targetMyPet.getOwner().getPlayer(), true)) {
                        continue;
                    }
                }
                if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), entityLiving.getBukkitEntity())) {
                    continue;
                }
                if (behaviorSkill != null) {
                    if (behaviorSkill.getBehavior() == BehaviorState.Raid) {
                        if (entityLiving instanceof EntityTameableAnimal) {
                            continue;
                        } else if (entityLiving instanceof EntityMyPet) {
                            continue;
                        } else if (entityLiving instanceof EntityPlayer) {
                            continue;
                        }
                    }
                }
                controlPathfinderGoal.stopControl();
                this.target = entityLiving;
                return true;
            }
        }
    }
    return false;
}
Also used : Player(org.bukkit.entity.Player) EntityPlayer(net.minecraft.server.v1_9_R2.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer) EntityMyPet(de.Keyle.MyPet.compat.v1_9_R2.entity.EntityMyPet) EntityLiving(net.minecraft.server.v1_9_R2.EntityLiving) MyPet(de.Keyle.MyPet.api.entity.MyPet) EntityMyPet(de.Keyle.MyPet.compat.v1_9_R2.entity.EntityMyPet) EntityPlayer(net.minecraft.server.v1_9_R2.EntityPlayer) EntityTameableAnimal(net.minecraft.server.v1_9_R2.EntityTameableAnimal) EntityArmorStand(net.minecraft.server.v1_9_R2.EntityArmorStand) Behavior(de.Keyle.MyPet.skill.skills.Behavior)

Example 4 with EntityTameableAnimal

use of net.minecraft.server.v1_9_R2.EntityTameableAnimal in project MyPet by xXKeyleXx.

the class ControlTarget method shouldStart.

@Override
public boolean shouldStart() {
    if (controlPathfinderGoal == null) {
        if (petEntity.getPathfinder().hasGoal("Control")) {
            controlPathfinderGoal = (Control) petEntity.getPathfinder().getGoal("Control");
        }
    }
    if (controlPathfinderGoal == null) {
        return false;
    }
    if (myPet.getDamage() <= 0 && myPet.getRangedDamage() <= 0) {
        return false;
    }
    if (controlPathfinderGoal.moveTo != null && petEntity.canMove()) {
        Behavior behaviorSkill = null;
        if (myPet.getSkills().isSkillActive(Behavior.class)) {
            behaviorSkill = myPet.getSkills().getSkill(Behavior.class).get();
            if (behaviorSkill.getBehavior() == Behavior.BehaviorState.Friendly) {
                return false;
            }
        }
        for (Object entityObj : this.petEntity.world.a(EntityLiving.class, this.petEntity.getBoundingBox().grow((double) this.range, 4.0D, (double) this.range))) {
            EntityLiving entityLiving = (EntityLiving) entityObj;
            if (entityLiving != petEntity && !(entityLiving instanceof EntityArmorStand)) {
                if (entityLiving instanceof EntityPlayer) {
                    Player targetPlayer = (Player) entityLiving.getBukkitEntity();
                    if (myPet.getOwner().equals(targetPlayer)) {
                        continue;
                    } else if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), targetPlayer, true)) {
                        continue;
                    }
                } else if (entityLiving instanceof EntityTameableAnimal) {
                    EntityTameableAnimal tameable = (EntityTameableAnimal) entityLiving;
                    if (tameable.isTamed() && tameable.getOwner() != null) {
                        Player tameableOwner = (Player) tameable.getOwner().getBukkitEntity();
                        if (myPet.getOwner().equals(tameableOwner)) {
                            continue;
                        } else if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), tameableOwner, true)) {
                            continue;
                        }
                    }
                } else if (entityLiving instanceof EntityMyPet) {
                    MyPet targetMyPet = ((EntityMyPet) entityLiving).getMyPet();
                    if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), targetMyPet.getOwner().getPlayer(), true)) {
                        continue;
                    }
                }
                if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), entityLiving.getBukkitEntity())) {
                    continue;
                }
                if (behaviorSkill != null) {
                    if (behaviorSkill.getBehavior() == BehaviorState.Raid) {
                        if (entityLiving instanceof EntityTameableAnimal) {
                            continue;
                        } else if (entityLiving instanceof EntityMyPet) {
                            continue;
                        } else if (entityLiving instanceof EntityPlayer) {
                            continue;
                        }
                    }
                }
                controlPathfinderGoal.stopControl();
                this.target = entityLiving;
                return true;
            }
        }
    }
    return false;
}
Also used : EntityPlayer(net.minecraft.server.v1_10_R1.EntityPlayer) Player(org.bukkit.entity.Player) CraftPlayer(org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer) EntityMyPet(de.Keyle.MyPet.compat.v1_10_R1.entity.EntityMyPet) EntityLiving(net.minecraft.server.v1_10_R1.EntityLiving) MyPet(de.Keyle.MyPet.api.entity.MyPet) EntityMyPet(de.Keyle.MyPet.compat.v1_10_R1.entity.EntityMyPet) EntityPlayer(net.minecraft.server.v1_10_R1.EntityPlayer) EntityTameableAnimal(net.minecraft.server.v1_10_R1.EntityTameableAnimal) EntityArmorStand(net.minecraft.server.v1_10_R1.EntityArmorStand) Behavior(de.Keyle.MyPet.skill.skills.Behavior)

Example 5 with EntityTameableAnimal

use of net.minecraft.server.v1_9_R2.EntityTameableAnimal in project solinia3-core by mixxit.

the class SoliniaLivingEntity method targetSelector.

public void targetSelector() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
    final net.minecraft.server.v1_12_R1.EntityInsentient e = (net.minecraft.server.v1_12_R1.EntityInsentient) ((org.bukkit.craftbukkit.v1_12_R1.entity.CraftLivingEntity) getBukkitLivingEntity()).getHandle();
    if (!(e instanceof net.minecraft.server.v1_12_R1.EntityCreature) && !(e instanceof net.minecraft.server.v1_12_R1.EntityTameableAnimal))
        return;
    final Field goalsField = net.minecraft.server.v1_12_R1.EntityInsentient.class.getDeclaredField("targetSelector");
    goalsField.setAccessible(true);
    final net.minecraft.server.v1_12_R1.PathfinderGoalSelector goals = (net.minecraft.server.v1_12_R1.PathfinderGoalSelector) goalsField.get(e);
    Field listField = net.minecraft.server.v1_12_R1.PathfinderGoalSelector.class.getDeclaredField("b");
    listField.setAccessible(true);
    Set list = (Set) listField.get(goals);
    list.clear();
    listField = net.minecraft.server.v1_12_R1.PathfinderGoalSelector.class.getDeclaredField("c");
    listField.setAccessible(true);
    list = (Set) listField.get(goals);
    list.clear();
    goals.a(1, (net.minecraft.server.v1_12_R1.PathfinderGoalLookAtPlayer) new net.minecraft.server.v1_12_R1.PathfinderGoalLookAtPlayer(e, (Class) net.minecraft.server.v1_12_R1.EntityHuman.class, 5.0f, 1.0f));
    goals.a(2, (net.minecraft.server.v1_12_R1.PathfinderGoalLookAtPlayer) new net.minecraft.server.v1_12_R1.PathfinderGoalLookAtPlayer(e, (Class) net.minecraft.server.v1_12_R1.EntityHuman.class, 5.0f, 1.0f));
    goals.a(10, (net.minecraft.server.v1_12_R1.PathfinderGoalLookAtPlayer) new net.minecraft.server.v1_12_R1.PathfinderGoalLookAtPlayer(e, (Class) net.minecraft.server.v1_12_R1.EntityHuman.class, 5.0f, 1.0f));
    goals.a(1, new PathfinderGoalOwnerHurtByTarget((EntityTameableAnimal) e));
    goals.a(2, new PathfinderGoalOwnerHurtTarget((EntityTameableAnimal) e));
    goals.a(3, new PathfinderGoalHurtByTarget((EntityCreature) e, true, new Class[0]));
}
Also used : Set(java.util.Set) EntityCreature(net.minecraft.server.v1_12_R1.EntityCreature) EntityTameableAnimal(net.minecraft.server.v1_12_R1.EntityTameableAnimal) Field(java.lang.reflect.Field) EntityTameableAnimal(net.minecraft.server.v1_12_R1.EntityTameableAnimal) PathfinderGoalOwnerHurtTarget(net.minecraft.server.v1_12_R1.PathfinderGoalOwnerHurtTarget) PathfinderGoalOwnerHurtByTarget(net.minecraft.server.v1_12_R1.PathfinderGoalOwnerHurtByTarget) PathfinderGoalHurtByTarget(net.minecraft.server.v1_12_R1.PathfinderGoalHurtByTarget) ISoliniaClass(com.solinia.solinia.Interfaces.ISoliniaClass) EntityCreature(net.minecraft.server.v1_12_R1.EntityCreature)

Aggregations

MyPet (de.Keyle.MyPet.api.entity.MyPet)9 Behavior (de.Keyle.MyPet.skill.skills.Behavior)9 Player (org.bukkit.entity.Player)9 EntityTameableAnimal (net.minecraft.server.v1_12_R1.EntityTameableAnimal)2 ISoliniaClass (com.solinia.solinia.Interfaces.ISoliniaClass)1 EntityMyPet (de.Keyle.MyPet.compat.v1_10_R1.entity.EntityMyPet)1 EntityMyPet (de.Keyle.MyPet.compat.v1_11_R1.entity.EntityMyPet)1 EntityMyPet (de.Keyle.MyPet.compat.v1_12_R1.entity.EntityMyPet)1 EntityMyPet (de.Keyle.MyPet.compat.v1_7_R4.entity.EntityMyPet)1 EntityMyPet (de.Keyle.MyPet.compat.v1_8_R1.entity.EntityMyPet)1 EntityMyPet (de.Keyle.MyPet.compat.v1_8_R2.entity.EntityMyPet)1 EntityMyPet (de.Keyle.MyPet.compat.v1_8_R3.entity.EntityMyPet)1 EntityMyPet (de.Keyle.MyPet.compat.v1_9_R1.entity.EntityMyPet)1 EntityMyPet (de.Keyle.MyPet.compat.v1_9_R2.entity.EntityMyPet)1 Field (java.lang.reflect.Field)1 Set (java.util.Set)1 EntityArmorStand (net.minecraft.server.v1_10_R1.EntityArmorStand)1 EntityLiving (net.minecraft.server.v1_10_R1.EntityLiving)1 EntityPlayer (net.minecraft.server.v1_10_R1.EntityPlayer)1 EntityTameableAnimal (net.minecraft.server.v1_10_R1.EntityTameableAnimal)1