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