Fixed movement speed not being set in attributes

This commit is contained in:
libraryaddict 2020-02-02 11:58:21 +13:00
parent b65bbb6340
commit 5f98e57316
No known key found for this signature in database
GPG Key ID: 052E4FBCD257AEA4

View File

@ -27,18 +27,21 @@ public class PacketHandlerAttributes implements IPacketHandler {
@Override @Override
public void handle(Disguise disguise, PacketContainer sentPacket, LibsPackets packets, Player observer, public void handle(Disguise disguise, PacketContainer sentPacket, LibsPackets packets, Player observer,
Entity entity) { Entity entity) {
if (disguise.isMiscDisguise()) { packets.clear();
if (!disguise.isMiscDisguise()) {
packets.clear(); packets.clear();
} else {
List<WrappedAttribute> attributes = new ArrayList<>(); List<WrappedAttribute> attributes = new ArrayList<>();
PacketContainer updateAttributes = new PacketContainer(PacketType.Play.Server.UPDATE_ATTRIBUTES);
for (WrappedAttribute attribute : sentPacket.getAttributeCollectionModifier().read(0)) { for (WrappedAttribute attribute : sentPacket.getAttributeCollectionModifier().read(0)) {
if (attribute.getAttributeKey().equals("generic.maxHealth")) { if (attribute.getAttributeKey().equals("generic.movementSpeed")) {
packets.clear(); WrappedAttribute.Builder builder = WrappedAttribute.newBuilder(attribute);
builder.packet(updateAttributes);
PacketContainer updateAttributes = new PacketContainer(PacketType.Play.Server.UPDATE_ATTRIBUTES);
packets.addPacket(updateAttributes);
attributes.add(builder.build());
} else if (attribute.getAttributeKey().equals("generic.maxHealth")) {
WrappedAttribute.Builder builder; WrappedAttribute.Builder builder;
if (((LivingWatcher) disguise.getWatcher()).isMaxHealthSet()) { if (((LivingWatcher) disguise.getWatcher()).isMaxHealthSet()) {
@ -56,15 +59,14 @@ public class PacketHandlerAttributes implements IPacketHandler {
builder.packet(updateAttributes); builder.packet(updateAttributes);
attributes.add(builder.build()); attributes.add(builder.build());
break;
} }
} }
if (!attributes.isEmpty()) { if (!attributes.isEmpty()) {
packets.getPackets().get(0).getIntegers().write(0, entity.getEntityId()); packets.getPackets().get(0).getIntegers().write(0, entity.getEntityId());
packets.getPackets().get(0).getAttributeCollectionModifier().write(0, attributes); packets.getPackets().get(0).getAttributeCollectionModifier().write(0, attributes);
} else {
packets.clear(); packets.addPacket(updateAttributes);
} }
} }
} }