consolidate and simplify into MovementHelper.isBottomSlab

This commit is contained in:
Leijurv 2018-09-03 09:50:26 -07:00
parent 7473e34602
commit 4b2f98ccfd
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
5 changed files with 25 additions and 30 deletions

View File

@ -20,7 +20,10 @@ package baritone.chunk;
import baritone.pathing.movement.MovementHelper;
import baritone.utils.Helper;
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;
@ -108,7 +111,7 @@ public final class ChunkPacker implements Helper {
return PathingBlockType.WATER;
}
if (MovementHelper.avoidWalkingInto(block) || block.equals(Blocks.FLOWING_WATER) || (block instanceof BlockSlab && state.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.BOTTOM)) {
if (MovementHelper.avoidWalkingInto(block) || block.equals(Blocks.FLOWING_WATER) || MovementHelper.isBottomSlab(state)) {
return PathingBlockType.AVOID;
}
// We used to do an AABB check here

View File

@ -270,6 +270,16 @@ public interface MovementHelper extends ActionCosts, Helper {
return 0; // we won't actually mine it, so don't check fallings above
}
static boolean isBottomSlab(IBlockState state) {
return state.getBlock() instanceof BlockSlab
&& !((BlockSlab) state.getBlock()).isDouble()
&& state.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.BOTTOM;
}
static boolean isBottomSlab(BlockPos pos) {
return isBottomSlab(BlockStateInterface.get(pos));
}
/**
* The entity the player is currently looking at
*

View File

@ -28,7 +28,6 @@ import baritone.utils.InputOverrideHandler;
import baritone.utils.Utils;
import net.minecraft.block.Block;
import net.minecraft.block.BlockFalling;
import net.minecraft.block.BlockSlab;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.init.Blocks;
@ -59,25 +58,12 @@ public class MovementAscend extends Movement {
return COST_INF;
}
// we can jump from soul sand, but not from a bottom slab
// the only thing we can ascend onto from a bottom slab is another bottom slab
boolean jumpingFromBottomSlab = false;
if (srcDown.getBlock() instanceof BlockSlab) {
BlockSlab jumpingFrom = (BlockSlab) srcDown.getBlock();
if (!jumpingFrom.isDouble()) {
jumpingFromBottomSlab = srcDown.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.BOTTOM;
}
}
boolean jumpingFromBottomSlab = MovementHelper.isBottomSlab(srcDown);
IBlockState toPlace = BlockStateInterface.get(positionToPlace);
boolean jumpingToBottomSlab = false;
if (toPlace.getBlock() instanceof BlockSlab) {
BlockSlab jumpingTo = (BlockSlab) toPlace.getBlock();
if (!jumpingTo.isDouble() && toPlace.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.BOTTOM) {
jumpingToBottomSlab = true;
} else if (jumpingFromBottomSlab) {
return COST_INF;
}
} else if (jumpingFromBottomSlab) {
return COST_INF;
boolean jumpingToBottomSlab = MovementHelper.isBottomSlab(toPlace);
if (jumpingFromBottomSlab && !jumpingToBottomSlab) {
return COST_INF;// the only thing we can ascend onto from a bottom slab is another bottom slab
}
if (!MovementHelper.canWalkOn(positionToPlace, toPlace)) {
if (!context.hasThrowaway()) {
@ -189,9 +175,8 @@ public class MovementAscend extends Movement {
return state.setStatus(MovementStatus.UNREACHABLE);
}
MovementHelper.moveTowards(state, dest);
if (jumpingOnto.getBlock() instanceof BlockSlab && !((BlockSlab) jumpingOnto.getBlock()).isDouble() && jumpingOnto.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.BOTTOM) {
IBlockState from = BlockStateInterface.get(src.down());
if (!(from.getBlock() instanceof BlockSlab) || ((BlockSlab) from.getBlock()).isDouble() || from.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.TOP) {
if (MovementHelper.isBottomSlab(jumpingOnto)) {
if (!MovementHelper.isBottomSlab(src.down())) {
return state; // don't jump while walking from a non double slab into a bottom slab
}
}

View File

@ -27,7 +27,6 @@ import baritone.pathing.movement.MovementState.MovementTarget;
import baritone.utils.*;
import net.minecraft.block.Block;
import net.minecraft.block.BlockFalling;
import net.minecraft.block.BlockSlab;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
@ -55,10 +54,8 @@ public class MovementFall extends Movement {
if (!MovementHelper.canWalkOn(dest.down(), fallOnto)) {
return COST_INF;
}
if (fallOnto.getBlock() instanceof BlockSlab) {
if (!((BlockSlab) fallOnto.getBlock()).isDouble() && fallOnto.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.BOTTOM) {
return COST_INF; // falling onto a half slab is really glitchy, and can cause more fall damage than we'd expect
}
if (MovementHelper.isBottomSlab(fallOnto)) {
return COST_INF; // falling onto a half slab is really glitchy, and can cause more fall damage than we'd expect
}
double placeBucketCost = 0.0;
if (!BlockStateInterface.isWater(dest) && src.getY() - dest.getY() > context.maxFallHeightNoWater()) {

View File

@ -150,7 +150,7 @@ public class MovementPillar extends Movement {
if (playerFeet().equals(against.up()) || playerFeet().equals(dest)) {
return state.setStatus(MovementState.MovementStatus.SUCCESS);
}
if (fromDown.getBlock() instanceof BlockSlab && !((BlockSlab) fromDown.getBlock()).isDouble() && fromDown.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.BOTTOM) {
if (MovementHelper.isBottomSlab(src.down())) {
state.setInput(InputOverrideHandler.Input.JUMP, true);
}
/*