Merge branch 'master' into 1.13.2
This commit is contained in:
@@ -325,6 +325,7 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
|
|||||||
|
|
||||||
public void softCancelIfSafe() {
|
public void softCancelIfSafe() {
|
||||||
synchronized (pathPlanLock) {
|
synchronized (pathPlanLock) {
|
||||||
|
getInProgress().ifPresent(AbstractNodeCostSearch::cancel); // only cancel ours
|
||||||
if (!isSafeToCancel()) {
|
if (!isSafeToCancel()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -332,7 +333,6 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
|
|||||||
next = null;
|
next = null;
|
||||||
}
|
}
|
||||||
cancelRequested = true;
|
cancelRequested = true;
|
||||||
getInProgress().ifPresent(AbstractNodeCostSearch::cancel); // only cancel ours
|
|
||||||
// do everything BUT clear keys
|
// do everything BUT clear keys
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -340,11 +340,11 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
|
|||||||
public void secretInternalSegmentCancel() {
|
public void secretInternalSegmentCancel() {
|
||||||
queuePathEvent(PathEvent.CANCELED);
|
queuePathEvent(PathEvent.CANCELED);
|
||||||
synchronized (pathPlanLock) {
|
synchronized (pathPlanLock) {
|
||||||
|
getInProgress().ifPresent(AbstractNodeCostSearch::cancel);
|
||||||
if (current != null) {
|
if (current != null) {
|
||||||
current = null;
|
current = null;
|
||||||
next = null;
|
next = null;
|
||||||
baritone.getInputOverrideHandler().clearAllKeys();
|
baritone.getInputOverrideHandler().clearAllKeys();
|
||||||
getInProgress().ifPresent(AbstractNodeCostSearch::cancel);
|
|
||||||
baritone.getInputOverrideHandler().getBlockBreakHelper().stopBreakingBlock();
|
baritone.getInputOverrideHandler().getBlockBreakHelper().stopBreakingBlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -212,7 +212,7 @@ public final class CachedChunk {
|
|||||||
if (special != null) {
|
if (special != null) {
|
||||||
String str = special.get(index);
|
String str = special.get(index);
|
||||||
if (str != null) {
|
if (str != null) {
|
||||||
return ChunkPacker.stringToBlock(str).getDefaultState();
|
return ChunkPacker.stringToBlockRequired(str).getDefaultState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -240,7 +240,7 @@ public final class CachedRegion implements ICachedRegion {
|
|||||||
for (int z = 0; z < 32; z++) {
|
for (int z = 0; z < 32; z++) {
|
||||||
if (present[x][z]) {
|
if (present[x][z]) {
|
||||||
for (int i = 0; i < 256; i++) {
|
for (int i = 0; i < 256; i++) {
|
||||||
overview[x][z][i] = ChunkPacker.stringToBlock(in.readUTF()).getDefaultState();
|
overview[x][z][i] = ChunkPacker.stringToBlockRequired(in.readUTF()).getDefaultState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -255,6 +255,7 @@ public final class CachedRegion implements ICachedRegion {
|
|||||||
int numSpecialBlockTypes = in.readShort() & 0xffff;
|
int numSpecialBlockTypes = in.readShort() & 0xffff;
|
||||||
for (int i = 0; i < numSpecialBlockTypes; i++) {
|
for (int i = 0; i < numSpecialBlockTypes; i++) {
|
||||||
String blockName = in.readUTF();
|
String blockName = in.readUTF();
|
||||||
|
ChunkPacker.stringToBlockRequired(blockName);
|
||||||
List<BlockPos> locs = new ArrayList<>();
|
List<BlockPos> locs = new ArrayList<>();
|
||||||
location[x][z].put(blockName, locs);
|
location[x][z].put(blockName, locs);
|
||||||
int numLocations = in.readShort() & 0xffff;
|
int numLocations = in.readShort() & 0xffff;
|
||||||
|
|||||||
+7
-1
@@ -118,7 +118,13 @@ public final class ChunkPacker {
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Block stringToBlock(String name) {
|
public static Block stringToBlockRequired(String name) {
|
||||||
|
Block block = stringToBlockNullable(name);
|
||||||
|
Objects.requireNonNull(block);
|
||||||
|
return block;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Block stringToBlockNullable(String name) {
|
||||||
return resourceCache.computeIfAbsent(name, n -> IRegistry.BLOCK.get(new ResourceLocation(n.contains(":") ? n : "minecraft:" + n)));
|
return resourceCache.computeIfAbsent(name, n -> IRegistry.BLOCK.get(new ResourceLocation(n.contains(":") ? n : "minecraft:" + n)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
if (block instanceof BlockAir) { // early return for most common case
|
if (block instanceof BlockAir) { // early return for most common case
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (block == Blocks.FIRE || block == Blocks.TRIPWIRE || block == Blocks.COBWEB || block == Blocks.END_PORTAL || block == Blocks.COCOA || block instanceof BlockSkull || block == Blocks.BUBBLE_COLUMN || block instanceof BlockShulkerBox || block instanceof BlockSlab) {
|
if (block == Blocks.FIRE || block == Blocks.TRIPWIRE || block == Blocks.COBWEB || block == Blocks.END_PORTAL || block == Blocks.COCOA || block instanceof BlockSkull || block == Blocks.BUBBLE_COLUMN || block instanceof BlockShulkerBox || block instanceof BlockSlab || block instanceof BlockTrapDoor) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (block instanceof BlockDoor || block instanceof BlockFenceGate) {
|
if (block instanceof BlockDoor || block instanceof BlockFenceGate) {
|
||||||
@@ -91,9 +91,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
if (block instanceof BlockCarpet) {
|
if (block instanceof BlockCarpet) {
|
||||||
return canWalkOn(bsi, x, y - 1, z);
|
return canWalkOn(bsi, x, y - 1, z);
|
||||||
}
|
}
|
||||||
boolean snow = block instanceof BlockSnowLayer;
|
if (block instanceof BlockSnowLayer) {
|
||||||
boolean trapdoor = block instanceof BlockTrapDoor;
|
|
||||||
if (snow || trapdoor) {
|
|
||||||
// we've already checked doors and fence gates
|
// we've already checked doors and fence gates
|
||||||
// so the only remaining dynamic isPassables are snow and trapdoor
|
// so the only remaining dynamic isPassables are snow and trapdoor
|
||||||
// if they're cached as a top block, we don't know their metadata
|
// if they're cached as a top block, we don't know their metadata
|
||||||
@@ -101,20 +99,13 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
if (!bsi.worldContainsLoadedChunk(x, z)) {
|
if (!bsi.worldContainsLoadedChunk(x, z)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (snow) {
|
// the check in BlockSnow.isPassable is layers < 5
|
||||||
// the check in BlockSnow.isPassable is layers < 5
|
// while actually, we want < 3 because 3 or greater makes it impassable in a 2 high ceiling
|
||||||
// while actually, we want < 3 because 3 or greater makes it impassable in a 2 high ceiling
|
if (state.get(BlockSnowLayer.LAYERS) >= 3) {
|
||||||
if (state.get(BlockSnowLayer.LAYERS) >= 3) {
|
return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// ok, it's low enough we could walk through it, but is it supported?
|
|
||||||
return canWalkOn(bsi, x, y - 1, z);
|
|
||||||
}
|
}
|
||||||
if (trapdoor) {
|
// ok, it's low enough we could walk through it, but is it supported?
|
||||||
return !state.get(BlockTrapDoor.OPEN); // see BlockTrapDoor.isPassable
|
return canWalkOn(bsi, x, y - 1, z);
|
||||||
}
|
|
||||||
// The previous condition should always be true, so this exception will never be thrown
|
|
||||||
throw new IllegalStateException();
|
|
||||||
}
|
}
|
||||||
if (isFlowing(x, y, z, state, bsi)) {
|
if (isFlowing(x, y, z, state, bsi)) {
|
||||||
return false; // Don't walk through flowing liquids
|
return false; // Don't walk through flowing liquids
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ public final class FollowProcess extends BaritoneProcessHelper implements IFollo
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String displayName0() {
|
public String displayName0() {
|
||||||
return "Follow " + cache;
|
return "Following " + cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -303,7 +303,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mineByName(int quantity, String... blocks) {
|
public void mineByName(int quantity, String... blocks) {
|
||||||
mine(quantity, blocks == null || blocks.length == 0 ? null : Arrays.stream(blocks).map(ChunkPacker::stringToBlock).toArray(Block[]::new));
|
mine(quantity, blocks == null || blocks.length == 0 ? null : Arrays.stream(blocks).map(ChunkPacker::stringToBlockRequired).toArray(Block[]::new));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -462,14 +462,13 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
|
|||||||
String[] blockTypes = msg.substring(4).trim().split(" ");
|
String[] blockTypes = msg.substring(4).trim().split(" ");
|
||||||
try {
|
try {
|
||||||
int quantity = Integer.parseInt(blockTypes[1]);
|
int quantity = Integer.parseInt(blockTypes[1]);
|
||||||
Block block = ChunkPacker.stringToBlock(blockTypes[0]);
|
Block block = ChunkPacker.stringToBlockRequired(blockTypes[0]);
|
||||||
Objects.requireNonNull(block);
|
|
||||||
baritone.getMineProcess().mine(quantity, block);
|
baritone.getMineProcess().mine(quantity, block);
|
||||||
logDirect("Will mine " + quantity + " " + blockTypes[0]);
|
logDirect("Will mine " + quantity + " " + blockTypes[0]);
|
||||||
return true;
|
return true;
|
||||||
} catch (NumberFormatException | ArrayIndexOutOfBoundsException | NullPointerException ex) {}
|
} catch (NumberFormatException | ArrayIndexOutOfBoundsException | NullPointerException ex) {}
|
||||||
for (String s : blockTypes) {
|
for (String s : blockTypes) {
|
||||||
if (ChunkPacker.stringToBlock(s) == null) {
|
if (ChunkPacker.stringToBlockNullable(s) == null) {
|
||||||
logDirect(s + " isn't a valid block name");
|
logDirect(s + " isn't a valid block name");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -552,7 +551,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
|
|||||||
IWaypoint waypoint;
|
IWaypoint waypoint;
|
||||||
if (tag == null) {
|
if (tag == null) {
|
||||||
String mining = waypointType;
|
String mining = waypointType;
|
||||||
Block block = ChunkPacker.stringToBlock(mining);
|
Block block = ChunkPacker.stringToBlockNullable(mining);
|
||||||
//logDirect("Not a valid tag. Tags are: " + Arrays.asList(Waypoint.Tag.values()).toString().toLowerCase());
|
//logDirect("Not a valid tag. Tags are: " + Arrays.asList(Waypoint.Tag.values()).toString().toLowerCase());
|
||||||
if (block == null) {
|
if (block == null) {
|
||||||
waypoint = baritone.getWorldProvider().getCurrentWorld().getWaypoints().getAllWaypoints().stream().filter(w -> w.getName().equalsIgnoreCase(mining)).max(Comparator.comparingLong(IWaypoint::getCreationTimestamp)).orElse(null);
|
waypoint = baritone.getWorldProvider().getCurrentWorld().getWaypoints().getAllWaypoints().stream().filter(w -> w.getName().equalsIgnoreCase(mining)).max(Comparator.comparingLong(IWaypoint::getCreationTimestamp)).orElse(null);
|
||||||
|
|||||||
Reference in New Issue
Block a user