no more stupid wrapper getters
This commit is contained in:
parent
8a4f48f08d
commit
b9b25e7e6b
@ -26,4 +26,4 @@ public enum MappingType {
|
||||
SEARGE,
|
||||
NOTCH,
|
||||
CUSTOM // forgegradle
|
||||
}
|
||||
}
|
||||
|
@ -60,4 +60,4 @@ public class ReobfWrapper {
|
||||
throw new IllegalStateException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ public final class MemoryBehavior extends Behavior {
|
||||
}
|
||||
|
||||
private BlockPos neighboringConnectedBlock(BlockPos in) {
|
||||
BlockStateInterface bsi = new CalculationContext(baritone).bsi();
|
||||
BlockStateInterface bsi = new CalculationContext(baritone).bsi;
|
||||
Block block = bsi.get0(in).getBlock();
|
||||
if (block != Blocks.TRAPPED_CHEST && block != Blocks.CHEST) {
|
||||
return null; // other things that have contents, but can be placed adjacent without combining
|
||||
|
@ -433,7 +433,7 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
|
||||
Optional<IPath> path = calcResult.getPath();
|
||||
if (Baritone.settings().cutoffAtLoadBoundary.get()) {
|
||||
path = path.map(p -> {
|
||||
IPath result = p.cutoffAtLoadedChunks(context.bsi());
|
||||
IPath result = p.cutoffAtLoadedChunks(context.bsi);
|
||||
|
||||
if (result instanceof CutoffPath) {
|
||||
logDebug("Cutting off path at edge of loaded chunks");
|
||||
@ -499,7 +499,7 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
|
||||
Goal transformed = goal;
|
||||
if (Baritone.settings().simplifyUnloadedYCoord.get() && goal instanceof IGoalRenderPos) {
|
||||
BlockPos pos = ((IGoalRenderPos) goal).getGoalPos();
|
||||
if (context.world().getChunk(pos) instanceof EmptyChunk) {
|
||||
if (context.world.getChunk(pos) instanceof EmptyChunk) {
|
||||
transformed = new GoalXZ(pos.getX(), pos.getZ());
|
||||
}
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ public final class AStarPathFinder extends AbstractNodeCostSearch implements Hel
|
||||
}
|
||||
MutableMoveResult res = new MutableMoveResult();
|
||||
Favoring favored = favoring;
|
||||
BetterWorldBorder worldBorder = new BetterWorldBorder(calcContext.world().getWorldBorder());
|
||||
BetterWorldBorder worldBorder = new BetterWorldBorder(calcContext.world.getWorldBorder());
|
||||
long startTime = System.nanoTime() / 1000000L;
|
||||
boolean slowPath = Baritone.settings().slowPath.get();
|
||||
if (slowPath) {
|
||||
|
@ -42,29 +42,29 @@ public class CalculationContext {
|
||||
|
||||
private static final ItemStack STACK_BUCKET_WATER = new ItemStack(Items.WATER_BUCKET);
|
||||
|
||||
private final IBaritone baritone;
|
||||
private final EntityPlayerSP player;
|
||||
private final World world;
|
||||
private final WorldData worldData;
|
||||
private final BlockStateInterface bsi;
|
||||
private final ToolSet toolSet;
|
||||
private final boolean hasWaterBucket;
|
||||
private final boolean hasThrowaway;
|
||||
private final boolean canSprint;
|
||||
private final double placeBlockCost;
|
||||
private final boolean allowBreak;
|
||||
private final boolean allowParkour;
|
||||
private final boolean allowParkourPlace;
|
||||
private final boolean allowJumpAt256;
|
||||
private final boolean assumeWalkOnWater;
|
||||
private final boolean allowDiagonalDescend;
|
||||
private final int maxFallHeightNoWater;
|
||||
private final int maxFallHeightBucket;
|
||||
private final double waterWalkSpeed;
|
||||
private final double breakBlockAdditionalCost;
|
||||
private final double jumpPenalty;
|
||||
private final double walkOnWaterOnePenalty;
|
||||
private final BetterWorldBorder worldBorder;
|
||||
public final IBaritone baritone;
|
||||
public final EntityPlayerSP player;
|
||||
public final World world;
|
||||
public final WorldData worldData;
|
||||
public final BlockStateInterface bsi;
|
||||
public final ToolSet toolSet;
|
||||
public final boolean hasWaterBucket;
|
||||
public final boolean hasThrowaway;
|
||||
public final boolean canSprint;
|
||||
public final double placeBlockCost;
|
||||
public final boolean allowBreak;
|
||||
public final boolean allowParkour;
|
||||
public final boolean allowParkourPlace;
|
||||
public final boolean allowJumpAt256;
|
||||
public final boolean assumeWalkOnWater;
|
||||
public final boolean allowDiagonalDescend;
|
||||
public final int maxFallHeightNoWater;
|
||||
public final int maxFallHeightBucket;
|
||||
public final double waterWalkSpeed;
|
||||
public final double breakBlockAdditionalCost;
|
||||
public final double jumpPenalty;
|
||||
public final double walkOnWaterOnePenalty;
|
||||
public final BetterWorldBorder worldBorder;
|
||||
|
||||
public CalculationContext(IBaritone baritone) {
|
||||
this(baritone, false);
|
||||
@ -126,7 +126,7 @@ public class CalculationContext {
|
||||
}
|
||||
|
||||
public boolean canPlaceThrowawayAt(int x, int y, int z) {
|
||||
if (!hasThrowaway()) { // only true if allowPlace is true, see constructor
|
||||
if (!hasThrowaway) { // only true if allowPlace is true, see constructor
|
||||
return false;
|
||||
}
|
||||
if (isPossiblyProtected(x, y, z)) {
|
||||
@ -136,7 +136,7 @@ public class CalculationContext {
|
||||
}
|
||||
|
||||
public boolean canBreakAt(int x, int y, int z) {
|
||||
if (!allowBreak()) {
|
||||
if (!allowBreak) {
|
||||
return false;
|
||||
}
|
||||
return !isPossiblyProtected(x, y, z);
|
||||
@ -146,88 +146,4 @@ public class CalculationContext {
|
||||
// TODO more protection logic here; see #220
|
||||
return false;
|
||||
}
|
||||
|
||||
public World world() {
|
||||
return world;
|
||||
}
|
||||
|
||||
public EntityPlayerSP player() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public BlockStateInterface bsi() {
|
||||
return bsi;
|
||||
}
|
||||
|
||||
public WorldData worldData() {
|
||||
return worldData;
|
||||
}
|
||||
|
||||
public ToolSet getToolSet() {
|
||||
return toolSet;
|
||||
}
|
||||
|
||||
public boolean hasWaterBucket() {
|
||||
return hasWaterBucket;
|
||||
}
|
||||
|
||||
public boolean hasThrowaway() {
|
||||
return hasThrowaway;
|
||||
}
|
||||
|
||||
public boolean canSprint() {
|
||||
return canSprint;
|
||||
}
|
||||
|
||||
public double placeBlockCost() {
|
||||
return placeBlockCost;
|
||||
}
|
||||
|
||||
public boolean allowBreak() {
|
||||
return allowBreak;
|
||||
}
|
||||
|
||||
public boolean allowParkour() {
|
||||
return allowParkour;
|
||||
}
|
||||
|
||||
public boolean allowParkourPlace() {
|
||||
return allowParkourPlace;
|
||||
}
|
||||
|
||||
public boolean allowJumpAt256() {
|
||||
return allowJumpAt256;
|
||||
}
|
||||
|
||||
public boolean assumeWalkOnWater() {
|
||||
return assumeWalkOnWater;
|
||||
}
|
||||
|
||||
public boolean allowDiagonalDescend() {
|
||||
return allowDiagonalDescend;
|
||||
}
|
||||
|
||||
public int maxFallHeightNoWater() {
|
||||
return maxFallHeightNoWater;
|
||||
}
|
||||
|
||||
public int maxFallHeightBucket() {
|
||||
return maxFallHeightBucket;
|
||||
}
|
||||
|
||||
public double waterWalkSpeed() {
|
||||
return waterWalkSpeed;
|
||||
}
|
||||
|
||||
public double breakBlockAdditionalCost() {
|
||||
return breakBlockAdditionalCost;
|
||||
}
|
||||
|
||||
public double jumpPenalty() {
|
||||
return jumpPenalty;
|
||||
}
|
||||
|
||||
public double walkOnWaterOnePenalty() {
|
||||
return walkOnWaterOnePenalty;
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,6 @@ import baritone.utils.BlockStateInterface;
|
||||
import net.minecraft.block.BlockLiquid;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.chunk.EmptyChunk;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -231,7 +230,7 @@ public abstract class Movement implements IMovement, MovementHelper {
|
||||
}
|
||||
|
||||
public void checkLoadedChunk(CalculationContext context) {
|
||||
calculatedWhileLoaded = !(context.world().getChunk(getDest()) instanceof EmptyChunk);
|
||||
calculatedWhileLoaded = context.bsi.worldContainsLoadedChunk(dest.x, dest.z);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -340,24 +340,24 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
|
||||
static double getMiningDurationTicks(CalculationContext context, int x, int y, int z, IBlockState state, boolean includeFalling) {
|
||||
Block block = state.getBlock();
|
||||
if (!canWalkThrough(context.bsi(), x, y, z, state)) {
|
||||
if (!canWalkThrough(context.bsi, x, y, z, state)) {
|
||||
if (!context.canBreakAt(x, y, z)) {
|
||||
return COST_INF;
|
||||
}
|
||||
if (avoidBreaking(context.bsi(), x, y, z, state)) {
|
||||
if (avoidBreaking(context.bsi, x, y, z, state)) {
|
||||
return COST_INF;
|
||||
}
|
||||
if (block instanceof BlockLiquid) {
|
||||
return COST_INF;
|
||||
}
|
||||
double m = Blocks.CRAFTING_TABLE.equals(block) ? 10 : 1; // TODO see if this is still necessary. it's from MineBot when we wanted to penalize breaking its crafting table
|
||||
double strVsBlock = context.getToolSet().getStrVsBlock(state);
|
||||
double strVsBlock = context.toolSet.getStrVsBlock(state);
|
||||
if (strVsBlock <= 0) {
|
||||
return COST_INF;
|
||||
}
|
||||
|
||||
double result = m / strVsBlock;
|
||||
result += context.breakBlockAdditionalCost();
|
||||
result += context.breakBlockAdditionalCost;
|
||||
if (includeFalling) {
|
||||
IBlockState above = context.get(x, y + 1, z);
|
||||
if (above.getBlock() instanceof BlockFalling) {
|
||||
|
@ -59,11 +59,11 @@ public class MovementAscend extends Movement {
|
||||
public static double cost(CalculationContext context, int x, int y, int z, int destX, int destZ) {
|
||||
IBlockState toPlace = context.get(destX, y, destZ);
|
||||
boolean hasToPlace = false;
|
||||
if (!MovementHelper.canWalkOn(context.bsi(), destX, y, destZ, toPlace)) {
|
||||
if (!MovementHelper.canWalkOn(context.bsi, destX, y, destZ, toPlace)) {
|
||||
if (!context.canPlaceThrowawayAt(destX, y, destZ)) {
|
||||
return COST_INF;
|
||||
}
|
||||
if (!MovementHelper.isReplacable(destX, y, destZ, toPlace, context.bsi())) {
|
||||
if (!MovementHelper.isReplacable(destX, y, destZ, toPlace, context.bsi)) {
|
||||
return COST_INF;
|
||||
}
|
||||
for (int i = 0; i < 5; i++) {
|
||||
@ -73,7 +73,7 @@ public class MovementAscend extends Movement {
|
||||
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
|
||||
continue;
|
||||
}
|
||||
if (MovementHelper.canPlaceAgainst(context.bsi(), againstX, againstY, againstZ)) {
|
||||
if (MovementHelper.canPlaceAgainst(context.bsi, againstX, againstY, againstZ)) {
|
||||
hasToPlace = true;
|
||||
break;
|
||||
}
|
||||
@ -83,7 +83,7 @@ public class MovementAscend extends Movement {
|
||||
}
|
||||
}
|
||||
IBlockState srcUp2 = context.get(x, y + 2, z); // used lower down anyway
|
||||
if (context.get(x, y + 3, z).getBlock() instanceof BlockFalling && (MovementHelper.canWalkThrough(context.bsi(), x, y + 1, z) || !(srcUp2.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.getBlock() instanceof BlockFalling))) {//it would fall on us and possibly suffocate us
|
||||
// HOWEVER, we assume that we're standing in the start position
|
||||
// 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
|
||||
@ -115,7 +115,7 @@ public class MovementAscend extends Movement {
|
||||
if (jumpingToBottomSlab) {
|
||||
if (jumpingFromBottomSlab) {
|
||||
walk = Math.max(JUMP_ONE_BLOCK_COST, WALK_ONE_BLOCK_COST); // we hit space immediately on entering this action
|
||||
walk += context.jumpPenalty();
|
||||
walk += context.jumpPenalty;
|
||||
} else {
|
||||
walk = WALK_ONE_BLOCK_COST; // we don't hit space we just walk into the slab
|
||||
}
|
||||
@ -126,7 +126,7 @@ public class MovementAscend extends Movement {
|
||||
} else {
|
||||
walk = Math.max(JUMP_ONE_BLOCK_COST, WALK_ONE_BLOCK_COST);
|
||||
}
|
||||
walk += context.jumpPenalty();
|
||||
walk += context.jumpPenalty;
|
||||
}
|
||||
|
||||
// cracks knuckles
|
||||
@ -134,7 +134,7 @@ public class MovementAscend extends Movement {
|
||||
double totalCost = 0;
|
||||
totalCost += walk;
|
||||
if (hasToPlace) {
|
||||
totalCost += context.placeBlockCost();
|
||||
totalCost += context.placeBlockCost;
|
||||
}
|
||||
// start with srcUp2 since we already have its state
|
||||
// includeFalling isn't needed because of the falling check above -- if srcUp3 is falling we will have already exited with COST_INF if we'd actually have to break it
|
||||
|
@ -93,7 +93,7 @@ public class MovementDescend extends Movement {
|
||||
//C, D, etc determine the length of the fall
|
||||
|
||||
IBlockState below = context.get(destX, y - 2, destZ);
|
||||
if (!MovementHelper.canWalkOn(context.bsi(), 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);
|
||||
return;
|
||||
}
|
||||
@ -122,7 +122,7 @@ public class MovementDescend extends Movement {
|
||||
// and potentially replace the water we're going to fall into
|
||||
return false;
|
||||
}
|
||||
if (!MovementHelper.canWalkThrough(context.bsi(), destX, y - 2, destZ, below) && below.getBlock() != Blocks.WATER) {
|
||||
if (!MovementHelper.canWalkThrough(context.bsi, destX, y - 2, destZ, below) && below.getBlock() != Blocks.WATER) {
|
||||
return false;
|
||||
}
|
||||
double costSoFar = 0;
|
||||
@ -140,13 +140,13 @@ public class MovementDescend extends Movement {
|
||||
if (ontoBlock.getBlock() == Blocks.WATER && context.getBlock(destX, newY + 1, destZ) != Blocks.WATERLILY) {
|
||||
// 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)
|
||||
if (context.assumeWalkOnWater()) {
|
||||
if (context.assumeWalkOnWater) {
|
||||
return false; // TODO fix
|
||||
}
|
||||
if (MovementHelper.isFlowing(ontoBlock)) {
|
||||
return false; // TODO flowing check required here?
|
||||
}
|
||||
if (!MovementHelper.canWalkOn(context.bsi(), destX, newY - 1, destZ)) {
|
||||
if (!MovementHelper.canWalkOn(context.bsi, destX, newY - 1, destZ)) {
|
||||
// we could punch right through the water into something else
|
||||
return false;
|
||||
}
|
||||
@ -168,23 +168,23 @@ public class MovementDescend extends Movement {
|
||||
effectiveStartHeight = newY;
|
||||
continue;
|
||||
}
|
||||
if (MovementHelper.canWalkThrough(context.bsi(), destX, newY, destZ, ontoBlock)) {
|
||||
if (MovementHelper.canWalkThrough(context.bsi, destX, newY, destZ, ontoBlock)) {
|
||||
continue;
|
||||
}
|
||||
if (!MovementHelper.canWalkOn(context.bsi(), destX, newY, destZ, ontoBlock)) {
|
||||
if (!MovementHelper.canWalkOn(context.bsi, destX, newY, destZ, ontoBlock)) {
|
||||
return false;
|
||||
}
|
||||
if (MovementHelper.isBottomSlab(ontoBlock)) {
|
||||
return false; // falling onto a half slab is really glitchy, and can cause more fall damage than we'd expect
|
||||
}
|
||||
if (context.hasWaterBucket() && unprotectedFallHeight <= context.maxFallHeightBucket() + 1) {
|
||||
if (context.hasWaterBucket && unprotectedFallHeight <= context.maxFallHeightBucket + 1) {
|
||||
res.x = destX;
|
||||
res.y = newY + 1;// this is the block we're falling onto, so dest is +1
|
||||
res.z = destZ;
|
||||
res.cost = tentativeCost + context.placeBlockCost();
|
||||
res.cost = tentativeCost + context.placeBlockCost;
|
||||
return true;
|
||||
}
|
||||
if (unprotectedFallHeight <= context.maxFallHeightNoWater() + 1) {
|
||||
if (unprotectedFallHeight <= context.maxFallHeightNoWater + 1) {
|
||||
// fallHeight = 4 means onto.up() is 3 blocks down, which is the max
|
||||
res.x = destX;
|
||||
res.y = newY + 1;
|
||||
|
@ -65,14 +65,14 @@ public class MovementDiagonal extends Movement {
|
||||
|
||||
public static void cost(CalculationContext context, int x, int y, int z, int destX, int destZ, MutableMoveResult res) {
|
||||
IBlockState destInto = context.get(destX, y, destZ);
|
||||
if (!MovementHelper.canWalkThrough(context.bsi(), destX, y, destZ, destInto) || !MovementHelper.canWalkThrough(context.bsi(), destX, y + 1, destZ)) {
|
||||
if (!MovementHelper.canWalkThrough(context.bsi, destX, y, destZ, destInto) || !MovementHelper.canWalkThrough(context.bsi, destX, y + 1, destZ)) {
|
||||
return;
|
||||
}
|
||||
IBlockState destWalkOn = context.get(destX, y - 1, destZ);
|
||||
boolean descend = false;
|
||||
if (!MovementHelper.canWalkOn(context.bsi(), destX, y - 1, destZ, destWalkOn)) {
|
||||
if (!MovementHelper.canWalkOn(context.bsi, destX, y - 1, destZ, destWalkOn)) {
|
||||
descend = true;
|
||||
if (!context.allowDiagonalDescend() || !MovementHelper.canWalkOn(context.bsi(), destX, y - 2, destZ) || !MovementHelper.canWalkThrough(context.bsi(), destX, y - 1, destZ, destWalkOn)) {
|
||||
if (!context.allowDiagonalDescend || !MovementHelper.canWalkOn(context.bsi, destX, y - 2, destZ) || !MovementHelper.canWalkThrough(context.bsi, destX, y - 1, destZ, destWalkOn)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -81,7 +81,7 @@ public class MovementDiagonal extends Movement {
|
||||
if (destWalkOn.getBlock() == Blocks.SOUL_SAND) {
|
||||
multiplier += (WALK_ONE_OVER_SOUL_SAND_COST - WALK_ONE_BLOCK_COST) / 2;
|
||||
} else if (destWalkOn.getBlock() == Blocks.WATER) {
|
||||
multiplier += context.walkOnWaterOnePenalty() * SQRT_2;
|
||||
multiplier += context.walkOnWaterOnePenalty * SQRT_2;
|
||||
}
|
||||
Block fromDown = context.get(x, y - 1, z).getBlock();
|
||||
if (fromDown == Blocks.LADDER || fromDown == Blocks.VINE) {
|
||||
@ -133,7 +133,7 @@ public class MovementDiagonal extends Movement {
|
||||
// Ignore previous multiplier
|
||||
// Whatever we were walking on (possibly soul sand) doesn't matter as we're actually floating on water
|
||||
// Not even touching the blocks below
|
||||
multiplier = context.waterWalkSpeed();
|
||||
multiplier = context.waterWalkSpeed;
|
||||
water = true;
|
||||
}
|
||||
if (optionA != 0 || optionB != 0) {
|
||||
@ -144,7 +144,7 @@ public class MovementDiagonal extends Movement {
|
||||
}
|
||||
} else {
|
||||
// only can sprint if not edging around
|
||||
if (context.canSprint() && !water) {
|
||||
if (context.canSprint && !water) {
|
||||
// If we aren't edging around anything, and we aren't in water
|
||||
// We can sprint =D
|
||||
// Don't check for soul sand, since we can sprint on that too
|
||||
|
@ -48,7 +48,7 @@ public class MovementDownward extends Movement {
|
||||
}
|
||||
|
||||
public static double cost(CalculationContext context, int x, int y, int z) {
|
||||
if (!MovementHelper.canWalkOn(context.bsi(), x, y - 2, z)) {
|
||||
if (!MovementHelper.canWalkOn(context.bsi, x, y - 2, z)) {
|
||||
return COST_INF;
|
||||
}
|
||||
IBlockState down = context.get(x, y - 1, z);
|
||||
|
@ -60,10 +60,10 @@ public class MovementParkour extends Movement {
|
||||
}
|
||||
|
||||
public static void cost(CalculationContext context, int x, int y, int z, EnumFacing dir, MutableMoveResult res) {
|
||||
if (!context.allowParkour()) {
|
||||
if (!context.allowParkour) {
|
||||
return;
|
||||
}
|
||||
if (y == 256 && !context.allowJumpAt256()) {
|
||||
if (y == 256 && !context.allowJumpAt256) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -74,7 +74,7 @@ public class MovementParkour extends Movement {
|
||||
return;
|
||||
}
|
||||
IBlockState adj = context.get(x + xDiff, y - 1, z + zDiff);
|
||||
if (MovementHelper.canWalkOn(context.bsi(), 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)
|
||||
// second most common case -- we could just traverse not parkour
|
||||
return;
|
||||
}
|
||||
@ -98,7 +98,7 @@ public class MovementParkour extends Movement {
|
||||
if (standingOn.getBlock() == Blocks.SOUL_SAND) {
|
||||
maxJump = 2; // 1 block gap
|
||||
} else {
|
||||
if (context.canSprint()) {
|
||||
if (context.canSprint) {
|
||||
maxJump = 4;
|
||||
} else {
|
||||
maxJump = 3;
|
||||
@ -111,18 +111,18 @@ public class MovementParkour extends Movement {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (MovementHelper.canWalkOn(context.bsi(), 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.y = y;
|
||||
res.z = z + zDiff * i;
|
||||
res.cost = costFromJumpDistance(i) + context.jumpPenalty();
|
||||
res.cost = costFromJumpDistance(i) + context.jumpPenalty;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (maxJump != 4) {
|
||||
return;
|
||||
}
|
||||
if (!context.allowParkourPlace()) {
|
||||
if (!context.allowParkourPlace) {
|
||||
return;
|
||||
}
|
||||
int destX = x + 4 * xDiff;
|
||||
@ -131,7 +131,7 @@ public class MovementParkour extends Movement {
|
||||
return;
|
||||
}
|
||||
IBlockState toReplace = context.get(destX, y - 1, destZ);
|
||||
if (!MovementHelper.isReplacable(destX, y - 1, destZ, toReplace, context.bsi())) {
|
||||
if (!MovementHelper.isReplacable(destX, y - 1, destZ, toReplace, context.bsi)) {
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < 5; i++) {
|
||||
@ -141,11 +141,11 @@ public class MovementParkour extends Movement {
|
||||
if (againstX == x + xDiff * 3 && againstZ == z + zDiff * 3) { // we can't turn around that fast
|
||||
continue;
|
||||
}
|
||||
if (MovementHelper.canPlaceAgainst(context.bsi(), againstX, againstY, againstZ)) {
|
||||
if (MovementHelper.canPlaceAgainst(context.bsi, againstX, againstY, againstZ)) {
|
||||
res.x = destX;
|
||||
res.y = y;
|
||||
res.z = destZ;
|
||||
res.cost = costFromJumpDistance(4) + context.placeBlockCost() + context.jumpPenalty();
|
||||
res.cost = costFromJumpDistance(4) + context.placeBlockCost + context.jumpPenalty;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ public class MovementPillar extends Movement {
|
||||
return COST_INF; // can't pillar up from a bottom slab onto a non ladder
|
||||
}
|
||||
}
|
||||
if (from instanceof BlockVine && !hasAgainst(context, x, y, z)) { // TODO this vine can't be climbed, but we could place a pillar still since vines are replacable, no? perhaps the pillar jump would be impossible because of the slowdown actually.
|
||||
if (from == Blocks.VINE && !hasAgainst(context, x, y, z)) { // TODO this vine can't be climbed, but we could place a pillar still since vines are replacable, no? perhaps the pillar jump would be impossible because of the slowdown actually.
|
||||
return COST_INF;
|
||||
}
|
||||
IBlockState toBreak = context.get(x, y + 2, z);
|
||||
@ -76,7 +76,7 @@ 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
|
||||
return COST_INF;
|
||||
}
|
||||
if (from instanceof BlockLiquid || (fromDown.getBlock() instanceof BlockLiquid && context.assumeWalkOnWater())) {
|
||||
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
|
||||
@ -112,7 +112,7 @@ public class MovementPillar extends Movement {
|
||||
if (ladder) {
|
||||
return LADDER_UP_ONE_COST + hardness * 5;
|
||||
} else {
|
||||
return JUMP_ONE_BLOCK_COST + context.placeBlockCost() + context.jumpPenalty() + hardness;
|
||||
return JUMP_ONE_BLOCK_COST + context.placeBlockCost + context.jumpPenalty + hardness;
|
||||
}
|
||||
}
|
||||
|
||||
@ -159,8 +159,8 @@ public class MovementPillar extends Movement {
|
||||
}
|
||||
return state;
|
||||
}
|
||||
boolean ladder = fromDown.getBlock() instanceof BlockLadder || fromDown.getBlock() instanceof BlockVine;
|
||||
boolean vine = fromDown.getBlock() instanceof BlockVine;
|
||||
boolean ladder = fromDown.getBlock() == Blocks.LADDER || fromDown.getBlock() == Blocks.VINE;
|
||||
boolean vine = fromDown.getBlock() == Blocks.VINE;
|
||||
Rotation rotation = RotationUtils.calcRotationFromVec3d(ctx.player().getPositionEyes(1.0F),
|
||||
VecUtils.getBlockPosCenter(positionToPlace),
|
||||
new Rotation(ctx.player().rotationYaw, ctx.player().rotationPitch));
|
||||
|
@ -30,7 +30,10 @@ import baritone.pathing.movement.Movement;
|
||||
import baritone.pathing.movement.MovementHelper;
|
||||
import baritone.pathing.movement.MovementState;
|
||||
import baritone.utils.BlockStateInterface;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockDoor;
|
||||
import net.minecraft.block.BlockFenceGate;
|
||||
import net.minecraft.block.BlockSlab;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
@ -66,17 +69,17 @@ public class MovementTraverse extends Movement {
|
||||
IBlockState pb1 = context.get(destX, y, destZ);
|
||||
IBlockState destOn = context.get(destX, y - 1, destZ);
|
||||
Block srcDown = context.getBlock(x, y - 1, z);
|
||||
if (MovementHelper.canWalkOn(context.bsi(), 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;
|
||||
boolean water = false;
|
||||
if (MovementHelper.isWater(pb0.getBlock()) || MovementHelper.isWater(pb1.getBlock())) {
|
||||
WC = context.waterWalkSpeed();
|
||||
WC = context.waterWalkSpeed;
|
||||
water = true;
|
||||
} else {
|
||||
if (destOn.getBlock() == Blocks.SOUL_SAND) {
|
||||
WC += (WALK_ONE_OVER_SOUL_SAND_COST - WALK_ONE_BLOCK_COST) / 2;
|
||||
} else if (destOn.getBlock() == Blocks.WATER) {
|
||||
WC += context.walkOnWaterOnePenalty();
|
||||
WC += context.walkOnWaterOnePenalty;
|
||||
}
|
||||
if (srcDown == Blocks.SOUL_SAND) {
|
||||
WC += (WALK_ONE_OVER_SOUL_SAND_COST - WALK_ONE_BLOCK_COST) / 2;
|
||||
@ -88,7 +91,7 @@ public class MovementTraverse extends Movement {
|
||||
}
|
||||
double hardness2 = MovementHelper.getMiningDurationTicks(context, destX, y + 1, destZ, pb0, true); // only include falling on the upper block to break
|
||||
if (hardness1 == 0 && hardness2 == 0) {
|
||||
if (!water && context.canSprint()) {
|
||||
if (!water && context.canSprint) {
|
||||
// If there's nothing in the way, and this isn't water, and we aren't sneak placing
|
||||
// We can sprint =D
|
||||
// Don't check for soul sand, since we can sprint on that too
|
||||
@ -105,7 +108,7 @@ public class MovementTraverse extends Movement {
|
||||
if (srcDown == Blocks.LADDER || srcDown == Blocks.VINE) {
|
||||
return COST_INF;
|
||||
}
|
||||
if (MovementHelper.isReplacable(destX, y - 1, destZ, destOn, context.bsi())) {
|
||||
if (MovementHelper.isReplacable(destX, y - 1, destZ, destOn, context.bsi)) {
|
||||
boolean throughWater = MovementHelper.isWater(pb0.getBlock()) || MovementHelper.isWater(pb1.getBlock());
|
||||
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
|
||||
@ -119,7 +122,7 @@ public class MovementTraverse extends Movement {
|
||||
return COST_INF;
|
||||
}
|
||||
double hardness2 = MovementHelper.getMiningDurationTicks(context, destX, y + 1, destZ, pb0, true); // only include falling on the upper block to break
|
||||
double WC = throughWater ? context.waterWalkSpeed() : WALK_ONE_BLOCK_COST;
|
||||
double WC = throughWater ? context.waterWalkSpeed : WALK_ONE_BLOCK_COST;
|
||||
for (int i = 0; i < 5; i++) {
|
||||
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();
|
||||
@ -127,8 +130,8 @@ public class MovementTraverse extends Movement {
|
||||
if (againstX == x && againstZ == z) { // this would be a backplace
|
||||
continue;
|
||||
}
|
||||
if (MovementHelper.canPlaceAgainst(context.bsi(), againstX, againstY, againstZ)) { // found a side place option
|
||||
return WC + context.placeBlockCost() + hardness1 + hardness2;
|
||||
if (MovementHelper.canPlaceAgainst(context.bsi, againstX, againstY, againstZ)) { // found a side place option
|
||||
return WC + context.placeBlockCost + hardness1 + hardness2;
|
||||
}
|
||||
}
|
||||
// now that we've checked all possible directions to side place, we actually need to backplace
|
||||
@ -139,7 +142,7 @@ public class MovementTraverse extends Movement {
|
||||
return COST_INF; // this is obviously impossible
|
||||
}
|
||||
WC = WC * SNEAK_ONE_BLOCK_COST / WALK_ONE_BLOCK_COST;//since we are sneak backplacing, we are sneaking lol
|
||||
return WC + context.placeBlockCost() + hardness1 + hardness2;
|
||||
return WC + context.placeBlockCost + hardness1 + hardness2;
|
||||
}
|
||||
return COST_INF;
|
||||
}
|
||||
@ -183,7 +186,7 @@ public class MovementTraverse extends Movement {
|
||||
state.setInput(Input.SNEAK, false);
|
||||
|
||||
Block fd = BlockStateInterface.get(ctx, src.down()).getBlock();
|
||||
boolean ladder = fd instanceof BlockLadder || fd instanceof BlockVine;
|
||||
boolean ladder = fd == Blocks.LADDER || fd == Blocks.VINE;
|
||||
IBlockState pb0 = BlockStateInterface.get(ctx, positionsToBreak[0]);
|
||||
IBlockState pb1 = BlockStateInterface.get(ctx, positionsToBreak[1]);
|
||||
|
||||
@ -236,7 +239,7 @@ public class MovementTraverse extends Movement {
|
||||
state.setInput(Input.SPRINT, true);
|
||||
}
|
||||
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 == Blocks.VINE || destDown == Blocks.LADDER)) {
|
||||
new MovementPillar(baritone, dest.down(), dest).updateState(state); // i'm sorry
|
||||
return state;
|
||||
}
|
||||
|
@ -374,7 +374,7 @@ public class PathExecutor implements IPathExecutor, Helper {
|
||||
|
||||
private void sprintIfRequested() {
|
||||
// first and foremost, if allowSprint is off, or if we don't have enough hunger, don't try and sprint
|
||||
if (!new CalculationContext(behavior.baritone).canSprint()) {
|
||||
if (!new CalculationContext(behavior.baritone).canSprint) {
|
||||
behavior.baritone.getInputOverrideHandler().setInputForceState(Input.SPRINT, false);
|
||||
ctx.player().setSprinting(false);
|
||||
return;
|
||||
|
@ -154,4 +154,4 @@ public class GetToBlockProcess extends BaritoneProcessHelper implements IGetToBl
|
||||
}
|
||||
return block == Blocks.CRAFTING_TABLE || block == Blocks.FURNACE || block == Blocks.ENDER_CHEST || block == Blocks.CHEST || block == Blocks.TRAPPED_CHEST;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -209,7 +209,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
||||
//long b = System.currentTimeMillis();
|
||||
for (Block m : mining) {
|
||||
if (CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.contains(m)) {
|
||||
locs.addAll(ctx.worldData().getCachedWorld().getLocationsOf(ChunkPacker.blockToString(m), 1, ctx.getBaritone().getPlayerContext().playerFeet().getX(), ctx.getBaritone().getPlayerContext().playerFeet().getZ(), 2));
|
||||
locs.addAll(ctx.worldData.getCachedWorld().getLocationsOf(ChunkPacker.blockToString(m), 1, ctx.getBaritone().getPlayerContext().playerFeet().getX(), ctx.getBaritone().getPlayerContext().playerFeet().getZ(), 2));
|
||||
} else {
|
||||
uninteresting.add(m);
|
||||
}
|
||||
@ -248,17 +248,17 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
||||
}
|
||||
|
||||
public static List<BlockPos> prune(CalculationContext ctx, List<BlockPos> locs2, List<Block> mining, int max) {
|
||||
List<BlockPos> dropped = droppedItemsScan(mining, ctx.world());
|
||||
List<BlockPos> dropped = droppedItemsScan(mining, ctx.world);
|
||||
List<BlockPos> locs = locs2
|
||||
.stream()
|
||||
.distinct()
|
||||
|
||||
// remove any that are within loaded chunks that aren't actually what we want
|
||||
|
||||
.filter(pos -> !ctx.bsi().worldContainsLoadedChunk(pos.getX(), pos.getZ()) || mining.contains(ctx.getBlock(pos.getX(), pos.getY(), pos.getZ())) || dropped.contains(pos))
|
||||
.filter(pos -> !ctx.bsi.worldContainsLoadedChunk(pos.getX(), pos.getZ()) || mining.contains(ctx.getBlock(pos.getX(), pos.getY(), pos.getZ())) || dropped.contains(pos))
|
||||
|
||||
// remove any that are implausible to mine (encased in bedrock, or touching lava)
|
||||
.filter(pos -> MineProcess.plausibleToBreak(ctx.bsi(), pos))
|
||||
.filter(pos -> MineProcess.plausibleToBreak(ctx.bsi, pos))
|
||||
|
||||
.sorted(Comparator.comparingDouble(ctx.getBaritone().getPlayerContext().playerFeet()::distanceSq))
|
||||
.collect(Collectors.toList());
|
||||
|
@ -44,4 +44,4 @@ public class CachedRegionTest {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -167,4 +167,4 @@ public class OpenSetsTest {
|
||||
assertTrue(set.isEmpty());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -47,4 +47,4 @@ public class GoalGetToBlockTest {
|
||||
}
|
||||
assertTrue(acceptableOffsets.toString(), acceptableOffsets.isEmpty());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -48,4 +48,4 @@ public class ActionCostsTest {
|
||||
return fallDistance;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -136,4 +136,4 @@ public class BetterBlockPosTest {
|
||||
long after2 = System.nanoTime() / 1000000L;
|
||||
System.out.println((after1 - before1) + " " + (after2 - before2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,4 +29,4 @@ public class PathingBlockTypeTest {
|
||||
assertTrue(type == PathingBlockType.fromBits(bits[0], bits[1]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user