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
public void handle(Disguise disguise, PacketContainer sentPacket, LibsPackets packets, Player observer,
Entity entity) {
if (disguise.isMiscDisguise()) {
packets.clear();
} else {
if (!disguise.isMiscDisguise()) {
packets.clear();
List<WrappedAttribute> 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);
}
}
}