Archived
0

добавление механизма выгрузки чанков, а так же поправлен механизм их загрузки

This commit is contained in:
2018-08-17 14:28:45 +03:00
parent f424363399
commit cb3df8f6fb
3 changed files with 61 additions and 9 deletions

View File

@@ -3,10 +3,12 @@ package mc.core.network.proto_1_12_2.netty;
import com.google.common.eventbus.Subscribe;
import lombok.extern.slf4j.Slf4j;
import mc.core.events.SC_ChunkLoadEvent;
import mc.core.events.SC_ChunkUnloadEvent;
import mc.core.events.SC_PlayerMoveEvent;
import mc.core.network.proto_1_12_2.TeleportManager;
import mc.core.network.proto_1_12_2.packets.ChunkDataPacket;
import mc.core.network.proto_1_12_2.packets.PlayerPositionAndLookPacket;
import mc.core.network.proto_1_12_2.packets.UnloadChunkPacket;
import mc.core.utils.CompactedCoords;
import mc.core.world.chunk.Chunk;
import mc.core.world.chunk.ChunkSection;
@@ -26,8 +28,6 @@ class PlayerEventListener {
@Subscribe
public void playerChunkLoadHandler(SC_ChunkLoadEvent event) {
log.debug("(SC) playerChunkLoadHandler()");
for(Integer compressXZ : event.getNeedLoadChunks()) {
int[] xz = CompactedCoords.uncompressXZ(compressXZ);
Chunk chunk = event.getPlayer().getLocation().getWorld().getChunk(xz[0], xz[1]);
@@ -43,4 +43,19 @@ class PlayerEventListener {
event.getPlayer().getChannel().flush();
}
@Subscribe
public void playerChunkUnloadHandler(SC_ChunkUnloadEvent event) {
for(Integer compressXZ : event.getNeedUnloadChunks()) {
int[] xz = CompactedCoords.uncompressXZ(compressXZ);
UnloadChunkPacket packet = new UnloadChunkPacket();
packet.setX(xz[0]);
packet.setZ(xz[1]);
event.getPlayer().getChannel().write(packet);
}
event.getPlayer().getChannel().flush();
}
}