diff --git a/src/main/java/baritone/map/Map.java b/src/main/java/baritone/map/Map.java index 403b5ded1..e362dcf45 100644 --- a/src/main/java/baritone/map/Map.java +++ b/src/main/java/baritone/map/Map.java @@ -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); } diff --git a/src/main/java/baritone/map/MapChunk.java b/src/main/java/baritone/map/MapChunk.java index 0126ddcda..4f8ad3c07 100644 --- a/src/main/java/baritone/map/MapChunk.java +++ b/src/main/java/baritone/map/MapChunk.java @@ -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();