Merge branch 'master' into segment-calculation

This commit is contained in:
Leijurv 2018-11-23 13:09:57 -08:00
commit 002c678b4a
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
7 changed files with 17 additions and 26 deletions

View File

@ -247,7 +247,9 @@ public class Settings {
public Setting<Integer> movementTimeoutTicks = new Setting<>(100); public Setting<Integer> movementTimeoutTicks = new Setting<>(100);
/** /**
* Pathing ends after this amount of time, if a path has been found * Pathing ends after this amount of time, but only if a path has been found
* <p>
* If no valid path (length above the minimum) has been found, pathing continues up until the failure timeout
*/ */
public Setting<Long> primaryTimeoutMS = new Setting<>(500L); public Setting<Long> primaryTimeoutMS = new Setting<>(500L);
@ -257,7 +259,9 @@ public class Settings {
public Setting<Long> failureTimeoutMS = new Setting<>(2000L); public Setting<Long> failureTimeoutMS = new Setting<>(2000L);
/** /**
* Planning ahead while executing a segment ends after this amount of time, if a path has been found * Planning ahead while executing a segment ends after this amount of time, but only if a path has been found
* <p>
* If no valid path (length above the minimum) has been found, pathing continues up until the failure timeout
*/ */
public Setting<Long> planAheadPrimaryTimeoutMS = new Setting<>(4000L); public Setting<Long> planAheadPrimaryTimeoutMS = new Setting<>(4000L);

View File

@ -17,10 +17,7 @@
package baritone.api.pathing.goals; package baritone.api.pathing.goals;
import net.minecraft.util.math.BlockPos;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection;
/** /**
* A composite of many goals, any one of which satisfies the composite. * A composite of many goals, any one of which satisfies the composite.
@ -40,14 +37,6 @@ public class GoalComposite implements Goal {
this.goals = goals; this.goals = goals;
} }
public GoalComposite(BlockPos... blocks) {
this(Arrays.asList(blocks));
}
public GoalComposite(Collection<BlockPos> blocks) {
this(blocks.stream().map(GoalBlock::new).toArray(Goal[]::new));
}
@Override @Override
public boolean isInGoal(int x, int y, int z) { public boolean isInGoal(int x, int y, int z) {
for (Goal goal : goals) { for (Goal goal : goals) {

View File

@ -48,10 +48,7 @@ public class GoalGetToBlock implements Goal, IGoalRenderPos {
int xDiff = x - this.x; int xDiff = x - this.x;
int yDiff = y - this.y; int yDiff = y - this.y;
int zDiff = z - this.z; int zDiff = z - this.z;
if (yDiff < 0) { return Math.abs(xDiff) + Math.abs(yDiff < 0 ? yDiff + 1 : yDiff) + Math.abs(zDiff) <= 1;
yDiff++;
}
return Math.abs(xDiff) + Math.abs(yDiff) + Math.abs(zDiff) <= 1;
} }
@Override @Override
@ -59,7 +56,7 @@ public class GoalGetToBlock implements Goal, IGoalRenderPos {
int xDiff = x - this.x; int xDiff = x - this.x;
int yDiff = y - this.y; int yDiff = y - this.y;
int zDiff = z - this.z; int zDiff = z - this.z;
return GoalBlock.calculate(xDiff, yDiff, zDiff); return GoalBlock.calculate(xDiff, yDiff < 0 ? yDiff + 1 : yDiff, zDiff);
} }
@Override @Override

View File

@ -63,10 +63,7 @@ public class GoalTwoBlocks implements Goal, IGoalRenderPos {
int xDiff = x - this.x; int xDiff = x - this.x;
int yDiff = y - this.y; int yDiff = y - this.y;
int zDiff = z - this.z; int zDiff = z - this.z;
if (yDiff < 0) { return GoalBlock.calculate(xDiff, yDiff < 0 ? yDiff + 1 : yDiff, zDiff);
yDiff++;
}
return GoalBlock.calculate(xDiff, yDiff, zDiff);
} }
@Override @Override

View File

@ -40,7 +40,10 @@ import baritone.utils.PathRenderer;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.chunk.EmptyChunk; import net.minecraft.world.chunk.EmptyChunk;
import java.util.*; import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashSet;
import java.util.Optional;
import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.LinkedBlockingQueue;
import java.util.stream.Collectors; import java.util.stream.Collectors;

View File

@ -92,7 +92,8 @@ public final class ChunkPacker {
for (int z = 0; z < 16; z++) { for (int z = 0; z < 16; z++) {
// @formatter:off // @formatter:off
https://www.ibm.com/developerworks/library/j-perry-writing-good-java-code/index.html https:
//www.ibm.com/developerworks/library/j-perry-writing-good-java-code/index.html
// @formatter:on // @formatter:on
for (int x = 0; x < 16; x++) { for (int x = 0; x < 16; x++) {
for (int y = 255; y >= 0; y--) { for (int y = 255; y >= 0; y--) {
@ -124,7 +125,7 @@ public final class ChunkPacker {
private static PathingBlockType getPathingBlockType(IBlockState state) { private static PathingBlockType getPathingBlockType(IBlockState state) {
Block block = state.getBlock(); Block block = state.getBlock();
if (block.equals(Blocks.WATER) && !MovementHelper.isFlowing(state)) { if (block == Blocks.WATER && !MovementHelper.isFlowing(state)) {
// only water source blocks are plausibly usable, flowing water should be avoid // only water source blocks are plausibly usable, flowing water should be avoid
return PathingBlockType.WATER; return PathingBlockType.WATER;
} }

View File

@ -88,7 +88,7 @@ public abstract class AbstractNodeCostSearch implements IPathFinder {
if (isFinished) { if (isFinished) {
throw new IllegalStateException("Path Finder is currently in use, and cannot be reused!"); throw new IllegalStateException("Path Finder is currently in use, and cannot be reused!");
} }
this.cancelRequested = false; cancelRequested = false;
try { try {
IPath path = calculate0(primaryTimeout, failureTimeout).map(IPath::postProcess).orElse(null); IPath path = calculate0(primaryTimeout, failureTimeout).map(IPath::postProcess).orElse(null);
isFinished = true; isFinished = true;