From dfb11dceda509a3eadcc51939a292a6b92d23ad8 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Mon, 25 Nov 2013 15:45:37 +1300 Subject: [PATCH] Fixed self disguises, wonder if I introduced new bug. --- .../disguise/disguisetypes/Disguise.java | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/me/libraryaddict/disguise/disguisetypes/Disguise.java b/src/me/libraryaddict/disguise/disguisetypes/Disguise.java index 7766e782..3e162f2b 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/Disguise.java +++ b/src/me/libraryaddict/disguise/disguisetypes/Disguise.java @@ -203,7 +203,6 @@ public abstract class Disguise { } if (getType() != DisguiseType.EXPERIENCE_ORB || !entity.isOnGround()) { PacketContainer lookPacket = null; - PacketContainer selfLookPacket = null; if (getType() == DisguiseType.WITHER_SKULL) { lookPacket = new PacketContainer(Packets.Server.ENTITY_LOOK); StructureModifier mods = lookPacket.getModifier(); @@ -214,35 +213,39 @@ public abstract class Disguise { PacketsManager.getYaw(getType(), DisguiseType.getType(entity.getType()), (byte) Math.floor(loc.getYaw() * 256.0F / 360.0F))); mods.write(5, (byte) Math.floor(loc.getPitch() * 256.0F / 360.0F)); - selfLookPacket = lookPacket.shallowClone(); + if (isSelfDisguiseVisible() && getEntity() instanceof Player) { + PacketContainer selfLookPacket = lookPacket.shallowClone(); + selfLookPacket.getModifier().write(0, DisguiseAPI.getFakeDisguise(entity.getEntityId())); + try { + ProtocolLibrary.getProtocolManager().sendServerPacket((Player) getEntity(), + selfLookPacket, false); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } + } } try { Field ping = ReflectionManager.getNmsClass("EntityPlayer").getField("ping"); for (Player player : getPerverts()) { PacketContainer packet = new PacketContainer(Packets.Server.ENTITY_VELOCITY); StructureModifier mods = packet.getModifier(); - if (entity == player) { - if (!isSelfDisguiseVisible()) + if (getEntity() == player) { + if (!isSelfDisguiseVisible()) { continue; - if (selfLookPacket != null) { - try { - ProtocolLibrary.getProtocolManager().sendServerPacket(player, selfLookPacket, - false); - } catch (InvocationTargetException e) { - e.printStackTrace(); - } } mods.write(0, DisguiseAPI.getFakeDisguise(entity.getEntityId())); - } else + } else { mods.write(0, entity.getEntityId()); + } mods.write(1, (int) (vector.getX() * 8000)); mods.write( 2, (int) (8000 * (vectorY * (double) ping.getInt(ReflectionManager.getNmsEntity(player)) * 0.069))); mods.write(3, (int) (vector.getZ() * 8000)); - if (lookPacket != null) - ProtocolLibrary.getProtocolManager().sendServerPacket(player, lookPacket, false); - ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet, false); + if (lookPacket != null) { + ProtocolLibrary.getProtocolManager().sendServerPacket(player, lookPacket); + } + ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet); } } catch (Exception e) {