25
25
26
26
package org .geysermc .geyser .translator .protocol .java .entity ;
27
27
28
- import org .geysermc .mcprotocollib .protocol .packet .ingame .clientbound .entity .ClientboundUpdateMobEffectPacket ;
29
28
import org .cloudburstmc .protocol .bedrock .packet .MobEffectPacket ;
29
+ import org .cloudburstmc .protocol .bedrock .packet .UpdateAttributesPacket ;
30
+ import org .geysermc .geyser .entity .attribute .GeyserAttributeType ;
30
31
import org .geysermc .geyser .entity .type .Entity ;
31
32
import org .geysermc .geyser .entity .vehicle .ClientVehicle ;
32
33
import org .geysermc .geyser .session .GeyserSession ;
33
34
import org .geysermc .geyser .translator .protocol .PacketTranslator ;
34
35
import org .geysermc .geyser .translator .protocol .Translator ;
35
36
import 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 ;
36
41
37
42
@ Translator (packet = ClientboundUpdateMobEffectPacket .class )
38
43
public class JavaUpdateMobEffectTranslator extends PacketTranslator <ClientboundUpdateMobEffectPacket > {
@@ -58,5 +63,20 @@ public void translate(GeyserSession session, ClientboundUpdateMobEffectPacket pa
58
63
mobEffectPacket .setParticles (packet .isShowParticles ());
59
64
mobEffectPacket .setEffectId (EntityUtils .toBedrockEffectId (packet .getEffect ()));
60
65
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
+ }
61
81
}
62
82
}
0 commit comments