From d79fbea4336dd56ecc018b3b5492ec9f1869c230 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 13 Mar 2019 18:08:15 -0700 Subject: [PATCH] scuffed air --- src/main/java/baritone/cache/ChunkPacker.java | 7 +++++-- .../java/baritone/pathing/movement/Movement.java | 3 +-- .../baritone/pathing/movement/MovementHelper.java | 12 ++++++++---- src/main/java/baritone/process/MineProcess.java | 5 ++--- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/main/java/baritone/cache/ChunkPacker.java b/src/main/java/baritone/cache/ChunkPacker.java index 117b88cd..31d1fcec 100644 --- a/src/main/java/baritone/cache/ChunkPacker.java +++ b/src/main/java/baritone/cache/ChunkPacker.java @@ -19,7 +19,10 @@ package baritone.cache; import baritone.pathing.movement.MovementHelper; import baritone.utils.pathing.PathingBlockType; -import net.minecraft.block.*; +import net.minecraft.block.Block; +import net.minecraft.block.BlockDoublePlant; +import net.minecraft.block.BlockFlower; +import net.minecraft.block.BlockTallGrass; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.util.ResourceLocation; @@ -149,7 +152,7 @@ public final class ChunkPacker { // 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 // this caused a nullpointerexception when we saved chunks on unload, because they were unable to check their neighbors - if (block == Blocks.AIR || block instanceof BlockTallGrass || block instanceof BlockDoublePlant || block instanceof BlockFlower) { + if (MovementHelper.isAir(block) || block instanceof BlockTallGrass || block instanceof BlockDoublePlant || block instanceof BlockFlower) { return PathingBlockType.AIR; } diff --git a/src/main/java/baritone/pathing/movement/Movement.java b/src/main/java/baritone/pathing/movement/Movement.java index 6eec9285..4fa1dc16 100644 --- a/src/main/java/baritone/pathing/movement/Movement.java +++ b/src/main/java/baritone/pathing/movement/Movement.java @@ -23,7 +23,6 @@ import baritone.api.pathing.movement.MovementStatus; import baritone.api.utils.*; import baritone.api.utils.input.Input; import baritone.utils.BlockStateInterface; -import net.minecraft.init.Blocks; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; @@ -143,7 +142,7 @@ public abstract class Movement implements IMovement, MovementHelper { } boolean somethingInTheWay = false; for (BetterBlockPos blockPos : positionsToBreak) { - if (!MovementHelper.canWalkThrough(ctx, blockPos) && BlockStateInterface.getBlock(ctx, blockPos) != Blocks.AIR) { // can't break air, so don't try + if (!MovementHelper.canWalkThrough(ctx, blockPos)) { // can't break air, so don't try somethingInTheWay = true; Optional reachable = RotationUtils.reachable(ctx.player(), blockPos, ctx.playerController().getBlockReachDistance()); if (reachable.isPresent()) { diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 7a49bb05..f276b458 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -80,7 +80,7 @@ public interface MovementHelper extends ActionCosts, Helper { static boolean canWalkThrough(BlockStateInterface bsi, int x, int y, int z, IBlockState state) { Block block = state.getBlock(); - if (block == Blocks.AIR) { // early return for most common case + if (isAir(block)) { // early return for most common case return true; } if (block == Blocks.FIRE || block == Blocks.TRIPWIRE || block == Blocks.COBWEB || block == Blocks.END_PORTAL || block == Blocks.COCOA || block instanceof BlockSkull || block == Blocks.BUBBLE_COLUMN || block instanceof BlockShulkerBox || block instanceof BlockSlab) { @@ -153,7 +153,7 @@ public interface MovementHelper extends ActionCosts, Helper { static boolean fullyPassable(IBlockState state) { Block block = state.getBlock(); - if (block == Blocks.AIR) { // early return for most common case + if (isAir(block)) { // early return for most common case return true; } // exceptions - blocks that are isPassable true, but we can't actually jump through @@ -189,7 +189,7 @@ public interface MovementHelper extends ActionCosts, Helper { * } */ Block block = state.getBlock(); - if (block == Blocks.AIR) { + if (isAir(block)) { // early return for common cases hehe return true; } @@ -277,7 +277,7 @@ public interface MovementHelper extends ActionCosts, Helper { */ static boolean canWalkOn(BlockStateInterface bsi, int x, int y, int z, IBlockState state) { Block block = state.getBlock(); - if (block == Blocks.AIR || block == Blocks.MAGMA_BLOCK || block == Blocks.BUBBLE_COLUMN) { + if (isAir(block) || block == Blocks.MAGMA_BLOCK || block == Blocks.BUBBLE_COLUMN) { // early return for most common case (air) // plus magma, which is a normal cube but it hurts you return false; @@ -386,6 +386,10 @@ public interface MovementHelper extends ActionCosts, Helper { return 0; // we won't actually mine it, so don't check fallings above } + static boolean isAir(Block block) { + return block == Blocks.AIR || block == Blocks.CAVE_AIR || block == Blocks.VOID_AIR; + } + static boolean isBottomSlab(IBlockState state) { return state.getBlock() instanceof BlockSlab && state.get(BlockSlab.TYPE) == SlabType.BOTTOM; diff --git a/src/main/java/baritone/process/MineProcess.java b/src/main/java/baritone/process/MineProcess.java index b9a857d8..c05dcd20 100644 --- a/src/main/java/baritone/process/MineProcess.java +++ b/src/main/java/baritone/process/MineProcess.java @@ -37,7 +37,6 @@ import net.minecraft.entity.item.EntityItem; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.util.IItemProvider; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; @@ -184,8 +183,8 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro } // Here, BlockStateInterface is used because the position may be in a cached chunk (the targeted block is one that is kept track of) - boolean upwardGoal = locs.contains(loc.up()) || (Baritone.settings().internalMiningAirException.value && BlockStateInterface.getBlock(ctx, loc.up()) == Blocks.AIR); - boolean downwardGoal = locs.contains(loc.down()) || (Baritone.settings().internalMiningAirException.value && BlockStateInterface.getBlock(ctx, loc.down()) == Blocks.AIR); + boolean upwardGoal = locs.contains(loc.up()) || (Baritone.settings().internalMiningAirException.value && MovementHelper.isAir(BlockStateInterface.getBlock(ctx, loc.up()))); + boolean downwardGoal = locs.contains(loc.down()) || (Baritone.settings().internalMiningAirException.value && MovementHelper.isAir(BlockStateInterface.getBlock(ctx, loc.down()))); return upwardGoal == downwardGoal ? new GoalTwoBlocks(loc) : upwardGoal ? new GoalBlock(loc) : new GoalBlock(loc.down()); }