From 5f98e57316cf1df52e909cb961cc848ae8cee943 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Sun, 2 Feb 2020 11:58:21 +1300 Subject: [PATCH] Fixed movement speed not being set in attributes --- .../PacketHandlerAttributes.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerAttributes.java b/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerAttributes.java index 4f81d08d..5c64cc62 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerAttributes.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerAttributes.java @@ -27,18 +27,21 @@ public class PacketHandlerAttributes implements IPacketHandler { @Override public void handle(Disguise disguise, PacketContainer sentPacket, LibsPackets packets, Player observer, Entity entity) { - if (disguise.isMiscDisguise()) { + packets.clear(); + + if (!disguise.isMiscDisguise()) { packets.clear(); - } else { + List attributes = new ArrayList<>(); + PacketContainer updateAttributes = new PacketContainer(PacketType.Play.Server.UPDATE_ATTRIBUTES); for (WrappedAttribute attribute : sentPacket.getAttributeCollectionModifier().read(0)) { - if (attribute.getAttributeKey().equals("generic.maxHealth")) { - packets.clear(); - - PacketContainer updateAttributes = new PacketContainer(PacketType.Play.Server.UPDATE_ATTRIBUTES); - packets.addPacket(updateAttributes); + if (attribute.getAttributeKey().equals("generic.movementSpeed")) { + WrappedAttribute.Builder builder = WrappedAttribute.newBuilder(attribute); + builder.packet(updateAttributes); + attributes.add(builder.build()); + } else if (attribute.getAttributeKey().equals("generic.maxHealth")) { WrappedAttribute.Builder builder; if (((LivingWatcher) disguise.getWatcher()).isMaxHealthSet()) { @@ -56,15 +59,14 @@ public class PacketHandlerAttributes implements IPacketHandler { builder.packet(updateAttributes); attributes.add(builder.build()); - break; } } if (!attributes.isEmpty()) { packets.getPackets().get(0).getIntegers().write(0, entity.getEntityId()); packets.getPackets().get(0).getAttributeCollectionModifier().write(0, attributes); - } else { - packets.clear(); + + packets.addPacket(updateAttributes); } } }