use of net.minecraft.server.v1_16_R3.EntityPlayer in project MyPet by xXKeyleXx.
the class OwnerHurtByTarget method shouldStart.
@Override
public boolean shouldStart() {
if (!petEntity.canMove()) {
return false;
}
if (myPet.getDamage() <= 0 && myPet.getRangedDamage() <= 0) {
return false;
}
this.lastDamager = owner.getLastDamager();
if (this.lastDamager == null || !lastDamager.isAlive()) {
return false;
}
if (lastDamager instanceof EntityArmorStand) {
return false;
}
if (lastDamager == petEntity) {
return false;
}
if (lastDamager instanceof EntityPlayer) {
if (owner == lastDamager) {
return false;
}
Player targetPlayer = (Player) lastDamager.getBukkitEntity();
if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), targetPlayer, true)) {
return false;
}
} else if (lastDamager instanceof EntityMyPet) {
MyPet targetMyPet = ((EntityMyPet) lastDamager).getMyPet();
if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), targetMyPet.getOwner().getPlayer(), true)) {
return false;
}
} else if (lastDamager instanceof EntityTameableAnimal) {
EntityTameableAnimal tameable = (EntityTameableAnimal) lastDamager;
if (tameable.isTamed() && tameable.getOwner() != null) {
Player tameableOwner = (Player) tameable.getOwner().getBukkitEntity();
if (myPet.getOwner().equals(tameableOwner)) {
return false;
}
}
}
if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), lastDamager.getBukkitEntity())) {
return false;
}
Behavior behaviorSkill = myPet.getSkills().get(Behavior.class);
if (behaviorSkill != null && behaviorSkill.isActive()) {
if (behaviorSkill.getBehavior() == BehaviorMode.Friendly) {
return false;
}
if (behaviorSkill.getBehavior() == BehaviorMode.Raid) {
if (lastDamager instanceof EntityTameableAnimal && ((EntityTameableAnimal) lastDamager).isTamed()) {
return false;
}
if (lastDamager instanceof EntityMyPet) {
return false;
}
return !(lastDamager instanceof EntityPlayer);
}
}
return true;
}
use of net.minecraft.server.v1_16_R3.EntityPlayer 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 = myPet.getSkills().get(Behavior.class);
if (behaviorSkill.isActive()) {
if (behaviorSkill.getBehavior() == BehaviorMode.Friendly) {
return false;
}
}
for (EntityLiving entityLiving : this.petEntity.world.a(EntityLiving.class, this.petEntity.getBoundingBox().grow((double) this.range, 4.0D, (double) this.range))) {
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() == BehaviorMode.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;
}
use of net.minecraft.server.v1_16_R3.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;
}
use of net.minecraft.server.v1_16_R3.EntityPlayer in project Denizen-For-Bukkit by DenizenScript.
the class ProfileEditor_v1_8_R3 method updatePlayer.
@Override
protected void updatePlayer(Player player, final boolean isSkinChanging) {
final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
final UUID uuid = player.getUniqueId();
PacketPlayOutEntityDestroy destroyPacket = new PacketPlayOutEntityDestroy(entityPlayer.getId());
for (Player p : Bukkit.getServer().getOnlinePlayers()) {
if (!p.getUniqueId().equals(uuid)) {
PacketHelper_v1_8_R3.sendPacket(p, destroyPacket);
}
}
new BukkitRunnable() {
@Override
public void run() {
PacketPlayOutPlayerInfo playerInfo = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, entityPlayer);
PacketPlayOutNamedEntitySpawn spawnPacket = new PacketPlayOutNamedEntitySpawn(entityPlayer);
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
PacketHelper_v1_8_R3.sendPacket(player, playerInfo);
if (!player.getUniqueId().equals(uuid)) {
PacketHelper_v1_8_R3.sendPacket(player, spawnPacket);
} else {
if (isSkinChanging) {
boolean isFlying = player.isFlying();
PacketHelper_v1_8_R3.sendPacket(player, new PacketPlayOutRespawn(player.getWorld().getEnvironment().getId(), entityPlayer.getWorld().getDifficulty(), entityPlayer.getWorld().worldData.getType(), entityPlayer.playerInteractManager.getGameMode()));
player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
player.setFlying(isFlying);
}
player.updateInventory();
}
}
}
}.runTaskLater(NMSHandler.getJavaPlugin(), 5);
}
use of net.minecraft.server.v1_16_R3.EntityPlayer in project Denizen-For-Bukkit by DenizenScript.
the class ProfileEditor_v1_10_R1 method updatePlayer.
@Override
protected void updatePlayer(Player player, final boolean isSkinChanging) {
final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
final UUID uuid = player.getUniqueId();
PacketPlayOutEntityDestroy destroyPacket = new PacketPlayOutEntityDestroy(entityPlayer.getId());
for (Player p : Bukkit.getServer().getOnlinePlayers()) {
if (!p.getUniqueId().equals(uuid)) {
PacketHelper_v1_10_R1.sendPacket(p, destroyPacket);
}
}
new BukkitRunnable() {
@Override
public void run() {
PacketPlayOutPlayerInfo playerInfo = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, entityPlayer);
PacketPlayOutNamedEntitySpawn spawnPacket = new PacketPlayOutNamedEntitySpawn(entityPlayer);
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
PacketHelper_v1_10_R1.sendPacket(player, playerInfo);
if (!player.getUniqueId().equals(uuid)) {
PacketHelper_v1_10_R1.sendPacket(player, spawnPacket);
} else {
if (isSkinChanging) {
boolean isFlying = player.isFlying();
PacketHelper_v1_10_R1.sendPacket(player, new PacketPlayOutRespawn(player.getWorld().getEnvironment().getId(), entityPlayer.getWorld().getDifficulty(), entityPlayer.getWorld().worldData.getType(), entityPlayer.playerInteractManager.getGameMode()));
player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
player.setFlying(isFlying);
}
player.updateInventory();
}
}
}
}.runTaskLater(NMSHandler.getJavaPlugin(), 5);
}
Aggregations