добавление механизма выгрузки чанков, а так же поправлен механизм их загрузки
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user