3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-09-08 20:43:04 +02:00

Fix players being 'dead' even with half heart

Dieser Commit ist enthalten in:
Camotoy 2021-07-08 20:21:21 -04:00
Ursprung 92cd36d81f
Commit 334e4fb059
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 7EEFB66FE798081F
2 geänderte Dateien mit 9 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -110,7 +110,7 @@ public class EnderDragonEntity extends InsentientEntity implements Tickable {
@Override
protected AttributeData createHealthAttribute() {
// Round health up, so that Bedrock doesn't consider the dragon to be dead when health is between 0 and 1
return GeyserAttributeType.HEALTH.getAttribute((float) Math.ceil(this.health), this.maxHealth);
return new AttributeData(GeyserAttributeType.HEALTH.getBedrockIdentifier(), 0f, this.maxHealth, (float) Math.ceil(this.health), this.maxHealth);
}
@Override

Datei anzeigen

@ -46,6 +46,7 @@ import lombok.Setter;
import net.kyori.adventure.text.Component;
import org.geysermc.connector.entity.Entity;
import org.geysermc.connector.entity.LivingEntity;
import org.geysermc.connector.entity.attribute.GeyserAttributeType;
import org.geysermc.connector.entity.living.animal.tameable.ParrotEntity;
import org.geysermc.connector.entity.type.EntityType;
import org.geysermc.connector.network.session.GeyserSession;
@ -244,6 +245,13 @@ public class PlayerEntity extends LivingEntity {
this.position = includeOffset ? position.add(0, entityType.getOffset(), 0) : position;
}
@Override
protected AttributeData createHealthAttribute() {
// Round health up, so that Bedrock doesn't consider the player to be dead when health is between 0 and 1 (half a heart)
// This issue, as of Bedrock 1.17.0, does not appear to persist with any other entity except the ender dragon
return new AttributeData(GeyserAttributeType.HEALTH.getBedrockIdentifier(), 0f, this.maxHealth, (float) Math.ceil(this.health), this.maxHealth);
}
@Override
public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) {
super.updateBedrockMetadata(entityMetadata, session);