Skip to content

Commit

Permalink
Dropping modification
Browse files Browse the repository at this point in the history
  • Loading branch information
HexatomicRing committed Nov 5, 2024
1 parent 2e1aed7 commit 46e06eb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class PathingOptions
/**
* Maximum cost used
*/
public static final int MAX_COST = 25;
public static final int MAX_COST = 100;

/**
* Additional cost of jumping
Expand All @@ -22,6 +22,11 @@ public class PathingOptions
*/
public double dropCost = 1D;

/**
* Additional cost of dropping damage
*/
public double dropDamage = 25D;

/**
* Cost improvement of paths - base 1.
*/
Expand All @@ -30,22 +35,22 @@ public class PathingOptions
/**
* Cost improvement of paths - base 1.
*/
public double onRailCost = 1 / 10d;
public double onRailCost = 1 / 10D;

/**
* The rails exit cost.
* The cost to open a door.
*/
public double openDoorCost = 4;

/**
* The rails exit cost.
*/
public double railsExitCost = 8d;
public double railsExitCost = 4;

/**
* Additional cost of swimming - base 1.
*/
public double swimCost = 2D;
public double swimCost = 4D;

/**
* Additional cost of cave air.
Expand All @@ -55,7 +60,7 @@ public class PathingOptions
/**
* Additional cost enter entering water
*/
public double swimCostEnter = 24D;
public double swimCostEnter = 4D;

/**
* Cost to traverse trap doors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,7 @@ else if (!node.isCornerNode() && newY - node.y < 0 && (dX != 0 || dZ != 0) &&
final BlockState aboveState = cachedBlockLookup.getBlockState(nextX, nextY + 1, nextZ);
final BlockState state = cachedBlockLookup.getBlockState(nextX, nextY, nextZ);
final BlockState belowState = cachedBlockLookup.getBlockState(nextX, nextY - 1, nextZ);
final BlockState lastState = cachedBlockLookup.getBlockState(node.x, node.y, node.z);

final boolean isSwimming = calculateSwimming(belowState, state, aboveState, nextNode);
if (isSwimming && !pathingOptions.canSwim())
Expand Down Expand Up @@ -763,7 +764,7 @@ else if (!node.isCornerNode() && newY - node.y < 0 && (dX != 0 || dZ != 0) &&
costFrom = node.parent;
}

nextCost = computeCost(costFrom, dX, dY, dZ, isSwimming, onRoad, isDiving, onRails, railsExit, swimStart, ladder, state, belowState, nextX, nextY, nextZ);
nextCost = computeCost(costFrom, dX, dY, dZ, isSwimming, onRoad, isDiving, onRails, railsExit, swimStart, ladder, state, belowState, lastState, nextX, nextY, nextZ);
nextCost = modifyCost(nextCost, costFrom, swimStart, isSwimming, nextX, nextY, nextZ, state, belowState);

if (nextCost > maxCost)
Expand Down Expand Up @@ -891,7 +892,7 @@ protected double computeCost(
final boolean railsExit,
final boolean swimStart,
final boolean ladder,
final BlockState state, final BlockState below,
final BlockState state, final BlockState below, final BlockState last,
final int x, final int y, final int z)
{
double cost = 1;
Expand Down Expand Up @@ -937,9 +938,16 @@ protected double computeCost(
{
cost += pathingOptions.jumpCost;
}
else if (pathingOptions.dropCost != 0)
//else if (pathingOptions.dropCost != 0)
//{
// cost += pathingOptions.dropCost * Math.abs(dY * dY * dY);
//}
if(dY < -3.375 && pathingOptions.dropDamage != 0)
{
cost += pathingOptions.dropCost * Math.abs(dY * dY * dY);
//Avoid falling damage.
if(!PathfindingUtils.isWater(world, null, below, null)){
cost += pathingOptions.dropDamage * (-dY - 3.375);
}
}
}
}
Expand Down Expand Up @@ -993,7 +1001,7 @@ else if (!ShapeUtil.isEmpty(state.getCollisionShape(cachedBlockLookup, tempWorld
if(controlled)
{
if(targetState) cost += pathingOptions.openDoorCost;
else cost += 1000; //This is a trap!!!
else cost += 100; //This is a trap!!!
}
else if(open != targetState)
{
Expand Down

0 comments on commit 46e06eb

Please sign in to comment.