mirror of
https://github.com/Minestom/Minestom.git
synced 2024-11-07 11:20:09 +01:00
Fixed empty chunk when connecting during its generation
This commit is contained in:
parent
da4216a51f
commit
7a1a43279a
@ -17,6 +17,7 @@ import net.minestom.server.network.packet.server.play.ChunkDataPacket;
|
|||||||
import net.minestom.server.network.packet.server.play.UpdateLightPacket;
|
import net.minestom.server.network.packet.server.play.UpdateLightPacket;
|
||||||
import net.minestom.server.network.player.PlayerConnection;
|
import net.minestom.server.network.player.PlayerConnection;
|
||||||
import net.minestom.server.utils.MathUtils;
|
import net.minestom.server.utils.MathUtils;
|
||||||
|
import net.minestom.server.utils.PacketUtils;
|
||||||
import net.minestom.server.utils.Position;
|
import net.minestom.server.utils.Position;
|
||||||
import net.minestom.server.utils.binary.BinaryReader;
|
import net.minestom.server.utils.binary.BinaryReader;
|
||||||
import net.minestom.server.utils.chunk.ChunkCallback;
|
import net.minestom.server.utils.chunk.ChunkCallback;
|
||||||
@ -512,13 +513,7 @@ public abstract class Chunk implements Viewable, DataContainer {
|
|||||||
* Sends a full {@link ChunkDataPacket} to all chunk viewers.
|
* Sends a full {@link ChunkDataPacket} to all chunk viewers.
|
||||||
*/
|
*/
|
||||||
public synchronized void sendChunkUpdate() {
|
public synchronized void sendChunkUpdate() {
|
||||||
final Set<Player> chunkViewers = getViewers();
|
PacketUtils.sendGroupedPacket(getViewers(), getFreshFullDataPacket());
|
||||||
if (!chunkViewers.isEmpty()) {
|
|
||||||
chunkViewers.forEach(player -> {
|
|
||||||
final PlayerConnection playerConnection = player.getPlayerConnection();
|
|
||||||
playerConnection.sendPacket(getFreshFullDataPacket());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -127,12 +127,17 @@ public class ChunkBatch implements InstanceBatch {
|
|||||||
chunkPopulator.populateChunk(this, chunk);
|
chunkPopulator.populateChunk(this, chunk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Refresh chunk for viewers
|
||||||
|
this.chunk.sendChunkUpdate();
|
||||||
|
|
||||||
|
this.instance.refreshLastBlockChangeTime();
|
||||||
|
|
||||||
// Safe callback
|
// Safe callback
|
||||||
instance.scheduleNextTick(inst -> {
|
instance.scheduleNextTick(inst -> {
|
||||||
OptionalCallback.execute(callback, chunk);
|
OptionalCallback.execute(callback, chunk);
|
||||||
});
|
});
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user