Empty player list on transition, despawn skulls

This commit is contained in:
valaphee 2024-07-12 05:22:46 +02:00
parent 2a6025f3fc
commit e391a67e38
No known key found for this signature in database
GPG key ID: 0F2ECD7ABFC35745
2 changed files with 21 additions and 2 deletions

View file

@ -87,6 +87,7 @@ import org.geysermc.geyser.entity.attribute.GeyserAttributeType;
import org.geysermc.geyser.entity.type.Entity;
import org.geysermc.geyser.entity.type.ItemFrameEntity;
import org.geysermc.geyser.entity.type.Tickable;
import org.geysermc.geyser.entity.type.player.PlayerEntity;
import org.geysermc.geyser.entity.type.player.SessionPlayerEntity;
import org.geysermc.geyser.erosion.AbstractGeyserboundPacketHandler;
import org.geysermc.geyser.erosion.GeyserboundHandshakePacketHandler;
@ -887,8 +888,18 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
public void packetReceived(Session session, Packet packet) {
if (protocol.getState() == ProtocolState.CONFIGURATION) {
if (packet instanceof ClientboundFinishConfigurationPacket) {
// Prevent
GeyserSession.this.ensureInEventLoop(() -> GeyserSession.this.sendDownstreamPacket(new ServerboundFinishConfigurationPacket()));
GeyserSession.this.ensureInEventLoop(() -> {
// Clear the player list, as on Java the player list is cleared after transitioning from config to play phase
PlayerListPacket playerListPacket = new PlayerListPacket();
playerListPacket.setAction(PlayerListPacket.Action.REMOVE);
for (PlayerEntity otherEntity : GeyserSession.this.getEntityCache().getAllPlayerEntities()) {
playerListPacket.getEntries().add(new PlayerListPacket.Entry(otherEntity.getTabListUuid()));
GeyserSession.this.getEntityCache().removePlayerEntity(otherEntity.getUuid());
}
GeyserSession.this.sendUpstreamPacket(playerListPacket);
GeyserSession.this.sendDownstreamPacket(new ServerboundFinishConfigurationPacket());
});
return;
}
}

View file

@ -243,8 +243,16 @@ public class SkullCache {
}
public void clear() {
for (Skull skull : skulls.values()) {
if (skull.entity != null) {
skull.entity.despawnEntity();
}
}
skulls.clear();
inRangeSkulls.clear();
for (SkullPlayerEntity skull : unusedSkullEntities) {
skull.despawnEntity();
}
unusedSkullEntities.clear();
totalSkullEntities = 0;
lastPlayerPosition = null;