fix heightMap bug

This commit is contained in:
Leijurv 2018-08-28 13:58:36 -07:00
parent 557f2e48c3
commit ff83b42132
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A

View File

@ -22,8 +22,6 @@ import baritone.utils.Helper;
import baritone.utils.pathing.PathingBlockType; import baritone.utils.pathing.PathingBlockType;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockAir; import net.minecraft.block.BlockAir;
import net.minecraft.block.BlockDoublePlant;
import net.minecraft.block.BlockTallGrass;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
@ -69,17 +67,17 @@ public final class ChunkPacker implements Helper {
//System.out.println("Chunk packing took " + (end - start) + "ms for " + chunk.x + "," + chunk.z); //System.out.println("Chunk packing took " + (end - start) + "ms for " + chunk.x + "," + chunk.z);
String[] blockNames = new String[256]; String[] blockNames = new String[256];
for (int z = 0; z < 16; z++) { for (int z = 0; z < 16; z++) {
outerLoop:
for (int x = 0; x < 16; x++) { for (int x = 0; x < 16; x++) {
int height = chunk.getHeightValue(x, z); for (int y = 255; y >= 0; y--) {
IBlockState blockState = chunk.getBlockState(x, height, z); int index = CachedChunk.getPositionIndex(x, y, z);
for (int y = height; y > 0; y--) { if (!bitSet.get(index) && !bitSet.get(index + 1)) {
blockState = chunk.getBlockState(x, y, z); String name = blockToString(chunk.getBlockState(x, y, z).getBlock());
if (getPathingBlockType(blockState.getBlock()) != PathingBlockType.AIR) {
break;
}
}
String name = blockToString(blockState.getBlock());
blockNames[z << 4 | x] = name; blockNames[z << 4 | x] = name;
continue outerLoop;
}
}
blockNames[z << 4 | x] = "air";
} }
} }
CachedChunk cached = new CachedChunk(chunk.x, chunk.z, bitSet, blockNames, specialBlocks); CachedChunk cached = new CachedChunk(chunk.x, chunk.z, bitSet, blockNames, specialBlocks);
@ -116,7 +114,7 @@ public final class ChunkPacker implements Helper {
// however, this failed in the nether when you were near a nether fortress // however, this failed in the nether when you were near a nether fortress
// because fences check their adjacent blocks in the world for their fence connection status to determine AABB shape // because fences check their adjacent blocks in the world for their fence connection status to determine AABB shape
// this caused a nullpointerexception when we saved chunks on unload, because they were unable to check their neighbors // this caused a nullpointerexception when we saved chunks on unload, because they were unable to check their neighbors
if (block instanceof BlockAir || block instanceof BlockTallGrass || block instanceof BlockDoublePlant) { if (block instanceof BlockAir) {
return PathingBlockType.AIR; return PathingBlockType.AIR;
} }