2525
2626package org .geysermc .geyser .translator .protocol .java .entity ;
2727
28- import org .geysermc .mcprotocollib .protocol .packet .ingame .clientbound .entity .ClientboundUpdateMobEffectPacket ;
2928import org .cloudburstmc .protocol .bedrock .packet .MobEffectPacket ;
29+ import org .cloudburstmc .protocol .bedrock .packet .UpdateAttributesPacket ;
30+ import org .geysermc .geyser .entity .attribute .GeyserAttributeType ;
3031import org .geysermc .geyser .entity .type .Entity ;
3132import org .geysermc .geyser .entity .vehicle .ClientVehicle ;
3233import org .geysermc .geyser .session .GeyserSession ;
3334import org .geysermc .geyser .translator .protocol .PacketTranslator ;
3435import org .geysermc .geyser .translator .protocol .Translator ;
3536import org .geysermc .geyser .util .EntityUtils ;
37+ import org .geysermc .mcprotocollib .protocol .data .game .entity .Effect ;
38+ import org .geysermc .mcprotocollib .protocol .packet .ingame .clientbound .entity .ClientboundUpdateMobEffectPacket ;
39+
40+ import java .util .Collections ;
3641
3742@ Translator (packet = ClientboundUpdateMobEffectPacket .class )
3843public class JavaUpdateMobEffectTranslator extends PacketTranslator <ClientboundUpdateMobEffectPacket > {
@@ -58,5 +63,20 @@ public void translate(GeyserSession session, ClientboundUpdateMobEffectPacket pa
5863 mobEffectPacket .setParticles (packet .isShowParticles ());
5964 mobEffectPacket .setEffectId (EntityUtils .toBedrockEffectId (packet .getEffect ()));
6065 session .sendUpstreamPacket (mobEffectPacket );
66+
67+ // Fixes https://github.com/GeyserMC/Geyser/issues/5347 by re-sending the correct absorption hearts
68+ if (entity == session .getPlayerEntity () && packet .getEffect () == Effect .ABSORPTION ) {
69+ var absorptionAttribute = session .getPlayerEntity ().getAttributes ().get (GeyserAttributeType .ABSORPTION );
70+ if (absorptionAttribute == null ) {
71+ return ;
72+ }
73+
74+ UpdateAttributesPacket attributesPacket = new UpdateAttributesPacket ();
75+ attributesPacket .setRuntimeEntityId (entity .getGeyserId ());
76+ // Setting to a higher maximum since plugins/datapacks can probably extend the Bedrock soft limit
77+ attributesPacket .setAttributes (Collections .singletonList (
78+ GeyserAttributeType .ABSORPTION .getAttribute (absorptionAttribute .getValue ())));
79+ session .sendUpstreamPacket (attributesPacket );
80+ }
6181 }
6282}
0 commit comments