mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-09-29 15:47:40 +02:00
Fix Minecraft 1.10 player looking
This commit is contained in:
parent
e3981a15a6
commit
86d6794b43
@ -305,7 +305,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
&& Util.isLoaded(getBukkitEntity().getLocation(LOADED_LOCATION))) {
|
&& Util.isLoaded(getBukkitEntity().getLocation(LOADED_LOCATION))) {
|
||||||
g(0, 0);
|
g(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Math.abs(motX) < EPSILON && Math.abs(motY) < EPSILON && Math.abs(motZ) < EPSILON) {
|
if (Math.abs(motX) < EPSILON && Math.abs(motY) < EPSILON && Math.abs(motZ) < EPSILON) {
|
||||||
motX = motY = motZ = 0;
|
motX = motY = motZ = 0;
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import java.net.URL;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.EnumSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -317,6 +318,15 @@ public class NMSImpl implements NMSBridge {
|
|||||||
return new BoundingBox(bb.a, bb.b, bb.c, bb.d, bb.e, bb.f);
|
return new BoundingBox(bb.a, bb.b, bb.c, bb.d, bb.e, bb.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
|
@Override
|
||||||
public GameProfileRepository getGameProfileRepository() {
|
public GameProfileRepository getGameProfileRepository() {
|
||||||
return ((CraftServer) Bukkit.getServer()).getServer().getGameProfileRepository();
|
return ((CraftServer) Bukkit.getServer()).getServer().getGameProfileRepository();
|
||||||
@ -589,7 +599,8 @@ public class NMSImpl implements NMSBridge {
|
|||||||
@Override
|
@Override
|
||||||
public void look(org.bukkit.entity.Entity entity, Location to, boolean headOnly) {
|
public void look(org.bukkit.entity.Entity entity, Location to, boolean headOnly) {
|
||||||
Entity handle = NMSImpl.getHandle(entity);
|
Entity handle = NMSImpl.getHandle(entity);
|
||||||
if (headOnly || (!(handle instanceof EntityInsentient) && !(handle instanceof EntityHumanNPC))) {
|
if (headOnly || BAD_CONTROLLER_LOOK.contains(handle.getBukkitEntity().getType())
|
||||||
|
|| (!(handle instanceof EntityInsentient) && !(handle instanceof EntityHumanNPC))) {
|
||||||
Location fromLocation = entity.getLocation(FROM_LOCATION);
|
Location fromLocation = entity.getLocation(FROM_LOCATION);
|
||||||
double xDiff, yDiff, zDiff;
|
double xDiff, yDiff, zDiff;
|
||||||
xDiff = to.getX() - fromLocation.getX();
|
xDiff = to.getX() - fromLocation.getX();
|
||||||
@ -603,21 +614,26 @@ public class NMSImpl implements NMSBridge {
|
|||||||
double pitch = Math.toDegrees(Math.acos(yDiff / distanceY)) - 90;
|
double pitch = Math.toDegrees(Math.acos(yDiff / distanceY)) - 90;
|
||||||
if (zDiff < 0.0)
|
if (zDiff < 0.0)
|
||||||
yaw += Math.abs(180 - yaw) * 2;
|
yaw += Math.abs(180 - yaw) * 2;
|
||||||
|
if (handle instanceof EntityEnderDragon) {
|
||||||
if (headOnly) {
|
yaw = getDragonYaw(handle, to.getX(), to.getZ());
|
||||||
setHeadYaw(entity, (float) yaw - 90);
|
|
||||||
} else {
|
} else {
|
||||||
look(entity, (float) yaw - 90, (float) pitch);
|
yaw = yaw - 90;
|
||||||
}
|
}
|
||||||
|
if (headOnly) {
|
||||||
|
setHeadYaw(entity, (float) yaw);
|
||||||
|
} else {
|
||||||
|
look(entity, (float) yaw, (float) pitch);
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (handle instanceof EntityInsentient) {
|
if (handle instanceof EntityInsentient) {
|
||||||
((EntityInsentient) handle).getControllerLook().a(to.getX(), to.getY(), to.getZ(), to.getYaw(),
|
((EntityInsentient) handle).getControllerLook().a(to.getX(), to.getY(), to.getZ(), to.getYaw(),
|
||||||
to.getPitch());
|
to.getPitch());
|
||||||
while (((EntityInsentient) handle).aO >= 180F) {
|
while (((EntityInsentient) handle).aQ >= 180F) {
|
||||||
((EntityInsentient) handle).aO -= 360F;
|
((EntityInsentient) handle).aQ -= 360F;
|
||||||
}
|
}
|
||||||
while (((EntityInsentient) handle).aO < -180F) {
|
while (((EntityInsentient) handle).aQ < -180F) {
|
||||||
((EntityInsentient) handle).aO += 360F;
|
((EntityInsentient) handle).aQ += 360F;
|
||||||
}
|
}
|
||||||
} else if (handle instanceof EntityHumanNPC) {
|
} else if (handle instanceof EntityHumanNPC) {
|
||||||
((EntityHumanNPC) handle).setTargetLook(to);
|
((EntityHumanNPC) handle).setTargetLook(to);
|
||||||
@ -627,8 +643,21 @@ public class NMSImpl implements NMSBridge {
|
|||||||
@Override
|
@Override
|
||||||
public void look(org.bukkit.entity.Entity from, org.bukkit.entity.Entity to) {
|
public void look(org.bukkit.entity.Entity from, org.bukkit.entity.Entity to) {
|
||||||
Entity handle = NMSImpl.getHandle(from), target = NMSImpl.getHandle(to);
|
Entity handle = NMSImpl.getHandle(from), target = NMSImpl.getHandle(to);
|
||||||
if (handle instanceof EntityInsentient) {
|
if (BAD_CONTROLLER_LOOK.contains(handle.getBukkitEntity().getType())) {
|
||||||
((EntityInsentient) handle).getControllerLook().a(target, 10.0F, ((EntityInsentient) handle).N());
|
if (to instanceof LivingEntity) {
|
||||||
|
look(from, ((LivingEntity) to).getEyeLocation(), false);
|
||||||
|
} else {
|
||||||
|
look(from, to.getLocation(), false);
|
||||||
|
}
|
||||||
|
} else if (handle instanceof EntityInsentient) {
|
||||||
|
((EntityInsentient) handle).getControllerLook().a(target, ((EntityInsentient) handle).cJ(),
|
||||||
|
((EntityInsentient) handle).N());
|
||||||
|
while (((EntityLiving) handle).aQ >= 180F) {
|
||||||
|
((EntityLiving) handle).aQ -= 360F;
|
||||||
|
}
|
||||||
|
while (((EntityLiving) handle).aQ < -180F) {
|
||||||
|
((EntityLiving) handle).aQ += 360F;
|
||||||
|
}
|
||||||
} else if (handle instanceof EntityHumanNPC) {
|
} else if (handle instanceof EntityHumanNPC) {
|
||||||
((EntityHumanNPC) handle).setTargetLook(target, 10F, 40F);
|
((EntityHumanNPC) handle).setTargetLook(target, 10F, 40F);
|
||||||
}
|
}
|
||||||
@ -1353,6 +1382,10 @@ public class NMSImpl implements NMSBridge {
|
|||||||
navigation.l();
|
navigation.l();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final Set<EntityType> BAD_CONTROLLER_LOOK = EnumSet.of(EntityType.SILVERFISH, EntityType.ENDERMITE,
|
||||||
|
EntityType.ENDER_DRAGON, EntityType.BAT, EntityType.SLIME, EntityType.MAGMA_CUBE, EntityType.HORSE,
|
||||||
|
EntityType.GHAST);
|
||||||
|
|
||||||
private static final Field CRAFT_BOSSBAR_HANDLE_FIELD = NMS.getField(CraftBossBar.class, "handle");
|
private static final Field CRAFT_BOSSBAR_HANDLE_FIELD = NMS.getField(CraftBossBar.class, "handle");
|
||||||
|
|
||||||
private static final float DEFAULT_SPEED = 1F;
|
private static final float DEFAULT_SPEED = 1F;
|
||||||
|
@ -31,24 +31,24 @@ public class PlayerControllerLook {
|
|||||||
float f1 = (float) (MathHelper.b(d3, d1) * 57.2957763671875D) - 90.0F;
|
float f1 = (float) (MathHelper.b(d3, d1) * 57.2957763671875D) - 90.0F;
|
||||||
float f2 = (float) -(MathHelper.b(d2, d4) * 57.2957763671875D);
|
float f2 = (float) -(MathHelper.b(d2, d4) * 57.2957763671875D);
|
||||||
this.a.pitch = a(this.a.pitch, f2, this.c);
|
this.a.pitch = a(this.a.pitch, f2, this.c);
|
||||||
this.a.aO = a(this.a.aO, f1, this.b);
|
this.a.aQ = a(this.a.aQ, f1, this.b);
|
||||||
this.a.yaw = this.a.aO;
|
this.a.yaw = this.a.aQ;
|
||||||
while (this.a.aO >= 180F) {
|
while (this.a.aQ >= 180F) {
|
||||||
this.a.aO -= 360F;
|
this.a.aQ -= 360F;
|
||||||
}
|
}
|
||||||
while (this.a.aO < -180F) {
|
while (this.a.aQ < -180F) {
|
||||||
this.a.aO += 360F;
|
this.a.aQ += 360F;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// this.a.aO = a(this.a.aO, this.a.aM, 10.0F);
|
// this.a.aQ = a(this.a.aQ, this.a.aO, 10.0F);
|
||||||
}
|
}
|
||||||
float f3 = MathHelper.g(this.a.aO - this.a.aM);
|
float f3 = MathHelper.g(this.a.aQ - this.a.aO);
|
||||||
if (!this.a.getNavigation().n()) {
|
if (!this.a.getNavigation().n()) {
|
||||||
if (f3 < -75.0F) {
|
if (f3 < -75.0F) {
|
||||||
this.a.aO = (this.a.aM - 75.0F);
|
this.a.aQ = (this.a.aO - 75.0F);
|
||||||
}
|
}
|
||||||
if (f3 > 75.0F) {
|
if (f3 > 75.0F) {
|
||||||
this.a.aO = (this.a.aM + 75.0F);
|
this.a.aQ = (this.a.aO + 75.0F);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ public class PlayerControllerMove extends ControllerMove {
|
|||||||
if (d3 < 2.500000277905201E-007D)
|
if (d3 < 2.500000277905201E-007D)
|
||||||
return;
|
return;
|
||||||
float f = (float) Math.toDegrees(Math.atan2(d1, d0)) - 90.0F;
|
float f = (float) Math.toDegrees(Math.atan2(d1, d0)) - 90.0F;
|
||||||
this.a.yaw = a(this.a.yaw, f, 30.0F);
|
this.a.yaw = a(this.a.yaw, f, 90.0F);
|
||||||
NMS.setHeadYaw(a.getBukkitEntity(), this.a.yaw);
|
NMS.setHeadYaw(a.getBukkitEntity(), this.a.yaw);
|
||||||
AttributeInstance speed = this.a.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED);
|
AttributeInstance speed = this.a.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED);
|
||||||
speed.setValue(0.1D * this.e);
|
speed.setValue(0.1D * this.e);
|
||||||
|
@ -111,10 +111,10 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
super.A_();
|
super.A_();
|
||||||
if (npc == null)
|
if (npc == null)
|
||||||
return;
|
return;
|
||||||
livingEntityBaseTick();
|
|
||||||
if (updateCounter + 1 > Setting.PACKET_UPDATE_DELAY.asInt()) {
|
if (updateCounter + 1 > Setting.PACKET_UPDATE_DELAY.asInt()) {
|
||||||
updateEffects = true;
|
updateEffects = true;
|
||||||
}
|
}
|
||||||
|
livingEntityBaseTick();
|
||||||
|
|
||||||
boolean navigating = npc.getNavigator().isNavigating();
|
boolean navigating = npc.getNavigator().isNavigating();
|
||||||
updatePackets(navigating);
|
updatePackets(navigating);
|
||||||
|
@ -676,7 +676,7 @@ public class NMSImpl implements NMSBridge {
|
|||||||
@Override
|
@Override
|
||||||
public void look(org.bukkit.entity.Entity from, org.bukkit.entity.Entity to) {
|
public void look(org.bukkit.entity.Entity from, org.bukkit.entity.Entity to) {
|
||||||
Entity handle = NMSImpl.getHandle(from), target = NMSImpl.getHandle(to);
|
Entity handle = NMSImpl.getHandle(from), target = NMSImpl.getHandle(to);
|
||||||
if (handle instanceof EntityEnderDragon || BAD_CONTROLLER_LOOK.contains(handle.getBukkitEntity().getType())) {
|
if (BAD_CONTROLLER_LOOK.contains(handle.getBukkitEntity().getType())) {
|
||||||
if (to instanceof LivingEntity) {
|
if (to instanceof LivingEntity) {
|
||||||
look(from, ((LivingEntity) to).getEyeLocation(), false);
|
look(from, ((LivingEntity) to).getEyeLocation(), false);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user