fix infinite recalc when jumping over flowing water

This commit is contained in:
Leijurv 2018-09-11 19:39:47 -07:00
parent 0412298555
commit 3afc77bc9a
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A

View File

@ -25,6 +25,7 @@ import baritone.pathing.movement.MovementState;
import baritone.utils.BlockStateInterface; import baritone.utils.BlockStateInterface;
import baritone.utils.InputOverrideHandler; import baritone.utils.InputOverrideHandler;
import baritone.utils.pathing.BetterBlockPos; import baritone.utils.pathing.BetterBlockPos;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
@ -43,6 +44,7 @@ public class MovementParkour extends Movement {
} }
public static MovementParkour generate(BetterBlockPos src, EnumFacing dir) { public static MovementParkour generate(BetterBlockPos src, EnumFacing dir) {
// MUST BE KEPT IN SYNC WITH calculateCost
if (!Baritone.settings().allowParkour.get()) { if (!Baritone.settings().allowParkour.get()) {
return null; return null;
} }
@ -101,10 +103,12 @@ public class MovementParkour extends Movement {
@Override @Override
protected double calculateCost(CalculationContext context) { protected double calculateCost(CalculationContext context) {
// MUST BE KEPT IN SYNC WITH generate
if (!MovementHelper.canWalkOn(dest.down())) { if (!MovementHelper.canWalkOn(dest.down())) {
return COST_INF; return COST_INF;
} }
if (MovementHelper.avoidWalkingInto(BlockStateInterface.get(src.down().offset(direction)).getBlock())) { Block walkOff = BlockStateInterface.get(src.down().offset(direction)).getBlock();
if (MovementHelper.avoidWalkingInto(walkOff) && walkOff != Blocks.WATER && walkOff != Blocks.FLOWING_WATER) {
return COST_INF; return COST_INF;
} }
for (int i = 1; i <= 4; i++) { for (int i = 1; i <= 4; i++) {