use of net.minecraft.server.v1_16_R2.EntityInsentient in project Citizens2 by CitizensDev.
the class NMSImpl method setShouldJump.
@Override
public void setShouldJump(org.bukkit.entity.Entity entity) {
Entity handle = NMSImpl.getHandle(entity);
if (handle == null)
return;
if (handle instanceof EntityInsentient) {
ControllerJump controller = ((EntityInsentient) handle).getControllerJump();
controller.a();
} else if (handle instanceof EntityHumanNPC) {
((EntityHumanNPC) handle).setShouldJump();
}
}
use of net.minecraft.server.v1_16_R2.EntityInsentient in project Citizens2 by CitizensDev.
the class NMSImpl method look.
@Override
public void look(org.bukkit.entity.Entity entity, Location to, boolean headOnly, boolean immediate) {
Entity handle = NMSImpl.getHandle(entity);
if (immediate || headOnly || BAD_CONTROLLER_LOOK.contains(handle.getBukkitEntity().getType()) || (!(handle instanceof EntityInsentient) && !(handle instanceof EntityHumanNPC))) {
Location fromLocation = entity.getLocation(FROM_LOCATION);
double xDiff, yDiff, zDiff;
xDiff = to.getX() - fromLocation.getX();
yDiff = to.getY() - fromLocation.getY();
zDiff = to.getZ() - fromLocation.getZ();
double distanceXZ = Math.sqrt(xDiff * xDiff + zDiff * zDiff);
double distanceY = Math.sqrt(distanceXZ * distanceXZ + yDiff * yDiff);
double yaw = Math.toDegrees(Math.acos(xDiff / distanceXZ));
double pitch = Math.toDegrees(Math.acos(yDiff / distanceY)) - 90;
if (zDiff < 0.0)
yaw += Math.abs(180 - yaw) * 2;
if (handle instanceof EntityEnderDragon) {
yaw = Util.getDragonYaw(handle.getBukkitEntity(), xDiff, zDiff);
} else {
yaw = yaw - 90;
}
if (headOnly) {
setHeadYaw(entity, (float) yaw);
} else {
look(entity, (float) yaw, (float) pitch);
}
return;
}
if (handle instanceof EntityInsentient) {
((EntityInsentient) handle).getControllerLook().a(to.getX(), to.getY(), to.getZ(), 10, ((EntityInsentient) handle).bQ());
while (((EntityInsentient) handle).aK >= 180F) {
((EntityInsentient) handle).aK -= 360F;
}
while (((EntityInsentient) handle).aK < -180F) {
((EntityInsentient) handle).aK += 360F;
}
} else if (handle instanceof EntityHumanNPC) {
((EntityHumanNPC) handle).setTargetLook(to);
}
}
use of net.minecraft.server.v1_16_R2.EntityInsentient in project UltraCosmetics by iSach.
the class PlayerFollower method follow.
@Override
public void follow(Player player) {
if (player == null)
return;
if (UltraCosmeticsData.get().getPlugin().getPlayerManager().getUltraPlayer(player).getCurrentTreasureChest() != null)
return;
Entity petEntity;
if (pet.isCustomEntity()) {
petEntity = ((CustomEntityPet) pet).getCustomEntity();
} else {
petEntity = ((CraftEntity) pet.getEntity()).getHandle();
}
((EntityInsentient) petEntity).getNavigation().a(2);
Location targetLocation = player.getLocation();
PathEntity path;
path = ((EntityInsentient) petEntity).getNavigation().a(targetLocation.getX() + 1, targetLocation.getY(), targetLocation.getZ() + 1);
try {
int distance = (int) Bukkit.getPlayer(player.getName()).getLocation().distance(petEntity.getBukkitEntity().getLocation());
if (distance > 10 && petEntity.valid && player.isOnGround()) {
petEntity.setLocation(targetLocation.getBlockX(), targetLocation.getBlockY(), targetLocation.getBlockZ(), 0, 0);
}
if (path != null && distance > 3.3) {
double speed = 1.05d;
if (pet.getType().getEntityType() == EntityType.ZOMBIE)
speed *= 1.5;
((EntityInsentient) petEntity).getNavigation().a(path, speed);
((EntityInsentient) petEntity).getNavigation().a(speed);
}
} catch (IllegalArgumentException exception) {
petEntity.setLocation(targetLocation.getBlockX(), targetLocation.getBlockY(), targetLocation.getBlockZ(), 0, 0);
}
}
use of net.minecraft.server.v1_16_R2.EntityInsentient in project UltraCosmetics by iSach.
the class EntityUtil method clearPathfinders.
@Override
public void clearPathfinders(Entity entity) {
EntityInsentient entitySheep = (EntityInsentient) ((CraftEntity) entity).getHandle();
try {
Field bField = PathfinderGoalSelector.class.getDeclaredField("b");
bField.setAccessible(true);
Field cField = PathfinderGoalSelector.class.getDeclaredField("c");
cField.setAccessible(true);
bField.set(entitySheep.goalSelector, new UnsafeList<PathfinderGoalSelector>());
bField.set(entitySheep.targetSelector, new UnsafeList<PathfinderGoalSelector>());
cField.set(entitySheep.goalSelector, new UnsafeList<PathfinderGoalSelector>());
cField.set(entitySheep.targetSelector, new UnsafeList<PathfinderGoalSelector>());
} catch (Exception exc) {
exc.printStackTrace();
}
}
use of net.minecraft.server.v1_16_R2.EntityInsentient in project UltraCosmetics by iSach.
the class EntityUtil method makePanic.
@Override
public void makePanic(Entity entity) {
EntityInsentient insentient = (EntityInsentient) ((CraftEntity) entity).getHandle();
insentient.goalSelector.a(3, new CustomPathFinderGoalPanic((EntityCreature) insentient, 0.4d));
}
Aggregations