Merge pull request #397 from Bloepiloepi/attribute-fix

Fix player stop sprinting when changing attributes
This commit is contained in:
TheMode 2021-08-09 17:40:43 +02:00 committed by GitHub
commit ccd8bea434
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 4 deletions

View File

@ -507,10 +507,11 @@ public class LivingEntity extends Entity implements EquipmentHandler {
// connection null during Player initialization (due to #super call)
self = playerConnection != null && playerConnection.getConnectionState() == ConnectionState.PLAY;
}
EntityPropertiesPacket propertiesPacket = getPropertiesPacket(Collections.singleton(attributeInstance));
if (self) {
sendPacketToViewersAndSelf(getPropertiesPacket());
sendPacketToViewersAndSelf(propertiesPacket);
} else {
sendPacketToViewers(getPropertiesPacket());
sendPacketToViewers(propertiesPacket);
}
}
}
@ -632,8 +633,19 @@ public class LivingEntity extends Entity implements EquipmentHandler {
*/
@NotNull
protected EntityPropertiesPacket getPropertiesPacket() {
return getPropertiesPacket(attributeModifiers.values());
}
/**
* Gets an {@link EntityPropertiesPacket} for this entity with the specified attribute values.
*
* @param attributes the attributes to include in the packet
* @return an {@link EntityPropertiesPacket} linked to this entity
*/
@NotNull
protected EntityPropertiesPacket getPropertiesPacket(@NotNull Collection<AttributeInstance> attributes) {
// Get all the attributes which should be sent to the client
final AttributeInstance[] instances = attributeModifiers.values().stream()
final AttributeInstance[] instances = attributes.stream()
.filter(i -> i.getAttribute().isShared())
.toArray(AttributeInstance[]::new);

View File

@ -81,7 +81,9 @@ public class CrossbowMeta extends ItemMeta implements ItemMetaBuilder.Provider<S
public static class Builder extends ItemMetaBuilder {
private boolean triple;
private ItemStack projectile1, projectile2, projectile3 = ItemStack.AIR;
private ItemStack projectile1 = ItemStack.AIR;
private ItemStack projectile2 = ItemStack.AIR;
private ItemStack projectile3 = ItemStack.AIR;
private boolean charged;
/**