Compare commits

...

18 Commits

Author SHA1 Message Date
Leijurv
e661330fb6 v1.0.0-hotfix-4 2018-12-04 14:19:20 -08:00
Leijurv
9b13380b29 fixed switched block states in traverse 2018-12-04 14:18:32 -08:00
Leijurv
b48444da8c don't splice if not on ground 2018-12-01 10:48:43 -08:00
Leijurv
11a4225eaf fix inability to break fire 2018-11-29 20:10:04 -08:00
Leijurv
0611e3088e cherry pick flowing cache fix 2018-11-28 16:04:13 -08:00
Leijurv
73628f09c1 don't crash when Auto mine does weird things 2018-11-27 10:23:26 -08:00
Leijurv
a907746f53 only walk through supported snow, fixes #276 2018-11-26 15:33:33 -08:00
Leijurv
8189e90569 unable to start a parkour jump from stairs 2018-11-26 15:19:03 -08:00
Leijurv
9f83677df9 favored lookup performance 2018-11-26 15:11:36 -08:00
Leijurv
5265c46f60 over 10k less objects per second 2018-11-26 15:08:37 -08:00
Leijurv
6d37e14b0e thousands here too, on long paths 2018-11-26 15:07:38 -08:00
Leijurv
fbecff52af believe it or not, this saves thousands of object allocations per second 2018-11-26 15:07:29 -08:00
Leijurv
4af14cf0a6 unneeded, and was allocating thousands of sets a second 2018-11-26 15:07:12 -08:00
Leijurv
16a201255e fix behavior around cocoa pods and vines, fixes #277 2018-11-26 15:03:59 -08:00
Leijurv
22bb9f0ec8 v1.0.0-hotfix-3 2018-11-12 09:07:48 -08:00
Leijurv
654ac1075a wait a tick until objectMouseOver matches, fixes #254 2018-11-10 09:26:32 -08:00
Leijurv
ffc050668b fix cherry pick merge errors 2018-11-07 10:01:58 -08:00
Leijurv
80f65452e1 make sure to pick up dropped items while mining, fixes #170 2018-11-07 09:56:47 -08:00
14 changed files with 100 additions and 48 deletions

View File

@@ -16,7 +16,7 @@
*/ */
group 'baritone' group 'baritone'
version '1.0.0-hotfix-2' version '1.0.0-hotfix-4'
buildscript { buildscript {
repositories { repositories {

View File

@@ -24,8 +24,8 @@ import net.minecraft.util.text.ITextComponent;
import java.awt.*; import java.awt.*;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.List;
import java.util.*; import java.util.*;
import java.util.List;
import java.util.function.Consumer; import java.util.function.Consumer;
/** /**
@@ -376,6 +376,11 @@ public class Settings {
*/ */
public Setting<Integer> mineGoalUpdateInterval = new Setting<>(5); public Setting<Integer> mineGoalUpdateInterval = new Setting<>(5);
/**
* While mining, should it also consider dropped items of the correct type as a pathing destination (as well as ore blocks)?
*/
public Setting<Boolean> mineScanDroppedItems = new Setting<>(true);
/** /**
* Cancel the current path if the goal has changed, and the path originally ended in the goal but doesn't anymore. * Cancel the current path if the goal has changed, and the path originally ended in the goal but doesn't anymore.
* <p> * <p>

View File

@@ -105,8 +105,9 @@ public interface IPath {
default double ticksRemainingFrom(int pathPosition) { default double ticksRemainingFrom(int pathPosition) {
double sum = 0; double sum = 0;
//this is fast because we aren't requesting recalculation, it's just cached //this is fast because we aren't requesting recalculation, it's just cached
for (int i = pathPosition; i < movements().size(); i++) { List<IMovement> movements = movements();
sum += movements().get(i).getCost(); for (int i = pathPosition; i < movements.size(); i++) {
sum += movements.get(i).getCost();
} }
return sum; return sum;
} }

View File

@@ -85,10 +85,9 @@ public final class VecUtils {
* @see #getBlockPosCenter(BlockPos) * @see #getBlockPosCenter(BlockPos)
*/ */
public static double distanceToCenter(BlockPos pos, double x, double y, double z) { public static double distanceToCenter(BlockPos pos, double x, double y, double z) {
Vec3d center = getBlockPosCenter(pos); double xdiff = pos.getX() + 0.5 - x;
double xdiff = x - center.x; double ydiff = pos.getY() + 0.5 - y;
double ydiff = y - center.y; double zdiff = pos.getZ() + 0.5 - z;
double zdiff = z - center.z;
return Math.sqrt(xdiff * xdiff + ydiff * ydiff + zdiff * zdiff); return Math.sqrt(xdiff * xdiff + ydiff * ydiff + zdiff * zdiff);
} }

View File

@@ -30,10 +30,13 @@ import baritone.pathing.movement.MovementHelper;
import baritone.utils.BlockStateInterface; import baritone.utils.BlockStateInterface;
import baritone.utils.Helper; import baritone.utils.Helper;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.chunk.EmptyChunk; import net.minecraft.world.chunk.EmptyChunk;
import java.util.*; import java.util.*;
@@ -45,7 +48,7 @@ import java.util.stream.Collectors;
* @author leijurv * @author leijurv
*/ */
public final class MineBehavior extends Behavior implements IMineBehavior, Helper { public final class MineBehavior extends Behavior implements IMineBehavior, Helper {
public static final int ORE_LOCATIONS_COUNT = 64;
private List<Block> mining; private List<Block> mining;
private List<BlockPos> knownOreLocations; private List<BlockPos> knownOreLocations;
private BlockPos branchPoint; private BlockPos branchPoint;
@@ -86,12 +89,12 @@ public final class MineBehavior extends Behavior implements IMineBehavior, Helpe
} }
private void updateGoal() { private void updateGoal() {
if (mining == null) { if (mining == null || world() == null || player() == null) {
return; return;
} }
List<BlockPos> locs = knownOreLocations; List<BlockPos> locs = knownOreLocations;
if (!locs.isEmpty()) { if (!locs.isEmpty()) {
List<BlockPos> locs2 = prune(new ArrayList<>(locs), mining, 64); List<BlockPos> locs2 = prune(new ArrayList<>(locs), mining, ORE_LOCATIONS_COUNT, world());
// can't reassign locs, gotta make a new var locs2, because we use it in a lambda right here, and variables you use in a lambda must be effectively final // can't reassign locs, gotta make a new var locs2, because we use it in a lambda right here, and variables you use in a lambda must be effectively final
baritone.getPathingBehavior().setGoalAndPath(new GoalComposite(locs2.stream().map(loc -> coalesce(loc, locs2)).toArray(Goal[]::new))); baritone.getPathingBehavior().setGoalAndPath(new GoalComposite(locs2.stream().map(loc -> coalesce(loc, locs2)).toArray(Goal[]::new)));
knownOreLocations = locs2; knownOreLocations = locs2;
@@ -121,13 +124,14 @@ public final class MineBehavior extends Behavior implements IMineBehavior, Helpe
} }
private void rescan() { private void rescan() {
if (mining == null) { if (mining == null || world() == null || player() == null) {
return; return;
} }
if (Baritone.settings().legitMine.get()) { if (Baritone.settings().legitMine.get()) {
return; return;
} }
List<BlockPos> locs = searchWorld(mining, 64); List<BlockPos> locs = searchWorld(mining, ORE_LOCATIONS_COUNT, world());
locs.addAll(droppedItemsScan(mining, world()));
if (locs.isEmpty()) { if (locs.isEmpty()) {
logDebug("No locations for " + mining + " known, cancelling"); logDebug("No locations for " + mining + " known, cancelling");
mine(0, (String[]) null); mine(0, (String[]) null);
@@ -158,7 +162,30 @@ public final class MineBehavior extends Behavior implements IMineBehavior, Helpe
} }
} }
public List<BlockPos> searchWorld(List<Block> mining, int max) { public static List<BlockPos> droppedItemsScan(List<Block> mining, World world) {
if (!Baritone.settings().mineScanDroppedItems.get()) {
return new ArrayList<>();
}
Set<Item> searchingFor = new HashSet<>();
for (Block block : mining) {
Item drop = block.getItemDropped(block.getDefaultState(), new Random(), 0);
Item ore = Item.getItemFromBlock(block);
searchingFor.add(drop);
searchingFor.add(ore);
}
List<BlockPos> ret = new ArrayList<>();
for (Entity entity : world.loadedEntityList) {
if (entity instanceof EntityItem) {
EntityItem ei = (EntityItem) entity;
if (searchingFor.contains(ei.getItem().getItem())) {
ret.add(entity.getPosition());
}
}
}
return ret;
}
public static List<BlockPos> searchWorld(List<Block> mining, int max, World world) {
List<BlockPos> locs = new ArrayList<>(); List<BlockPos> locs = new ArrayList<>();
List<Block> uninteresting = new ArrayList<>(); List<Block> uninteresting = new ArrayList<>();
//long b = System.currentTimeMillis(); //long b = System.currentTimeMillis();
@@ -178,7 +205,7 @@ public final class MineBehavior extends Behavior implements IMineBehavior, Helpe
locs.addAll(WorldScanner.INSTANCE.scanChunkRadius(uninteresting, max, 10, 26)); locs.addAll(WorldScanner.INSTANCE.scanChunkRadius(uninteresting, max, 10, 26));
//System.out.println("Scan of loaded chunks took " + (System.currentTimeMillis() - before) + "ms"); //System.out.println("Scan of loaded chunks took " + (System.currentTimeMillis() - before) + "ms");
} }
return prune(locs, mining, max); return prune(locs, mining, max, world);
} }
public void addNearby() { public void addNearby() {
@@ -194,15 +221,16 @@ public final class MineBehavior extends Behavior implements IMineBehavior, Helpe
} }
} }
} }
knownOreLocations = prune(knownOreLocations, mining, 64); knownOreLocations = prune(knownOreLocations, mining, ORE_LOCATIONS_COUNT, world());
} }
public List<BlockPos> prune(List<BlockPos> locs2, List<Block> mining, int max) { public static List<BlockPos> prune(List<BlockPos> locs2, List<Block> mining, int max, World world) {
List<BlockPos> dropped = droppedItemsScan(mining, world);
List<BlockPos> locs = locs2 List<BlockPos> locs = locs2
.stream() .stream()
// remove any that are within loaded chunks that aren't actually what we want // remove any that are within loaded chunks that aren't actually what we want
.filter(pos -> world().getChunk(pos) instanceof EmptyChunk || mining.contains(BlockStateInterface.get(pos).getBlock())) .filter(pos -> world.getChunk(pos) instanceof EmptyChunk || mining.contains(BlockStateInterface.get(pos).getBlock()) || dropped.contains(pos))
// remove any that are implausible to mine (encased in bedrock, or touching lava) // remove any that are implausible to mine (encased in bedrock, or touching lava)
.filter(MineBehavior::plausibleToBreak) .filter(MineBehavior::plausibleToBreak)

View File

@@ -38,12 +38,14 @@ import baritone.pathing.path.PathExecutor;
import baritone.utils.BlockBreakHelper; import baritone.utils.BlockBreakHelper;
import baritone.utils.Helper; import baritone.utils.Helper;
import baritone.utils.PathRenderer; import baritone.utils.PathRenderer;
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
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.Optional;
import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.LinkedBlockingQueue;
import java.util.stream.Collectors;
public final class PathingBehavior extends Behavior implements IPathingBehavior, Helper { public final class PathingBehavior extends Behavior implements IPathingBehavior, Helper {
@@ -134,7 +136,7 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
return; return;
} }
// at this point, we know current is in progress // at this point, we know current is in progress
if (safe && next != null && next.snipsnapifpossible()) { if (safe && next != null && player().onGround && next.snipsnapifpossible()) {
// a movement just ended; jump directly onto the next path // a movement just ended; jump directly onto the next path
logDebug("Splicing into planned next path early..."); logDebug("Splicing into planned next path early...");
queuePathEvent(PathEvent.SPLICING_ONTO_NEXT_EARLY); queuePathEvent(PathEvent.SPLICING_ONTO_NEXT_EARLY);
@@ -419,11 +421,11 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
} else { } else {
timeout = Baritone.settings().planAheadTimeoutMS.<Long>get(); timeout = Baritone.settings().planAheadTimeoutMS.<Long>get();
} }
Optional<HashSet<Long>> favoredPositions; Optional<LongOpenHashSet> favoredPositions = Optional.empty();
if (Baritone.settings().backtrackCostFavoringCoefficient.get() == 1D) { if (Baritone.settings().backtrackCostFavoringCoefficient.get() != 1D && previous.isPresent()) {
favoredPositions = Optional.empty(); LongOpenHashSet tmp = new LongOpenHashSet();
} else { previous.get().positions().forEach(pos -> tmp.add(BetterBlockPos.longHash(pos)));
favoredPositions = previous.map(IPath::positions).map(Collection::stream).map(x -> x.map(BetterBlockPos::longHash)).map(x -> x.collect(Collectors.toList())).map(HashSet::new); // <-- okay this is EPIC favoredPositions = Optional.of(tmp);
} }
try { try {
IPathFinder pf = new AStarPathFinder(start.getX(), start.getY(), start.getZ(), goal, favoredPositions, context); IPathFinder pf = new AStarPathFinder(start.getX(), start.getY(), start.getZ(), goal, favoredPositions, context);

View File

@@ -40,6 +40,8 @@ import java.util.*;
*/ */
public final class ChunkPacker implements Helper { public final class ChunkPacker implements Helper {
private static final Map<String, Block> resourceCache = new HashMap<>();
private ChunkPacker() {} private ChunkPacker() {}
public static CachedChunk pack(Chunk chunk) { public static CachedChunk pack(Chunk chunk) {
@@ -93,7 +95,8 @@ public final class ChunkPacker implements Helper {
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--) {
@@ -120,12 +123,12 @@ public final class ChunkPacker implements Helper {
} }
public static Block stringToBlock(String name) { public static Block stringToBlock(String name) {
return Block.getBlockFromName(name.contains(":") ? name : "minecraft:" + name); return resourceCache.computeIfAbsent(name, n -> Block.getBlockFromName(n.contains(":") ? n : "minecraft:" + n));
} }
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)) { 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

@@ -29,8 +29,8 @@ import baritone.utils.BlockStateInterface;
import baritone.utils.Helper; import baritone.utils.Helper;
import baritone.utils.pathing.BetterWorldBorder; import baritone.utils.pathing.BetterWorldBorder;
import baritone.utils.pathing.MutableMoveResult; import baritone.utils.pathing.MutableMoveResult;
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
import java.util.HashSet;
import java.util.Optional; import java.util.Optional;
/** /**
@@ -40,10 +40,10 @@ import java.util.Optional;
*/ */
public final class AStarPathFinder extends AbstractNodeCostSearch implements Helper { public final class AStarPathFinder extends AbstractNodeCostSearch implements Helper {
private final Optional<HashSet<Long>> favoredPositions; private final Optional<LongOpenHashSet> favoredPositions;
private final CalculationContext calcContext; private final CalculationContext calcContext;
public AStarPathFinder(int startX, int startY, int startZ, Goal goal, Optional<HashSet<Long>> favoredPositions, CalculationContext context) { public AStarPathFinder(int startX, int startY, int startZ, Goal goal, Optional<LongOpenHashSet> favoredPositions, CalculationContext context) {
super(startX, startY, startZ, goal); super(startX, startY, startZ, goal);
this.favoredPositions = favoredPositions; this.favoredPositions = favoredPositions;
this.calcContext = context; this.calcContext = context;
@@ -64,9 +64,9 @@ public final class AStarPathFinder extends AbstractNodeCostSearch implements Hel
bestSoFar[i] = startNode; bestSoFar[i] = startNode;
} }
MutableMoveResult res = new MutableMoveResult(); MutableMoveResult res = new MutableMoveResult();
HashSet<Long> favored = favoredPositions.orElse(null);
BetterWorldBorder worldBorder = new BetterWorldBorder(world().getWorldBorder()); BetterWorldBorder worldBorder = new BetterWorldBorder(world().getWorldBorder());
BlockStateInterface.clearCachedChunk(); BlockStateInterface.clearCachedChunk();
LongOpenHashSet favored = favoredPositions.orElse(null);
long startTime = System.nanoTime() / 1000000L; long startTime = System.nanoTime() / 1000000L;
boolean slowPath = Baritone.settings().slowPath.get(); boolean slowPath = Baritone.settings().slowPath.get();
if (slowPath) { if (slowPath) {

View File

@@ -20,15 +20,13 @@ package baritone.pathing.movement;
import baritone.Baritone; import baritone.Baritone;
import baritone.api.pathing.movement.IMovement; import baritone.api.pathing.movement.IMovement;
import baritone.api.pathing.movement.MovementStatus; import baritone.api.pathing.movement.MovementStatus;
import baritone.api.utils.BetterBlockPos; import baritone.api.utils.*;
import baritone.api.utils.Rotation;
import baritone.api.utils.RotationUtils;
import baritone.api.utils.VecUtils;
import baritone.utils.BlockBreakHelper; import baritone.utils.BlockBreakHelper;
import baritone.utils.BlockStateInterface; import baritone.utils.BlockStateInterface;
import baritone.utils.Helper; import baritone.utils.Helper;
import baritone.utils.InputOverrideHandler; import baritone.utils.InputOverrideHandler;
import net.minecraft.block.BlockLiquid; import net.minecraft.block.BlockLiquid;
import net.minecraft.init.Blocks;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.RayTraceResult;
@@ -36,6 +34,7 @@ import net.minecraft.world.chunk.EmptyChunk;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.Optional; import java.util.Optional;
import static baritone.utils.InputOverrideHandler.Input; import static baritone.utils.InputOverrideHandler.Input;
@@ -177,7 +176,10 @@ public abstract class Movement implements IMovement, Helper, MovementHelper {
Optional<Rotation> reachable = RotationUtils.reachable(player(), blockPos); Optional<Rotation> reachable = RotationUtils.reachable(player(), blockPos);
if (reachable.isPresent()) { if (reachable.isPresent()) {
MovementHelper.switchToBestToolFor(BlockStateInterface.get(blockPos)); MovementHelper.switchToBestToolFor(BlockStateInterface.get(blockPos));
state.setTarget(new MovementState.MovementTarget(reachable.get(), true)).setInput(Input.CLICK_LEFT, true); state.setTarget(new MovementState.MovementTarget(reachable.get(), true));
if (Objects.equals(RayTraceUtils.getSelectedBlock().orElse(null), blockPos) || BlockStateInterface.getBlock(blockPos) == Blocks.FIRE) {
state.setInput(Input.CLICK_LEFT, true);
}
return false; return false;
} }
//get rekt minecraft //get rekt minecraft
@@ -186,7 +188,9 @@ public abstract class Movement implements IMovement, Helper, MovementHelper {
//you dont own me!!!! //you dont own me!!!!
state.setTarget(new MovementState.MovementTarget(RotationUtils.calcRotationFromVec3d(player().getPositionEyes(1.0F), state.setTarget(new MovementState.MovementTarget(RotationUtils.calcRotationFromVec3d(player().getPositionEyes(1.0F),
VecUtils.getBlockPosCenter(blockPos)), true) VecUtils.getBlockPosCenter(blockPos)), true)
).setInput(InputOverrideHandler.Input.CLICK_LEFT, true); );
// don't check selectedblock on this one, this is a fallback when we can't see any face directly, it's intended to be breaking the "incorrect" block
state.setInput(InputOverrideHandler.Input.CLICK_LEFT, true);
return false; return false;
} }
} }

View File

@@ -76,7 +76,7 @@ public interface MovementHelper extends ActionCosts, Helper {
if (block == Blocks.AIR) { // early return for most common case if (block == Blocks.AIR) { // early return for most common case
return true; return true;
} }
if (block == Blocks.FIRE || block == Blocks.TRIPWIRE || block == Blocks.WEB || block == Blocks.END_PORTAL) { if (block == Blocks.FIRE || block == Blocks.TRIPWIRE || block == Blocks.WEB || block == Blocks.END_PORTAL || block == Blocks.COCOA) {
return false; return false;
} }
if (block instanceof BlockDoor || block instanceof BlockFenceGate) { if (block instanceof BlockDoor || block instanceof BlockFenceGate) {
@@ -98,7 +98,11 @@ public interface MovementHelper extends ActionCosts, Helper {
if (snow) { 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
return state.getValue(BlockSnow.LAYERS) < 3; if (state.getValue(BlockSnow.LAYERS) >= 3) {
return false;
}
// ok, it's low enough we could walk through it, but is it supported?
return canWalkOn(x, y - 1, z);
} }
if (trapdoor) { if (trapdoor) {
return !state.getValue(BlockTrapDoor.OPEN); // see BlockTrapDoor.isPassable return !state.getValue(BlockTrapDoor.OPEN); // see BlockTrapDoor.isPassable
@@ -145,6 +149,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|| block == Blocks.WEB || block == Blocks.WEB
|| block == Blocks.VINE || block == Blocks.VINE
|| block == Blocks.LADDER || block == Blocks.LADDER
|| block == Blocks.COCOA
|| block instanceof BlockDoor || block instanceof BlockDoor
|| block instanceof BlockFenceGate || block instanceof BlockFenceGate
|| block instanceof BlockSnow || block instanceof BlockSnow
@@ -280,7 +285,7 @@ public interface MovementHelper extends ActionCosts, Helper {
// if assumeWalkOnWater is off, we can only walk on water if there is water above it // if assumeWalkOnWater is off, we can only walk on water if there is water above it
return isWater(up) ^ Baritone.settings().assumeWalkOnWater.get(); return isWater(up) ^ Baritone.settings().assumeWalkOnWater.get();
} }
if (block instanceof BlockGlass || block instanceof BlockStainedGlass) { if (block == Blocks.GLASS || block == Blocks.STAINED_GLASS) {
return true; return true;
} }
if (block instanceof BlockSlab) { if (block instanceof BlockSlab) {
@@ -481,7 +486,6 @@ public interface MovementHelper extends ActionCosts, Helper {
static boolean isFlowing(IBlockState state) { static boolean isFlowing(IBlockState state) {
// Will be IFluidState in 1.13 // Will be IFluidState in 1.13
return state.getBlock() instanceof BlockLiquid return state.getBlock() instanceof BlockLiquid
&& state.getPropertyKeys().contains(BlockLiquid.LEVEL)
&& state.getValue(BlockLiquid.LEVEL) != 0; && state.getValue(BlockLiquid.LEVEL) != 0;
} }
} }

View File

@@ -115,7 +115,8 @@ public class MovementDiagonal extends Movement {
return COST_INF; return COST_INF;
} }
boolean water = false; boolean water = false;
if (MovementHelper.isWater(BlockStateInterface.getBlock(x, y, z)) || MovementHelper.isWater(destInto.getBlock())) { Block startIn = BlockStateInterface.getBlock(x, y, z);
if (MovementHelper.isWater(startIn) || MovementHelper.isWater(destInto.getBlock())) {
// Ignore previous multiplier // Ignore previous multiplier
// Whatever we were walking on (possibly soul sand) doesn't matter as we're actually floating on water // Whatever we were walking on (possibly soul sand) doesn't matter as we're actually floating on water
// Not even touching the blocks below // Not even touching the blocks below
@@ -124,6 +125,10 @@ 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
if (startIn == Blocks.LADDER || startIn == Blocks.VINE) {
// edging around doesn't work if doing so would climb a ladder or vine instead of moving sideways
return COST_INF;
}
} }
if (context.canSprint() && !water) { if (context.canSprint() && !water) {
// If we aren't edging around anything, and we aren't in water // If we aren't edging around anything, and we aren't in water

View File

@@ -32,6 +32,7 @@ import baritone.utils.Helper;
import baritone.utils.InputOverrideHandler; import baritone.utils.InputOverrideHandler;
import baritone.utils.pathing.MutableMoveResult; import baritone.utils.pathing.MutableMoveResult;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockStairs;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
@@ -68,7 +69,7 @@ public class MovementParkour extends Movement {
return; return;
} }
IBlockState standingOn = BlockStateInterface.get(x, y - 1, z); IBlockState standingOn = BlockStateInterface.get(x, y - 1, z);
if (standingOn.getBlock() == Blocks.VINE || standingOn.getBlock() == Blocks.LADDER || MovementHelper.isBottomSlab(standingOn)) { if (standingOn.getBlock() == Blocks.VINE || standingOn.getBlock() == Blocks.LADDER || standingOn.getBlock() instanceof BlockStairs || MovementHelper.isBottomSlab(standingOn)) {
return; return;
} }
int xDiff = dir.getXOffset(); int xDiff = dir.getXOffset();

View File

@@ -108,11 +108,11 @@ public class MovementTraverse extends Movement {
if (!context.canPlaceThrowawayAt(destX, y - 1, destZ)) { if (!context.canPlaceThrowawayAt(destX, y - 1, destZ)) {
return COST_INF; return COST_INF;
} }
double hardness1 = MovementHelper.getMiningDurationTicks(context, destX, y, destZ, pb0, false); double hardness1 = MovementHelper.getMiningDurationTicks(context, destX, y, destZ, pb1, false);
if (hardness1 >= COST_INF) { if (hardness1 >= COST_INF) {
return COST_INF; return COST_INF;
} }
double hardness2 = MovementHelper.getMiningDurationTicks(context, destX, y + 1, destZ, pb1, true); double hardness2 = MovementHelper.getMiningDurationTicks(context, destX, y + 1, destZ, pb0, true);
double WC = throughWater ? context.waterWalkSpeed() : WALK_ONE_BLOCK_COST; double WC = throughWater ? context.waterWalkSpeed() : WALK_ONE_BLOCK_COST;
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {

View File

@@ -410,7 +410,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
return true; return true;
} }
} else { } else {
List<BlockPos> locs = baritone.getMineBehavior().searchWorld(Collections.singletonList(block), 64); List<BlockPos> locs = baritone.getMineBehavior().searchWorld(Collections.singletonList(block), 64, world());
if (locs.isEmpty()) { if (locs.isEmpty()) {
logDirect("No locations for " + mining + " known, cancelling"); logDirect("No locations for " + mining + " known, cancelling");
return true; return true;