уточнение алгоритма сериализации чанков (ChunkDataPacket)
This commit is contained in:
@@ -13,7 +13,8 @@ import mc.core.events.SC_ChunkLoadEvent;
|
||||
import mc.core.player.PlayerManager;
|
||||
import mc.core.time.TimeProcessor;
|
||||
import mc.core.utils.CompactedCoords;
|
||||
import mc.core.world.chunk.ChunkSection;
|
||||
import mc.core.world.World;
|
||||
import mc.core.world.chunk.Chunk;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@Slf4j
|
||||
@@ -49,27 +50,28 @@ public class GameLoop extends Thread {
|
||||
log.trace("(GameLoop) playerMoveEventHandler()");
|
||||
event.getPlayer().getLocation().setXYZ(event.getNewLocation());
|
||||
|
||||
ChunkSection chunkSection = event.getNewLocation().getChunkSection();
|
||||
int ncX = chunkSection.getX();
|
||||
int ncZ = chunkSection.getZ();
|
||||
chunkSection = event.getPlayer().getLocation().getChunkSection();
|
||||
int ccX = chunkSection.getX();
|
||||
int ccZ = chunkSection.getZ();
|
||||
Chunk chunk = event.getNewLocation().getChunk(); // Next chunk
|
||||
int ncX = chunk.getX();
|
||||
int ncZ = chunk.getZ();
|
||||
chunk = event.getPlayer().getLocation().getChunk(); // Current chunk
|
||||
int ccX = chunk.getX();
|
||||
int ccZ = chunk.getZ();
|
||||
|
||||
if (event.isRecalcChunk() || (ncX != ccX && ncZ != ccZ)) {
|
||||
/* FIXME заменить "8" на актуальный view distance */
|
||||
final int viewDistance = 8;
|
||||
int cMinX = chunkSection.getX() - viewDistance;
|
||||
int cMaxX = chunkSection.getX() + viewDistance;
|
||||
int cMinZ = chunkSection.getZ() - viewDistance;
|
||||
int cMaxZ = chunkSection.getZ() + viewDistance;
|
||||
final int viewDistance = event.getPlayer().getSettings().getViewDistance();
|
||||
int cMinX = chunk.getX() - viewDistance;
|
||||
int cMaxX = chunk.getX() + viewDistance;
|
||||
int cMinZ = chunk.getZ() - viewDistance;
|
||||
int cMaxZ = chunk.getZ() + viewDistance;
|
||||
|
||||
SC_ChunkLoadEvent eventChunkLoad = new SC_ChunkLoadEvent(event.getPlayer());
|
||||
for (int cZ = cMinZ; cZ <= cMaxZ; cZ++) {
|
||||
for (int cX = cMinX; cX <= cMaxX; cX++) {
|
||||
int compressXZ = CompactedCoords.compressXZ(cX, cZ);
|
||||
if (!event.getPlayer().getLoadedChunks().contains(compressXZ)) {
|
||||
eventChunkLoad.getNeedLoadChunks().add(compressXZ);
|
||||
if (!event.getPlayer().getLoadedChunks().contains(compressXZ)) {
|
||||
eventChunkLoad.getNeedLoadChunks().add(compressXZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ import mc.core.player.Player;
|
||||
import mc.core.player.PlayerManager;
|
||||
import mc.core.text.Text;
|
||||
import mc.core.text.Title;
|
||||
import mc.core.world.chunk.Chunk;
|
||||
import mc.core.world.chunk.ChunkSection;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
package mc.core.world.chunk;
|
||||
|
||||
import mc.core.world.Biome;
|
||||
import mc.core.world.World;
|
||||
import mc.core.world.block.Block;
|
||||
|
||||
@@ -22,5 +23,7 @@ public interface ChunkSection {
|
||||
int getAddition(int x, int y, int z);
|
||||
void setAddition(int x, int y, int z, int value);
|
||||
|
||||
Biome getBiome(int localX, int localZ);
|
||||
|
||||
World getWorld();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user