mirror of
https://github.com/Minestom/Minestom.git
synced 2024-09-04 18:51:16 +02: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.player.PlayerConnection;
|
||||
import net.minestom.server.utils.MathUtils;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import net.minestom.server.utils.Position;
|
||||
import net.minestom.server.utils.binary.BinaryReader;
|
||||
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.
|
||||
*/
|
||||
public synchronized void sendChunkUpdate() {
|
||||
final Set<Player> chunkViewers = getViewers();
|
||||
if (!chunkViewers.isEmpty()) {
|
||||
chunkViewers.forEach(player -> {
|
||||
final PlayerConnection playerConnection = player.getPlayerConnection();
|
||||
playerConnection.sendPacket(getFreshFullDataPacket());
|
||||
});
|
||||
}
|
||||
PacketUtils.sendGroupedPacket(getViewers(), getFreshFullDataPacket());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -127,12 +127,17 @@ public class ChunkBatch implements InstanceBatch {
|
|||
chunkPopulator.populateChunk(this, chunk);
|
||||
}
|
||||
}
|
||||
|
||||
// Safe callback
|
||||
instance.scheduleNextTick(inst -> {
|
||||
OptionalCallback.execute(callback, chunk);
|
||||
});
|
||||
}
|
||||
|
||||
// Refresh chunk for viewers
|
||||
this.chunk.sendChunkUpdate();
|
||||
|
||||
this.instance.refreshLastBlockChangeTime();
|
||||
|
||||
// Safe callback
|
||||
instance.scheduleNextTick(inst -> {
|
||||
OptionalCallback.execute(callback, chunk);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user