mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
parent
31a84ea302
commit
05e98c3a10
2 changed files with 17 additions and 0 deletions
|
@ -134,6 +134,10 @@ public class SessionPlayerEntity extends PlayerEntity {
|
|||
return maxHealth;
|
||||
}
|
||||
|
||||
public float getHealth() {
|
||||
return this.health;
|
||||
}
|
||||
|
||||
public void setHealth(float health) {
|
||||
this.health = health;
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ package org.geysermc.geyser.translator.protocol.java.entity.player;
|
|||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundSetHealthPacket;
|
||||
import com.nukkitx.protocol.bedrock.data.AttributeData;
|
||||
import com.nukkitx.protocol.bedrock.packet.RespawnPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.UpdateAttributesPacket;
|
||||
import org.geysermc.geyser.entity.attribute.GeyserAttributeType;
|
||||
import org.geysermc.geyser.entity.type.player.SessionPlayerEntity;
|
||||
|
@ -43,6 +44,18 @@ public class JavaSetHealthTranslator extends PacketTranslator<ClientboundSetHeal
|
|||
public void translate(GeyserSession session, ClientboundSetHealthPacket packet) {
|
||||
SessionPlayerEntity entity = session.getPlayerEntity();
|
||||
|
||||
float oldHealth = entity.getHealth();
|
||||
if (oldHealth <= 0f && Math.ceil(packet.getHealth()) > 0f) {
|
||||
// Needed as of 1.18.30 (tested with a totem of undying on SPIGOT 1.12.2
|
||||
// This shouldn't be triggered on a proper respawn because JavaSetHealthTranslator sets the health back to 20
|
||||
// https://github.com/GeyserMC/Geyser/issues/2957
|
||||
RespawnPacket respawnPacket = new RespawnPacket();
|
||||
respawnPacket.setRuntimeEntityId(0);
|
||||
respawnPacket.setPosition(entity.getPosition());
|
||||
respawnPacket.setState(RespawnPacket.State.SERVER_READY);
|
||||
session.sendUpstreamPacket(respawnPacket);
|
||||
}
|
||||
|
||||
entity.setHealth(packet.getHealth());
|
||||
|
||||
UpdateAttributesPacket attributesPacket = new UpdateAttributesPacket();
|
||||
|
|
Loading…
Reference in a new issue