allow down placement, and fixes to replacable
This commit is contained in:
parent
2bd81b08c2
commit
862746038d
@ -55,6 +55,7 @@ public class CalculationContext {
|
|||||||
private final boolean allowBreak;
|
private final boolean allowBreak;
|
||||||
private final boolean allowParkour;
|
private final boolean allowParkour;
|
||||||
private final boolean allowParkourPlace;
|
private final boolean allowParkourPlace;
|
||||||
|
private final boolean assumeWalkOnWater;
|
||||||
private final int maxFallHeightNoWater;
|
private final int maxFallHeightNoWater;
|
||||||
private final int maxFallHeightBucket;
|
private final int maxFallHeightBucket;
|
||||||
private final double waterWalkSpeed;
|
private final double waterWalkSpeed;
|
||||||
@ -80,6 +81,7 @@ public class CalculationContext {
|
|||||||
this.allowBreak = Baritone.settings().allowBreak.get();
|
this.allowBreak = Baritone.settings().allowBreak.get();
|
||||||
this.allowParkour = Baritone.settings().allowParkour.get();
|
this.allowParkour = Baritone.settings().allowParkour.get();
|
||||||
this.allowParkourPlace = Baritone.settings().allowParkourPlace.get();
|
this.allowParkourPlace = Baritone.settings().allowParkourPlace.get();
|
||||||
|
this.assumeWalkOnWater = Baritone.settings().assumeWalkOnWater.get();
|
||||||
this.maxFallHeightNoWater = Baritone.settings().maxFallHeightNoWater.get();
|
this.maxFallHeightNoWater = Baritone.settings().maxFallHeightNoWater.get();
|
||||||
this.maxFallHeightBucket = Baritone.settings().maxFallHeightBucket.get();
|
this.maxFallHeightBucket = Baritone.settings().maxFallHeightBucket.get();
|
||||||
int depth = EnchantmentHelper.getDepthStriderModifier(player);
|
int depth = EnchantmentHelper.getDepthStriderModifier(player);
|
||||||
@ -185,6 +187,10 @@ public class CalculationContext {
|
|||||||
return allowParkourPlace;
|
return allowParkourPlace;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean assumeWalkOnWater() {
|
||||||
|
return assumeWalkOnWater;
|
||||||
|
}
|
||||||
|
|
||||||
public int maxFallHeightNoWater() {
|
public int maxFallHeightNoWater() {
|
||||||
return maxFallHeightNoWater;
|
return maxFallHeightNoWater;
|
||||||
}
|
}
|
||||||
|
@ -35,8 +35,6 @@ import net.minecraft.item.ItemStack;
|
|||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.NonNullList;
|
import net.minecraft.util.NonNullList;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraft.world.chunk.EmptyChunk;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Static helpers for cost calculation
|
* Static helpers for cost calculation
|
||||||
@ -160,7 +158,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
return block.isPassable(null, null);
|
return block.isPassable(null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean isReplacable(int x, int y, int z, IBlockState state, World world) {
|
static boolean isReplacable(int x, int y, int z, IBlockState state, BlockStateInterface bsi) {
|
||||||
// for MovementTraverse and MovementAscend
|
// for MovementTraverse and MovementAscend
|
||||||
// block double plant defaults to true when the block doesn't match, so don't need to check that case
|
// block double plant defaults to true when the block doesn't match, so don't need to check that case
|
||||||
// all other overrides just return true or false
|
// all other overrides just return true or false
|
||||||
@ -172,9 +170,13 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
|
if (block == Blocks.AIR || isWater(block)) {
|
||||||
|
// early return for common cases hehe
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (block instanceof BlockSnow) {
|
if (block instanceof BlockSnow) {
|
||||||
// as before, default to true (mostly because it would otherwise make long distance pathing through snowy biomes impossible)
|
// as before, default to true (mostly because it would otherwise make long distance pathing through snowy biomes impossible)
|
||||||
if (world.getChunk(x >> 4, z >> 4) instanceof EmptyChunk) {
|
if (!bsi.worldContainsLoadedChunk(x, z)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return state.getValue(BlockSnow.LAYERS) == 1;
|
return state.getValue(BlockSnow.LAYERS) == 1;
|
||||||
|
@ -37,6 +37,8 @@ import net.minecraft.util.math.Vec3d;
|
|||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import static baritone.pathing.movement.movements.MovementParkour.HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP;
|
||||||
|
|
||||||
public class MovementAscend extends Movement {
|
public class MovementAscend extends Movement {
|
||||||
|
|
||||||
private int ticksWithoutPlacement = 0;
|
private int ticksWithoutPlacement = 0;
|
||||||
@ -63,19 +65,17 @@ public class MovementAscend extends Movement {
|
|||||||
if (!context.canPlaceThrowawayAt(destX, y, destZ)) {
|
if (!context.canPlaceThrowawayAt(destX, y, destZ)) {
|
||||||
return COST_INF;
|
return COST_INF;
|
||||||
}
|
}
|
||||||
if (toPlace.getBlock() != Blocks.AIR && !MovementHelper.isWater(toPlace.getBlock()) && !MovementHelper.isReplacable(destX, y, destZ, toPlace, context.world())) {
|
if (!MovementHelper.isReplacable(destX, y, destZ, toPlace, context.bsi())) {
|
||||||
return COST_INF;
|
return COST_INF;
|
||||||
}
|
}
|
||||||
// TODO: add ability to place against .down() as well as the cardinal directions
|
for (int i = 0; i < 5; i++) {
|
||||||
// useful for when you are starting a staircase without anything to place against
|
int againstX = destX + HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP[i].getXOffset();
|
||||||
// Counterpoint to the above TODO ^ you should move then pillar instead of ascend
|
int againstY = y + HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP[i].getYOffset();
|
||||||
for (int i = 0; i < 4; i++) {
|
int againstZ = destZ + HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP[i].getZOffset();
|
||||||
int againstX = destX + HORIZONTALS[i].getXOffset();
|
if (againstX == x && againstZ == z) { // we might be able to backplace now, but it doesn't matter because it will have been broken by the time we'd need to use it
|
||||||
int againstZ = destZ + HORIZONTALS[i].getZOffset();
|
|
||||||
if (againstX == x && againstZ == z) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (MovementHelper.canPlaceAgainst(context.bsi(), againstX, y, againstZ)) {
|
if (MovementHelper.canPlaceAgainst(context.bsi(), againstX, againstY, againstZ)) {
|
||||||
hasToPlace = true;
|
hasToPlace = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -164,8 +164,8 @@ public class MovementAscend extends Movement {
|
|||||||
|
|
||||||
IBlockState jumpingOnto = BlockStateInterface.get(ctx, positionToPlace);
|
IBlockState jumpingOnto = BlockStateInterface.get(ctx, positionToPlace);
|
||||||
if (!MovementHelper.canWalkOn(ctx, positionToPlace, jumpingOnto)) {
|
if (!MovementHelper.canWalkOn(ctx, positionToPlace, jumpingOnto)) {
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
BlockPos anAgainst = positionToPlace.offset(HORIZONTALS[i]);
|
BlockPos anAgainst = positionToPlace.offset(HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP[i]);
|
||||||
if (anAgainst.equals(src)) {
|
if (anAgainst.equals(src)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
|
|
||||||
package baritone.pathing.movement.movements;
|
package baritone.pathing.movement.movements;
|
||||||
|
|
||||||
import baritone.Baritone;
|
|
||||||
import baritone.api.IBaritone;
|
import baritone.api.IBaritone;
|
||||||
import baritone.api.pathing.movement.MovementStatus;
|
import baritone.api.pathing.movement.MovementStatus;
|
||||||
import baritone.api.utils.BetterBlockPos;
|
import baritone.api.utils.BetterBlockPos;
|
||||||
@ -138,7 +137,7 @@ public class MovementDescend extends Movement {
|
|||||||
if (ontoBlock.getBlock() == Blocks.WATER && !MovementHelper.isFlowing(ontoBlock) && context.getBlock(destX, newY + 1, destZ) != Blocks.WATERLILY) { // TODO flowing check required here?
|
if (ontoBlock.getBlock() == Blocks.WATER && !MovementHelper.isFlowing(ontoBlock) && context.getBlock(destX, newY + 1, destZ) != Blocks.WATERLILY) { // TODO flowing check required here?
|
||||||
// lilypads are canWalkThrough, but we can't end a fall that should be broken by water if it's covered by a lilypad
|
// lilypads are canWalkThrough, but we can't end a fall that should be broken by water if it's covered by a lilypad
|
||||||
// however, don't return impossible in the lilypad scenario, because we could still jump right on it (water that's below a lilypad is canWalkOn so it works)
|
// however, don't return impossible in the lilypad scenario, because we could still jump right on it (water that's below a lilypad is canWalkOn so it works)
|
||||||
if (Baritone.settings().assumeWalkOnWater.get()) {
|
if (context.assumeWalkOnWater()) {
|
||||||
return; // TODO fix
|
return; // TODO fix
|
||||||
}
|
}
|
||||||
// found a fall into water
|
// found a fall into water
|
||||||
|
@ -43,7 +43,7 @@ import java.util.Objects;
|
|||||||
|
|
||||||
public class MovementParkour extends Movement {
|
public class MovementParkour extends Movement {
|
||||||
|
|
||||||
private static final EnumFacing[] HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP = {EnumFacing.NORTH, EnumFacing.SOUTH, EnumFacing.EAST, EnumFacing.WEST, EnumFacing.DOWN};
|
static final EnumFacing[] HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP = {EnumFacing.NORTH, EnumFacing.SOUTH, EnumFacing.EAST, EnumFacing.WEST, EnumFacing.DOWN};
|
||||||
private static final BetterBlockPos[] EMPTY = new BetterBlockPos[]{};
|
private static final BetterBlockPos[] EMPTY = new BetterBlockPos[]{};
|
||||||
|
|
||||||
private final EnumFacing direction;
|
private final EnumFacing direction;
|
||||||
@ -131,16 +131,17 @@ public class MovementParkour extends Movement {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IBlockState toReplace = context.get(destX, y - 1, destZ);
|
IBlockState toReplace = context.get(destX, y - 1, destZ);
|
||||||
if (toReplace.getBlock() != Blocks.AIR && !MovementHelper.isWater(toReplace.getBlock()) && !MovementHelper.isReplacable(destX, y - 1, destZ, toReplace, context.world())) {
|
if (!MovementHelper.isReplacable(destX, y - 1, destZ, toReplace, context.bsi())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
int againstX = destX + HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP[i].getXOffset();
|
int againstX = destX + HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP[i].getXOffset();
|
||||||
|
int againstY = y - 1 + HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP[i].getYOffset();
|
||||||
int againstZ = destZ + HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP[i].getZOffset();
|
int againstZ = destZ + HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP[i].getZOffset();
|
||||||
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.bsi(), againstX, y - 1, againstZ)) {
|
if (MovementHelper.canPlaceAgainst(context.bsi(), againstX, againstY, againstZ)) {
|
||||||
res.x = destX;
|
res.x = destX;
|
||||||
res.y = y;
|
res.y = y;
|
||||||
res.z = destZ;
|
res.z = destZ;
|
||||||
|
@ -76,7 +76,10 @@ public class MovementPillar extends Movement {
|
|||||||
if (!ladder && !context.canPlaceThrowawayAt(x, y, z)) { // we need to place a block where we started to jump on it
|
if (!ladder && !context.canPlaceThrowawayAt(x, y, z)) { // we need to place a block where we started to jump on it
|
||||||
return COST_INF;
|
return COST_INF;
|
||||||
}
|
}
|
||||||
if (from instanceof BlockLiquid || fromDown.getBlock() instanceof BlockLiquid) {//can't pillar on water or in water
|
if (from instanceof BlockLiquid || (fromDown.getBlock() instanceof BlockLiquid && context.assumeWalkOnWater())) {
|
||||||
|
// otherwise, if we're standing in water, we cannot pillar
|
||||||
|
// if we're standing on water and assumeWalkOnWater is true, we cannot pillar
|
||||||
|
// if we're standing on water and assumeWalkOnWater is false, we must have ascended to here, or sneak backplaced, so it is possible to pillar again
|
||||||
return COST_INF;
|
return COST_INF;
|
||||||
}
|
}
|
||||||
double hardness = MovementHelper.getMiningDurationTicks(context, x, y + 2, z, toBreak, true);
|
double hardness = MovementHelper.getMiningDurationTicks(context, x, y + 2, z, toBreak, true);
|
||||||
|
@ -103,7 +103,7 @@ public class MovementTraverse extends Movement {
|
|||||||
if (srcDown == Blocks.LADDER || srcDown == Blocks.VINE) {
|
if (srcDown == Blocks.LADDER || srcDown == Blocks.VINE) {
|
||||||
return COST_INF;
|
return COST_INF;
|
||||||
}
|
}
|
||||||
if (destOn.getBlock().equals(Blocks.AIR) || MovementHelper.isReplacable(destX, y - 1, destZ, destOn, context.world())) {
|
if (MovementHelper.isReplacable(destX, y - 1, destZ, destOn, context.bsi())) {
|
||||||
boolean throughWater = MovementHelper.isWater(pb0.getBlock()) || MovementHelper.isWater(pb1.getBlock());
|
boolean throughWater = MovementHelper.isWater(pb0.getBlock()) || MovementHelper.isWater(pb1.getBlock());
|
||||||
if (MovementHelper.isWater(destOn.getBlock()) && throughWater) {
|
if (MovementHelper.isWater(destOn.getBlock()) && throughWater) {
|
||||||
// this happens when assume walk on water is true and this is a traverse in water, which isn't allowed
|
// this happens when assume walk on water is true and this is a traverse in water, which isn't allowed
|
||||||
|
Loading…
Reference in New Issue
Block a user