mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-02 14:38:26 +01:00
Merge pull request #461 from Moulberry/master
Fix FakePlayers not being able to re-spawn, fix entities being immediately unloaded after switching dimensions
This commit is contained in:
commit
f307e81f04
@ -546,21 +546,27 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
|
|||||||
if (!firstSpawn) {
|
if (!firstSpawn) {
|
||||||
// Player instance changed, clear current viewable collections
|
// Player instance changed, clear current viewable collections
|
||||||
previousChunks.forEach(chunk -> chunk.removeViewer(this));
|
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));
|
this.viewableEntities.forEach(entity -> entity.removeViewer(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
super.setInstance(instance, spawnPosition);
|
|
||||||
|
|
||||||
if (dimensionChange) {
|
if (dimensionChange) {
|
||||||
sendDimension(instance.getDimensionType());
|
sendDimension(instance.getDimensionType());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
super.setInstance(instance, spawnPosition);
|
||||||
|
|
||||||
if (updateChunks) {
|
if (updateChunks) {
|
||||||
refreshVisibleChunks();
|
refreshVisibleChunks();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
synchronizePosition(true); // So the player doesn't get stuck
|
||||||
|
|
||||||
if (dimensionChange || firstSpawn) {
|
if (dimensionChange || firstSpawn) {
|
||||||
synchronizePosition(true); // So the player doesn't get stuck
|
|
||||||
this.inventory.update();
|
this.inventory.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,6 +134,7 @@ public class FakePlayer extends Player implements NavigableEntity {
|
|||||||
protected boolean addViewer0(@NotNull Player player) {
|
protected boolean addViewer0(@NotNull Player player) {
|
||||||
final boolean result = super.addViewer0(player);
|
final boolean result = super.addViewer0(player);
|
||||||
if (result) {
|
if (result) {
|
||||||
|
player.getPlayerConnection().sendPacket(getAddPlayerToList());
|
||||||
handleTabList(player.getPlayerConnection());
|
handleTabList(player.getPlayerConnection());
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
Loading…
Reference in New Issue
Block a user