From 052f49aa862730a7a4809e0cbb42ff24ed557a28 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Wed, 14 Jul 2021 01:10:29 +1200 Subject: [PATCH] Fix up packet spawn not having modified heights --- .../packethandlers/PacketHandlerSpawn.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerSpawn.java b/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerSpawn.java index fca9a6f5..2f98156c 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerSpawn.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerSpawn.java @@ -175,7 +175,8 @@ public class PacketHandlerSpawn implements IPacketHandler { // 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()).toVector().distanceSquared(disguisedEntity.getLocation().toVector()) - dist) < 0.3; + (observer.getLocation().add(observer.getLocation().getDirection().normalize()).toVector() + .distanceSquared(disguisedEntity.getLocation().toVector()) - dist) < 0.3; sendArmor = normalPlayerDisguise; skin.setSleepPackets(!normalPlayerDisguise); @@ -335,8 +336,17 @@ public class PacketHandlerSpawn implements IPacketHandler { spawnEntity = ProtocolLibrary.getProtocolManager().createPacketConstructor(PacketType.Play.Server.SPAWN_ENTITY, nmsEntity, objectId, data) .createPacket(nmsEntity, objectId, data); + + StructureModifier doubles = spawnEntity.getDoubles(); + + doubles.write(0, x); + doubles.write(1, y); + doubles.write(2, z); } + spawnEntity.getModifier().write(8, pitch); + spawnEntity.getModifier().write(9, yaw); + packets.addPacket(spawnEntity); // If it's not the same type, then highly likely they have different velocity settings which we'd want to @@ -356,9 +366,6 @@ public class PacketHandlerSpawn implements IPacketHandler { } } - spawnEntity.getModifier().write(8, pitch); - spawnEntity.getModifier().write(9, yaw); - if (disguise.getType() == DisguiseType.ITEM_FRAME) { if (data % 2 == 0) { spawnEntity.getModifier().write(4, loc.getZ() + (data == 0 ? -1 : 1));