Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-26 00:00:41 +01:00
Fix health edge case
If the java server sent a health value between 0 and 1, the player would die in the bedrock client
Dieser Commit ist enthalten in:
Ursprung
4153e98134
Commit
377a87f7e3
@ -40,8 +40,9 @@ public class JavaPlayerHealthTranslator extends PacketTranslator<ServerPlayerHea
|
||||
if (entity == null)
|
||||
return;
|
||||
|
||||
int health = (int) Math.ceil(packet.getHealth());
|
||||
SetHealthPacket setHealthPacket = new SetHealthPacket();
|
||||
setHealthPacket.setHealth((int) Math.ceil(packet.getHealth()));
|
||||
setHealthPacket.setHealth(health);
|
||||
session.getUpstream().sendPacket(setHealthPacket);
|
||||
|
||||
float maxHealth = entity.getAttributes().containsKey(AttributeType.MAX_HEALTH) ? entity.getAttributes().get(AttributeType.MAX_HEALTH).getValue() : 20f;
|
||||
@ -50,7 +51,7 @@ public class JavaPlayerHealthTranslator extends PacketTranslator<ServerPlayerHea
|
||||
maxHealth += 1;
|
||||
}
|
||||
|
||||
entity.getAttributes().put(AttributeType.HEALTH, AttributeType.HEALTH.getAttribute(packet.getHealth(), maxHealth));
|
||||
entity.getAttributes().put(AttributeType.HEALTH, AttributeType.HEALTH.getAttribute(health, maxHealth));
|
||||
entity.getAttributes().put(AttributeType.HUNGER, AttributeType.HUNGER.getAttribute(packet.getFood()));
|
||||
entity.getAttributes().put(AttributeType.SATURATION, AttributeType.SATURATION.getAttribute(packet.getSaturation()));
|
||||
entity.updateBedrockAttributes(session);
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren