less indentation
This commit is contained in:
@@ -113,4 +113,6 @@ public interface IGameEventListener {
|
|||||||
* @see NetworkManager#dispatchPacket(Packet, GenericFutureListener[])
|
* @see NetworkManager#dispatchPacket(Packet, GenericFutureListener[])
|
||||||
*/
|
*/
|
||||||
void onReceivePacket(PacketEvent event);
|
void onReceivePacket(PacketEvent event);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,8 +21,6 @@ import baritone.bot.pathing.goals.Goal;
|
|||||||
import baritone.bot.pathing.movement.Movement;
|
import baritone.bot.pathing.movement.Movement;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A node in the path, containing the cost and steps to get to it.
|
* A node in the path, containing the cost and steps to get to it.
|
||||||
*
|
*
|
||||||
@@ -80,6 +78,8 @@ public class PathNode {
|
|||||||
*/
|
*/
|
||||||
public int heapPosition;
|
public int heapPosition;
|
||||||
|
|
||||||
|
public final int hashCode;
|
||||||
|
|
||||||
public PathNode(BlockPos pos, Goal goal) {
|
public PathNode(BlockPos pos, Goal goal) {
|
||||||
this.pos = pos;
|
this.pos = pos;
|
||||||
this.previous = null;
|
this.previous = null;
|
||||||
@@ -88,6 +88,7 @@ public class PathNode {
|
|||||||
this.estimatedCostToGoal = goal.heuristic(pos);
|
this.estimatedCostToGoal = goal.heuristic(pos);
|
||||||
this.previousMovement = null;
|
this.previousMovement = null;
|
||||||
this.isOpen = false;
|
this.isOpen = false;
|
||||||
|
this.hashCode = calcHashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -97,12 +98,25 @@ public class PathNode {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
|
throw new IllegalStateException();
|
||||||
|
}
|
||||||
|
|
||||||
|
private final int calcHashCode() {
|
||||||
|
/*
|
||||||
|
* This is the hashcode implementation of Vec3i, the superclass of BlockPos
|
||||||
|
*
|
||||||
|
* public int hashCode() {
|
||||||
|
* return (this.getY() + this.getZ() * 31) * 31 + this.getX();
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* That is terrible and has tons of collisions and makes the HashMap terribly inefficient.
|
||||||
|
*
|
||||||
|
* That's why we grab out the X, Y, Z and calculate our own hashcode
|
||||||
|
*/
|
||||||
int hash = 3241;
|
int hash = 3241;
|
||||||
hash = 3457689 * hash + this.pos.getX();
|
hash = 3457689 * hash + this.pos.getX();
|
||||||
hash = 8734625 * hash + this.pos.getY();
|
hash = 8734625 * hash + this.pos.getY();
|
||||||
hash = 2873465 * hash + this.pos.getZ();
|
hash = 2873465 * hash + this.pos.getZ();
|
||||||
// Don't call goal.hashCode(). this calls objects hashcode to verify that the actual goal objects are == identical, which is important for node caching
|
|
||||||
hash = 3241543 * hash + Objects.hashCode(this.goal);
|
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -66,8 +66,11 @@ public class MovementDescend extends Movement {
|
|||||||
case WAITING:
|
case WAITING:
|
||||||
state.setStatus(MovementStatus.RUNNING);
|
state.setStatus(MovementStatus.RUNNING);
|
||||||
case RUNNING:
|
case RUNNING:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return state;
|
||||||
|
}
|
||||||
BlockPos playerFeet = playerFeet();
|
BlockPos playerFeet = playerFeet();
|
||||||
|
|
||||||
if (playerFeet.equals(dest)) {
|
if (playerFeet.equals(dest)) {
|
||||||
if (BlockStateInterface.isLiquid(dest) || player().posY - playerFeet.getY() < 0.01) {
|
if (BlockStateInterface.isLiquid(dest) || player().posY - playerFeet.getY() < 0.01) {
|
||||||
// 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
|
||||||
@@ -99,9 +102,5 @@ public class MovementDescend extends Movement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return state;
|
return state;
|
||||||
default:
|
|
||||||
return state;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -59,6 +59,10 @@ public class MovementDownward extends Movement {
|
|||||||
return state;
|
return state;
|
||||||
case WAITING:
|
case WAITING:
|
||||||
case RUNNING:
|
case RUNNING:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return state;
|
||||||
|
}
|
||||||
if (playerFeet().equals(dest)) {
|
if (playerFeet().equals(dest)) {
|
||||||
state.setStatus(MovementState.MovementStatus.SUCCESS);
|
state.setStatus(MovementState.MovementStatus.SUCCESS);
|
||||||
return state;
|
return state;
|
||||||
@@ -72,8 +76,5 @@ public class MovementDownward extends Movement {
|
|||||||
}
|
}
|
||||||
MovementHelper.moveTowards(state, positionsToBreak[0]);
|
MovementHelper.moveTowards(state, positionsToBreak[0]);
|
||||||
return state;
|
return state;
|
||||||
default:
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,6 +74,10 @@ public class MovementFall extends Movement {
|
|||||||
case WAITING:
|
case WAITING:
|
||||||
state.setStatus(MovementStatus.RUNNING);
|
state.setStatus(MovementStatus.RUNNING);
|
||||||
case RUNNING:
|
case RUNNING:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return state;
|
||||||
|
}
|
||||||
BlockPos playerFeet = playerFeet();
|
BlockPos playerFeet = playerFeet();
|
||||||
Optional<Rotation> targetRotation = Optional.empty();
|
Optional<Rotation> targetRotation = Optional.empty();
|
||||||
if (!BlockStateInterface.isWater(dest) && src.getY() - dest.getY() > 3 && !playerFeet.equals(dest)) {
|
if (!BlockStateInterface.isWater(dest) && src.getY() - dest.getY() > 3 && !playerFeet.equals(dest)) {
|
||||||
@@ -109,9 +113,6 @@ public class MovementFall extends Movement {
|
|||||||
state.setInput(InputOverrideHandler.Input.MOVE_FORWARD, true);
|
state.setInput(InputOverrideHandler.Input.MOVE_FORWARD, true);
|
||||||
}
|
}
|
||||||
return state;
|
return state;
|
||||||
default:
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static BlockPos[] buildPositionsToBreak(BlockPos src, BlockPos dest) {
|
private static BlockPos[] buildPositionsToBreak(BlockPos src, BlockPos dest) {
|
||||||
|
|||||||
Reference in New Issue
Block a user