This commit is contained in:
Nachiketa Gargi 2018-08-14 23:49:08 -07:00
parent c67c9582c4
commit 3d4f516938
2 changed files with 59 additions and 0 deletions

View File

@ -87,9 +87,50 @@ public interface MovementHelper extends ActionCosts, Helper {
if (BlockStateInterface.isFlowing(state) || BlockStateInterface.isLiquid(pos.up())) {
return false; // Don't walk through flowing liquids
}
if (block instanceof BlockDoor) {
return true; // we can just open the door
}
return block.isPassable(mc.world, pos);
}
static boolean isDoorPassable(BlockPos doorPos, BlockPos playerPos) {
IBlockState door = BlockStateInterface.get(doorPos);
if (!(door.getBlock() instanceof BlockDoor)) {
return true;
}
String facing = door.getValue(BlockDoor.FACING).getName();
boolean open = door.getValue(BlockDoor.OPEN).booleanValue();
/**
* yes this is dumb
* change it if you want
*/
String playerFacing = "";
if (playerPos.equals(doorPos)) {
return false;
}
if (playerPos.north().equals(doorPos) || playerPos.south().equals(doorPos)) {
playerFacing = "northsouth";
} else if (playerPos.east().equals(doorPos) || playerPos.west().equals(doorPos)){
playerFacing = "eastwest";
} else {
return true;
}
if (facing == "north" || facing == "south") {
if (open) {
return playerFacing == "northsouth";
} else {
return playerFacing == "eastwest";
}
} else {
if (open) {
return playerFacing == "eastwest";
} else {
return playerFacing == "northsouth";
}
}
}
static boolean avoidWalkingInto(Block block) {
return BlockStateInterface.isLava(block)
|| block instanceof BlockCactus

View File

@ -26,6 +26,7 @@ import baritone.bot.pathing.movement.MovementState;
import baritone.bot.utils.BlockStateInterface;
import baritone.bot.utils.Utils;
import net.minecraft.block.Block;
import net.minecraft.block.BlockDoor;
import net.minecraft.block.BlockLadder;
import net.minecraft.block.BlockVine;
import net.minecraft.block.state.IBlockState;
@ -49,6 +50,7 @@ public class MovementTraverse extends Movement {
public MovementTraverse(BlockPos from, BlockPos to) {
super(from, to, new BlockPos[]{to.up(), to}, new BlockPos[]{to.down()});
int i = 0;
if (!to.north().equals(from))
against[i++] = to.north().down();
@ -130,6 +132,22 @@ public class MovementTraverse extends Movement {
}
Block fd = BlockStateInterface.get(src.down()).getBlock();
boolean ladder = fd instanceof BlockLadder || fd instanceof BlockVine;
IBlockState pb0 = BlockStateInterface.get(positionsToBreak[0]);
IBlockState pb1 = BlockStateInterface.get(positionsToBreak[1]);
boolean door = BlockStateInterface.get(src).getBlock() instanceof BlockDoor || pb0.getBlock() instanceof BlockDoor || pb1.getBlock() instanceof BlockDoor;
if (door) {
boolean isDoorActuallyBlockingUs = false;
Block srcBlock = BlockStateInterface.get(src).getBlock();
if (srcBlock instanceof BlockDoor && !MovementHelper.isDoorPassable(src, dest)) {
isDoorActuallyBlockingUs = true;
} else if (pb1.getBlock() instanceof BlockDoor && !MovementHelper.isDoorPassable(dest, src)) {
isDoorActuallyBlockingUs = true;
}
if (isDoorActuallyBlockingUs) {
state.setInput(InputOverrideHandler.Input.CLICK_RIGHT, true);
return state;
}
}
boolean isTheBridgeBlockThere = MovementHelper.canWalkOn(positionsToPlace[0]) || ladder;
BlockPos whereAmI = playerFeet();
if (whereAmI.getY() != dest.getY() && !ladder) {