misc cleanup 3
This commit is contained in:
parent
e75d0ff102
commit
af58304b38
@ -23,13 +23,18 @@ public final class TickEvent {
|
||||
|
||||
private final EventState state;
|
||||
private final Type type;
|
||||
private final int count;
|
||||
|
||||
private static int count;
|
||||
private static int overallTickCount;
|
||||
|
||||
public TickEvent(EventState state, Type type) {
|
||||
this.state = state;
|
||||
this.type = type;
|
||||
count++;
|
||||
this.count = incrementCount();
|
||||
}
|
||||
|
||||
private static synchronized int incrementCount() {
|
||||
return overallTickCount++;
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
|
@ -168,7 +168,7 @@ public final class MineBehavior extends Behavior implements Helper {
|
||||
.filter(pos -> !mining.contains(BlockStateInterface.get(pos).getBlock()))
|
||||
.collect(Collectors.toList()));
|
||||
if (locs.size() > max) {
|
||||
locs = locs.subList(0, max);
|
||||
return locs.subList(0, max);
|
||||
}
|
||||
return locs;
|
||||
}
|
||||
|
10
src/main/java/baritone/cache/ChunkPacker.java
vendored
10
src/main/java/baritone/cache/ChunkPacker.java
vendored
@ -91,8 +91,7 @@ public final class ChunkPacker implements Helper {
|
||||
//System.out.println("Chunk packing took " + (end - start) + "ms for " + chunk.x + "," + chunk.z);
|
||||
String[] blockNames = new String[256];
|
||||
for (int z = 0; z < 16; z++) {
|
||||
https:
|
||||
//www.ibm.com/developerworks/library/j-perry-writing-good-java-code/index.html
|
||||
https://www.ibm.com/developerworks/library/j-perry-writing-good-java-code/index.html
|
||||
for (int x = 0; x < 16; x++) {
|
||||
for (int y = 255; y >= 0; y--) {
|
||||
int index = CachedChunk.getPositionIndex(x, y, z);
|
||||
@ -119,10 +118,7 @@ public final class ChunkPacker implements Helper {
|
||||
}
|
||||
|
||||
public static Block stringToBlock(String name) {
|
||||
if (!name.contains(":")) {
|
||||
name = "minecraft:" + name;
|
||||
}
|
||||
return Block.getBlockFromName(name);
|
||||
return Block.getBlockFromName(name.contains(":") ? name : "minecraft:" + name);
|
||||
}
|
||||
|
||||
private static PathingBlockType getPathingBlockType(IBlockState state) {
|
||||
@ -146,7 +142,7 @@ public final class ChunkPacker implements Helper {
|
||||
return PathingBlockType.SOLID;
|
||||
}
|
||||
|
||||
static IBlockState pathingTypeToBlock(PathingBlockType type) {
|
||||
public static IBlockState pathingTypeToBlock(PathingBlockType type) {
|
||||
if (type != null) {
|
||||
switch (type) {
|
||||
case AIR:
|
||||
|
@ -38,22 +38,22 @@ class Path implements IPath {
|
||||
/**
|
||||
* The start position of this path
|
||||
*/
|
||||
final BetterBlockPos start;
|
||||
private final BetterBlockPos start;
|
||||
|
||||
/**
|
||||
* The end position of this path
|
||||
*/
|
||||
final BetterBlockPos end;
|
||||
private final BetterBlockPos end;
|
||||
|
||||
/**
|
||||
* The blocks on the path. Guaranteed that path.get(0) equals start and
|
||||
* path.get(path.size()-1) equals end
|
||||
*/
|
||||
final List<BetterBlockPos> path;
|
||||
private final List<BetterBlockPos> path;
|
||||
|
||||
final List<Movement> movements;
|
||||
private final List<Movement> movements;
|
||||
|
||||
final Goal goal;
|
||||
private final Goal goal;
|
||||
|
||||
private final int numNodes;
|
||||
|
||||
|
@ -17,9 +17,10 @@
|
||||
|
||||
package baritone.pathing.goals;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
/**
|
||||
* A composite of many goals, any one of which satisfies the composite.
|
||||
@ -33,7 +34,7 @@ public class GoalComposite implements Goal {
|
||||
/**
|
||||
* An array of goals that any one of must be satisfied
|
||||
*/
|
||||
public final Goal[] goals;
|
||||
private final Goal[] goals;
|
||||
|
||||
public GoalComposite(Goal... goals) {
|
||||
this.goals = goals;
|
||||
|
@ -21,10 +21,10 @@ import baritone.utils.interfaces.IGoalRenderPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public class GoalNear implements Goal, IGoalRenderPos {
|
||||
final int x;
|
||||
final int y;
|
||||
final int z;
|
||||
final int rangeSq;
|
||||
private final int x;
|
||||
private final int y;
|
||||
private final int z;
|
||||
private final int rangeSq;
|
||||
|
||||
public GoalNear(BlockPos pos, int range) {
|
||||
this.x = pos.getX();
|
||||
|
@ -28,9 +28,9 @@ import java.util.Arrays;
|
||||
*/
|
||||
public class GoalRunAway implements Goal {
|
||||
|
||||
public final BlockPos[] from;
|
||||
private final BlockPos[] from;
|
||||
|
||||
final double distanceSq;
|
||||
private final double distanceSq;
|
||||
|
||||
public GoalRunAway(double distance, BlockPos... from) {
|
||||
if (from.length == 0) {
|
||||
|
@ -45,7 +45,7 @@ public class GoalYLevel implements Goal {
|
||||
return calculate(level, pos.getY());
|
||||
}
|
||||
|
||||
static double calculate(int goalY, int currentY) {
|
||||
public static double calculate(int goalY, int currentY) {
|
||||
if (currentY > goalY) {
|
||||
// need to descend
|
||||
return FALL_N_BLOCKS_COST[2] / 2 * (currentY - goalY);
|
||||
|
@ -57,16 +57,15 @@ public interface ActionCostsButOnlyTheOnesThatMakeMickeyDieInside {
|
||||
if (distance == 0) {
|
||||
return 0; // Avoid 0/0 NaN
|
||||
}
|
||||
double tmpDistance = distance;
|
||||
int tickCount = 0;
|
||||
while (true) {
|
||||
double fallDistance = velocity(tickCount);
|
||||
if (distance <= fallDistance) {
|
||||
return tickCount + distance / fallDistance;
|
||||
if (tmpDistance <= fallDistance) {
|
||||
return tickCount + tmpDistance / fallDistance;
|
||||
}
|
||||
distance -= fallDistance;
|
||||
tmpDistance -= fallDistance;
|
||||
tickCount++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -72,10 +72,7 @@ public abstract class Movement implements Helper, MovementHelper {
|
||||
|
||||
public double getCost(CalculationContext context) {
|
||||
if (cost == null) {
|
||||
if (context == null) {
|
||||
context = new CalculationContext();
|
||||
}
|
||||
cost = calculateCost(context);
|
||||
cost = calculateCost(context != null ? context : new CalculationContext());
|
||||
}
|
||||
return cost;
|
||||
}
|
||||
|
@ -438,15 +438,15 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
if (canWalkThrough(onto, ontoBlock)) {
|
||||
continue;
|
||||
}
|
||||
if (canWalkOn(onto, ontoBlock)) {
|
||||
if ((calcContext.hasWaterBucket() && fallHeight <= calcContext.maxFallHeightBucket() + 1) || fallHeight <= calcContext.maxFallHeightNoWater() + 1) {
|
||||
// fallHeight = 4 means onto.up() is 3 blocks down, which is the max
|
||||
return new MovementFall(pos, onto.up());
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
if (!canWalkOn(onto, ontoBlock)) {
|
||||
break;
|
||||
}
|
||||
if ((calcContext.hasWaterBucket() && fallHeight <= calcContext.maxFallHeightBucket() + 1) || fallHeight <= calcContext.maxFallHeightNoWater() + 1) {
|
||||
// fallHeight = 4 means onto.up() is 3 blocks down, which is the max
|
||||
return new MovementFall(pos, onto.up());
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -31,6 +31,8 @@ import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public class MovementDescend extends Movement {
|
||||
|
||||
private int numTicks = 0;
|
||||
|
||||
public MovementDescend(BetterBlockPos start, BetterBlockPos end) {
|
||||
super(start, end, new BlockPos[]{end.up(2), end.up(), end}, end.down());
|
||||
}
|
||||
@ -63,8 +65,6 @@ public class MovementDescend extends Movement {
|
||||
return walk + Math.max(FALL_N_BLOCKS_COST[1], CENTER_AFTER_FALL_COST) + getTotalHardnessOfBlocksToBreak(context);
|
||||
}
|
||||
|
||||
int numTicks = 0;
|
||||
|
||||
@Override
|
||||
public MovementState updateState(MovementState state) {
|
||||
super.updateState(state);
|
||||
|
@ -38,11 +38,10 @@ import net.minecraft.util.math.Vec3d;
|
||||
import java.util.Objects;
|
||||
|
||||
public class MovementParkour extends Movement {
|
||||
protected 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 EnumFacing[] HORIZONTALS_BUT_ALSO_DOWN_SO_EVERY_DIRECTION_EXCEPT_UP = {EnumFacing.NORTH, EnumFacing.SOUTH, EnumFacing.EAST, EnumFacing.WEST, EnumFacing.DOWN};
|
||||
|
||||
|
||||
final EnumFacing direction;
|
||||
final int dist;
|
||||
private final EnumFacing direction;
|
||||
private final int dist;
|
||||
|
||||
private MovementParkour(BetterBlockPos src, int dist, EnumFacing dir) {
|
||||
super(src, src.offset(dir, dist), new BlockPos[]{});
|
||||
|
@ -26,13 +26,13 @@ import java.util.List;
|
||||
|
||||
public class CutoffPath implements IPath {
|
||||
|
||||
final List<BetterBlockPos> path;
|
||||
private final List<BetterBlockPos> path;
|
||||
|
||||
final List<Movement> movements;
|
||||
private final List<Movement> movements;
|
||||
|
||||
private final int numNodes;
|
||||
|
||||
final Goal goal;
|
||||
private final Goal goal;
|
||||
|
||||
public CutoffPath(IPath prev, int lastPositionToInclude) {
|
||||
path = prev.positions().subList(0, lastPositionToInclude + 1);
|
||||
|
@ -49,8 +49,6 @@ import java.util.Map;
|
||||
*/
|
||||
public final class InputOverrideHandler implements Helper {
|
||||
|
||||
public InputOverrideHandler() {}
|
||||
|
||||
/**
|
||||
* Maps keybinds to whether or not we are forcing their state down.
|
||||
*/
|
||||
|
@ -41,11 +41,6 @@ public class ToolSet implements Helper {
|
||||
*/
|
||||
private Map<Block, Double> breakStrengthCache = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Create a toolset from the current player's inventory (but don't calculate any hardness values just yet)
|
||||
*/
|
||||
public ToolSet() {}
|
||||
|
||||
/**
|
||||
* Calculate which tool on the hotbar is best for mining
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user