This commit is contained in:
Eoghanmc22 2020-11-20 13:38:41 -05:00
commit 62663ccb64
2 changed files with 8 additions and 9 deletions

View File

@ -57,7 +57,6 @@ public final class EntityManager {
private void waitingPlayersTick() {
Player waitingPlayer;
while ((waitingPlayer = waitingPlayers.poll()) != null) {
waitingPlayer.init();
PlayerLoginEvent loginEvent = new PlayerLoginEvent(waitingPlayer);
waitingPlayer.callEvent(PlayerLoginEvent.class, loginEvent);
@ -65,6 +64,8 @@ public final class EntityManager {
Check.notNull(spawningInstance, "You need to specify a spawning instance in the PlayerLoginEvent");
waitingPlayer.init();
spawningInstance.scheduleNextTick(waitingPlayer::setInstance);
}
}

View File

@ -697,7 +697,7 @@ public class Player extends LivingEntity implements CommandSender {
sendDimension(instanceDimensionType);
}
final long[] visibleChunks = ChunkUtils.getChunksInRange(firstSpawn ? getRespawnPoint() : position, getChunkRange());
final long[] visibleChunks = ChunkUtils.getChunksInRange(position, getChunkRange());
final int length = visibleChunks.length;
AtomicInteger counter = new AtomicInteger(0);
@ -709,8 +709,9 @@ public class Player extends LivingEntity implements CommandSender {
if (chunk != null) {
chunk.addViewer(this);
if (chunk.getChunkX() == ChunkUtils.getChunkCoordinate((int) getPosition().getX()) &&
chunk.getChunkZ() == ChunkUtils.getChunkCoordinate((int) getPosition().getZ()))
chunk.getChunkZ() == ChunkUtils.getChunkCoordinate((int) getPosition().getZ())) {
updateViewPosition(chunk);
}
}
final boolean isLast = counter.get() == length - 1;
if (isLast) {
@ -742,15 +743,12 @@ public class Player extends LivingEntity implements CommandSender {
private void spawnPlayer(Instance instance, boolean firstSpawn) {
this.viewableEntities.forEach(entity -> entity.removeViewer(this));
super.setInstance(instance);
if (firstSpawn) {
this.position = getRespawnPoint();
this.cacheX = position.getX();
this.cacheY = position.getY();
this.cacheZ = position.getZ();
updatePlayerPosition();
teleport(getRespawnPoint());
}
super.setInstance(instance);
PlayerSpawnEvent spawnEvent = new PlayerSpawnEvent(this, instance, firstSpawn);
callEvent(PlayerSpawnEvent.class, spawnEvent);