Search in sources :

Example 11 with EntityPlayer

use of net.minecraft.server.v1_13_R2.EntityPlayer in project MyPet by xXKeyleXx.

the class MeleeAttack method shouldStart.

@Override
public boolean shouldStart() {
    if (myPet.getDamage() <= 0) {
        return false;
    }
    if (!this.petEntity.hasTarget()) {
        return false;
    }
    EntityLiving targetEntity = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle();
    if (targetEntity instanceof EntityArmorStand) {
        return false;
    }
    if (petEntity.getMyPet().getRangedDamage() > 0 && this.petEntity.f(targetEntity.locX, targetEntity.getBoundingBox().b, targetEntity.locZ) >= 20) {
        return false;
    }
    Behavior behaviorSkill = myPet.getSkills().get(Behavior.class);
    if (behaviorSkill != null && behaviorSkill.isActive()) {
        if (behaviorSkill.getBehavior() == Behavior.BehaviorMode.Friendly) {
            return false;
        }
        if (behaviorSkill.getBehavior() == Behavior.BehaviorMode.Raid) {
            if (targetEntity instanceof EntityTameableAnimal && ((EntityTameableAnimal) targetEntity).isTamed()) {
                return false;
            }
            if (targetEntity instanceof EntityMyPet) {
                return false;
            }
            if (targetEntity instanceof EntityPlayer) {
                return false;
            }
        }
    }
    this.targetEntity = targetEntity;
    return true;
}
Also used : EntityMyPet(de.Keyle.MyPet.compat.v1_8_R3.entity.EntityMyPet) EntityLiving(net.minecraft.server.v1_8_R3.EntityLiving) EntityTameableAnimal(net.minecraft.server.v1_8_R3.EntityTameableAnimal) EntityPlayer(net.minecraft.server.v1_8_R3.EntityPlayer) CraftLivingEntity(org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity) EntityArmorStand(net.minecraft.server.v1_8_R3.EntityArmorStand) Behavior(de.Keyle.MyPet.api.skill.skills.Behavior)

Example 12 with EntityPlayer

use of net.minecraft.server.v1_13_R2.EntityPlayer in project Citizens2 by CitizensDev.

the class CitizensBlockBreaker method run.

@Override
public BehaviorStatus run() {
    if (entity.dead) {
        return BehaviorStatus.FAILURE;
    }
    if (!isDigging) {
        return BehaviorStatus.SUCCESS;
    }
    // CraftBukkit
    currentTick = (int) (System.currentTimeMillis() / 50);
    if (configuration.radiusSquared() > 0 && distanceSquared() >= configuration.radiusSquared()) {
        startDigTick = currentTick;
        if (entity instanceof NPCHolder) {
            NPC npc = ((NPCHolder) entity).getNPC();
            if (npc != null && !npc.getNavigator().isNavigating()) {
                npc.getNavigator().setTarget(entity.world.getWorld().getBlockAt(x, y, z).getLocation().add(0, 1, 0));
            }
        }
        return BehaviorStatus.RUNNING;
    }
    Util.faceLocation(entity.getBukkitEntity(), location);
    if (entity instanceof EntityPlayer) {
        PlayerAnimation.ARM_SWING.play((Player) entity.getBukkitEntity());
    }
    IBlockData block = entity.world.getType(new BlockPosition(x, y, z));
    if (block == null || block == Blocks.AIR) {
        return BehaviorStatus.SUCCESS;
    } else {
        int tickDifference = currentTick - startDigTick;
        float damage = getStrength(block) * (tickDifference + 1) * configuration.blockStrengthModifier();
        if (damage >= 1F) {
            entity.world.getWorld().getBlockAt(x, y, z).breakNaturally(CraftItemStack.asCraftMirror(getCurrentItem()));
            return BehaviorStatus.SUCCESS;
        }
        int modifiedDamage = (int) (damage * 10.0F);
        if (modifiedDamage != currentDamage) {
            setBlockDamage(modifiedDamage);
            currentDamage = modifiedDamage;
        }
    }
    return BehaviorStatus.RUNNING;
}
Also used : NPC(net.citizensnpcs.api.npc.NPC) IBlockData(net.minecraft.server.v1_10_R1.IBlockData) BlockPosition(net.minecraft.server.v1_10_R1.BlockPosition) NPCHolder(net.citizensnpcs.npc.ai.NPCHolder) EntityPlayer(net.minecraft.server.v1_10_R1.EntityPlayer)

Example 13 with EntityPlayer

use of net.minecraft.server.v1_13_R2.EntityPlayer in project Citizens2 by CitizensDev.

the class CitizensBlockBreaker method run.

@Override
public BehaviorStatus run() {
    if (entity.dead) {
        return BehaviorStatus.FAILURE;
    }
    if (!isDigging) {
        return BehaviorStatus.SUCCESS;
    }
    // CraftBukkit
    currentTick = (int) (System.currentTimeMillis() / 50);
    if (configuration.radiusSquared() > 0 && distanceSquared() >= configuration.radiusSquared()) {
        startDigTick = currentTick;
        if (entity instanceof NPCHolder) {
            NPC npc = ((NPCHolder) entity).getNPC();
            if (npc != null && !npc.getNavigator().isNavigating()) {
                npc.getNavigator().setTarget(entity.world.getWorld().getBlockAt(x, y, z).getLocation().add(0, 1, 0));
            }
        }
        return BehaviorStatus.RUNNING;
    }
    Util.faceLocation(entity.getBukkitEntity(), location);
    if (entity instanceof EntityPlayer) {
        PlayerAnimation.ARM_SWING.play((Player) entity.getBukkitEntity());
    }
    IBlockData block = entity.world.getType(new BlockPosition(x, y, z));
    if (block == null || block == Blocks.AIR) {
        return BehaviorStatus.SUCCESS;
    } else {
        int tickDifference = currentTick - startDigTick;
        float damage = getStrength(block) * (tickDifference + 1) * configuration.blockStrengthModifier();
        if (damage >= 1F) {
            entity.world.getWorld().getBlockAt(x, y, z).breakNaturally(CraftItemStack.asCraftMirror(getCurrentItem()));
            return BehaviorStatus.SUCCESS;
        }
        int modifiedDamage = (int) (damage * 10.0F);
        if (modifiedDamage != currentDamage) {
            setBlockDamage(modifiedDamage);
            currentDamage = modifiedDamage;
        }
    }
    return BehaviorStatus.RUNNING;
}
Also used : NPC(net.citizensnpcs.api.npc.NPC) IBlockData(net.minecraft.server.v1_12_R1.IBlockData) BlockPosition(net.minecraft.server.v1_12_R1.BlockPosition) NPCHolder(net.citizensnpcs.npc.ai.NPCHolder) EntityPlayer(net.minecraft.server.v1_12_R1.EntityPlayer)

Example 14 with EntityPlayer

use of net.minecraft.server.v1_13_R2.EntityPlayer in project Citizens2 by CitizensDev.

the class PlayerlistTrackerEntry method updatePlayer.

@Override
public void updatePlayer(final EntityPlayer entityplayer) {
    // prevent updates to NPC "viewers"
    if (entityplayer instanceof EntityHumanNPC)
        return;
    Entity tracker = getTracker(this);
    if (entityplayer != tracker && c(entityplayer)) {
        if (!this.trackedPlayers.contains(entityplayer) && ((entityplayer.u().getPlayerChunkMap().a(entityplayer, tracker.ae, tracker.ag)) || (tracker.attachedToPlayer))) {
            if ((tracker instanceof SkinnableEntity)) {
                SkinnableEntity skinnable = (SkinnableEntity) tracker;
                Player player = skinnable.getBukkitEntity();
                if (!entityplayer.getBukkitEntity().canSee(player))
                    return;
                skinnable.getSkinTracker().updateViewer(entityplayer.getBukkitEntity());
            }
        }
    }
    super.updatePlayer(entityplayer);
}
Also used : SkinnableEntity(net.citizensnpcs.npc.skin.SkinnableEntity) Entity(net.minecraft.server.v1_8_R3.Entity) Player(org.bukkit.entity.Player) EntityPlayer(net.minecraft.server.v1_8_R3.EntityPlayer) SkinnableEntity(net.citizensnpcs.npc.skin.SkinnableEntity) EntityHumanNPC(net.citizensnpcs.nms.v1_8_R3.entity.EntityHumanNPC)

Example 15 with EntityPlayer

use of net.minecraft.server.v1_13_R2.EntityPlayer in project Citizens2 by CitizensDev.

the class CitizensBlockBreaker method run.

@Override
public BehaviorStatus run() {
    if (entity.dead) {
        return BehaviorStatus.FAILURE;
    }
    if (!isDigging) {
        return BehaviorStatus.SUCCESS;
    }
    // CraftBukkit
    currentTick = (int) (System.currentTimeMillis() / 50);
    if (configuration.radiusSquared() > 0 && distanceSquared() >= configuration.radiusSquared()) {
        startDigTick = currentTick;
        if (entity instanceof NPCHolder) {
            NPC npc = ((NPCHolder) entity).getNPC();
            if (npc != null && !npc.getNavigator().isNavigating()) {
                npc.getNavigator().setTarget(entity.world.getWorld().getBlockAt(x, y, z).getLocation().add(0, 1, 0));
            }
        }
        return BehaviorStatus.RUNNING;
    }
    Util.faceLocation(entity.getBukkitEntity(), location);
    if (entity instanceof EntityPlayer) {
        PlayerAnimation.ARM_SWING.play((Player) entity.getBukkitEntity());
    }
    IBlockData block = entity.world.getType(new BlockPosition(x, y, z));
    if (block == null || block == Blocks.AIR) {
        return BehaviorStatus.SUCCESS;
    } else {
        int tickDifference = currentTick - startDigTick;
        float damage = getStrength(block) * (tickDifference + 1) * configuration.blockStrengthModifier();
        if (damage >= 1F) {
            entity.world.getWorld().getBlockAt(x, y, z).breakNaturally(CraftItemStack.asCraftMirror(getCurrentItem()));
            return BehaviorStatus.SUCCESS;
        }
        int modifiedDamage = (int) (damage * 10.0F);
        if (modifiedDamage != currentDamage) {
            setBlockDamage(modifiedDamage);
            currentDamage = modifiedDamage;
        }
    }
    return BehaviorStatus.RUNNING;
}
Also used : NPC(net.citizensnpcs.api.npc.NPC) IBlockData(net.minecraft.server.v1_11_R1.IBlockData) BlockPosition(net.minecraft.server.v1_11_R1.BlockPosition) NPCHolder(net.citizensnpcs.npc.ai.NPCHolder) EntityPlayer(net.minecraft.server.v1_11_R1.EntityPlayer)

Aggregations

Player (org.bukkit.entity.Player)69 ItemStack (org.bukkit.inventory.ItemStack)46 EntityPlayer (net.minecraft.server.v1_8_R3.EntityPlayer)31 EntityPlayer (net.minecraft.server.v1_12_R1.EntityPlayer)30 EntityPlayer (net.minecraft.server.v1_16_R3.EntityPlayer)30 EntityPlayer (net.minecraft.server.v1_10_R1.EntityPlayer)25 EntityPlayer (net.minecraft.server.v1_11_R1.EntityPlayer)25 EntityPlayer (net.minecraft.server.v1_13_R2.EntityPlayer)25 EntityPlayer (net.minecraft.server.v1_15_R1.EntityPlayer)25 CraftPlayer (org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer)22 EntityPlayer (net.minecraft.server.v1_14_R1.EntityPlayer)21 NPCHolder (net.citizensnpcs.npc.ai.NPCHolder)19 SkinnableEntity (net.citizensnpcs.npc.skin.SkinnableEntity)19 CraftPlayer (org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer)19 CraftPlayer (org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer)18 CraftPlayer (org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer)18 GameProfile (com.mojang.authlib.GameProfile)16 MyPet (de.Keyle.MyPet.api.entity.MyPet)16 CraftPlayer (org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer)16 OfflinePlayer (org.bukkit.OfflinePlayer)15