File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
core/src/main/java/org/geysermc/geyser/entity/type Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -226,7 +226,13 @@ protected void setSpinAttack(boolean value) {
226226 }
227227
228228 public void setHealth (FloatEntityMetadata entityMetadata ) {
229- this .health = entityMetadata .getPrimitiveValue ();
229+ // The server can send health value early, causing health to be larger than maxHealth, which can freaks out Bedrock client
230+ // in some weird way, eg: https://github.com/GeyserMC/Geyser/issues/5918 or it could be intentional.... Either way
231+ // we do this to account for it, since currently it seems like Java client doesn't care while Bedrock does.
232+ this .health = Math .max (0 , entityMetadata .getPrimitiveValue ());
233+ if (this .health > this .maxHealth ) {
234+ this .maxHealth = this .health ;
235+ }
230236
231237 AttributeData healthData = createHealthAttribute ();
232238 UpdateAttributesPacket attributesPacket = new UpdateAttributesPacket ();
You can’t perform that action at this time.
0 commit comments