mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Clear bossbars & entity attributes on server switching (#4278)
* This ensures bossbars are cleared on server switch. Additionally, this clears the EntityCache - which should resolve issues around air supply/hearts persisting visually. * - Also reset attributes on server switch, aswell as air
This commit is contained in:
parent
06663bcafd
commit
aa899af908
3 changed files with 26 additions and 5 deletions
|
@ -254,4 +254,17 @@ public class SessionPlayerEntity extends PlayerEntity {
|
|||
public UUID getTabListUuid() {
|
||||
return session.getAuthData().uuid();
|
||||
}
|
||||
|
||||
public void resetMetadata() {
|
||||
// Reset all metadata to their default values
|
||||
// This is used when a player respawns
|
||||
this.initializeMetadata();
|
||||
|
||||
// Reset air
|
||||
this.resetAir();
|
||||
}
|
||||
|
||||
public void resetAir() {
|
||||
this.setAirSupply(getMaxAir());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -162,4 +162,9 @@ public class EntityCache {
|
|||
public List<Tickable> getTickableEntities() {
|
||||
return tickableEntities;
|
||||
}
|
||||
|
||||
public void removeAllBossBars() {
|
||||
bossBars.values().forEach(BossBar::removeBossBar);
|
||||
bossBars.clear();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,12 +64,17 @@ public class JavaLoginTranslator extends PacketTranslator<ClientboundLoginPacket
|
|||
DimensionUtils.switchDimension(session, fakeDim);
|
||||
|
||||
session.getWorldCache().removeScoreboard();
|
||||
|
||||
// Remove all bossbars
|
||||
session.getEntityCache().removeAllBossBars();
|
||||
// Remove extra hearts, hunger, etc.
|
||||
entity.getAttributes().clear();
|
||||
entity.resetMetadata();
|
||||
}
|
||||
|
||||
session.setWorldName(spawnInfo.getWorldName());
|
||||
session.setLevels(packet.getWorldNames());
|
||||
|
||||
session.setGameMode(spawnInfo.getGameMode());
|
||||
|
||||
String newDimension = spawnInfo.getDimension();
|
||||
|
||||
boolean needsSpawnPacket = !session.isSentSpawnPacket();
|
||||
|
@ -81,9 +86,7 @@ public class JavaLoginTranslator extends PacketTranslator<ClientboundLoginPacket
|
|||
|
||||
// It is now safe to send these packets
|
||||
session.getUpstream().sendPostStartGamePackets();
|
||||
}
|
||||
|
||||
if (!needsSpawnPacket) {
|
||||
} else {
|
||||
SetPlayerGameTypePacket playerGameTypePacket = new SetPlayerGameTypePacket();
|
||||
playerGameTypePacket.setGamemode(EntityUtils.toBedrockGamemode(spawnInfo.getGameMode()).ordinal());
|
||||
session.sendUpstreamPacket(playerGameTypePacket);
|
||||
|
|
Loading…
Reference in a new issue