mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-08 01:17:47 +01:00
Fix slow dimension changes (#1892)
* only send spawn point on dimension change
This commit is contained in:
parent
954e8b3915
commit
824ae0a25b
@ -489,6 +489,7 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
|
|||||||
* Sends necessary packets to synchronize player data after a {@link RespawnPacket}
|
* Sends necessary packets to synchronize player data after a {@link RespawnPacket}
|
||||||
*/
|
*/
|
||||||
private void refreshClientStateAfterRespawn() {
|
private void refreshClientStateAfterRespawn() {
|
||||||
|
sendPacket(new ServerDifficultyPacket(MinecraftServer.getDifficulty(), false));
|
||||||
sendPacket(new UpdateHealthPacket(this.getHealth(), food, foodSaturation));
|
sendPacket(new UpdateHealthPacket(this.getHealth(), food, foodSaturation));
|
||||||
sendPacket(new SetExperiencePacket(exp, level, 0));
|
sendPacket(new SetExperiencePacket(exp, level, 0));
|
||||||
triggerStatus((byte) (24 + permissionLevel)); // Set permission level
|
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,
|
private void spawnPlayer(@NotNull Instance instance, @NotNull Pos spawnPosition,
|
||||||
boolean firstSpawn, boolean dimensionChange, boolean updateChunks) {
|
boolean firstSpawn, boolean dimensionChange, boolean updateChunks) {
|
||||||
if (!firstSpawn) {
|
if (!firstSpawn && !dimensionChange) {
|
||||||
// Player instance changed, clear current viewable collections
|
// Player instance changed, clear current viewable collections
|
||||||
if (updateChunks)
|
if (updateChunks)
|
||||||
ChunkUtils.forChunksInRange(spawnPosition, MinecraftServer.getChunkViewDistance(), chunkRemover);
|
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
|
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) {
|
if (dimensionChange || firstSpawn) {
|
||||||
this.inventory.update();
|
this.inventory.update();
|
||||||
|
sendPacket(new HeldItemChangePacket(heldSlot));
|
||||||
}
|
}
|
||||||
|
|
||||||
EventDispatcher.call(new PlayerSpawnEvent(this, instance, firstSpawn));
|
EventDispatcher.call(new PlayerSpawnEvent(this, instance, firstSpawn));
|
||||||
|
Loading…
Reference in New Issue
Block a user