Skip to content

Commit

Permalink
Slight cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexProgrammerDE committed Apr 4, 2024
1 parent 39ff823 commit dd67809
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 23 deletions.
17 changes: 0 additions & 17 deletions server/src/main/java/com/soulfiremc/server/pathfinding/Costs.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,23 +110,6 @@ public class Costs {
public static final BlockState SOLID_PLACED_BLOCK_STATE =
BlockState.forDefaultBlockType(BlockType.STONE);

public static void main(String[] args) {
var y = 0d;
for (var i = 0; i < 32; i++) {
var acceleration = getAcceleration(i);
System.out.println(i + " acc: " + getAcceleration(i) + " y: " + y);
y += acceleration;
}
}

public static double getAcceleration(double ticks) {
if (ticks == 0) {
return 0.42;
}

return (getAcceleration(ticks - 1) - 0.08) * 0.98;
}

private Costs() {}

public static BlockMiningCosts calculateBlockBreakCost(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ public SimpleMovement(MovementDirection direction, MovementSide side, MovementMo

this.cost =
(diagonal ? Costs.DIAGONAL : Costs.STRAIGHT)
// Add additional "discouraged" costs to prevent the bot from
// doing too much parkour
// Add mdoifier costs
// Jump up block gets a tiny bit extra (you can move midair)
// But that's fine since we also want to slightly discourage jumping up
+ switch (modifier) {
case NORMAL -> 0;
case FALL_1 -> Costs.FALL_1;
Expand All @@ -86,10 +87,10 @@ public SimpleMovement(MovementDirection direction, MovementSide side, MovementMo

this.targetFeetBlock = modifier.offset(direction.offset(FEET_POSITION_RELATIVE_BLOCK));
this.allowBlockActions =
!diagonal
&& (modifier == MovementModifier.JUMP_UP_BLOCK
|| modifier == MovementModifier.NORMAL
|| modifier == MovementModifier.FALL_1);
!diagonal && switch (modifier) {
case JUMP_UP_BLOCK, NORMAL, FALL_1 -> true;
default -> false;
};

if (allowBlockActions) {
blockBreakCosts = new MovementMiningCost[freeCapacity()];
Expand Down

0 comments on commit dd67809

Please sign in to comment.