mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-22 10:36:10 +01:00
Fix dragon yaw and make it same as rider yaw. Refactor out redundant calculation of yaw
This commit is contained in:
parent
97d4c3b117
commit
897c511757
@ -128,6 +128,20 @@ public class Util {
|
||||
return center;
|
||||
}
|
||||
|
||||
public static float getDragonYaw(Entity entity, double motX, double motZ) {
|
||||
Location location = entity.getLocation(AT_LOCATION);
|
||||
double x = location.getX();
|
||||
double z = location.getZ();
|
||||
double tX = x + motX;
|
||||
double tZ = z + motZ;
|
||||
if (z > tZ)
|
||||
return (float) (-Math.toDegrees(Math.atan((x - tX) / (z - tZ))));
|
||||
if (z < tZ) {
|
||||
return (float) (-Math.toDegrees(Math.atan((x - tX) / (z - tZ)))) + 180.0F;
|
||||
}
|
||||
return location.getYaw();
|
||||
}
|
||||
|
||||
public static Scoreboard getDummyScoreboard() {
|
||||
return DUMMY_SCOREBOARD;
|
||||
}
|
||||
|
@ -112,15 +112,6 @@ public class EnderDragonController extends MobEntityController {
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
private float getCorrectYaw(double tX, double tZ) {
|
||||
if (locZ > tZ)
|
||||
return (float) (-Math.toDegrees(Math.atan((locX - tX) / (locZ - tZ))));
|
||||
if (locZ < tZ) {
|
||||
return (float) (-Math.toDegrees(Math.atan((locX - tX) / (locZ - tZ)))) + 180.0F;
|
||||
}
|
||||
return yaw;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
@ -150,11 +141,16 @@ public class EnderDragonController extends MobEntityController {
|
||||
public void n() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
if (getBukkitEntity().getPassenger() != null) {
|
||||
yaw = getBukkitEntity().getPassenger().getLocation().getYaw() - 180;
|
||||
}
|
||||
if (motX != 0 || motY != 0 || motZ != 0) {
|
||||
motX *= 0.98;
|
||||
motY *= 0.98;
|
||||
motZ *= 0.98;
|
||||
yaw = getCorrectYaw(locX + motX, locZ + motZ);
|
||||
if (getBukkitEntity().getPassenger() == null) {
|
||||
yaw = Util.getDragonYaw(getBukkitEntity(), motX, motZ);
|
||||
}
|
||||
setPosition(locX + motX, locY + motY, locZ + motZ);
|
||||
}
|
||||
} else {
|
||||
|
@ -370,15 +370,6 @@ public class NMSImpl implements NMSBridge {
|
||||
return new Location(entity.getWorld(), controller.d(), controller.e(), controller.f());
|
||||
}
|
||||
|
||||
private float getDragonYaw(Entity handle, double tX, double tZ) {
|
||||
if (handle.locZ > tZ)
|
||||
return (float) (-Math.toDegrees(Math.atan((handle.locX - tX) / (handle.locZ - tZ))));
|
||||
if (handle.locZ < tZ) {
|
||||
return (float) (-Math.toDegrees(Math.atan((handle.locX - tX) / (handle.locZ - tZ)))) + 180.0F;
|
||||
}
|
||||
return handle.yaw;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameProfileRepository getGameProfileRepository() {
|
||||
return ((CraftServer) Bukkit.getServer()).getServer().getGameProfileRepository();
|
||||
@ -733,7 +724,7 @@ public class NMSImpl implements NMSBridge {
|
||||
if (zDiff < 0.0)
|
||||
yaw += Math.abs(180 - yaw) * 2;
|
||||
if (handle instanceof EntityEnderDragon) {
|
||||
yaw = getDragonYaw(handle, to.getX(), to.getZ());
|
||||
yaw = Util.getDragonYaw(handle.getBukkitEntity(), xDiff, zDiff);
|
||||
} else {
|
||||
yaw = yaw - 90;
|
||||
}
|
||||
|
@ -113,15 +113,6 @@ public class EnderDragonController extends MobEntityController {
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
private float getCorrectYaw(double tX, double tZ) {
|
||||
if (locZ > tZ)
|
||||
return (float) (-Math.toDegrees(Math.atan((locX - tX) / (locZ - tZ))));
|
||||
if (locZ < tZ) {
|
||||
return (float) (-Math.toDegrees(Math.atan((locX - tX) / (locZ - tZ)))) + 180.0F;
|
||||
}
|
||||
return yaw;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
@ -151,11 +142,16 @@ public class EnderDragonController extends MobEntityController {
|
||||
public void n() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
if (getBukkitEntity().getPassenger() != null) {
|
||||
yaw = getBukkitEntity().getPassenger().getLocation().getYaw() - 180;
|
||||
}
|
||||
if (motX != 0 || motY != 0 || motZ != 0) {
|
||||
motX *= 0.98;
|
||||
motY *= 0.98;
|
||||
motZ *= 0.98;
|
||||
yaw = getCorrectYaw(locX + motX, locZ + motZ);
|
||||
if (getBukkitEntity().getPassenger() == null) {
|
||||
yaw = Util.getDragonYaw(getBukkitEntity(), motX, motZ);
|
||||
}
|
||||
setPosition(locX + motX, locY + motY, locZ + motZ);
|
||||
}
|
||||
} else {
|
||||
|
@ -389,15 +389,6 @@ public class NMSImpl implements NMSBridge {
|
||||
return new Location(entity.getWorld(), controller.d(), controller.e(), controller.f());
|
||||
}
|
||||
|
||||
private float getDragonYaw(Entity handle, double tX, double tZ) {
|
||||
if (handle.locZ > tZ)
|
||||
return (float) (-Math.toDegrees(Math.atan((handle.locX - tX) / (handle.locZ - tZ))));
|
||||
if (handle.locZ < tZ) {
|
||||
return (float) (-Math.toDegrees(Math.atan((handle.locX - tX) / (handle.locZ - tZ)))) + 180.0F;
|
||||
}
|
||||
return handle.yaw;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameProfileRepository getGameProfileRepository() {
|
||||
return ((CraftServer) Bukkit.getServer()).getServer().getGameProfileRepository();
|
||||
@ -787,7 +778,7 @@ public class NMSImpl implements NMSBridge {
|
||||
if (zDiff < 0.0)
|
||||
yaw += Math.abs(180 - yaw) * 2;
|
||||
if (handle instanceof EntityEnderDragon) {
|
||||
yaw = getDragonYaw(handle, to.getX(), to.getZ());
|
||||
yaw = Util.getDragonYaw(handle.getBukkitEntity(), xDiff, zDiff);
|
||||
} else {
|
||||
yaw = yaw - 90;
|
||||
}
|
||||
|
@ -116,15 +116,6 @@ public class EnderDragonController extends MobEntityController {
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
private float getCorrectYaw(double tX, double tZ) {
|
||||
if (locZ > tZ)
|
||||
return (float) (-Math.toDegrees(Math.atan((locX - tX) / (locZ - tZ))));
|
||||
if (locZ < tZ) {
|
||||
return (float) (-Math.toDegrees(Math.atan((locX - tX) / (locZ - tZ)))) + 180.0F;
|
||||
}
|
||||
return yaw;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
@ -154,11 +145,16 @@ public class EnderDragonController extends MobEntityController {
|
||||
public void n() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
if (getBukkitEntity().getPassenger() != null) {
|
||||
yaw = getBukkitEntity().getPassenger().getLocation().getYaw() - 180;
|
||||
}
|
||||
if (motX != 0 || motY != 0 || motZ != 0) {
|
||||
motX *= 0.98;
|
||||
motY *= 0.98;
|
||||
motZ *= 0.98;
|
||||
yaw = getCorrectYaw(locX + motX, locZ + motZ);
|
||||
if (getBukkitEntity().getPassenger() == null) {
|
||||
yaw = Util.getDragonYaw(getBukkitEntity(), motX, motZ);
|
||||
}
|
||||
setPosition(locX + motX, locY + motY, locZ + motZ);
|
||||
}
|
||||
} else {
|
||||
|
@ -393,15 +393,6 @@ public class NMSImpl implements NMSBridge {
|
||||
return new Location(entity.getWorld(), controller.d(), controller.e(), controller.f());
|
||||
}
|
||||
|
||||
private float getDragonYaw(Entity handle, double tX, double tZ) {
|
||||
if (handle.locZ > tZ)
|
||||
return (float) (-Math.toDegrees(Math.atan((handle.locX - tX) / (handle.locZ - tZ))));
|
||||
if (handle.locZ < tZ) {
|
||||
return (float) (-Math.toDegrees(Math.atan((handle.locX - tX) / (handle.locZ - tZ)))) + 180.0F;
|
||||
}
|
||||
return handle.yaw;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameProfileRepository getGameProfileRepository() {
|
||||
return ((CraftServer) Bukkit.getServer()).getServer().getGameProfileRepository();
|
||||
@ -794,7 +785,7 @@ public class NMSImpl implements NMSBridge {
|
||||
if (zDiff < 0.0)
|
||||
yaw += Math.abs(180 - yaw) * 2;
|
||||
if (handle instanceof EntityEnderDragon) {
|
||||
yaw = getDragonYaw(handle, to.getX(), to.getZ());
|
||||
yaw = Util.getDragonYaw(handle.getBukkitEntity(), xDiff, zDiff);
|
||||
} else {
|
||||
yaw = yaw - 90;
|
||||
}
|
||||
|
@ -122,15 +122,6 @@ public class EnderDragonController extends MobEntityController {
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
private float getCorrectYaw(double tX, double tZ) {
|
||||
if (locZ > tZ)
|
||||
return (float) (-Math.toDegrees(Math.atan((locX - tX) / (locZ - tZ))));
|
||||
if (locZ < tZ) {
|
||||
return (float) (-Math.toDegrees(Math.atan((locX - tX) / (locZ - tZ)))) + 180.0F;
|
||||
}
|
||||
return yaw;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
@ -160,11 +151,16 @@ public class EnderDragonController extends MobEntityController {
|
||||
public void movementTick() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
if (getBukkitEntity().getPassenger() != null) {
|
||||
yaw = getBukkitEntity().getPassenger().getLocation().getYaw() - 180;
|
||||
}
|
||||
if (motX != 0 || motY != 0 || motZ != 0) {
|
||||
motX *= 0.98;
|
||||
motY *= 0.98;
|
||||
motZ *= 0.98;
|
||||
yaw = getCorrectYaw(locX + motX, locZ + motZ);
|
||||
if (getBukkitEntity().getPassenger() == null) {
|
||||
yaw = Util.getDragonYaw(getBukkitEntity(), motX, motZ);
|
||||
}
|
||||
setPosition(locX + motX, locY + motY, locZ + motZ);
|
||||
}
|
||||
} else {
|
||||
|
@ -415,15 +415,6 @@ public class NMSImpl implements NMSBridge {
|
||||
return new Location(entity.getWorld(), controller.d(), controller.e(), controller.f());
|
||||
}
|
||||
|
||||
private float getDragonYaw(Entity handle, double tX, double tZ) {
|
||||
if (handle.locZ > tZ)
|
||||
return (float) (-Math.toDegrees(Math.atan((handle.locX - tX) / (handle.locZ - tZ))));
|
||||
if (handle.locZ < tZ) {
|
||||
return (float) (-Math.toDegrees(Math.atan((handle.locX - tX) / (handle.locZ - tZ)))) + 180.0F;
|
||||
}
|
||||
return handle.yaw;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameProfileRepository getGameProfileRepository() {
|
||||
return ((CraftServer) Bukkit.getServer()).getServer().getGameProfileRepository();
|
||||
@ -830,7 +821,7 @@ public class NMSImpl implements NMSBridge {
|
||||
if (zDiff < 0.0)
|
||||
yaw += Math.abs(180 - yaw) * 2;
|
||||
if (handle instanceof EntityEnderDragon) {
|
||||
yaw = getDragonYaw(handle, to.getX(), to.getZ());
|
||||
yaw = Util.getDragonYaw(handle.getBukkitEntity(), xDiff, zDiff);
|
||||
} else {
|
||||
yaw = yaw - 90;
|
||||
}
|
||||
|
@ -113,15 +113,6 @@ public class EnderDragonController extends MobEntityController {
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
private float getCorrectYaw(double tX, double tZ) {
|
||||
if (locZ > tZ)
|
||||
return (float) (-Math.toDegrees(Math.atan((locX - tX) / (locZ - tZ))));
|
||||
if (locZ < tZ) {
|
||||
return (float) (-Math.toDegrees(Math.atan((locX - tX) / (locZ - tZ)))) + 180.0F;
|
||||
}
|
||||
return yaw;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
@ -159,10 +150,15 @@ public class EnderDragonController extends MobEntityController {
|
||||
public void movementTick() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
if (getRidingPassenger() != null) {
|
||||
yaw = getRidingPassenger().getBukkitYaw() - 180;
|
||||
}
|
||||
Vec3D mot = getMot();
|
||||
if (mot.getX() != 0 || mot.getY() != 0 || mot.getZ() != 0) {
|
||||
mot = mot.d(0.98, 0.98, 0.98);
|
||||
yaw = getCorrectYaw(locX + mot.getX(), locZ + mot.getZ());
|
||||
if (getRidingPassenger() == null) {
|
||||
yaw = Util.getDragonYaw(getBukkitEntity(), mot.x, mot.z);
|
||||
}
|
||||
setPosition(locX + mot.getX(), locY + mot.getY(), locZ + mot.getZ());
|
||||
setMot(mot);
|
||||
}
|
||||
|
@ -458,15 +458,6 @@ public class NMSImpl implements NMSBridge {
|
||||
return new Location(entity.getWorld(), controller.d(), controller.e(), controller.f());
|
||||
}
|
||||
|
||||
private float getDragonYaw(Entity handle, double tX, double tZ) {
|
||||
if (handle.locZ > tZ)
|
||||
return (float) (-Math.toDegrees(Math.atan((handle.locX - tX) / (handle.locZ - tZ))));
|
||||
if (handle.locZ < tZ) {
|
||||
return (float) (-Math.toDegrees(Math.atan((handle.locX - tX) / (handle.locZ - tZ)))) + 180.0F;
|
||||
}
|
||||
return handle.yaw;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameProfileRepository getGameProfileRepository() {
|
||||
return ((CraftServer) Bukkit.getServer()).getServer().getGameProfileRepository();
|
||||
@ -898,7 +889,7 @@ public class NMSImpl implements NMSBridge {
|
||||
if (zDiff < 0.0)
|
||||
yaw += Math.abs(180 - yaw) * 2;
|
||||
if (handle instanceof EntityEnderDragon) {
|
||||
yaw = getDragonYaw(handle, to.getX(), to.getZ());
|
||||
yaw = Util.getDragonYaw(handle.getBukkitEntity(), xDiff, zDiff);
|
||||
} else {
|
||||
yaw = yaw - 90;
|
||||
}
|
||||
|
@ -105,15 +105,6 @@ public class EnderDragonController extends MobEntityController {
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
private float getCorrectYaw(double tX, double tZ) {
|
||||
if (locZ() > tZ)
|
||||
return (float) (-Math.toDegrees(Math.atan((locX() - tX) / (locZ() - tZ))));
|
||||
if (locZ() < tZ) {
|
||||
return (float) (-Math.toDegrees(Math.atan((locX() - tX) / (locX() - tZ)))) + 180.0F;
|
||||
}
|
||||
return yaw;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
@ -162,10 +153,15 @@ public class EnderDragonController extends MobEntityController {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
}
|
||||
if (npc != null && !npc.useMinecraftAI()) {
|
||||
if (getRidingPassenger() != null) {
|
||||
yaw = getRidingPassenger().getBukkitYaw() - 180;
|
||||
}
|
||||
Vec3D mot = getMot();
|
||||
if (mot.getX() != 0 || mot.getY() != 0 || mot.getZ() != 0) {
|
||||
mot = mot.d(0.98, 0.98, 0.98);
|
||||
yaw = getCorrectYaw(locX() + mot.getX(), locZ() + mot.getZ());
|
||||
if (getRidingPassenger() == null) {
|
||||
yaw = Util.getDragonYaw(getBukkitEntity(), mot.x, mot.z);
|
||||
}
|
||||
setPosition(locX() + mot.getX(), locY() + mot.getY(), locZ() + mot.getZ());
|
||||
setMot(mot);
|
||||
}
|
||||
|
@ -467,15 +467,6 @@ public class NMSImpl implements NMSBridge {
|
||||
return new Location(entity.getWorld(), controller.d(), controller.e(), controller.f());
|
||||
}
|
||||
|
||||
private float getDragonYaw(Entity handle, double tX, double tZ) {
|
||||
if (handle.locZ() > tZ)
|
||||
return (float) (-Math.toDegrees(Math.atan((handle.locX() - tX) / (handle.locZ() - tZ))));
|
||||
if (handle.locZ() < tZ) {
|
||||
return (float) (-Math.toDegrees(Math.atan((handle.locX() - tX) / (handle.locZ() - tZ)))) + 180.0F;
|
||||
}
|
||||
return handle.yaw;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameProfileRepository getGameProfileRepository() {
|
||||
return ((CraftServer) Bukkit.getServer()).getServer().getGameProfileRepository();
|
||||
@ -910,7 +901,7 @@ public class NMSImpl implements NMSBridge {
|
||||
if (zDiff < 0.0)
|
||||
yaw += Math.abs(180 - yaw) * 2;
|
||||
if (handle instanceof EntityEnderDragon) {
|
||||
yaw = getDragonYaw(handle, to.getX(), to.getZ());
|
||||
yaw = Util.getDragonYaw(handle.getBukkitEntity(), xDiff, zDiff);
|
||||
} else {
|
||||
yaw = yaw - 90;
|
||||
}
|
||||
|
@ -98,15 +98,6 @@ public class EnderDragonController extends MobEntityController {
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
private float getCorrectYaw(double tX, double tZ) {
|
||||
if (locZ() > tZ)
|
||||
return (float) (-Math.toDegrees(Math.atan((locX() - tX) / (locZ() - tZ))));
|
||||
if (locZ() < tZ) {
|
||||
return (float) (-Math.toDegrees(Math.atan((locX() - tX) / (locX() - tZ)))) + 180.0F;
|
||||
}
|
||||
return yaw;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
@ -155,10 +146,15 @@ public class EnderDragonController extends MobEntityController {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
}
|
||||
if (npc != null && !npc.useMinecraftAI()) {
|
||||
if (getRidingPassenger() != null) {
|
||||
yaw = getRidingPassenger().getBukkitYaw() - 180;
|
||||
}
|
||||
Vec3D mot = getMot();
|
||||
if (mot.getX() != 0 || mot.getY() != 0 || mot.getZ() != 0) {
|
||||
mot = mot.d(0.98, 0.98, 0.98);
|
||||
yaw = getCorrectYaw(locX() + mot.getX(), locZ() + mot.getZ());
|
||||
if (getRidingPassenger() == null) {
|
||||
yaw = Util.getDragonYaw(getBukkitEntity(), mot.x, mot.z);
|
||||
}
|
||||
setPosition(locX() + mot.getX(), locY() + mot.getY(), locZ() + mot.getZ());
|
||||
setMot(mot);
|
||||
}
|
||||
|
@ -473,15 +473,6 @@ public class NMSImpl implements NMSBridge {
|
||||
return new Location(entity.getWorld(), controller.d(), controller.e(), controller.f());
|
||||
}
|
||||
|
||||
private float getDragonYaw(Entity handle, double tX, double tZ) {
|
||||
if (handle.locZ() > tZ)
|
||||
return (float) (-Math.toDegrees(Math.atan((handle.locX() - tX) / (handle.locZ() - tZ))));
|
||||
if (handle.locZ() < tZ) {
|
||||
return (float) (-Math.toDegrees(Math.atan((handle.locX() - tX) / (handle.locZ() - tZ)))) + 180.0F;
|
||||
}
|
||||
return handle.yaw;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameProfileRepository getGameProfileRepository() {
|
||||
return ((CraftServer) Bukkit.getServer()).getServer().getGameProfileRepository();
|
||||
@ -930,7 +921,7 @@ public class NMSImpl implements NMSBridge {
|
||||
if (zDiff < 0.0)
|
||||
yaw += Math.abs(180 - yaw) * 2;
|
||||
if (handle.getBukkitEntity().getType() == EntityType.ENDER_DRAGON) {
|
||||
yaw = getDragonYaw(handle, to.getX(), to.getZ());
|
||||
yaw = Util.getDragonYaw(handle.getBukkitEntity(), xDiff, zDiff);
|
||||
} else {
|
||||
yaw = yaw - 90;
|
||||
}
|
||||
|
@ -62,10 +62,15 @@ public class EnderDragonController extends MobEntityController {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
}
|
||||
if (npc != null && !npc.useMinecraftAI()) {
|
||||
if (getFirstPassenger() != null) {
|
||||
setYRot(getFirstPassenger().getBukkitYaw() - 180);
|
||||
}
|
||||
Vec3 mot = getDeltaMovement();
|
||||
if (mot.x != 0 || mot.y != 0 || mot.z != 0) {
|
||||
mot = mot.multiply(0.98, 0.98, 0.98);
|
||||
setYRot(getCorrectYaw(getX() + mot.x, getZ() + mot.z));
|
||||
if (getFirstPassenger() == null) {
|
||||
setYRot(Util.getDragonYaw(getBukkitEntity(), mot.x, mot.z));
|
||||
}
|
||||
setPos(getX() + mot.x, getY() + mot.y, getZ() + mot.z);
|
||||
setDeltaMovement(mot);
|
||||
}
|
||||
@ -115,15 +120,6 @@ public class EnderDragonController extends MobEntityController {
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
private float getCorrectYaw(double tX, double tZ) {
|
||||
if (getZ() > tZ)
|
||||
return (float) (-Math.toDegrees(Math.atan((getX() - tX) / (getZ() - tZ))));
|
||||
if (getZ() < tZ) {
|
||||
return (float) (-Math.toDegrees(Math.atan((getX() - tX) / (getX() - tZ)))) + 180.0F;
|
||||
}
|
||||
return getYRot();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEvent getDeathSound() {
|
||||
return NMSImpl.getSoundEffect(npc, super.getDeathSound(), NPC.DEATH_SOUND_METADATA);
|
||||
|
@ -486,15 +486,6 @@ public class NMSImpl implements NMSBridge {
|
||||
controller.getWantedZ());
|
||||
}
|
||||
|
||||
private float getDragonYaw(Entity handle, double tX, double tZ) {
|
||||
if (handle.getZ() > tZ)
|
||||
return (float) (-Math.toDegrees(Math.atan((handle.getX() - tX) / (handle.getZ() - tZ))));
|
||||
if (handle.getZ() < tZ) {
|
||||
return (float) (-Math.toDegrees(Math.atan((handle.getX() - tX) / (handle.getZ() - tZ)))) + 180.0F;
|
||||
}
|
||||
return handle.getYRot();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameProfileRepository getGameProfileRepository() {
|
||||
return ((CraftServer) Bukkit.getServer()).getServer().getProfileRepository();
|
||||
@ -934,7 +925,7 @@ public class NMSImpl implements NMSBridge {
|
||||
if (zDiff < 0.0)
|
||||
yaw += Math.abs(180 - yaw) * 2;
|
||||
if (handle.getBukkitEntity().getType() == EntityType.ENDER_DRAGON) {
|
||||
yaw = getDragonYaw(handle, to.getX(), to.getZ());
|
||||
yaw = Util.getDragonYaw(handle.getBukkitEntity(), xDiff, zDiff);
|
||||
} else {
|
||||
yaw = yaw - 90;
|
||||
}
|
||||
|
@ -64,10 +64,15 @@ public class EnderDragonController extends MobEntityController {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
}
|
||||
if (npc != null && !npc.useMinecraftAI()) {
|
||||
if (getFirstPassenger() != null) {
|
||||
setYRot(getFirstPassenger().getBukkitYaw() - 180);
|
||||
}
|
||||
Vec3 mot = getDeltaMovement();
|
||||
if (mot.x != 0 || mot.y != 0 || mot.z != 0) {
|
||||
mot = mot.multiply(0.98, 0.98, 0.98);
|
||||
setYRot(getCorrectYaw(getX() + mot.x, getZ() + mot.z));
|
||||
if (getFirstPassenger() == null) {
|
||||
setYRot(Util.getDragonYaw(getBukkitEntity(), mot.x, mot.z));
|
||||
}
|
||||
setPos(getX() + mot.x, getY() + mot.y, getZ() + mot.z);
|
||||
setDeltaMovement(mot);
|
||||
}
|
||||
@ -117,15 +122,6 @@ public class EnderDragonController extends MobEntityController {
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
private float getCorrectYaw(double tX, double tZ) {
|
||||
if (getZ() > tZ)
|
||||
return (float) (-Math.toDegrees(Math.atan((getX() - tX) / (getZ() - tZ))));
|
||||
if (getZ() < tZ) {
|
||||
return (float) (-Math.toDegrees(Math.atan((getX() - tX) / (getX() - tZ)))) + 180.0F;
|
||||
}
|
||||
return getYRot();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEvent getDeathSound() {
|
||||
return NMSImpl.getSoundEffect(npc, super.getDeathSound(), NPC.DEATH_SOUND_METADATA);
|
||||
|
@ -490,15 +490,6 @@ public class NMSImpl implements NMSBridge {
|
||||
controller.getWantedZ());
|
||||
}
|
||||
|
||||
private float getDragonYaw(Entity handle, double tX, double tZ) {
|
||||
if (handle.getZ() > tZ)
|
||||
return (float) (-Math.toDegrees(Math.atan((handle.getX() - tX) / (handle.getZ() - tZ))));
|
||||
if (handle.getZ() < tZ) {
|
||||
return (float) (-Math.toDegrees(Math.atan((handle.getX() - tX) / (handle.getZ() - tZ)))) + 180.0F;
|
||||
}
|
||||
return handle.getYRot();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameProfileRepository getGameProfileRepository() {
|
||||
return ((CraftServer) Bukkit.getServer()).getServer().getProfileRepository();
|
||||
@ -937,7 +928,7 @@ public class NMSImpl implements NMSBridge {
|
||||
if (zDiff < 0.0)
|
||||
yaw += Math.abs(180 - yaw) * 2;
|
||||
if (handle.getBukkitEntity().getType() == EntityType.ENDER_DRAGON) {
|
||||
yaw = getDragonYaw(handle, to.getX(), to.getZ());
|
||||
yaw = Util.getDragonYaw(handle.getBukkitEntity(), xDiff, zDiff);
|
||||
} else {
|
||||
yaw = yaw - 90;
|
||||
}
|
||||
|
@ -56,14 +56,27 @@ public class EnderDragonController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String bo() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bo(), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String bp() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bp(), NPC.DEATH_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String bo() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bo(), NPC.HURT_SOUND_METADATA);
|
||||
public boolean cc() {
|
||||
if (npc == null)
|
||||
return super.cc();
|
||||
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
|
||||
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
|
||||
return super.cc();
|
||||
if (super.cc()) {
|
||||
unleash(true, false); // clearLeash with client update
|
||||
}
|
||||
return false; // shouldLeash
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -80,6 +93,13 @@ public class EnderDragonController extends MobEntityController {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void D() {
|
||||
if (npc == null) {
|
||||
super.D();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enderTeleportTo(double d0, double d1, double d2) {
|
||||
if (npc == null)
|
||||
@ -99,11 +119,6 @@ public class EnderDragonController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String z() {
|
||||
return NMSImpl.getSoundEffect(npc, super.z(), NPC.AMBIENT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(bukkitEntity instanceof NPCHolder))
|
||||
@ -111,54 +126,35 @@ public class EnderDragonController extends MobEntityController {
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
private float getCorrectYaw(double tX, double tZ) {
|
||||
if (locZ > tZ)
|
||||
return (float) (-Math.toDegrees(Math.atan((locX - tX) / (locZ - tZ))));
|
||||
if (locZ < tZ) {
|
||||
return (float) (-Math.toDegrees(Math.atan((locX - tX) / (locZ - tZ)))) + 180.0F;
|
||||
}
|
||||
return yaw;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean cc() {
|
||||
if (npc == null)
|
||||
return super.cc();
|
||||
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
|
||||
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
|
||||
return super.cc();
|
||||
if (super.cc()) {
|
||||
unleash(true, false); // clearLeash with client update
|
||||
}
|
||||
return false; // shouldLeash
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void D() {
|
||||
if (npc == null) {
|
||||
super.D();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void m() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
if (getBukkitEntity().getPassenger() != null) {
|
||||
yaw = getBukkitEntity().getPassenger().getLocation().getYaw() - 180;
|
||||
}
|
||||
if (motX != 0 || motY != 0 || motZ != 0) {
|
||||
motX *= 0.98;
|
||||
motY *= 0.98;
|
||||
motZ *= 0.98;
|
||||
yaw = getCorrectYaw(locX + motX, locZ + motZ);
|
||||
if (getBukkitEntity().getPassenger() == null) {
|
||||
yaw = Util.getDragonYaw(getBukkitEntity(), motX, motZ);
|
||||
}
|
||||
setPosition(locX + motX, locY + motY, locZ + motZ);
|
||||
}
|
||||
} else {
|
||||
super.m();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String z() {
|
||||
return NMSImpl.getSoundEffect(npc, super.z(), NPC.AMBIENT_SOUND_METADATA);
|
||||
}
|
||||
}
|
||||
}
|
@ -322,15 +322,6 @@ public class NMSImpl implements NMSBridge {
|
||||
return new Location(entity.getWorld(), controller.d(), controller.e(), controller.f());
|
||||
}
|
||||
|
||||
private float getDragonYaw(Entity handle, double tX, double tZ) {
|
||||
if (handle.locZ > tZ)
|
||||
return (float) (-Math.toDegrees(Math.atan((handle.locX - tX) / (handle.locZ - tZ))));
|
||||
if (handle.locZ < tZ) {
|
||||
return (float) (-Math.toDegrees(Math.atan((handle.locX - tX) / (handle.locZ - tZ)))) + 180.0F;
|
||||
}
|
||||
return handle.yaw;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameProfileRepository getGameProfileRepository() {
|
||||
return ((CraftServer) Bukkit.getServer()).getServer().getGameProfileRepository();
|
||||
@ -665,7 +656,7 @@ public class NMSImpl implements NMSBridge {
|
||||
if (zDiff < 0.0)
|
||||
yaw += Math.abs(180 - yaw) * 2;
|
||||
if (handle instanceof EntityEnderDragon) {
|
||||
yaw = getDragonYaw(handle, to.getX(), to.getZ());
|
||||
yaw = Util.getDragonYaw(handle.getBukkitEntity(), xDiff, zDiff);
|
||||
} else {
|
||||
yaw = yaw - 90;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user