fix: correct index for world view
Fixes
@@ -208,8 +208,7 @@ private ChunkViewCore createWorldView(BlockRegion region, Vector3i offset) {
Chunk[] chunks = new Chunk[region.getSizeX() * region.getSizeY() * region.getSizeZ()];
for (Vector3ic chunkPos : region) {
Chunk chunk = chunkCache.get(chunkPos);
- chunkPos.sub(region.minX(), region.minY(), region.minZ(), new Vector3i());
- int index = chunkPos.x() + region.getSizeX() * (chunkPos.z() + region.getSizeZ() * (chunkPos.y()));
+ int index = (chunkPos.x() - region.minX()) + region.getSizeX() * ((chunkPos.z() - region.minZ()) + region.getSizeZ() * (chunkPos.y() - region.minY()));
chunks[index] = chunk;
}
return new ChunkViewCoreImpl(chunks, region, offset, blockManager.getBlock(BlockManager.AIR_ID));
