diff --git a/src/main/java/net/minestom/server/entity/Player.java b/src/main/java/net/minestom/server/entity/Player.java index 5149b5e91..33f4fe1d6 100644 --- a/src/main/java/net/minestom/server/entity/Player.java +++ b/src/main/java/net/minestom/server/entity/Player.java @@ -489,6 +489,7 @@ public class Player extends LivingEntity implements CommandSender, Localizable, * Sends necessary packets to synchronize player data after a {@link RespawnPacket} */ private void refreshClientStateAfterRespawn() { + sendPacket(new ServerDifficultyPacket(MinecraftServer.getDifficulty(), false)); sendPacket(new UpdateHealthPacket(this.getHealth(), food, foodSaturation)); sendPacket(new SetExperiencePacket(exp, level, 0)); triggerStatus((byte) (24 + permissionLevel)); // Set permission level @@ -653,7 +654,7 @@ public class Player extends LivingEntity implements CommandSender, Localizable, */ private void spawnPlayer(@NotNull Instance instance, @NotNull Pos spawnPosition, boolean firstSpawn, boolean dimensionChange, boolean updateChunks) { - if (!firstSpawn) { + if (!firstSpawn && !dimensionChange) { // Player instance changed, clear current viewable collections if (updateChunks) ChunkUtils.forChunksInRange(spawnPosition, MinecraftServer.getChunkViewDistance(), chunkRemover); @@ -674,8 +675,15 @@ public class Player extends LivingEntity implements CommandSender, Localizable, synchronizePosition(true); // So the player doesn't get stuck + if (dimensionChange) { + sendPacket(new SpawnPositionPacket(spawnPosition, 0)); // Without this the client gets stuck on loading terrain for a while + instance.getWorldBorder().init(this); + sendPacket(new TimeUpdatePacket(instance.getWorldAge(), instance.getTime())); + } + if (dimensionChange || firstSpawn) { this.inventory.update(); + sendPacket(new HeldItemChangePacket(heldSlot)); } EventDispatcher.call(new PlayerSpawnEvent(this, instance, firstSpawn));