mirror of
https://github.com/PaperMC/Paper.git
synced 2025-05-19 05:30:23 -07:00
Don't resync all attributes when updating scaled health (#12232)
This commit is contained in:
parent
2526fe063a
commit
20df25d3a5
@ -2827,14 +2827,9 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
}
|
||||
|
||||
public void updateScaledHealth(boolean sendHealth) {
|
||||
AttributeMap attributemapserver = this.getHandle().getAttributes();
|
||||
Collection<AttributeInstance> set = attributemapserver.getSyncableAttributes();
|
||||
|
||||
this.injectScaledMaxHealth(set, true);
|
||||
|
||||
// SPIGOT-3813: Attributes before health
|
||||
if (this.getHandle().connection != null) {
|
||||
this.getHandle().connection.send(new ClientboundUpdateAttributesPacket(this.getHandle().getId(), set));
|
||||
this.getHandle().connection.send(new ClientboundUpdateAttributesPacket(this.getHandle().getId(), Set.of(this.getScaledMaxHealth())));
|
||||
if (sendHealth) {
|
||||
this.sendHealthUpdate();
|
||||
}
|
||||
@ -2874,8 +2869,11 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
break;
|
||||
}
|
||||
}
|
||||
collection.add(getScaledMaxHealth());
|
||||
}
|
||||
|
||||
public AttributeInstance getScaledMaxHealth() {
|
||||
AttributeInstance dummy = new AttributeInstance(Attributes.MAX_HEALTH, (attribute) -> { });
|
||||
// Spigot start
|
||||
double healthMod = this.scaledHealth ? this.healthScale : this.getMaxHealth();
|
||||
if ( healthMod >= Float.MAX_VALUE || healthMod <= 0 )
|
||||
{
|
||||
@ -2883,8 +2881,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
this.getServer().getLogger().warning( this.getName() + " tried to crash the server with a large health attribute" );
|
||||
}
|
||||
dummy.setBaseValue(healthMod);
|
||||
// Spigot end
|
||||
collection.add(dummy);
|
||||
return dummy;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
x
Reference in New Issue
Block a user