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; 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() { public void resetAir() {
this.setAirSupply(getMaxAir()); this.setAirSupply(getMaxAir());
} }

View File

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

View File

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