sprinting yay

This commit is contained in:
Leijurv 2018-08-13 13:40:50 -07:00
parent 5acb86e390
commit 532d4d1f31
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
2 changed files with 20 additions and 6 deletions

View File

@ -81,10 +81,10 @@ public class MovementDiagonal extends Movement {
if (!MovementHelper.canWalkOn(positionsToPlace[0], destWalkOn)) { if (!MovementHelper.canWalkOn(positionsToPlace[0], destWalkOn)) {
return COST_INF; return COST_INF;
} }
double multiplier = 1; double multiplier = WALK_ONE_BLOCK_COST;
if (destWalkOn.getBlock().equals(Blocks.SOUL_SAND)) { if (destWalkOn.getBlock().equals(Blocks.SOUL_SAND)) {
multiplier *= WALK_ONE_IN_WATER_COST / WALK_ONE_BLOCK_COST; multiplier *= WALK_ONE_IN_WATER_COST / WALK_ONE_BLOCK_COST;
} else if (BlockStateInterface.get(src).getBlock().equals(Blocks.SOUL_SAND)) { } else if (BlockStateInterface.get(src.down()).getBlock().equals(Blocks.SOUL_SAND)) {
multiplier *= WALK_ONE_IN_WATER_COST / WALK_ONE_BLOCK_COST; multiplier *= WALK_ONE_IN_WATER_COST / WALK_ONE_BLOCK_COST;
} }
if (BlockStateInterface.get(positionsToBreak[2].down()).getBlock() instanceof BlockMagma) { if (BlockStateInterface.get(positionsToBreak[2].down()).getBlock() instanceof BlockMagma) {
@ -117,7 +117,15 @@ public class MovementDiagonal extends Movement {
if (optionA != 0 || optionB != 0) { if (optionA != 0 || optionB != 0) {
multiplier *= SQRT_2 - 0.001; // TODO tune multiplier *= SQRT_2 - 0.001; // TODO tune
} }
return multiplier * SQRT_2 * (BlockStateInterface.isWater(src) || BlockStateInterface.isWater(dest) ? WALK_ONE_IN_WATER_COST : WALK_ONE_BLOCK_COST); if (BlockStateInterface.isWater(src) || BlockStateInterface.isWater(dest)) {
multiplier *= WALK_ONE_IN_WATER_COST / WALK_ONE_BLOCK_COST;
}
if (multiplier == WALK_ONE_BLOCK_COST) {
// if we aren't edging around anything, and we aren't in water or soul sand
// we can sprint =D
multiplier = SPRINT_ONE_BLOCK_COST;
}
return multiplier * SQRT_2;
} }
@Override @Override

View File

@ -68,13 +68,18 @@ public class MovementTraverse extends Movement {
protected double calculateCost(CalculationContext context) { protected double calculateCost(CalculationContext context) {
IBlockState pb0 = BlockStateInterface.get(positionsToBreak[0]); IBlockState pb0 = BlockStateInterface.get(positionsToBreak[0]);
IBlockState pb1 = BlockStateInterface.get(positionsToBreak[1]); IBlockState pb1 = BlockStateInterface.get(positionsToBreak[1]);
double WC = BlockStateInterface.isWater(pb0.getBlock()) || BlockStateInterface.isWater(pb1.getBlock()) ? WALK_ONE_IN_WATER_COST : WALK_ONE_BLOCK_COST;
IBlockState destOn = BlockStateInterface.get(positionsToPlace[0]); IBlockState destOn = BlockStateInterface.get(positionsToPlace[0]);
if (MovementHelper.canWalkOn(positionsToPlace[0], destOn)) {//this is a walk, not a bridge if (MovementHelper.canWalkOn(positionsToPlace[0], destOn)) {//this is a walk, not a bridge
double WC = BlockStateInterface.isWater(pb0.getBlock()) || BlockStateInterface.isWater(pb1.getBlock()) ? WALK_ONE_IN_WATER_COST : WALK_ONE_BLOCK_COST;
if (destOn.getBlock().equals(Blocks.SOUL_SAND)) { if (destOn.getBlock().equals(Blocks.SOUL_SAND)) {
WC *= SNEAK_ONE_BLOCK_COST / WALK_ONE_BLOCK_COST; WC *= WALK_ONE_IN_WATER_COST / WALK_ONE_BLOCK_COST;
} }
if (MovementHelper.canWalkThrough(positionsToBreak[0]) && MovementHelper.canWalkThrough(positionsToBreak[1])) { if (MovementHelper.canWalkThrough(positionsToBreak[0]) && MovementHelper.canWalkThrough(positionsToBreak[1])) {
if (WC == WALK_ONE_BLOCK_COST) {
// if there's nothing in the way, and this isn't water or soul sand, and we aren't sneak placing
// we can sprint =D
WC = SPRINT_ONE_BLOCK_COST;
}
return WC; return WC;
} }
//double hardness1 = blocksToBreak[0].getBlockHardness(Minecraft.getMinecraft().world, positionsToBreak[0]); //double hardness1 = blocksToBreak[0].getBlockHardness(Minecraft.getMinecraft().world, positionsToBreak[0]);
@ -92,6 +97,7 @@ public class MovementTraverse extends Movement {
if (!context.hasThrowaway()) { if (!context.hasThrowaway()) {
return COST_INF; return COST_INF;
} }
double WC = BlockStateInterface.isWater(pb0.getBlock()) || BlockStateInterface.isWater(pb1.getBlock()) ? WALK_ONE_IN_WATER_COST : WALK_ONE_BLOCK_COST;
for (BlockPos against1 : against) { for (BlockPos against1 : against) {
if (BlockStateInterface.get(against1).isBlockNormalCube()) { if (BlockStateInterface.get(against1).isBlockNormalCube()) {
return WC + PLACE_ONE_BLOCK_COST + getTotalHardnessOfBlocksToBreak(context.getToolSet()); return WC + PLACE_ONE_BLOCK_COST + getTotalHardnessOfBlocksToBreak(context.getToolSet());