use of net.minecraft.server.v1_10_R1.Entity in project Village_Defense by Plajer.
the class RidableVillager method g.
@Override
public void g(float f, float f1) {
EntityLiving entityliving = (EntityLiving) bw();
if (entityliving == null) {
// search first human passenger
for (final Entity e : passengers) {
if (e instanceof EntityHuman) {
entityliving = (EntityLiving) e;
break;
}
}
if (entityliving == null) {
this.l((float) 0.12);
super.g(f, f1);
return;
}
}
this.lastYaw = this.yaw = entityliving.yaw;
this.pitch = entityliving.pitch * 0.5F;
this.setYawPitch(this.yaw, this.pitch);
this.aQ = this.aO = this.yaw;
f = entityliving.be * 0.75F;
f1 = entityliving.bf;
if (f1 <= 0.0f) {
f1 *= 0.25F;
}
this.l((float) 0.12);
super.g(f, f1);
P = (float) 1.0;
}
use of net.minecraft.server.v1_10_R1.Entity in project Village_Defense by Plajer.
the class RidableIronGolem method g.
@Override
public void g(float f, float f1) {
EntityLiving entityliving = (EntityLiving) bt();
if (entityliving == null) {
for (final Entity e : passengers) {
if (e instanceof EntityHuman) {
entityliving = (EntityLiving) e;
break;
}
}
if (entityliving == null) {
P = 0.5f;
this.l((float) 0.12);
super.g(f, f1);
return;
}
}
final float yaw = entityliving.yaw;
this.yaw = yaw;
lastYaw = yaw;
pitch = entityliving.pitch * 0.5f;
setYawPitch(this.yaw, pitch);
final float yaw2 = this.yaw;
aM = yaw2;
aO = yaw2;
f = entityliving.bd * 0.75F;
f1 = entityliving.be;
if (f1 <= 0.0f) {
f1 *= 0.25F;
}
this.l((float) 0.12);
super.g(f, f1);
P = 1.0F;
}
use of net.minecraft.server.v1_10_R1.Entity in project Citizens2 by CitizensDev.
the class NMSImpl method updateNavigationWorld.
@Override
public void updateNavigationWorld(org.bukkit.entity.Entity entity, World world) {
if (NAVIGATION_WORLD_FIELD == null)
return;
Entity en = NMSImpl.getHandle(entity);
if (en == null || !(en instanceof EntityInsentient))
return;
EntityInsentient handle = (EntityInsentient) en;
WorldServer worldHandle = ((CraftWorld) world).getHandle();
try {
NAVIGATION_WORLD_FIELD.set(handle.getNavigation(), worldHandle);
} catch (Exception e) {
Messaging.logTr(Messages.ERROR_UPDATING_NAVIGATION_WORLD, e.getMessage());
}
}
use of net.minecraft.server.v1_10_R1.Entity 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_10_R1.Entity 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 = getDragonYaw(handle, to.getX(), to.getZ());
} 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(), ((EntityInsentient) handle).cJ(), ((EntityInsentient) handle).N());
while (((EntityInsentient) handle).aQ >= 180F) {
((EntityInsentient) handle).aQ -= 360F;
}
while (((EntityInsentient) handle).aQ < -180F) {
((EntityInsentient) handle).aQ += 360F;
}
} else if (handle instanceof EntityHumanNPC) {
((EntityHumanNPC) handle).setTargetLook(to);
}
}
Aggregations