allow smaller parkour place jumps

allows 2 and 1 block parkour place jumps
This commit is contained in:
Harry 2021-06-21 10:58:11 +10:00
parent 199d5d57d5
commit 051325e10f
1 changed files with 30 additions and 30 deletions

View File

@ -124,7 +124,7 @@ public class MovementParkour extends Movement {
return; return;
} }
IBlockState landingOn = context.bsi.get0(destX, y - 1, destZ); IBlockState landingOn = context.bsi.get0(destX, y - 1, destZ);
// farmland needs to be canwalkon otherwise farm can never work at all, but we want to specifically disallow ending a jumy on farmland haha // farmland needs to be canWalkOn otherwise farm can never work at all, but we want to specifically disallow ending a jump on farmland haha
if (landingOn.getBlock() != Blocks.FARMLAND && MovementHelper.canWalkOn(context.bsi, destX, y - 1, destZ, landingOn)) { if (landingOn.getBlock() != Blocks.FARMLAND && MovementHelper.canWalkOn(context.bsi, destX, y - 1, destZ, landingOn)) {
if (checkOvershootSafety(context.bsi, destX + xDiff, y, destZ + zDiff)) { if (checkOvershootSafety(context.bsi, destX + xDiff, y, destZ + zDiff)) {
res.x = destX; res.x = destX;
@ -138,30 +138,29 @@ public class MovementParkour extends Movement {
return; return;
} }
} }
if (maxJump != 4) { // parkour place starts here
return;
}
if (!context.allowParkourPlace) { if (!context.allowParkourPlace) {
return; return;
} }
// time 2 pop off with that dank skynet parkour place // check parkour jumps from largest to smallest
int destX = x + 4 * xDiff; for (int i = maxJump; i > 1; i--) {
int destZ = z + 4 * zDiff; int destX = x + i * xDiff;
int destZ = z + i * zDiff;
IBlockState toReplace = context.get(destX, y - 1, destZ); IBlockState toReplace = context.get(destX, y - 1, destZ);
double placeCost = context.costOfPlacingAt(destX, y - 1, destZ, toReplace); double placeCost = context.costOfPlacingAt(destX, y - 1, destZ, toReplace);
if (placeCost >= COST_INF) { if (placeCost >= COST_INF) {
return; continue;
} }
if (!MovementHelper.isReplaceable(destX, y - 1, destZ, toReplace, context.bsi)) { if (!MovementHelper.isReplaceable(destX, y - 1, destZ, toReplace, context.bsi)) {
return; continue;
} }
if (!checkOvershootSafety(context.bsi, destX + xDiff, y, destZ + zDiff)) { if (!checkOvershootSafety(context.bsi, destX + xDiff, y, destZ + zDiff)) {
return; continue;
} }
for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) {
int againstX = destX + HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP[i].getXOffset(); int againstX = destX + HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP[j].getXOffset();
int againstY = y - 1 + HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP[i].getYOffset(); int againstY = y - 1 + HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP[j].getYOffset();
int againstZ = destZ + HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP[i].getZOffset(); int againstZ = destZ + HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP[j].getZOffset();
if (againstX == x + xDiff * 3 && againstZ == z + zDiff * 3) { // we can't turn around that fast if (againstX == x + xDiff * 3 && againstZ == z + zDiff * 3) { // we can't turn around that fast
continue; continue;
} }
@ -169,11 +168,12 @@ public class MovementParkour extends Movement {
res.x = destX; res.x = destX;
res.y = y; res.y = y;
res.z = destZ; res.z = destZ;
res.cost = costFromJumpDistance(4) + placeCost + context.jumpPenalty; res.cost = costFromJumpDistance(i) + placeCost + context.jumpPenalty;
return; return;
} }
} }
} }
}
private static boolean checkOvershootSafety(BlockStateInterface bsi, int x, int y, int z) { private static boolean checkOvershootSafety(BlockStateInterface bsi, int x, int y, int z) {
// we're going to walk into these two blocks after the landing of the parkour anyway, so make sure they aren't avoidWalkingInto // we're going to walk into these two blocks after the landing of the parkour anyway, so make sure they aren't avoidWalkingInto