mirror of
https://github.com/Minestom/Minestom.git
synced 2024-11-14 14:45:49 +01:00
Fix 2 entity loading issues
This commit is contained in:
parent
788bb71587
commit
0360fd3f79
@ -546,24 +546,32 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
|
||||
if (!firstSpawn) {
|
||||
// Player instance changed, clear current viewable collections
|
||||
previousChunks.forEach(chunk -> chunk.removeViewer(this));
|
||||
|
||||
//TODO: entity#removeViewer sends a packet for each removed entity
|
||||
//Sending destroy entity packets is not necessary when the dimension changes
|
||||
//and, potentially, this could also be rewritten to send only a single DestroyEntitiesPacket
|
||||
//with the list of all destroyed entities
|
||||
this.viewableEntities.forEach(entity -> entity.removeViewer(this));
|
||||
}
|
||||
|
||||
super.setInstance(instance, spawnPosition);
|
||||
|
||||
if (dimensionChange) {
|
||||
sendDimension(instance.getDimensionType());
|
||||
}
|
||||
|
||||
super.setInstance(instance, spawnPosition);
|
||||
|
||||
if (updateChunks) {
|
||||
// Warning: loop to remove once `refreshVisibleChunks` manage it
|
||||
previousChunks.forEach(chunk ->
|
||||
playerConnection.sendPacket(new UnloadChunkPacket(chunk.getChunkX(), chunk.getChunkZ())));
|
||||
if(!dimensionChange) { //The client already forcefully unloads all chunks & entities when the dimension changes
|
||||
previousChunks.forEach(chunk ->
|
||||
playerConnection.sendPacket(new UnloadChunkPacket(chunk.getChunkX(), chunk.getChunkZ())));
|
||||
}
|
||||
refreshVisibleChunks();
|
||||
}
|
||||
|
||||
synchronizePosition(true); // So the player doesn't get stuck
|
||||
|
||||
if (dimensionChange || firstSpawn) {
|
||||
synchronizePosition(true); // So the player doesn't get stuck
|
||||
this.inventory.update();
|
||||
}
|
||||
|
||||
|
@ -134,6 +134,7 @@ public class FakePlayer extends Player implements NavigableEntity {
|
||||
protected boolean addViewer0(@NotNull Player player) {
|
||||
final boolean result = super.addViewer0(player);
|
||||
if (result) {
|
||||
player.getPlayerConnection().sendPacket(getAddPlayerToList());
|
||||
handleTabList(player.getPlayerConnection());
|
||||
}
|
||||
return result;
|
||||
|
Loading…
Reference in New Issue
Block a user