Fix chunk stitch ordering, fix north border lines

This commit is contained in:
Howard Stark
2018-08-21 12:45:41 -07:00
parent 3abacb3b65
commit c89324be5b
2 changed files with 14 additions and 12 deletions

View File

@@ -27,19 +27,16 @@ public class Map extends Behavior {
return;
MapChunk map = new MapChunk(world().getChunk(event.getX(), event.getZ()));
ChunkPos pos = map.getChunk().getPos();
int startX;
int startZ;
if(pos.x == 0 && pos.z == 0) {
startX = (fullImage.getWidth() / 2) - 9;
startZ = (fullImage.getHeight() / 2) - 9;
} else {
int widthOffset = (((fullImage.getWidth() / 2) - 1) + (int) Math.signum(pos.x) * -8);
int heightOffset = (((fullImage.getHeight() / 2) - 1) + (int) Math.signum(pos.z) * -8);
startX = widthOffset + (16 * (pos.x + (pos.x > 0 ? -1 : 0)));
startZ = heightOffset + (16 * (pos.z + (pos.z > 0 ? -1 : 0)));
stitchMapChunk(map);
if(world().getChunkProvider().isChunkGeneratedAt(event.getX(), event.getZ() - 1)) {
stitchMapChunk(new MapChunk(world().getChunk(event.getX(), event.getZ() - 1)));
}
}
private void stitchMapChunk(MapChunk map) {
ChunkPos pos = map.getChunk().getPos();
int startX = pos.x * 16 + (fullImage.getWidth() / 2) - 8;
int startZ = pos.z * 16 + (fullImage.getHeight() / 2) - 8;
Graphics graphics = fullImage.getGraphics();
graphics.drawImage(map.generateOverview(), startX, startZ, null);
}

View File

@@ -90,7 +90,12 @@ public class MapChunk {
// Now we get the proper block for the position one to the north.
BlockPos offset = blockPos.offset(EnumFacing.NORTH);
offset = new BlockPos(offset.getX(), chunk.getHeight(offset), offset.getZ());
// If we are at the north border of the chunk, we need to get the next chunk
// to the north to ensure that we shade properly.
offset = chunk.getWorld().getChunk(offset).isLoaded() ? offset : offset.south();
// We adjust the height of the offset to the proper height value if the shading chunk is
// loaded, or the same as our target block if the shading chunk is not.
offset = new BlockPos(offset.getX(), chunk.getWorld().getChunk(offset).getHeight(offset), offset.getZ());
// And once again, check to make sure we have an actual colored block an not "air"
if(BlockStateInterface.get(offset).getMapColor(chunk.getWorld(), offset) == MapColor.AIR)
offset = offset.down();