scuffed air

This commit is contained in:
Leijurv 2019-03-13 18:08:15 -07:00
parent 4d22c10ddb
commit d79fbea433
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
4 changed files with 16 additions and 11 deletions

View File

@ -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;
}

View File

@ -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<Rotation> reachable = RotationUtils.reachable(ctx.player(), blockPos, ctx.playerController().getBlockReachDistance());
if (reachable.isPresent()) {

View File

@ -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;

View File

@ -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());
}