3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-08 09:10:06 +01:00

Prevent max health from being set below 0 (#2980)

* Prevent max health from being set below 0

* Add more detail to comment
Dieser Commit ist enthalten in:
David Choo 2022-05-21 11:54:32 -04:00 committet von GitHub
Ursprung c3c8161a43
Commit 38625312a1
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23

Datei anzeigen

@ -300,7 +300,9 @@ public class LivingEntity extends Entity {
if (javaAttribute.getType() instanceof AttributeType.Builtin type) {
switch (type) {
case GENERIC_MAX_HEALTH -> {
this.maxHealth = (float) AttributeUtils.calculateValue(javaAttribute);
// Since 1.18.0, setting the max health to 0 or below causes the entity to die on Bedrock but not on Java
// See https://github.com/GeyserMC/Geyser/issues/2971
this.maxHealth = Math.max((float) AttributeUtils.calculateValue(javaAttribute), 1f);
newAttributes.add(createHealthAttribute());
}
case GENERIC_ATTACK_DAMAGE -> newAttributes.add(calculateAttribute(javaAttribute, GeyserAttributeType.ATTACK_DAMAGE));