Use toVector for location.distanceSquared

This commit is contained in:
libraryaddict 2021-05-17 14:15:16 +12:00 committed by GitHub
parent e267d1d344
commit 4ea5c87645
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -172,11 +172,11 @@ public class PacketHandlerSpawn implements IPacketHandler {
spawnPlayer.getIntegers().write(0, entityId); // Id
spawnPlayer.getModifier().write(1, playerDisguise.getUUID());
double dist = observer.getLocation().distanceSquared(disguisedEntity.getLocation());
double dist = observer.getLocation().toVector().distanceSquared(disguisedEntity.getLocation().toVector());
// If self disguise, or further than 50 blocks, or not in front of entity
normalPlayerDisguise = observer == disguisedEntity || disguisedEntity.getPassengers().contains(observer) || dist > (50 * 50) ||
(observer.getLocation().add(observer.getLocation().getDirection().normalize()).distanceSquared(disguisedEntity.getLocation()) - dist) < 0.3;
(observer.getLocation().add(observer.getLocation().getDirection().normalize()).toVector().distanceSquared(disguisedEntity.getLocation().toVector()) - dist) < 0.3;
sendArmor = normalPlayerDisguise;
skin.setSleepPackets(!normalPlayerDisguise);