Awesome
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
package baritone.api.utils;
|
package baritone.api.utils;
|
||||||
|
|
||||||
|
import baritone.api.cache.IWorldData;
|
||||||
import net.minecraft.client.entity.EntityPlayerSP;
|
import net.minecraft.client.entity.EntityPlayerSP;
|
||||||
import net.minecraft.client.multiplayer.PlayerControllerMP;
|
import net.minecraft.client.multiplayer.PlayerControllerMP;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
@@ -34,6 +35,8 @@ public interface IPlayerContext {
|
|||||||
|
|
||||||
World world();
|
World world();
|
||||||
|
|
||||||
|
IWorldData worldData();
|
||||||
|
|
||||||
BetterBlockPos playerFeet();
|
BetterBlockPos playerFeet();
|
||||||
|
|
||||||
default Vec3d playerFeetAsVec() {
|
default Vec3d playerFeetAsVec() {
|
||||||
|
@@ -120,7 +120,7 @@ public final class MemoryBehavior extends Behavior implements IMemoryBehavior, H
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBlockInteract(BlockInteractEvent event) {
|
public void onBlockInteract(BlockInteractEvent event) {
|
||||||
if (event.getType() == BlockInteractEvent.Type.USE && BlockStateInterface.getBlock(event.getPos()) instanceof BlockBed) {
|
if (event.getType() == BlockInteractEvent.Type.USE && BlockStateInterface.getBlock(ctx, event.getPos()) instanceof BlockBed) {
|
||||||
baritone.getWorldProvider().getCurrentWorld().getWaypoints().addWaypoint(new Waypoint("bed", Waypoint.Tag.BED, event.getPos()));
|
baritone.getWorldProvider().getCurrentWorld().getWaypoints().addWaypoint(new Waypoint("bed", Waypoint.Tag.BED, event.getPos()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -339,7 +339,7 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
|
|||||||
*/
|
*/
|
||||||
public BlockPos pathStart() {
|
public BlockPos pathStart() {
|
||||||
BetterBlockPos feet = ctx.playerFeet();
|
BetterBlockPos feet = ctx.playerFeet();
|
||||||
if (!MovementHelper.canWalkOn(feet.down())) {
|
if (!MovementHelper.canWalkOn(ctx, feet.down())) {
|
||||||
if (ctx.player().onGround) {
|
if (ctx.player().onGround) {
|
||||||
double playerX = ctx.player().posX;
|
double playerX = ctx.player().posX;
|
||||||
double playerZ = ctx.player().posZ;
|
double playerZ = ctx.player().posZ;
|
||||||
@@ -358,7 +358,7 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
|
|||||||
// can't possibly be sneaking off of this one, we're too far away
|
// can't possibly be sneaking off of this one, we're too far away
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (MovementHelper.canWalkOn(possibleSupport.down()) && MovementHelper.canWalkThrough(possibleSupport) && MovementHelper.canWalkThrough(possibleSupport.up())) {
|
if (MovementHelper.canWalkOn(ctx, possibleSupport.down()) && MovementHelper.canWalkThrough(ctx, possibleSupport) && MovementHelper.canWalkThrough(ctx, possibleSupport.up())) {
|
||||||
// this is plausible
|
// this is plausible
|
||||||
logDebug("Faking path start assuming player is standing off the edge of a block");
|
logDebug("Faking path start assuming player is standing off the edge of a block");
|
||||||
return possibleSupport;
|
return possibleSupport;
|
||||||
@@ -368,7 +368,7 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
|
|||||||
} else {
|
} else {
|
||||||
// !onGround
|
// !onGround
|
||||||
// we're in the middle of a jump
|
// we're in the middle of a jump
|
||||||
if (MovementHelper.canWalkOn(feet.down().down())) {
|
if (MovementHelper.canWalkOn(ctx, feet.down().down())) {
|
||||||
logDebug("Faking path start assuming player is midair and falling");
|
logDebug("Faking path start assuming player is midair and falling");
|
||||||
return feet.down();
|
return feet.down();
|
||||||
}
|
}
|
||||||
|
@@ -115,7 +115,7 @@ public abstract class Movement implements IMovement, Helper, MovementHelper {
|
|||||||
public MovementStatus update() {
|
public MovementStatus update() {
|
||||||
ctx.player().capabilities.isFlying = false;
|
ctx.player().capabilities.isFlying = false;
|
||||||
currentState = updateState(currentState);
|
currentState = updateState(currentState);
|
||||||
if (MovementHelper.isLiquid(ctx.playerFeet())) {
|
if (MovementHelper.isLiquid(ctx, ctx.playerFeet())) {
|
||||||
currentState.setInput(Input.JUMP, true);
|
currentState.setInput(Input.JUMP, true);
|
||||||
}
|
}
|
||||||
if (ctx.player().isEntityInsideOpaqueBlock()) {
|
if (ctx.player().isEntityInsideOpaqueBlock()) {
|
||||||
@@ -150,11 +150,11 @@ public abstract class Movement implements IMovement, Helper, MovementHelper {
|
|||||||
}
|
}
|
||||||
boolean somethingInTheWay = false;
|
boolean somethingInTheWay = false;
|
||||||
for (BetterBlockPos blockPos : positionsToBreak) {
|
for (BetterBlockPos blockPos : positionsToBreak) {
|
||||||
if (!MovementHelper.canWalkThrough(blockPos) && !(BlockStateInterface.getBlock(blockPos) instanceof BlockLiquid)) { // can't break liquid, so don't try
|
if (!MovementHelper.canWalkThrough(ctx, blockPos) && !(BlockStateInterface.getBlock(ctx, blockPos) instanceof BlockLiquid)) { // can't break liquid, so don't try
|
||||||
somethingInTheWay = true;
|
somethingInTheWay = true;
|
||||||
Optional<Rotation> reachable = RotationUtils.reachable(ctx.player(), blockPos, ctx.playerController().getBlockReachDistance());
|
Optional<Rotation> reachable = RotationUtils.reachable(ctx.player(), blockPos, ctx.playerController().getBlockReachDistance());
|
||||||
if (reachable.isPresent()) {
|
if (reachable.isPresent()) {
|
||||||
MovementHelper.switchToBestToolFor(ctx, BlockStateInterface.get(blockPos));
|
MovementHelper.switchToBestToolFor(ctx, BlockStateInterface.get(ctx, blockPos));
|
||||||
state.setTarget(new MovementState.MovementTarget(reachable.get(), true));
|
state.setTarget(new MovementState.MovementTarget(reachable.get(), true));
|
||||||
if (Objects.equals(RayTraceUtils.getSelectedBlock().orElse(null), blockPos)) {
|
if (Objects.equals(RayTraceUtils.getSelectedBlock().orElse(null), blockPos)) {
|
||||||
state.setInput(Input.CLICK_LEFT, true);
|
state.setInput(Input.CLICK_LEFT, true);
|
||||||
@@ -254,7 +254,7 @@ public abstract class Movement implements IMovement, Helper, MovementHelper {
|
|||||||
}
|
}
|
||||||
List<BlockPos> result = new ArrayList<>();
|
List<BlockPos> result = new ArrayList<>();
|
||||||
for (BetterBlockPos positionToBreak : positionsToBreak) {
|
for (BetterBlockPos positionToBreak : positionsToBreak) {
|
||||||
if (!MovementHelper.canWalkThrough(positionToBreak)) {
|
if (!MovementHelper.canWalkThrough(ctx, positionToBreak)) {
|
||||||
result.add(positionToBreak);
|
result.add(positionToBreak);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -268,7 +268,7 @@ public abstract class Movement implements IMovement, Helper, MovementHelper {
|
|||||||
return toPlaceCached;
|
return toPlaceCached;
|
||||||
}
|
}
|
||||||
List<BlockPos> result = new ArrayList<>();
|
List<BlockPos> result = new ArrayList<>();
|
||||||
if (positionToPlace != null && !MovementHelper.canWalkOn(positionToPlace)) {
|
if (positionToPlace != null && !MovementHelper.canWalkOn(ctx, positionToPlace)) {
|
||||||
result.add(positionToPlace);
|
result.add(positionToPlace);
|
||||||
}
|
}
|
||||||
toPlaceCached = result;
|
toPlaceCached = result;
|
||||||
|
@@ -44,33 +44,27 @@ import net.minecraft.world.chunk.EmptyChunk;
|
|||||||
*/
|
*/
|
||||||
public interface MovementHelper extends ActionCosts, Helper {
|
public interface MovementHelper extends ActionCosts, Helper {
|
||||||
|
|
||||||
static boolean avoidBreaking(CalculationContext context, int x, int y, int z, IBlockState state) {
|
static boolean avoidBreaking(BlockStateInterface bsi, int x, int y, int z, IBlockState state) {
|
||||||
Block b = state.getBlock();
|
Block b = state.getBlock();
|
||||||
return b == Blocks.ICE // ice becomes water, and water can mess up the path
|
return b == Blocks.ICE // ice becomes water, and water can mess up the path
|
||||||
|| b instanceof BlockSilverfish // obvious reasons
|
|| b instanceof BlockSilverfish // obvious reasons
|
||||||
// call context.get directly with x,y,z. no need to make 5 new BlockPos for no reason
|
// call context.get directly with x,y,z. no need to make 5 new BlockPos for no reason
|
||||||
|| context.get(x, y + 1, z).getBlock() instanceof BlockLiquid//don't break anything touching liquid on any side
|
|| bsi.get0(x, y + 1, z).getBlock() instanceof BlockLiquid//don't break anything touching liquid on any side
|
||||||
|| context.get(x + 1, y, z).getBlock() instanceof BlockLiquid
|
|| bsi.get0(x + 1, y, z).getBlock() instanceof BlockLiquid
|
||||||
|| context.get(x - 1, y, z).getBlock() instanceof BlockLiquid
|
|| bsi.get0(x - 1, y, z).getBlock() instanceof BlockLiquid
|
||||||
|| context.get(x, y, z + 1).getBlock() instanceof BlockLiquid
|
|| bsi.get0(x, y, z + 1).getBlock() instanceof BlockLiquid
|
||||||
|| context.get(x, y, z - 1).getBlock() instanceof BlockLiquid;
|
|| bsi.get0(x, y, z - 1).getBlock() instanceof BlockLiquid;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
static boolean canWalkThrough(IPlayerContext ctx, BetterBlockPos pos) {
|
||||||
* Can I walk through this block? e.g. air, saplings, torches, etc
|
return canWalkThrough(new BlockStateInterface(ctx), pos.x, pos.y, pos.z);
|
||||||
*
|
|
||||||
* @param pos
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
static boolean canWalkThrough(BetterBlockPos pos) {
|
|
||||||
return canWalkThrough(new CalculationContext(Baritone.INSTANCE), pos.x, pos.y, pos.z, BlockStateInterface.get(pos));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean canWalkThrough(CalculationContext context, int x, int y, int z) {
|
static boolean canWalkThrough(BlockStateInterface bsi, int x, int y, int z) {
|
||||||
return canWalkThrough(context, x, y, z, context.get(x, y, z));
|
return canWalkThrough(bsi, x, y, z, bsi.get0(x, y, z));
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean canWalkThrough(CalculationContext context, int x, int y, int z, IBlockState state) {
|
static boolean canWalkThrough(BlockStateInterface bsi, int x, int y, int z, IBlockState state) {
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
if (block == Blocks.AIR) { // early return for most common case
|
if (block == Blocks.AIR) { // early return for most common case
|
||||||
return true;
|
return true;
|
||||||
@@ -111,7 +105,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
if (Baritone.settings().assumeWalkOnWater.get()) {
|
if (Baritone.settings().assumeWalkOnWater.get()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
IBlockState up = context.get(x, y + 1, z);
|
IBlockState up = bsi.get0(x, y + 1, z);
|
||||||
if (up.getBlock() instanceof BlockLiquid || up.getBlock() instanceof BlockLilyPad) {
|
if (up.getBlock() instanceof BlockLiquid || up.getBlock() instanceof BlockLilyPad) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -182,12 +176,12 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
return state.getMaterial().isReplaceable();
|
return state.getMaterial().isReplaceable();
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean isDoorPassable(BlockPos doorPos, BlockPos playerPos) {
|
static boolean isDoorPassable(IPlayerContext ctx, BlockPos doorPos, BlockPos playerPos) {
|
||||||
if (playerPos.equals(doorPos)) {
|
if (playerPos.equals(doorPos)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
IBlockState state = BlockStateInterface.get(doorPos);
|
IBlockState state = BlockStateInterface.get(ctx, doorPos);
|
||||||
if (!(state.getBlock() instanceof BlockDoor)) {
|
if (!(state.getBlock() instanceof BlockDoor)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -195,12 +189,12 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
return isHorizontalBlockPassable(doorPos, state, playerPos, BlockDoor.OPEN);
|
return isHorizontalBlockPassable(doorPos, state, playerPos, BlockDoor.OPEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean isGatePassable(BlockPos gatePos, BlockPos playerPos) {
|
static boolean isGatePassable(IPlayerContext ctx, BlockPos gatePos, BlockPos playerPos) {
|
||||||
if (playerPos.equals(gatePos)) {
|
if (playerPos.equals(gatePos)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
IBlockState state = BlockStateInterface.get(gatePos);
|
IBlockState state = BlockStateInterface.get(ctx, gatePos);
|
||||||
if (!(state.getBlock() instanceof BlockFenceGate)) {
|
if (!(state.getBlock() instanceof BlockFenceGate)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -245,7 +239,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
static boolean canWalkOn(CalculationContext context, int x, int y, int z, IBlockState state) {
|
static boolean canWalkOn(BlockStateInterface bsi, int x, int y, int z, IBlockState state) {
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
if (block == Blocks.AIR || block == Blocks.MAGMA) {
|
if (block == Blocks.AIR || block == Blocks.MAGMA) {
|
||||||
// early return for most common case (air)
|
// early return for most common case (air)
|
||||||
@@ -267,7 +261,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
if (isWater(block)) {
|
if (isWater(block)) {
|
||||||
// since this is called literally millions of times per second, the benefit of not allocating millions of useless "pos.up()"
|
// since this is called literally millions of times per second, the benefit of not allocating millions of useless "pos.up()"
|
||||||
// BlockPos s that we'd just garbage collect immediately is actually noticeable. I don't even think its a decrease in readability
|
// BlockPos s that we'd just garbage collect immediately is actually noticeable. I don't even think its a decrease in readability
|
||||||
Block up = context.get(x, y + 1, z).getBlock();
|
Block up = bsi.get0(x, y + 1, z).getBlock();
|
||||||
if (up == Blocks.WATERLILY) {
|
if (up == Blocks.WATERLILY) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -294,24 +288,28 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
return block instanceof BlockStairs;
|
return block instanceof BlockStairs;
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean canWalkOn(BetterBlockPos pos, IBlockState state) {
|
static boolean canWalkOn(IPlayerContext ctx, BetterBlockPos pos, IBlockState state) {
|
||||||
return canWalkOn(new CalculationContext(Baritone.INSTANCE), pos.x, pos.y, pos.z, state);
|
return canWalkOn(new BlockStateInterface(ctx), pos.x, pos.y, pos.z, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean canWalkOn(BetterBlockPos pos) {
|
static boolean canWalkOn(IPlayerContext ctx, BetterBlockPos pos) {
|
||||||
return canWalkOn(new CalculationContext(Baritone.INSTANCE), pos.x, pos.y, pos.z, BlockStateInterface.get(pos));
|
return canWalkOn(new BlockStateInterface(ctx), pos.x, pos.y, pos.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean canWalkOn(CalculationContext context, int x, int y, int z) {
|
static boolean canWalkOn(BlockStateInterface bsi, int x, int y, int z) {
|
||||||
return canWalkOn(context, x, y, z, context.get(x, y, z));
|
return canWalkOn(bsi, x, y, z, bsi.get0(x, y, z));
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean canPlaceAgainst(CalculationContext context, int x, int y, int z) {
|
static boolean canPlaceAgainst(BlockStateInterface bsi, int x, int y, int z) {
|
||||||
return canPlaceAgainst(context.get(x, y, z));
|
return canPlaceAgainst(bsi.get0(x, y, z));
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean canPlaceAgainst(BlockPos pos) {
|
static boolean canPlaceAgainst(BlockStateInterface bsi, BlockPos pos) {
|
||||||
return canPlaceAgainst(BlockStateInterface.get(pos));
|
return canPlaceAgainst(bsi.get0(pos.getX(), pos.getY(), pos.getZ()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean canPlaceAgainst(IPlayerContext ctx, BlockPos pos) {
|
||||||
|
return canPlaceAgainst(new BlockStateInterface(ctx), pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean canPlaceAgainst(IBlockState state) {
|
static boolean canPlaceAgainst(IBlockState state) {
|
||||||
@@ -325,11 +323,11 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
|
|
||||||
static double getMiningDurationTicks(CalculationContext context, int x, int y, int z, IBlockState state, boolean includeFalling) {
|
static double getMiningDurationTicks(CalculationContext context, int x, int y, int z, IBlockState state, boolean includeFalling) {
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
if (!canWalkThrough(context, x, y, z, state)) {
|
if (!canWalkThrough(context.bsi(), x, y, z, state)) {
|
||||||
if (!context.canBreakAt(x, y, z)) {
|
if (!context.canBreakAt(x, y, z)) {
|
||||||
return COST_INF;
|
return COST_INF;
|
||||||
}
|
}
|
||||||
if (avoidBreaking(context, x, y, z, state)) {
|
if (avoidBreaking(context.bsi(), x, y, z, state)) {
|
||||||
return COST_INF;
|
return COST_INF;
|
||||||
}
|
}
|
||||||
if (block instanceof BlockLiquid) {
|
if (block instanceof BlockLiquid) {
|
||||||
@@ -440,11 +438,12 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
* Returns whether or not the block at the specified pos is
|
* Returns whether or not the block at the specified pos is
|
||||||
* water, regardless of whether or not it is flowing.
|
* water, regardless of whether or not it is flowing.
|
||||||
*
|
*
|
||||||
|
* @param ctx The player context
|
||||||
* @param bp The block pos
|
* @param bp The block pos
|
||||||
* @return Whether or not the block is water
|
* @return Whether or not the block is water
|
||||||
*/
|
*/
|
||||||
static boolean isWater(BlockPos bp) {
|
static boolean isWater(IPlayerContext ctx, BlockPos bp) {
|
||||||
return isWater(BlockStateInterface.getBlock(bp));
|
return isWater(BlockStateInterface.getBlock(ctx, bp));
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean isLava(Block b) {
|
static boolean isLava(Block b) {
|
||||||
@@ -454,11 +453,12 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
/**
|
/**
|
||||||
* Returns whether or not the specified pos has a liquid
|
* Returns whether or not the specified pos has a liquid
|
||||||
*
|
*
|
||||||
|
* @param ctx The player context
|
||||||
* @param p The pos
|
* @param p The pos
|
||||||
* @return Whether or not the block is a liquid
|
* @return Whether or not the block is a liquid
|
||||||
*/
|
*/
|
||||||
static boolean isLiquid(BlockPos p) {
|
static boolean isLiquid(IPlayerContext ctx, BlockPos p) {
|
||||||
return BlockStateInterface.getBlock(p) instanceof BlockLiquid;
|
return BlockStateInterface.getBlock(ctx, p) instanceof BlockLiquid;
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean isFlowing(IBlockState state) {
|
static boolean isFlowing(IBlockState state) {
|
||||||
|
@@ -72,7 +72,7 @@ public class MovementAscend extends Movement {
|
|||||||
return COST_INF;// the only thing we can ascend onto from a bottom slab is another bottom slab
|
return COST_INF;// the only thing we can ascend onto from a bottom slab is another bottom slab
|
||||||
}
|
}
|
||||||
boolean hasToPlace = false;
|
boolean hasToPlace = false;
|
||||||
if (!MovementHelper.canWalkOn(context, destX, y, destZ, toPlace)) {
|
if (!MovementHelper.canWalkOn(context.bsi(), destX, y, destZ, toPlace)) {
|
||||||
if (!context.canPlaceThrowawayAt(destX, y, destZ)) {
|
if (!context.canPlaceThrowawayAt(destX, y, destZ)) {
|
||||||
return COST_INF;
|
return COST_INF;
|
||||||
}
|
}
|
||||||
@@ -88,7 +88,7 @@ public class MovementAscend extends Movement {
|
|||||||
if (againstX == x && againstZ == z) {
|
if (againstX == x && againstZ == z) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (MovementHelper.canPlaceAgainst(context, againstX, y, againstZ)) {
|
if (MovementHelper.canPlaceAgainst(context.bsi(), againstX, y, againstZ)) {
|
||||||
hasToPlace = true;
|
hasToPlace = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -98,7 +98,7 @@ public class MovementAscend extends Movement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
IBlockState srcUp2 = null;
|
IBlockState srcUp2 = null;
|
||||||
if (context.get(x, y + 3, z).getBlock() instanceof BlockFalling && (MovementHelper.canWalkThrough(context, x, y + 1, z) || !((srcUp2 = context.get(x, y + 2, z)).getBlock() instanceof BlockFalling))) {//it would fall on us and possibly suffocate us
|
if (context.get(x, y + 3, z).getBlock() instanceof BlockFalling && (MovementHelper.canWalkThrough(context.bsi(), x, y + 1, z) || !((srcUp2 = context.get(x, y + 2, z)).getBlock() instanceof BlockFalling))) {//it would fall on us and possibly suffocate us
|
||||||
// HOWEVER, we assume that we're standing in the start position
|
// HOWEVER, we assume that we're standing in the start position
|
||||||
// that means that src and src.up(1) are both air
|
// that means that src and src.up(1) are both air
|
||||||
// maybe they aren't now, but they will be by the time this starts
|
// maybe they aren't now, but they will be by the time this starts
|
||||||
@@ -166,14 +166,14 @@ public class MovementAscend extends Movement {
|
|||||||
return state.setStatus(MovementStatus.SUCCESS);
|
return state.setStatus(MovementStatus.SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
IBlockState jumpingOnto = BlockStateInterface.get(positionToPlace);
|
IBlockState jumpingOnto = BlockStateInterface.get(ctx, positionToPlace);
|
||||||
if (!MovementHelper.canWalkOn(positionToPlace, jumpingOnto)) {
|
if (!MovementHelper.canWalkOn(ctx, positionToPlace, jumpingOnto)) {
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
BlockPos anAgainst = positionToPlace.offset(HORIZONTALS[i]);
|
BlockPos anAgainst = positionToPlace.offset(HORIZONTALS[i]);
|
||||||
if (anAgainst.equals(src)) {
|
if (anAgainst.equals(src)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (MovementHelper.canPlaceAgainst(anAgainst)) {
|
if (MovementHelper.canPlaceAgainst(ctx, anAgainst)) {
|
||||||
if (!MovementHelper.throwaway(ctx, true)) {//get ready to place a throwaway block
|
if (!MovementHelper.throwaway(ctx, true)) {//get ready to place a throwaway block
|
||||||
return state.setStatus(MovementStatus.UNREACHABLE);
|
return state.setStatus(MovementStatus.UNREACHABLE);
|
||||||
}
|
}
|
||||||
@@ -205,7 +205,7 @@ public class MovementAscend extends Movement {
|
|||||||
return state.setStatus(MovementStatus.UNREACHABLE);
|
return state.setStatus(MovementStatus.UNREACHABLE);
|
||||||
}
|
}
|
||||||
MovementHelper.moveTowards(ctx, state, dest);
|
MovementHelper.moveTowards(ctx, state, dest);
|
||||||
if (MovementHelper.isBottomSlab(jumpingOnto) && !MovementHelper.isBottomSlab(BlockStateInterface.get(src.down()))) {
|
if (MovementHelper.isBottomSlab(jumpingOnto) && !MovementHelper.isBottomSlab(BlockStateInterface.get(ctx, src.down()))) {
|
||||||
return state; // don't jump while walking from a non double slab into a bottom slab
|
return state; // don't jump while walking from a non double slab into a bottom slab
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,7 +236,7 @@ public class MovementAscend extends Movement {
|
|||||||
BetterBlockPos startUp = src.up(2);
|
BetterBlockPos startUp = src.up(2);
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
BetterBlockPos check = startUp.offset(EnumFacing.byHorizontalIndex(i));
|
BetterBlockPos check = startUp.offset(EnumFacing.byHorizontalIndex(i));
|
||||||
if (!MovementHelper.canWalkThrough(check)) {
|
if (!MovementHelper.canWalkThrough(ctx, check)) {
|
||||||
// We might bonk our head
|
// We might bonk our head
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -89,7 +89,7 @@ public class MovementDescend extends Movement {
|
|||||||
//C, D, etc determine the length of the fall
|
//C, D, etc determine the length of the fall
|
||||||
|
|
||||||
IBlockState below = context.get(destX, y - 2, destZ);
|
IBlockState below = context.get(destX, y - 2, destZ);
|
||||||
if (!MovementHelper.canWalkOn(context, destX, y - 2, destZ, below)) {
|
if (!MovementHelper.canWalkOn(context.bsi(), destX, y - 2, destZ, below)) {
|
||||||
dynamicFallCost(context, x, y, z, destX, destZ, totalCost, below, res);
|
dynamicFallCost(context, x, y, z, destX, destZ, totalCost, below, res);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -118,7 +118,7 @@ public class MovementDescend extends Movement {
|
|||||||
// and potentially replace the water we're going to fall into
|
// and potentially replace the water we're going to fall into
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!MovementHelper.canWalkThrough(context, destX, y - 2, destZ, below) && below.getBlock() != Blocks.WATER) {
|
if (!MovementHelper.canWalkThrough(context.bsi(), destX, y - 2, destZ, below) && below.getBlock() != Blocks.WATER) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (int fallHeight = 3; true; fallHeight++) {
|
for (int fallHeight = 3; true; fallHeight++) {
|
||||||
@@ -146,10 +146,10 @@ public class MovementDescend extends Movement {
|
|||||||
if (ontoBlock.getBlock() == Blocks.FLOWING_WATER) {
|
if (ontoBlock.getBlock() == Blocks.FLOWING_WATER) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (MovementHelper.canWalkThrough(context, destX, newY, destZ, ontoBlock)) {
|
if (MovementHelper.canWalkThrough(context.bsi(), destX, newY, destZ, ontoBlock)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!MovementHelper.canWalkOn(context, destX, newY, destZ, ontoBlock)) {
|
if (!MovementHelper.canWalkOn(context.bsi(), destX, newY, destZ, ontoBlock)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (MovementHelper.isBottomSlab(ontoBlock)) {
|
if (MovementHelper.isBottomSlab(ontoBlock)) {
|
||||||
@@ -183,7 +183,7 @@ public class MovementDescend extends Movement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BlockPos playerFeet = ctx.playerFeet();
|
BlockPos playerFeet = ctx.playerFeet();
|
||||||
if (playerFeet.equals(dest) && (MovementHelper.isLiquid(dest) || ctx.player().posY - playerFeet.getY() < 0.094)) { // lilypads
|
if (playerFeet.equals(dest) && (MovementHelper.isLiquid(ctx, dest) || ctx.player().posY - playerFeet.getY() < 0.094)) { // lilypads
|
||||||
// Wait until we're actually on the ground before saying we're done because sometimes we continue to fall if the next action starts immediately
|
// Wait until we're actually on the ground before saying we're done because sometimes we continue to fall if the next action starts immediately
|
||||||
return state.setStatus(MovementStatus.SUCCESS);
|
return state.setStatus(MovementStatus.SUCCESS);
|
||||||
/* else {
|
/* else {
|
||||||
|
@@ -62,11 +62,11 @@ public class MovementDiagonal extends Movement {
|
|||||||
return COST_INF;
|
return COST_INF;
|
||||||
}
|
}
|
||||||
IBlockState destInto = context.get(destX, y, destZ);
|
IBlockState destInto = context.get(destX, y, destZ);
|
||||||
if (!MovementHelper.canWalkThrough(context, destX, y, destZ, destInto) || !MovementHelper.canWalkThrough(context, destX, y + 1, destZ)) {
|
if (!MovementHelper.canWalkThrough(context.bsi(), destX, y, destZ, destInto) || !MovementHelper.canWalkThrough(context.bsi(), destX, y + 1, destZ)) {
|
||||||
return COST_INF;
|
return COST_INF;
|
||||||
}
|
}
|
||||||
IBlockState destWalkOn = context.get(destX, y - 1, destZ);
|
IBlockState destWalkOn = context.get(destX, y - 1, destZ);
|
||||||
if (!MovementHelper.canWalkOn(context, destX, y - 1, destZ, destWalkOn)) {
|
if (!MovementHelper.canWalkOn(context.bsi(), destX, y - 1, destZ, destWalkOn)) {
|
||||||
return COST_INF;
|
return COST_INF;
|
||||||
}
|
}
|
||||||
double multiplier = WALK_ONE_BLOCK_COST;
|
double multiplier = WALK_ONE_BLOCK_COST;
|
||||||
@@ -145,7 +145,7 @@ public class MovementDiagonal extends Movement {
|
|||||||
state.setStatus(MovementStatus.SUCCESS);
|
state.setStatus(MovementStatus.SUCCESS);
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
if (!MovementHelper.isLiquid(ctx.playerFeet())) {
|
if (!MovementHelper.isLiquid(ctx, ctx.playerFeet())) {
|
||||||
state.setInput(Input.SPRINT, true);
|
state.setInput(Input.SPRINT, true);
|
||||||
}
|
}
|
||||||
MovementHelper.moveTowards(ctx, state, dest);
|
MovementHelper.moveTowards(ctx, state, dest);
|
||||||
@@ -164,7 +164,7 @@ public class MovementDiagonal extends Movement {
|
|||||||
}
|
}
|
||||||
List<BlockPos> result = new ArrayList<>();
|
List<BlockPos> result = new ArrayList<>();
|
||||||
for (int i = 4; i < 6; i++) {
|
for (int i = 4; i < 6; i++) {
|
||||||
if (!MovementHelper.canWalkThrough(positionsToBreak[i])) {
|
if (!MovementHelper.canWalkThrough(ctx, positionsToBreak[i])) {
|
||||||
result.add(positionsToBreak[i]);
|
result.add(positionsToBreak[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -179,7 +179,7 @@ public class MovementDiagonal extends Movement {
|
|||||||
}
|
}
|
||||||
List<BlockPos> result = new ArrayList<>();
|
List<BlockPos> result = new ArrayList<>();
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
if (!MovementHelper.canWalkThrough(positionsToBreak[i])) {
|
if (!MovementHelper.canWalkThrough(ctx, positionsToBreak[i])) {
|
||||||
result.add(positionsToBreak[i]);
|
result.add(positionsToBreak[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -48,7 +48,7 @@ public class MovementDownward extends Movement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static double cost(CalculationContext context, int x, int y, int z) {
|
public static double cost(CalculationContext context, int x, int y, int z) {
|
||||||
if (!MovementHelper.canWalkOn(context, x, y - 2, z)) {
|
if (!MovementHelper.canWalkOn(context.bsi(), x, y - 2, z)) {
|
||||||
return COST_INF;
|
return COST_INF;
|
||||||
}
|
}
|
||||||
IBlockState d = context.get(x, y - 1, z);
|
IBlockState d = context.get(x, y - 1, z);
|
||||||
|
@@ -66,7 +66,7 @@ public class MovementFall extends Movement {
|
|||||||
|
|
||||||
BlockPos playerFeet = ctx.playerFeet();
|
BlockPos playerFeet = ctx.playerFeet();
|
||||||
Rotation targetRotation = null;
|
Rotation targetRotation = null;
|
||||||
if (!MovementHelper.isWater(dest) && src.getY() - dest.getY() > Baritone.settings().maxFallHeightNoWater.get() && !playerFeet.equals(dest)) {
|
if (!MovementHelper.isWater(ctx, dest) && src.getY() - dest.getY() > Baritone.settings().maxFallHeightNoWater.get() && !playerFeet.equals(dest)) {
|
||||||
if (!InventoryPlayer.isHotbar(ctx.player().inventory.getSlotFor(STACK_BUCKET_WATER)) || ctx.world().provider.isNether()) {
|
if (!InventoryPlayer.isHotbar(ctx.player().inventory.getSlotFor(STACK_BUCKET_WATER)) || ctx.world().provider.isNether()) {
|
||||||
return state.setStatus(MovementStatus.UNREACHABLE);
|
return state.setStatus(MovementStatus.UNREACHABLE);
|
||||||
}
|
}
|
||||||
@@ -87,8 +87,8 @@ public class MovementFall extends Movement {
|
|||||||
} else {
|
} else {
|
||||||
state.setTarget(new MovementTarget(RotationUtils.calcRotationFromVec3d(ctx.playerHead(), VecUtils.getBlockPosCenter(dest)), false));
|
state.setTarget(new MovementTarget(RotationUtils.calcRotationFromVec3d(ctx.playerHead(), VecUtils.getBlockPosCenter(dest)), false));
|
||||||
}
|
}
|
||||||
if (playerFeet.equals(dest) && (ctx.player().posY - playerFeet.getY() < 0.094 || MovementHelper.isWater(dest))) { // 0.094 because lilypads
|
if (playerFeet.equals(dest) && (ctx.player().posY - playerFeet.getY() < 0.094 || MovementHelper.isWater(ctx, dest))) { // 0.094 because lilypads
|
||||||
if (MovementHelper.isWater(dest)) {
|
if (MovementHelper.isWater(ctx, dest)) {
|
||||||
if (InventoryPlayer.isHotbar(ctx.player().inventory.getSlotFor(STACK_BUCKET_EMPTY))) {
|
if (InventoryPlayer.isHotbar(ctx.player().inventory.getSlotFor(STACK_BUCKET_EMPTY))) {
|
||||||
ctx.player().inventory.currentItem = ctx.player().inventory.getSlotFor(STACK_BUCKET_EMPTY);
|
ctx.player().inventory.currentItem = ctx.player().inventory.getSlotFor(STACK_BUCKET_EMPTY);
|
||||||
if (ctx.player().motionY >= 0) {
|
if (ctx.player().motionY >= 0) {
|
||||||
@@ -139,7 +139,7 @@ public class MovementFall extends Movement {
|
|||||||
// only break if one of the first three needs to be broken
|
// only break if one of the first three needs to be broken
|
||||||
// specifically ignore the last one which might be water
|
// specifically ignore the last one which might be water
|
||||||
for (int i = 0; i < 4 && i < positionsToBreak.length; i++) {
|
for (int i = 0; i < 4 && i < positionsToBreak.length; i++) {
|
||||||
if (!MovementHelper.canWalkThrough(positionsToBreak[i])) {
|
if (!MovementHelper.canWalkThrough(ctx, positionsToBreak[i])) {
|
||||||
return super.prepared(state);
|
return super.prepared(state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -78,7 +78,7 @@ public class MovementParkour extends Movement {
|
|||||||
if (MovementHelper.avoidWalkingInto(adj.getBlock()) && adj.getBlock() != Blocks.WATER && adj.getBlock() != Blocks.FLOWING_WATER) { // magma sucks
|
if (MovementHelper.avoidWalkingInto(adj.getBlock()) && adj.getBlock() != Blocks.WATER && adj.getBlock() != Blocks.FLOWING_WATER) { // magma sucks
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (MovementHelper.canWalkOn(context,x + xDiff, y - 1, z + zDiff, adj)) { // don't parkour if we could just traverse (for now)
|
if (MovementHelper.canWalkOn(context.bsi(), x + xDiff, y - 1, z + zDiff, adj)) { // don't parkour if we could just traverse (for now)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,7 +111,7 @@ public class MovementParkour extends Movement {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (MovementHelper.canWalkOn(context,x + xDiff * i, y - 1, z + zDiff * i)) {
|
if (MovementHelper.canWalkOn(context.bsi(), x + xDiff * i, y - 1, z + zDiff * i)) {
|
||||||
res.x = x + xDiff * i;
|
res.x = x + xDiff * i;
|
||||||
res.y = y;
|
res.y = y;
|
||||||
res.z = z + zDiff * i;
|
res.z = z + zDiff * i;
|
||||||
@@ -144,7 +144,7 @@ public class MovementParkour extends Movement {
|
|||||||
if (againstX == x + xDiff * 3 && againstZ == z + zDiff * 3) { // we can't turn around that fast
|
if (againstX == x + xDiff * 3 && againstZ == z + zDiff * 3) { // we can't turn around that fast
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (MovementHelper.canPlaceAgainst(context,againstX, y - 1, againstZ)) {
|
if (MovementHelper.canPlaceAgainst(context.bsi(), againstX, y - 1, againstZ)) {
|
||||||
res.x = destX;
|
res.x = destX;
|
||||||
res.y = y;
|
res.y = y;
|
||||||
res.z = destZ;
|
res.z = destZ;
|
||||||
@@ -201,7 +201,7 @@ public class MovementParkour extends Movement {
|
|||||||
}
|
}
|
||||||
MovementHelper.moveTowards(ctx, state, dest);
|
MovementHelper.moveTowards(ctx, state, dest);
|
||||||
if (ctx.playerFeet().equals(dest)) {
|
if (ctx.playerFeet().equals(dest)) {
|
||||||
Block d = BlockStateInterface.getBlock(dest);
|
Block d = BlockStateInterface.getBlock(ctx, dest);
|
||||||
if (d == Blocks.VINE || d == Blocks.LADDER) {
|
if (d == Blocks.VINE || d == Blocks.LADDER) {
|
||||||
// it physically hurt me to add support for parkour jumping onto a vine
|
// it physically hurt me to add support for parkour jumping onto a vine
|
||||||
// but i did it anyway
|
// but i did it anyway
|
||||||
@@ -213,14 +213,14 @@ public class MovementParkour extends Movement {
|
|||||||
} else if (!ctx.playerFeet().equals(src)) {
|
} else if (!ctx.playerFeet().equals(src)) {
|
||||||
if (ctx.playerFeet().equals(src.offset(direction)) || ctx.player().posY - ctx.playerFeet().getY() > 0.0001) {
|
if (ctx.playerFeet().equals(src.offset(direction)) || ctx.player().posY - ctx.playerFeet().getY() > 0.0001) {
|
||||||
|
|
||||||
if (!MovementHelper.canWalkOn(dest.down()) && !ctx.player().onGround) {
|
if (!MovementHelper.canWalkOn(ctx, dest.down()) && !ctx.player().onGround) {
|
||||||
BlockPos positionToPlace = dest.down();
|
BlockPos positionToPlace = dest.down();
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
BlockPos against1 = positionToPlace.offset(HORIZONTAL_AND_DOWN[i]);
|
BlockPos against1 = positionToPlace.offset(HORIZONTAL_AND_DOWN[i]);
|
||||||
if (against1.up().equals(src.offset(direction, 3))) { // we can't turn around that fast
|
if (against1.up().equals(src.offset(direction, 3))) { // we can't turn around that fast
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (MovementHelper.canPlaceAgainst(against1)) {
|
if (MovementHelper.canPlaceAgainst(ctx, against1)) {
|
||||||
if (!MovementHelper.throwaway(ctx, true)) {//get ready to place a throwaway block
|
if (!MovementHelper.throwaway(ctx, true)) {//get ready to place a throwaway block
|
||||||
return state.setStatus(MovementStatus.UNREACHABLE);
|
return state.setStatus(MovementStatus.UNREACHABLE);
|
||||||
}
|
}
|
||||||
|
@@ -143,8 +143,8 @@ public class MovementPillar extends Movement {
|
|||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
IBlockState fromDown = BlockStateInterface.get(src);
|
IBlockState fromDown = BlockStateInterface.get(ctx, src);
|
||||||
if (MovementHelper.isWater(fromDown.getBlock()) && MovementHelper.isWater(dest)) {
|
if (MovementHelper.isWater(fromDown.getBlock()) && MovementHelper.isWater(ctx, dest)) {
|
||||||
// stay centered while swimming up a water column
|
// stay centered while swimming up a water column
|
||||||
state.setTarget(new MovementState.MovementTarget(RotationUtils.calcRotationFromVec3d(ctx.playerHead(), VecUtils.getBlockPosCenter(dest)), false));
|
state.setTarget(new MovementState.MovementTarget(RotationUtils.calcRotationFromVec3d(ctx.playerHead(), VecUtils.getBlockPosCenter(dest)), false));
|
||||||
Vec3d destCenter = VecUtils.getBlockPosCenter(dest);
|
Vec3d destCenter = VecUtils.getBlockPosCenter(dest);
|
||||||
@@ -165,7 +165,7 @@ public class MovementPillar extends Movement {
|
|||||||
state.setTarget(new MovementState.MovementTarget(new Rotation(ctx.player().rotationYaw, rotation.getPitch()), true));
|
state.setTarget(new MovementState.MovementTarget(new Rotation(ctx.player().rotationYaw, rotation.getPitch()), true));
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean blockIsThere = MovementHelper.canWalkOn(src) || ladder;
|
boolean blockIsThere = MovementHelper.canWalkOn(ctx, src) || ladder;
|
||||||
if (ladder) {
|
if (ladder) {
|
||||||
BlockPos against = vine ? getAgainst(new CalculationContext(baritone), src) : src.offset(fromDown.getValue(BlockLadder.FACING).getOpposite());
|
BlockPos against = vine ? getAgainst(new CalculationContext(baritone), src) : src.offset(fromDown.getValue(BlockLadder.FACING).getOpposite());
|
||||||
if (against == null) {
|
if (against == null) {
|
||||||
@@ -176,7 +176,7 @@ public class MovementPillar extends Movement {
|
|||||||
if (ctx.playerFeet().equals(against.up()) || ctx.playerFeet().equals(dest)) {
|
if (ctx.playerFeet().equals(against.up()) || ctx.playerFeet().equals(dest)) {
|
||||||
return state.setStatus(MovementStatus.SUCCESS);
|
return state.setStatus(MovementStatus.SUCCESS);
|
||||||
}
|
}
|
||||||
if (MovementHelper.isBottomSlab(BlockStateInterface.get(src.down()))) {
|
if (MovementHelper.isBottomSlab(BlockStateInterface.get(ctx, src.down()))) {
|
||||||
state.setInput(Input.JUMP, true);
|
state.setInput(Input.JUMP, true);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@@ -214,7 +214,7 @@ public class MovementPillar extends Movement {
|
|||||||
|
|
||||||
|
|
||||||
if (!blockIsThere) {
|
if (!blockIsThere) {
|
||||||
Block fr = BlockStateInterface.get(src).getBlock();
|
Block fr = BlockStateInterface.get(ctx, src).getBlock();
|
||||||
if (!(fr instanceof BlockAir || fr.isReplaceable(ctx.world(), src))) {
|
if (!(fr instanceof BlockAir || fr.isReplaceable(ctx.world(), src))) {
|
||||||
state.setInput(Input.CLICK_LEFT, true);
|
state.setInput(Input.CLICK_LEFT, true);
|
||||||
blockIsThere = false;
|
blockIsThere = false;
|
||||||
@@ -235,12 +235,12 @@ public class MovementPillar extends Movement {
|
|||||||
@Override
|
@Override
|
||||||
protected boolean prepared(MovementState state) {
|
protected boolean prepared(MovementState state) {
|
||||||
if (ctx.playerFeet().equals(src) || ctx.playerFeet().equals(src.down())) {
|
if (ctx.playerFeet().equals(src) || ctx.playerFeet().equals(src.down())) {
|
||||||
Block block = BlockStateInterface.getBlock(src.down());
|
Block block = BlockStateInterface.getBlock(ctx, src.down());
|
||||||
if (block == Blocks.LADDER || block == Blocks.VINE) {
|
if (block == Blocks.LADDER || block == Blocks.VINE) {
|
||||||
state.setInput(Input.SNEAK, true);
|
state.setInput(Input.SNEAK, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (MovementHelper.isWater(dest.up())) {
|
if (MovementHelper.isWater(ctx, dest.up())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return super.prepared(state);
|
return super.prepared(state);
|
||||||
|
@@ -64,7 +64,7 @@ public class MovementTraverse extends Movement {
|
|||||||
IBlockState pb1 = context.get(destX, y, destZ);
|
IBlockState pb1 = context.get(destX, y, destZ);
|
||||||
IBlockState destOn = context.get(destX, y - 1, destZ);
|
IBlockState destOn = context.get(destX, y - 1, destZ);
|
||||||
Block srcDown = context.getBlock(x, y - 1, z);
|
Block srcDown = context.getBlock(x, y - 1, z);
|
||||||
if (MovementHelper.canWalkOn(context, destX, y - 1, destZ, destOn)) {//this is a walk, not a bridge
|
if (MovementHelper.canWalkOn(context.bsi(), destX, y - 1, destZ, destOn)) {//this is a walk, not a bridge
|
||||||
double WC = WALK_ONE_BLOCK_COST;
|
double WC = WALK_ONE_BLOCK_COST;
|
||||||
boolean water = false;
|
boolean water = false;
|
||||||
if (MovementHelper.isWater(pb0.getBlock()) || MovementHelper.isWater(pb1.getBlock())) {
|
if (MovementHelper.isWater(pb0.getBlock()) || MovementHelper.isWater(pb1.getBlock())) {
|
||||||
@@ -122,7 +122,7 @@ public class MovementTraverse extends Movement {
|
|||||||
if (againstX == x && againstZ == z) {
|
if (againstX == x && againstZ == z) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (MovementHelper.canPlaceAgainst(context, againstX, y - 1, againstZ)) {
|
if (MovementHelper.canPlaceAgainst(context.bsi(), againstX, y - 1, againstZ)) {
|
||||||
return WC + context.placeBlockCost() + hardness1 + hardness2;
|
return WC + context.placeBlockCost() + hardness1 + hardness2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -153,10 +153,10 @@ public class MovementTraverse extends Movement {
|
|||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
// and if it's fine to walk into the blocks in front
|
// and if it's fine to walk into the blocks in front
|
||||||
if (MovementHelper.avoidWalkingInto(BlockStateInterface.get(positionsToBreak[0]).getBlock())) {
|
if (MovementHelper.avoidWalkingInto(BlockStateInterface.get(ctx, positionsToBreak[0]).getBlock())) {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
if (MovementHelper.avoidWalkingInto(BlockStateInterface.get(positionsToBreak[1]).getBlock())) {
|
if (MovementHelper.avoidWalkingInto(BlockStateInterface.get(ctx, positionsToBreak[1]).getBlock())) {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
// and we aren't already pressed up against the block
|
// and we aren't already pressed up against the block
|
||||||
@@ -177,17 +177,17 @@ public class MovementTraverse extends Movement {
|
|||||||
//sneak may have been set to true in the PREPPING state while mining an adjacent block
|
//sneak may have been set to true in the PREPPING state while mining an adjacent block
|
||||||
state.setInput(Input.SNEAK, false);
|
state.setInput(Input.SNEAK, false);
|
||||||
|
|
||||||
Block fd = BlockStateInterface.get(src.down()).getBlock();
|
Block fd = BlockStateInterface.get(ctx, src.down()).getBlock();
|
||||||
boolean ladder = fd instanceof BlockLadder || fd instanceof BlockVine;
|
boolean ladder = fd instanceof BlockLadder || fd instanceof BlockVine;
|
||||||
IBlockState pb0 = BlockStateInterface.get(positionsToBreak[0]);
|
IBlockState pb0 = BlockStateInterface.get(ctx, positionsToBreak[0]);
|
||||||
IBlockState pb1 = BlockStateInterface.get(positionsToBreak[1]);
|
IBlockState pb1 = BlockStateInterface.get(ctx, positionsToBreak[1]);
|
||||||
|
|
||||||
boolean door = pb0.getBlock() instanceof BlockDoor || pb1.getBlock() instanceof BlockDoor;
|
boolean door = pb0.getBlock() instanceof BlockDoor || pb1.getBlock() instanceof BlockDoor;
|
||||||
if (door) {
|
if (door) {
|
||||||
boolean isDoorActuallyBlockingUs = false;
|
boolean isDoorActuallyBlockingUs = false;
|
||||||
if (pb0.getBlock() instanceof BlockDoor && !MovementHelper.isDoorPassable(src, dest)) {
|
if (pb0.getBlock() instanceof BlockDoor && !MovementHelper.isDoorPassable(ctx, src, dest)) {
|
||||||
isDoorActuallyBlockingUs = true;
|
isDoorActuallyBlockingUs = true;
|
||||||
} else if (pb1.getBlock() instanceof BlockDoor && !MovementHelper.isDoorPassable(dest, src)) {
|
} else if (pb1.getBlock() instanceof BlockDoor && !MovementHelper.isDoorPassable(ctx, dest, src)) {
|
||||||
isDoorActuallyBlockingUs = true;
|
isDoorActuallyBlockingUs = true;
|
||||||
}
|
}
|
||||||
if (isDoorActuallyBlockingUs && !(Blocks.IRON_DOOR.equals(pb0.getBlock()) || Blocks.IRON_DOOR.equals(pb1.getBlock()))) {
|
if (isDoorActuallyBlockingUs && !(Blocks.IRON_DOOR.equals(pb0.getBlock()) || Blocks.IRON_DOOR.equals(pb1.getBlock()))) {
|
||||||
@@ -198,9 +198,9 @@ public class MovementTraverse extends Movement {
|
|||||||
|
|
||||||
if (pb0.getBlock() instanceof BlockFenceGate || pb1.getBlock() instanceof BlockFenceGate) {
|
if (pb0.getBlock() instanceof BlockFenceGate || pb1.getBlock() instanceof BlockFenceGate) {
|
||||||
BlockPos blocked = null;
|
BlockPos blocked = null;
|
||||||
if (!MovementHelper.isGatePassable(positionsToBreak[0], src.up())) {
|
if (!MovementHelper.isGatePassable(ctx, positionsToBreak[0], src.up())) {
|
||||||
blocked = positionsToBreak[0];
|
blocked = positionsToBreak[0];
|
||||||
} else if (!MovementHelper.isGatePassable(positionsToBreak[1], src)) {
|
} else if (!MovementHelper.isGatePassable(ctx, positionsToBreak[1], src)) {
|
||||||
blocked = positionsToBreak[1];
|
blocked = positionsToBreak[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -210,7 +210,7 @@ public class MovementTraverse extends Movement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isTheBridgeBlockThere = MovementHelper.canWalkOn(positionToPlace) || ladder;
|
boolean isTheBridgeBlockThere = MovementHelper.canWalkOn(ctx, positionToPlace) || ladder;
|
||||||
BlockPos whereAmI = ctx.playerFeet();
|
BlockPos whereAmI = ctx.playerFeet();
|
||||||
if (whereAmI.getY() != dest.getY() && !ladder) {
|
if (whereAmI.getY() != dest.getY() && !ladder) {
|
||||||
logDebug("Wrong Y coordinate");
|
logDebug("Wrong Y coordinate");
|
||||||
@@ -224,10 +224,10 @@ public class MovementTraverse extends Movement {
|
|||||||
if (ctx.playerFeet().equals(dest)) {
|
if (ctx.playerFeet().equals(dest)) {
|
||||||
return state.setStatus(MovementStatus.SUCCESS);
|
return state.setStatus(MovementStatus.SUCCESS);
|
||||||
}
|
}
|
||||||
if (wasTheBridgeBlockAlwaysThere && !MovementHelper.isLiquid(ctx.playerFeet())) {
|
if (wasTheBridgeBlockAlwaysThere && !MovementHelper.isLiquid(ctx, ctx.playerFeet())) {
|
||||||
state.setInput(Input.SPRINT, true);
|
state.setInput(Input.SPRINT, true);
|
||||||
}
|
}
|
||||||
Block destDown = BlockStateInterface.get(dest.down()).getBlock();
|
Block destDown = BlockStateInterface.get(ctx, dest.down()).getBlock();
|
||||||
if (whereAmI.getY() != dest.getY() && ladder && (destDown instanceof BlockVine || destDown instanceof BlockLadder)) {
|
if (whereAmI.getY() != dest.getY() && ladder && (destDown instanceof BlockVine || destDown instanceof BlockLadder)) {
|
||||||
new MovementPillar(baritone, dest.down(), dest).updateState(state); // i'm sorry
|
new MovementPillar(baritone, dest.down(), dest).updateState(state); // i'm sorry
|
||||||
return state;
|
return state;
|
||||||
@@ -242,7 +242,7 @@ public class MovementTraverse extends Movement {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
against1 = against1.down();
|
against1 = against1.down();
|
||||||
if (MovementHelper.canPlaceAgainst(against1)) {
|
if (MovementHelper.canPlaceAgainst(ctx, against1)) {
|
||||||
if (!MovementHelper.throwaway(ctx, true)) { // get ready to place a throwaway block
|
if (!MovementHelper.throwaway(ctx, true)) { // get ready to place a throwaway block
|
||||||
logDebug("bb pls get me some blocks. dirt or cobble");
|
logDebug("bb pls get me some blocks. dirt or cobble");
|
||||||
return state.setStatus(MovementStatus.UNREACHABLE);
|
return state.setStatus(MovementStatus.UNREACHABLE);
|
||||||
@@ -250,7 +250,7 @@ public class MovementTraverse extends Movement {
|
|||||||
if (!Baritone.settings().assumeSafeWalk.get()) {
|
if (!Baritone.settings().assumeSafeWalk.get()) {
|
||||||
state.setInput(Input.SNEAK, true);
|
state.setInput(Input.SNEAK, true);
|
||||||
}
|
}
|
||||||
Block standingOn = BlockStateInterface.get(ctx.playerFeet().down()).getBlock();
|
Block standingOn = BlockStateInterface.get(ctx, ctx.playerFeet().down()).getBlock();
|
||||||
if (standingOn.equals(Blocks.SOUL_SAND) || standingOn instanceof BlockSlab) { // see issue #118
|
if (standingOn.equals(Blocks.SOUL_SAND) || standingOn instanceof BlockSlab) { // see issue #118
|
||||||
double dist = Math.max(Math.abs(dest.getX() + 0.5 - ctx.player().posX), Math.abs(dest.getZ() + 0.5 - ctx.player().posZ));
|
double dist = Math.max(Math.abs(dest.getX() + 0.5 - ctx.player().posX), Math.abs(dest.getZ() + 0.5 - ctx.player().posZ));
|
||||||
if (dist < 0.85) { // 0.5 + 0.3 + epsilon
|
if (dist < 0.85) { // 0.5 + 0.3 + epsilon
|
||||||
@@ -318,13 +318,13 @@ public class MovementTraverse extends Movement {
|
|||||||
// if we're in the process of breaking blocks before walking forwards
|
// if we're in the process of breaking blocks before walking forwards
|
||||||
// or if this isn't a sneak place (the block is already there)
|
// or if this isn't a sneak place (the block is already there)
|
||||||
// then it's safe to cancel this
|
// then it's safe to cancel this
|
||||||
return state.getStatus() != MovementStatus.RUNNING || MovementHelper.canWalkOn(dest.down());
|
return state.getStatus() != MovementStatus.RUNNING || MovementHelper.canWalkOn(ctx, dest.down());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean prepared(MovementState state) {
|
protected boolean prepared(MovementState state) {
|
||||||
if (ctx.playerFeet().equals(src) || ctx.playerFeet().equals(src.down())) {
|
if (ctx.playerFeet().equals(src) || ctx.playerFeet().equals(src.down())) {
|
||||||
Block block = BlockStateInterface.getBlock(src.down());
|
Block block = BlockStateInterface.getBlock(ctx, src.down());
|
||||||
if (block == Blocks.LADDER || block == Blocks.VINE) {
|
if (block == Blocks.LADDER || block == Blocks.VINE) {
|
||||||
state.setInput(Input.SNEAK, true);
|
state.setInput(Input.SNEAK, true);
|
||||||
}
|
}
|
||||||
|
@@ -110,7 +110,7 @@ public class PathExecutor implements IPathExecutor, Helper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//System.out.println("Should be at " + whereShouldIBe + " actually am at " + whereAmI);
|
//System.out.println("Should be at " + whereShouldIBe + " actually am at " + whereAmI);
|
||||||
if (!Blocks.AIR.equals(BlockStateInterface.getBlock(whereAmI.down()))) {//do not skip if standing on air, because our position isn't stable to skip
|
if (!Blocks.AIR.equals(BlockStateInterface.getBlock(ctx, whereAmI.down()))) {//do not skip if standing on air, because our position isn't stable to skip
|
||||||
for (int i = 0; i < pathPosition - 1 && i < path.length(); i++) {//this happens for example when you lag out and get teleported back a couple blocks
|
for (int i = 0; i < pathPosition - 1 && i < path.length(); i++) {//this happens for example when you lag out and get teleported back a couple blocks
|
||||||
if (whereAmI.equals(path.positions().get(i))) {
|
if (whereAmI.equals(path.positions().get(i))) {
|
||||||
logDebug("Skipping back " + (pathPosition - i) + " steps, to " + i);
|
logDebug("Skipping back " + (pathPosition - i) + " steps, to " + i);
|
||||||
@@ -303,11 +303,11 @@ public class PathExecutor implements IPathExecutor, Helper {
|
|||||||
if (!ctx.player().onGround) {
|
if (!ctx.player().onGround) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!MovementHelper.canWalkOn(ctx.playerFeet().down())) {
|
if (!MovementHelper.canWalkOn(ctx, ctx.playerFeet().down())) {
|
||||||
// we're in some kind of sketchy situation, maybe parkouring
|
// we're in some kind of sketchy situation, maybe parkouring
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!MovementHelper.canWalkThrough(ctx.playerFeet()) || !MovementHelper.canWalkThrough(ctx.playerFeet().up())) {
|
if (!MovementHelper.canWalkThrough(ctx, ctx.playerFeet()) || !MovementHelper.canWalkThrough(ctx, ctx.playerFeet().up())) {
|
||||||
// suffocating?
|
// suffocating?
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -384,7 +384,7 @@ public class PathExecutor implements IPathExecutor, Helper {
|
|||||||
|
|
||||||
BlockPos into = current.getDest().subtract(current.getSrc().down()).add(current.getDest());
|
BlockPos into = current.getDest().subtract(current.getSrc().down()).add(current.getDest());
|
||||||
for (int y = 0; y <= 2; y++) { // we could hit any of the three blocks
|
for (int y = 0; y <= 2; y++) { // we could hit any of the three blocks
|
||||||
if (MovementHelper.avoidWalkingInto(BlockStateInterface.getBlock(into.up(y)))) {
|
if (MovementHelper.avoidWalkingInto(BlockStateInterface.getBlock(ctx, into.up(y)))) {
|
||||||
logDebug("Sprinting would be unsafe");
|
logDebug("Sprinting would be unsafe");
|
||||||
ctx.player().setSprinting(false);
|
ctx.player().setSprinting(false);
|
||||||
return;
|
return;
|
||||||
@@ -402,7 +402,7 @@ public class PathExecutor implements IPathExecutor, Helper {
|
|||||||
logDebug("Skipping descend to straight ascend");
|
logDebug("Skipping descend to straight ascend");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (canSprintInto(current, next)) {
|
if (canSprintInto(ctx, current, next)) {
|
||||||
if (ctx.playerFeet().equals(current.getDest())) {
|
if (ctx.playerFeet().equals(current.getDest())) {
|
||||||
pathPosition++;
|
pathPosition++;
|
||||||
onChangeInPathPosition();
|
onChangeInPathPosition();
|
||||||
@@ -430,11 +430,11 @@ public class PathExecutor implements IPathExecutor, Helper {
|
|||||||
ctx.player().setSprinting(false);
|
ctx.player().setSprinting(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean canSprintInto(IMovement current, IMovement next) {
|
private static boolean canSprintInto(IPlayerContext ctx, IMovement current, IMovement next) {
|
||||||
if (next instanceof MovementDescend && next.getDirection().equals(current.getDirection())) {
|
if (next instanceof MovementDescend && next.getDirection().equals(current.getDirection())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (next instanceof MovementTraverse && next.getDirection().down().equals(current.getDirection()) && MovementHelper.canWalkOn(next.getDest().down())) {
|
if (next instanceof MovementTraverse && next.getDirection().down().equals(current.getDirection()) && MovementHelper.canWalkOn(ctx, next.getDest().down())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return next instanceof MovementDiagonal && Baritone.settings().allowOvershootDiagonalDescend.get();
|
return next instanceof MovementDiagonal && Baritone.settings().allowOvershootDiagonalDescend.get();
|
||||||
|
@@ -97,6 +97,6 @@ public class GetToBlockProcess extends BaritoneProcessHelper implements IGetToBl
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void rescan(List<BlockPos> known) {
|
private void rescan(List<BlockPos> known) {
|
||||||
knownLocations = MineProcess.searchWorld(baritone, Collections.singletonList(gettingTo), 64, known);
|
knownLocations = MineProcess.searchWorld(ctx, Collections.singletonList(gettingTo), 64, known);
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -18,7 +18,6 @@
|
|||||||
package baritone.process;
|
package baritone.process;
|
||||||
|
|
||||||
import baritone.Baritone;
|
import baritone.Baritone;
|
||||||
import baritone.api.IBaritone;
|
|
||||||
import baritone.api.pathing.goals.*;
|
import baritone.api.pathing.goals.*;
|
||||||
import baritone.api.process.IMineProcess;
|
import baritone.api.process.IMineProcess;
|
||||||
import baritone.api.process.PathingCommand;
|
import baritone.api.process.PathingCommand;
|
||||||
@@ -27,13 +26,10 @@ import baritone.api.utils.IPlayerContext;
|
|||||||
import baritone.api.utils.RotationUtils;
|
import baritone.api.utils.RotationUtils;
|
||||||
import baritone.cache.CachedChunk;
|
import baritone.cache.CachedChunk;
|
||||||
import baritone.cache.ChunkPacker;
|
import baritone.cache.ChunkPacker;
|
||||||
import baritone.cache.WorldProvider;
|
|
||||||
import baritone.cache.WorldScanner;
|
import baritone.cache.WorldScanner;
|
||||||
import baritone.pathing.movement.CalculationContext;
|
|
||||||
import baritone.pathing.movement.MovementHelper;
|
import baritone.pathing.movement.MovementHelper;
|
||||||
import baritone.utils.BaritoneProcessHelper;
|
import baritone.utils.BaritoneProcessHelper;
|
||||||
import baritone.utils.BlockStateInterface;
|
import baritone.utils.BlockStateInterface;
|
||||||
import baritone.utils.Helper;
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
import net.minecraft.entity.item.EntityItem;
|
||||||
@@ -92,7 +88,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
int mineGoalUpdateInterval = Baritone.settings().mineGoalUpdateInterval.get();
|
int mineGoalUpdateInterval = Baritone.settings().mineGoalUpdateInterval.get();
|
||||||
if (mineGoalUpdateInterval != 0 && tickCount++ % mineGoalUpdateInterval == 0) { // big brain
|
if (mineGoalUpdateInterval != 0 && tickCount++ % mineGoalUpdateInterval == 0) { // big brain
|
||||||
List<BlockPos> curr = new ArrayList<>(knownOreLocations);
|
List<BlockPos> curr = new ArrayList<>(knownOreLocations);
|
||||||
baritone.getExecutor().execute(() -> rescan(curr));
|
Baritone.getExecutor().execute(() -> rescan(curr));
|
||||||
}
|
}
|
||||||
if (Baritone.settings().legitMine.get()) {
|
if (Baritone.settings().legitMine.get()) {
|
||||||
addNearby();
|
addNearby();
|
||||||
@@ -120,9 +116,9 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
private Goal updateGoal() {
|
private Goal updateGoal() {
|
||||||
List<BlockPos> locs = knownOreLocations;
|
List<BlockPos> locs = knownOreLocations;
|
||||||
if (!locs.isEmpty()) {
|
if (!locs.isEmpty()) {
|
||||||
List<BlockPos> locs2 = prune(baritone, new ArrayList<>(locs), mining, ORE_LOCATIONS_COUNT);
|
List<BlockPos> locs2 = prune(ctx, new ArrayList<>(locs), mining, ORE_LOCATIONS_COUNT);
|
||||||
// can't reassign locs, gotta make a new var locs2, because we use it in a lambda right here, and variables you use in a lambda must be effectively final
|
// can't reassign locs, gotta make a new var locs2, because we use it in a lambda right here, and variables you use in a lambda must be effectively final
|
||||||
Goal goal = new GoalComposite(locs2.stream().map(loc -> coalesce(loc, locs2)).toArray(Goal[]::new));
|
Goal goal = new GoalComposite(locs2.stream().map(loc -> coalesce(ctx, loc, locs2)).toArray(Goal[]::new));
|
||||||
knownOreLocations = locs2;
|
knownOreLocations = locs2;
|
||||||
return goal;
|
return goal;
|
||||||
}
|
}
|
||||||
@@ -162,7 +158,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
if (Baritone.settings().legitMine.get()) {
|
if (Baritone.settings().legitMine.get()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<BlockPos> locs = searchWorld(baritone, mining, ORE_LOCATIONS_COUNT, already);
|
List<BlockPos> locs = searchWorld(ctx, mining, ORE_LOCATIONS_COUNT, already);
|
||||||
locs.addAll(droppedItemsScan(mining, ctx.world()));
|
locs.addAll(droppedItemsScan(mining, ctx.world()));
|
||||||
if (locs.isEmpty()) {
|
if (locs.isEmpty()) {
|
||||||
logDebug("No locations for " + mining + " known, cancelling");
|
logDebug("No locations for " + mining + " known, cancelling");
|
||||||
@@ -172,26 +168,15 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
knownOreLocations = locs;
|
knownOreLocations = locs;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Goal coalesce(BlockPos loc, List<BlockPos> locs) {
|
private static Goal coalesce(IPlayerContext ctx, BlockPos loc, List<BlockPos> locs) {
|
||||||
if (!Baritone.settings().forceInternalMining.get()) {
|
if (!Baritone.settings().forceInternalMining.get()) {
|
||||||
return new GoalTwoBlocks(loc);
|
return new GoalTwoBlocks(loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean upwardGoal = locs.contains(loc.up()) || (Baritone.settings().internalMiningAirException.get() && BlockStateInterface.getBlock(loc.up()) == Blocks.AIR);
|
// Here, BlockStateInterface is used because the position may be in a cached chunk (the targeted block is one that is kept track of)
|
||||||
boolean downwardGoal = locs.contains(loc.down()) || (Baritone.settings().internalMiningAirException.get() && BlockStateInterface.getBlock(loc.up()) == Blocks.AIR);
|
boolean upwardGoal = locs.contains(loc.up()) || (Baritone.settings().internalMiningAirException.get() && BlockStateInterface.getBlock(ctx, loc.up()) == Blocks.AIR);
|
||||||
if (upwardGoal) {
|
boolean downwardGoal = locs.contains(loc.down()) || (Baritone.settings().internalMiningAirException.get() && BlockStateInterface.getBlock(ctx, loc.down()) == Blocks.AIR);
|
||||||
if (downwardGoal) {
|
return upwardGoal == downwardGoal ? new GoalTwoBlocks(loc) : upwardGoal ? new GoalBlock(loc) : new GoalBlock(loc.down());
|
||||||
return new GoalTwoBlocks(loc);
|
|
||||||
} else {
|
|
||||||
return new GoalBlock(loc);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (downwardGoal) {
|
|
||||||
return new GoalBlock(loc.down());
|
|
||||||
} else {
|
|
||||||
return new GoalTwoBlocks(loc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<BlockPos> droppedItemsScan(List<Block> mining, World world) {
|
public static List<BlockPos> droppedItemsScan(List<Block> mining, World world) {
|
||||||
@@ -220,15 +205,13 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
/*public static List<BlockPos> searchWorld(List<Block> mining, int max, World world) {
|
/*public static List<BlockPos> searchWorld(List<Block> mining, int max, World world) {
|
||||||
|
|
||||||
}*/
|
}*/
|
||||||
public static List<BlockPos> searchWorld(IBaritone baritone, List<Block> mining, int max, List<BlockPos> alreadyKnown) {
|
public static List<BlockPos> searchWorld(IPlayerContext ctx, List<Block> mining, int max, List<BlockPos> alreadyKnown) {
|
||||||
IPlayerContext ctx = baritone.getPlayerContext();
|
|
||||||
|
|
||||||
List<BlockPos> locs = new ArrayList<>();
|
List<BlockPos> locs = new ArrayList<>();
|
||||||
List<Block> uninteresting = new ArrayList<>();
|
List<Block> uninteresting = new ArrayList<>();
|
||||||
//long b = System.currentTimeMillis();
|
//long b = System.currentTimeMillis();
|
||||||
for (Block m : mining) {
|
for (Block m : mining) {
|
||||||
if (CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.contains(m)) {
|
if (CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.contains(m)) {
|
||||||
locs.addAll(baritone.getWorldProvider().getCurrentWorld().getCachedWorld().getLocationsOf(ChunkPacker.blockToString(m), 1, ctx.playerFeet().getX(), ctx.playerFeet().getZ(), 1));
|
locs.addAll(ctx.worldData().getCachedWorld().getLocationsOf(ChunkPacker.blockToString(m), 1, ctx.playerFeet().getX(), ctx.playerFeet().getZ(), 1));
|
||||||
} else {
|
} else {
|
||||||
uninteresting.add(m);
|
uninteresting.add(m);
|
||||||
}
|
}
|
||||||
@@ -243,7 +226,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
//System.out.println("Scan of loaded chunks took " + (System.currentTimeMillis() - before) + "ms");
|
//System.out.println("Scan of loaded chunks took " + (System.currentTimeMillis() - before) + "ms");
|
||||||
}
|
}
|
||||||
locs.addAll(alreadyKnown);
|
locs.addAll(alreadyKnown);
|
||||||
return prune(baritone, locs, mining, max);
|
return prune(ctx, locs, mining, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addNearby() {
|
public void addNearby() {
|
||||||
@@ -254,29 +237,28 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
for (int y = playerFeet.getY() - searchDist; y <= playerFeet.getY() + searchDist; y++) {
|
for (int y = playerFeet.getY() - searchDist; y <= playerFeet.getY() + searchDist; y++) {
|
||||||
for (int z = playerFeet.getZ() - searchDist; z <= playerFeet.getZ() + searchDist; z++) {
|
for (int z = playerFeet.getZ() - searchDist; z <= playerFeet.getZ() + searchDist; z++) {
|
||||||
BlockPos pos = new BlockPos(x, y, z);
|
BlockPos pos = new BlockPos(x, y, z);
|
||||||
// crucial to only add blocks we can see because otherwise this is an x-ray and it'll get caught
|
// crucial to only add blocks we can see because otherwise this
|
||||||
if (mining.contains(BlockStateInterface.getBlock(pos)) && RotationUtils.reachable(ctx.player(), pos, ctx.playerController().getBlockReachDistance()).isPresent()) {
|
// is an x-ray and it'll get caught
|
||||||
|
if (mining.contains(BlockStateInterface.getBlock(ctx, pos)) && RotationUtils.reachable(ctx.player(), pos, ctx.playerController().getBlockReachDistance()).isPresent()) {
|
||||||
knownOreLocations.add(pos);
|
knownOreLocations.add(pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
knownOreLocations = prune(baritone, knownOreLocations, mining, ORE_LOCATIONS_COUNT);
|
knownOreLocations = prune(ctx, knownOreLocations, mining, ORE_LOCATIONS_COUNT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<BlockPos> prune(IBaritone baritone, List<BlockPos> locs2, List<Block> mining, int max) {
|
public static List<BlockPos> prune(IPlayerContext ctx, List<BlockPos> locs2, List<Block> mining, int max) {
|
||||||
IPlayerContext ctx = baritone.getPlayerContext();
|
|
||||||
|
|
||||||
List<BlockPos> dropped = droppedItemsScan(mining, ctx.world());
|
List<BlockPos> dropped = droppedItemsScan(mining, ctx.world());
|
||||||
List<BlockPos> locs = locs2
|
List<BlockPos> locs = locs2
|
||||||
.stream()
|
.stream()
|
||||||
.distinct()
|
.distinct()
|
||||||
|
|
||||||
// remove any that are within loaded chunks that aren't actually what we want
|
// remove any that are within loaded chunks that aren't actually what we want
|
||||||
.filter(pos -> ctx.world().getChunk(pos) instanceof EmptyChunk || mining.contains(BlockStateInterface.get(pos).getBlock()) || dropped.contains(pos))
|
.filter(pos -> ctx.world().getChunk(pos) instanceof EmptyChunk || mining.contains(BlockStateInterface.getBlock(ctx, pos)) || dropped.contains(pos))
|
||||||
|
|
||||||
// remove any that are implausible to mine (encased in bedrock, or touching lava)
|
// remove any that are implausible to mine (encased in bedrock, or touching lava)
|
||||||
.filter(pos -> MineProcess.plausibleToBreak(baritone, pos))
|
.filter(pos -> MineProcess.plausibleToBreak(ctx, pos))
|
||||||
|
|
||||||
.sorted(Comparator.comparingDouble(ctx.playerFeet()::distanceSq))
|
.sorted(Comparator.comparingDouble(ctx.playerFeet()::distanceSq))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
@@ -287,12 +269,12 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
return locs;
|
return locs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean plausibleToBreak(IBaritone baritone, BlockPos pos) {
|
public static boolean plausibleToBreak(IPlayerContext ctx, BlockPos pos) {
|
||||||
if (MovementHelper.avoidBreaking(new CalculationContext(baritone), pos.getX(), pos.getY(), pos.getZ(), BlockStateInterface.get(pos))) {
|
if (MovementHelper.avoidBreaking(new BlockStateInterface(ctx), pos.getX(), pos.getY(), pos.getZ(), BlockStateInterface.get(ctx, pos))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// bedrock above and below makes it implausible, otherwise we're good
|
// bedrock above and below makes it implausible, otherwise we're good
|
||||||
return !(BlockStateInterface.getBlock(pos.up()) == Blocks.BEDROCK && BlockStateInterface.getBlock(pos.down()) == Blocks.BEDROCK);
|
return !(BlockStateInterface.getBlock(ctx, pos.up()) == Blocks.BEDROCK && BlockStateInterface.getBlock(ctx, pos.down()) == Blocks.BEDROCK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -18,6 +18,8 @@
|
|||||||
package baritone.utils;
|
package baritone.utils;
|
||||||
|
|
||||||
import baritone.Baritone;
|
import baritone.Baritone;
|
||||||
|
import baritone.api.IBaritone;
|
||||||
|
import baritone.api.utils.IPlayerContext;
|
||||||
import baritone.cache.CachedRegion;
|
import baritone.cache.CachedRegion;
|
||||||
import baritone.cache.WorldData;
|
import baritone.cache.WorldData;
|
||||||
import baritone.pathing.movement.CalculationContext;
|
import baritone.pathing.movement.CalculationContext;
|
||||||
@@ -43,22 +45,26 @@ public class BlockStateInterface implements Helper {
|
|||||||
|
|
||||||
private static final IBlockState AIR = Blocks.AIR.getDefaultState();
|
private static final IBlockState AIR = Blocks.AIR.getDefaultState();
|
||||||
|
|
||||||
|
public BlockStateInterface(IPlayerContext ctx) {
|
||||||
|
this(ctx.world(), (WorldData) ctx.worldData());
|
||||||
|
}
|
||||||
|
|
||||||
public BlockStateInterface(World world, WorldData worldData) {
|
public BlockStateInterface(World world, WorldData worldData) {
|
||||||
this.worldData = worldData;
|
this.worldData = worldData;
|
||||||
this.world = world;
|
this.world = world;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Block getBlock(BlockPos pos) { // won't be called from the pathing thread because the pathing thread doesn't make a single blockpos pog
|
public static Block getBlock(IPlayerContext ctx, BlockPos pos) { // won't be called from the pathing thread because the pathing thread doesn't make a single blockpos pog
|
||||||
return get(pos).getBlock();
|
return get(ctx, pos).getBlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IBlockState get(BlockPos pos) {
|
public static IBlockState get(IPlayerContext ctx, BlockPos pos) {
|
||||||
return new CalculationContext(Baritone.INSTANCE).get(pos); // immense iq
|
return new BlockStateInterface(ctx).get0(pos.getX(), pos.getY(), pos.getZ()); // immense iq
|
||||||
// can't just do world().get because that doesn't work for out of bounds
|
// can't just do world().get because that doesn't work for out of bounds
|
||||||
// and toBreak and stuff fails when the movement is instantiated out of load range but it's not able to BlockStateInterface.get what it's going to walk on
|
// and toBreak and stuff fails when the movement is instantiated out of load range but it's not able to BlockStateInterface.get what it's going to walk on
|
||||||
}
|
}
|
||||||
|
|
||||||
public IBlockState get0(int x, int y, int z) {
|
public IBlockState get0(int x, int y, int z) { // Mickey resigned
|
||||||
|
|
||||||
// Invalid vertical position
|
// Invalid vertical position
|
||||||
if (y < 0 || y >= 256) {
|
if (y < 0 || y >= 256) {
|
||||||
|
@@ -303,7 +303,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
|
|||||||
LinkedList<BlockPos> locs = baritone.getWorldProvider().getCurrentWorld().getCachedWorld().getLocationsOf(blockType, 1, ctx.playerFeet().getX(), ctx.playerFeet().getZ(), 4);
|
LinkedList<BlockPos> locs = baritone.getWorldProvider().getCurrentWorld().getCachedWorld().getLocationsOf(blockType, 1, ctx.playerFeet().getX(), ctx.playerFeet().getZ(), 4);
|
||||||
logDirect("Have " + locs.size() + " locations");
|
logDirect("Have " + locs.size() + " locations");
|
||||||
for (BlockPos pos : locs) {
|
for (BlockPos pos : locs) {
|
||||||
Block actually = BlockStateInterface.get(pos).getBlock();
|
Block actually = BlockStateInterface.get(ctx, pos).getBlock();
|
||||||
if (!ChunkPacker.blockToString(actually).equalsIgnoreCase(blockType)) {
|
if (!ChunkPacker.blockToString(actually).equalsIgnoreCase(blockType)) {
|
||||||
System.out.println("Was looking for " + blockType + " but actually found " + actually + " " + ChunkPacker.blockToString(actually));
|
System.out.println("Was looking for " + blockType + " but actually found " + actually + " " + ChunkPacker.blockToString(actually));
|
||||||
}
|
}
|
||||||
|
@@ -206,7 +206,7 @@ public final class PathRenderer implements Helper {
|
|||||||
double renderPosY = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double) partialTicks;
|
double renderPosY = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double) partialTicks;
|
||||||
double renderPosZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double) partialTicks;
|
double renderPosZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double) partialTicks;
|
||||||
positions.forEach(pos -> {
|
positions.forEach(pos -> {
|
||||||
IBlockState state = BlockStateInterface.get(pos);
|
IBlockState state = BlockStateInterface.get(Baritone.INSTANCE.getPlayerContext(), pos);
|
||||||
AxisAlignedBB toDraw;
|
AxisAlignedBB toDraw;
|
||||||
if (state.getBlock().equals(Blocks.AIR)) {
|
if (state.getBlock().equals(Blocks.AIR)) {
|
||||||
toDraw = Blocks.DIRT.getDefaultState().getSelectedBoundingBox(Minecraft.getMinecraft().world, pos);
|
toDraw = Blocks.DIRT.getDefaultState().getSelectedBoundingBox(Minecraft.getMinecraft().world, pos);
|
||||||
|
@@ -17,6 +17,8 @@
|
|||||||
|
|
||||||
package baritone.utils.player;
|
package baritone.utils.player;
|
||||||
|
|
||||||
|
import baritone.Baritone;
|
||||||
|
import baritone.api.cache.IWorldData;
|
||||||
import baritone.api.utils.IPlayerContext;
|
import baritone.api.utils.IPlayerContext;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.entity.EntityPlayerSP;
|
import net.minecraft.client.entity.EntityPlayerSP;
|
||||||
@@ -51,4 +53,9 @@ public final class LocalPlayerContext extends AbstractPlayerContext {
|
|||||||
public World world() {
|
public World world() {
|
||||||
return mc.world;
|
return mc.world;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IWorldData worldData() {
|
||||||
|
return Baritone.INSTANCE.getWorldProvider().getCurrentWorld();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user