(int x, int y, int z, DimensionType dimension)
| 193 | } |
| 194 | |
| 195 | public final BlockState getBlock(int x, int y, int z, DimensionType dimension) { |
| 196 | int index = getPositionIndex(x, y, z); |
| 197 | PathingBlockType type = getType(index); |
| 198 | int internalPos = z << 4 | x; |
| 199 | if (heightMap[internalPos] == y && type != PathingBlockType.AVOID) { |
| 200 | // if the top block in a column is water, we cache it as AVOID but we don't want to just return default state water (which is not flowing) beacuse then it would try to path through it |
| 201 | |
| 202 | // we have this exact block, it's a surface block |
| 203 | /*System.out.println("Saying that " + x + "," + y + "," + z + " is " + state); |
| 204 | if (!Minecraft.getInstance().world.getBlockState(new BlockPos(x + this.x * 16, y, z + this.z * 16)).getBlock().equals(state.getBlock())) { |
| 205 | throw new IllegalStateException("failed " + Minecraft.getInstance().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)); |
| 206 | }*/ |
| 207 | return overview[internalPos]; |
| 208 | } |
| 209 | if (special != null) { |
| 210 | String str = special.get(index); |
| 211 | if (str != null) { |
| 212 | return BlockUtils.stringToBlockRequired(str).defaultBlockState(); |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | if (type == PathingBlockType.SOLID) { |
| 217 | if (y == dimension.logicalHeight() - 1 && dimension.hasCeiling()) { |
| 218 | // nether roof is always unbreakable |
| 219 | return Blocks.BEDROCK.defaultBlockState(); |
| 220 | } |
| 221 | if (y < -59 && dimension.natural()) { |
| 222 | // solid blocks below 5 are commonly bedrock |
| 223 | // however, returning bedrock always would be a little yikes |
| 224 | // discourage paths that include breaking blocks below 5 a little more heavily just so that it takes paths breaking what's known to be stone (at 5 or above) instead of what could maybe be bedrock (below 5) |
| 225 | return Blocks.OBSIDIAN.defaultBlockState(); |
| 226 | } |
| 227 | } |
| 228 | return ChunkPacker.pathingTypeToBlock(type, dimension); |
| 229 | } |
| 230 | |
| 231 | private PathingBlockType getType(int index) { |
| 232 | return PathingBlockType.fromBits(data.get(index), data.get(index + 1)); |
no test coverage detected