Reset attributes in JavaLoginTranslator

This commit is contained in:
AJ Ferguson 2024-04-14 17:42:13 -04:00
parent 1bd595826b
commit 14e7145503
3 changed files with 9 additions and 4 deletions

View File

@ -281,6 +281,13 @@ public class SessionPlayerEntity extends PlayerEntity {
silent = false;
}
public void resetAttributes() {
attributes.clear();
maxHealth = GeyserAttributeType.MAX_HEALTH.getDefaultValue();
// Relying on the server to resend speed attribute
// Armor attribute reset would go here
}
public void resetAir() {
this.setAirSupply(getMaxAir());
}

View File

@ -71,7 +71,7 @@ public class JavaLoginTranslator extends PacketTranslator<ClientboundLoginPacket
// Remove all bossbars
session.getEntityCache().removeAllBossBars();
// Remove extra hearts, hunger, etc.
entity.getAttributes().clear();
entity.resetAttributes();
entity.resetMetadata();
// Reset weather

View File

@ -54,9 +54,7 @@ public class JavaRespawnTranslator extends PacketTranslator<ClientboundRespawnPa
}
if (!packet.isKeepAttributes()) {
entity.getAttributes().clear();
entity.setMaxHealth(GeyserAttributeType.MAX_HEALTH.getDefaultValue());
// Relying on the server to resend speed attribute
entity.resetAttributes();
}
session.setSpawned(false);