diff --git a/src/main/java/baritone/cache/CachedChunk.java b/src/main/java/baritone/cache/CachedChunk.java index fbdd42f7b..f9a7d96b8 100644 --- a/src/main/java/baritone/cache/CachedChunk.java +++ b/src/main/java/baritone/cache/CachedChunk.java @@ -99,13 +99,13 @@ public final class CachedChunk implements IBlockTypeAccess { /** * The block names of each surface level block for generating an overview */ - private final String[] overview; + private final IBlockState[] overview; private final int[] heightMap; private final Map> specialBlockLocations; - CachedChunk(int x, int z, BitSet data, String[] overview, Map> specialBlockLocations) { + CachedChunk(int x, int z, BitSet data, IBlockState[] overview, Map> specialBlockLocations) { validateSize(data); this.x = x; @@ -122,12 +122,11 @@ public final class CachedChunk implements IBlockTypeAccess { int internalPos = z << 4 | x; if (heightMap[internalPos] == y) { // we have this exact block, it's a surface block - IBlockState state = ChunkPacker.stringToBlock(overview[internalPos]).getDefaultState(); /*System.out.println("Saying that " + x + "," + y + "," + z + " is " + state); if (!Minecraft.getMinecraft().world.getBlockState(new BlockPos(x + this.x * 16, y, z + this.z * 16)).getBlock().equals(state.getBlock())) { throw new IllegalStateException("failed " + Minecraft.getMinecraft().world.getBlockState(new BlockPos(x + this.x * 16, y, z + this.z * 16)).getBlock() + " " + state.getBlock() + " " + (x + this.x * 16) + " " + y + " " + (z + this.z * 16)); }*/ - return state; + return overview[internalPos]; } PathingBlockType type = getType(x, y, z); if (type == PathingBlockType.SOLID && y == 127 && mc.player.dimension == -1) { @@ -157,7 +156,7 @@ public final class CachedChunk implements IBlockTypeAccess { } } - public final String[] getOverview() { + public final IBlockState[] getOverview() { return overview; } diff --git a/src/main/java/baritone/cache/CachedRegion.java b/src/main/java/baritone/cache/CachedRegion.java index f036f264f..7409ff38e 100644 --- a/src/main/java/baritone/cache/CachedRegion.java +++ b/src/main/java/baritone/cache/CachedRegion.java @@ -145,7 +145,7 @@ public final class CachedRegion implements IBlockTypeAccess { for (int x = 0; x < 32; x++) { if (chunks[x][z] != null) { for (int i = 0; i < 256; i++) { - out.writeUTF(chunks[x][z].getOverview()[i]); + out.writeUTF(ChunkPacker.blockToString(chunks[x][z].getOverview()[i].getBlock())); } } } @@ -215,7 +215,7 @@ public final class CachedRegion implements IBlockTypeAccess { int regionZ = this.z; int chunkX = x + 32 * regionX; int chunkZ = z + 32 * regionZ; - tmpCached[x][z] = new CachedChunk(chunkX, chunkZ, BitSet.valueOf(bytes), new String[256], location[x][z]); + tmpCached[x][z] = new CachedChunk(chunkX, chunkZ, BitSet.valueOf(bytes), new IBlockState[256], location[x][z]); break; case CHUNK_NOT_PRESENT: tmpCached[x][z] = null; @@ -229,7 +229,7 @@ public final class CachedRegion implements IBlockTypeAccess { for (int x = 0; x < 32; x++) { if (tmpCached[x][z] != null) { for (int i = 0; i < 256; i++) { - tmpCached[x][z].getOverview()[i] = in.readUTF(); + tmpCached[x][z].getOverview()[i] = ChunkPacker.stringToBlock(in.readUTF()).getDefaultState(); } } } diff --git a/src/main/java/baritone/cache/ChunkPacker.java b/src/main/java/baritone/cache/ChunkPacker.java index 59a56f0ee..4164be3ca 100644 --- a/src/main/java/baritone/cache/ChunkPacker.java +++ b/src/main/java/baritone/cache/ChunkPacker.java @@ -89,7 +89,8 @@ public final class ChunkPacker implements Helper { } //long end = System.nanoTime() / 1000000L; //System.out.println("Chunk packing took " + (end - start) + "ms for " + chunk.x + "," + chunk.z); - String[] blockNames = new String[256]; + IBlockState[] blocks = new IBlockState[256]; + for (int z = 0; z < 16; z++) { // @formatter:off https://www.ibm.com/developerworks/library/j-perry-writing-good-java-code/index.html @@ -98,15 +99,14 @@ public final class ChunkPacker implements Helper { for (int y = 255; y >= 0; y--) { int index = CachedChunk.getPositionIndex(x, y, z); if (bitSet.get(index) || bitSet.get(index + 1)) { - String name = blockToString(chunk.getBlockState(x, y, z).getBlock()); - blockNames[z << 4 | x] = name; + blocks[z << 4 | x] = chunk.getBlockState(x, y, z); continue https; } } - blockNames[z << 4 | x] = "air"; + blocks[z << 4 | x] = Blocks.AIR.getDefaultState(); } } - return new CachedChunk(chunk.x, chunk.z, bitSet, blockNames, specialBlocks); + return new CachedChunk(chunk.x, chunk.z, bitSet, blocks, specialBlocks); } public static String blockToString(Block block) {