context specific blockstateinterface lookups. also toxic
This commit is contained in:
parent
a83074e773
commit
45e4239b26
@ -82,6 +82,8 @@ public enum Baritone implements IBaritone {
|
|||||||
|
|
||||||
private PathingControlManager pathingControlManager;
|
private PathingControlManager pathingControlManager;
|
||||||
|
|
||||||
|
private WorldProvider worldProvider;
|
||||||
|
|
||||||
private static ThreadPoolExecutor threadPool = new ThreadPoolExecutor(4, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, new SynchronousQueue<>());
|
private static ThreadPoolExecutor threadPool = new ThreadPoolExecutor(4, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, new SynchronousQueue<>());
|
||||||
|
|
||||||
Baritone() {
|
Baritone() {
|
||||||
@ -115,6 +117,8 @@ public enum Baritone implements IBaritone {
|
|||||||
getToBlockProcess = new GetToBlockProcess(this);
|
getToBlockProcess = new GetToBlockProcess(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.worldProvider = new WorldProvider();
|
||||||
|
|
||||||
if (BaritoneAutoTest.ENABLE_AUTO_TEST) {
|
if (BaritoneAutoTest.ENABLE_AUTO_TEST) {
|
||||||
registerEventListener(BaritoneAutoTest.INSTANCE);
|
registerEventListener(BaritoneAutoTest.INSTANCE);
|
||||||
}
|
}
|
||||||
@ -194,7 +198,7 @@ public enum Baritone implements IBaritone {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WorldProvider getWorldProvider() {
|
public WorldProvider getWorldProvider() {
|
||||||
return WorldProvider.INSTANCE;
|
return worldProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -26,7 +26,6 @@ import baritone.api.event.events.PacketEvent;
|
|||||||
import baritone.api.event.events.PlayerUpdateEvent;
|
import baritone.api.event.events.PlayerUpdateEvent;
|
||||||
import baritone.api.event.events.type.EventState;
|
import baritone.api.event.events.type.EventState;
|
||||||
import baritone.cache.Waypoint;
|
import baritone.cache.Waypoint;
|
||||||
import baritone.cache.WorldProvider;
|
|
||||||
import baritone.utils.BlockStateInterface;
|
import baritone.utils.BlockStateInterface;
|
||||||
import baritone.utils.Helper;
|
import baritone.utils.Helper;
|
||||||
import net.minecraft.block.BlockBed;
|
import net.minecraft.block.BlockBed;
|
||||||
@ -122,13 +121,13 @@ public final class MemoryBehavior extends Behavior implements IMemoryBehavior, H
|
|||||||
@Override
|
@Override
|
||||||
public void onBlockInteract(BlockInteractEvent event) {
|
public void onBlockInteract(BlockInteractEvent event) {
|
||||||
if (event.getType() == BlockInteractEvent.Type.USE && BlockStateInterface.getBlock(event.getPos()) instanceof BlockBed) {
|
if (event.getType() == BlockInteractEvent.Type.USE && BlockStateInterface.getBlock(event.getPos()) instanceof BlockBed) {
|
||||||
WorldProvider.INSTANCE.getCurrentWorld().getWaypoints().addWaypoint(new Waypoint("bed", Waypoint.Tag.BED, event.getPos()));
|
baritone.getWorldProvider().getCurrentWorld().getWaypoints().addWaypoint(new Waypoint("bed", Waypoint.Tag.BED, event.getPos()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerDeath() {
|
public void onPlayerDeath() {
|
||||||
WorldProvider.INSTANCE.getCurrentWorld().getWaypoints().addWaypoint(new Waypoint("death", Waypoint.Tag.DEATH, playerFeet()));
|
baritone.getWorldProvider().getCurrentWorld().getWaypoints().addWaypoint(new Waypoint("death", Waypoint.Tag.DEATH, playerFeet()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Optional<RememberedInventory> getInventoryFromWindow(int windowId) {
|
private Optional<RememberedInventory> getInventoryFromWindow(int windowId) {
|
||||||
@ -143,7 +142,7 @@ public final class MemoryBehavior extends Behavior implements IMemoryBehavior, H
|
|||||||
}
|
}
|
||||||
|
|
||||||
private WorldDataContainer getCurrentContainer() {
|
private WorldDataContainer getCurrentContainer() {
|
||||||
return this.worldDataContainers.computeIfAbsent(WorldProvider.INSTANCE.getCurrentWorld(), data -> new WorldDataContainer());
|
return this.worldDataContainers.computeIfAbsent(baritone.getWorldProvider().getCurrentWorld(), data -> new WorldDataContainer());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -190,7 +190,7 @@ public final class CachedWorld implements ICachedWorld, Helper {
|
|||||||
* If we are still in this world and dimension, return player feet, otherwise return most recently modified chunk
|
* If we are still in this world and dimension, return player feet, otherwise return most recently modified chunk
|
||||||
*/
|
*/
|
||||||
private BlockPos guessPosition() {
|
private BlockPos guessPosition() {
|
||||||
WorldData data = WorldProvider.INSTANCE.getCurrentWorld();
|
WorldData data = Baritone.INSTANCE.getWorldProvider().getCurrentWorld();
|
||||||
if (data != null && data.getCachedWorld() == this) {
|
if (data != null && data.getCachedWorld() == this) {
|
||||||
return playerFeet();
|
return playerFeet();
|
||||||
}
|
}
|
||||||
|
@ -39,11 +39,9 @@ import java.util.function.Consumer;
|
|||||||
* @author Brady
|
* @author Brady
|
||||||
* @since 8/4/2018 11:06 AM
|
* @since 8/4/2018 11:06 AM
|
||||||
*/
|
*/
|
||||||
public enum WorldProvider implements IWorldProvider, Helper {
|
public class WorldProvider implements IWorldProvider, Helper {
|
||||||
|
|
||||||
INSTANCE;
|
private static final Map<Path, WorldData> worldCache = new HashMap<>(); // this is how the bots have the same cached world
|
||||||
|
|
||||||
private final Map<Path, WorldData> worldCache = new HashMap<>();
|
|
||||||
|
|
||||||
private WorldData currentWorld;
|
private WorldData currentWorld;
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ public final class GameEventHandler implements IGameEventListener, Helper {
|
|||||||
&& mc.world.getChunkProvider().isChunkGeneratedAt(event.getX(), event.getZ());
|
&& mc.world.getChunkProvider().isChunkGeneratedAt(event.getX(), event.getZ());
|
||||||
|
|
||||||
if (isPostPopulate || isPreUnload) {
|
if (isPostPopulate || isPreUnload) {
|
||||||
WorldProvider.INSTANCE.ifWorldLoaded(world -> {
|
baritone.getWorldProvider().ifWorldLoaded(world -> {
|
||||||
Chunk chunk = mc.world.getChunk(event.getX(), event.getZ());
|
Chunk chunk = mc.world.getChunk(event.getX(), event.getZ());
|
||||||
world.getCachedWorld().queueForPacking(chunk);
|
world.getCachedWorld().queueForPacking(chunk);
|
||||||
});
|
});
|
||||||
@ -96,7 +96,7 @@ public final class GameEventHandler implements IGameEventListener, Helper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void onWorldEvent(WorldEvent event) {
|
public final void onWorldEvent(WorldEvent event) {
|
||||||
WorldProvider cache = WorldProvider.INSTANCE;
|
WorldProvider cache = baritone.getWorldProvider();
|
||||||
|
|
||||||
BlockStateInterface.clearCachedChunk();
|
BlockStateInterface.clearCachedChunk();
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ public final class AStarPathFinder extends AbstractNodeCostSearch implements Hel
|
|||||||
}
|
}
|
||||||
MutableMoveResult res = new MutableMoveResult();
|
MutableMoveResult res = new MutableMoveResult();
|
||||||
HashSet<Long> favored = favoredPositions.orElse(null);
|
HashSet<Long> favored = favoredPositions.orElse(null);
|
||||||
BetterWorldBorder worldBorder = new BetterWorldBorder(world().getWorldBorder());
|
BetterWorldBorder worldBorder = new BetterWorldBorder(calcContext.world().getWorldBorder());
|
||||||
BlockStateInterface.clearCachedChunk();
|
BlockStateInterface.clearCachedChunk();
|
||||||
long startTime = System.nanoTime() / 1000000L;
|
long startTime = System.nanoTime() / 1000000L;
|
||||||
boolean slowPath = Baritone.settings().slowPath.get();
|
boolean slowPath = Baritone.settings().slowPath.get();
|
||||||
@ -100,7 +100,7 @@ public final class AStarPathFinder extends AbstractNodeCostSearch implements Hel
|
|||||||
for (Moves moves : Moves.values()) {
|
for (Moves moves : Moves.values()) {
|
||||||
int newX = currentNode.x + moves.xOffset;
|
int newX = currentNode.x + moves.xOffset;
|
||||||
int newZ = currentNode.z + moves.zOffset;
|
int newZ = currentNode.z + moves.zOffset;
|
||||||
if ((newX >> 4 != currentNode.x >> 4 || newZ >> 4 != currentNode.z >> 4) && !BlockStateInterface.isLoaded(newX, newZ)) {
|
if ((newX >> 4 != currentNode.x >> 4 || newZ >> 4 != currentNode.z >> 4) && !BlockStateInterface.isLoaded(calcContext, newX, newZ)) {
|
||||||
// only need to check if the destination is a loaded chunk if it's in a different chunk than the start of the movement
|
// only need to check if the destination is a loaded chunk if it's in a different chunk than the start of the movement
|
||||||
if (!moves.dynamicXZ) { // only increment the counter if the movement would have gone out of bounds guaranteed
|
if (!moves.dynamicXZ) { // only increment the counter if the movement would have gone out of bounds guaranteed
|
||||||
numEmptyChunk++;
|
numEmptyChunk++;
|
||||||
|
@ -148,7 +148,7 @@ class Path extends PathBase {
|
|||||||
}
|
}
|
||||||
verified = true;
|
verified = true;
|
||||||
boolean failed = assembleMovements();
|
boolean failed = assembleMovements();
|
||||||
movements.forEach(Movement::checkLoadedChunk);
|
movements.forEach(m -> m.checkLoadedChunk(context));
|
||||||
|
|
||||||
if (failed) { // at least one movement became impossible during calculation
|
if (failed) { // at least one movement became impossible during calculation
|
||||||
CutoffPath res = new CutoffPath(this, movements().size());
|
CutoffPath res = new CutoffPath(this, movements().size());
|
||||||
|
@ -19,14 +19,18 @@ package baritone.pathing.movement;
|
|||||||
|
|
||||||
import baritone.Baritone;
|
import baritone.Baritone;
|
||||||
import baritone.api.pathing.movement.ActionCosts;
|
import baritone.api.pathing.movement.ActionCosts;
|
||||||
|
import baritone.utils.BlockStateInterface;
|
||||||
import baritone.utils.Helper;
|
import baritone.utils.Helper;
|
||||||
import baritone.utils.ToolSet;
|
import baritone.utils.ToolSet;
|
||||||
import baritone.utils.pathing.BetterWorldBorder;
|
import baritone.utils.pathing.BetterWorldBorder;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.client.entity.EntityPlayerSP;
|
import net.minecraft.client.entity.EntityPlayerSP;
|
||||||
import net.minecraft.enchantment.EnchantmentHelper;
|
import net.minecraft.enchantment.EnchantmentHelper;
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
import net.minecraft.init.Items;
|
import net.minecraft.init.Items;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -75,6 +79,18 @@ public class CalculationContext {
|
|||||||
this.worldBorder = new BetterWorldBorder(world.getWorldBorder());
|
this.worldBorder = new BetterWorldBorder(world.getWorldBorder());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IBlockState get(int x, int y, int z) {
|
||||||
|
return BlockStateInterface.get(world, x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IBlockState get(BlockPos pos) {
|
||||||
|
return get(pos.getX(), pos.getY(), pos.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Block getBlock(int x, int y, int z) {
|
||||||
|
return get(x, y, z).getBlock();
|
||||||
|
}
|
||||||
|
|
||||||
public boolean canPlaceThrowawayAt(int x, int y, int z) {
|
public boolean canPlaceThrowawayAt(int x, int y, int z) {
|
||||||
if (!hasThrowaway()) { // only true if allowPlace is true, see constructor
|
if (!hasThrowaway()) { // only true if allowPlace is true, see constructor
|
||||||
return false;
|
return false;
|
||||||
|
@ -21,7 +21,9 @@ 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.*;
|
import baritone.api.utils.*;
|
||||||
import baritone.utils.*;
|
import baritone.utils.BlockStateInterface;
|
||||||
|
import baritone.utils.Helper;
|
||||||
|
import baritone.utils.InputOverrideHandler;
|
||||||
import net.minecraft.block.BlockLiquid;
|
import net.minecraft.block.BlockLiquid;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
@ -226,8 +228,8 @@ public abstract class Movement implements IMovement, Helper, MovementHelper {
|
|||||||
return getDest().subtract(getSrc());
|
return getDest().subtract(getSrc());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkLoadedChunk() {
|
public void checkLoadedChunk(CalculationContext context) {
|
||||||
calculatedWhileLoaded = !(world().getChunk(getDest()) instanceof EmptyChunk);
|
calculatedWhileLoaded = !(context.world().getChunk(getDest()) instanceof EmptyChunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -21,7 +21,10 @@ import baritone.Baritone;
|
|||||||
import baritone.api.pathing.movement.ActionCosts;
|
import baritone.api.pathing.movement.ActionCosts;
|
||||||
import baritone.api.utils.*;
|
import baritone.api.utils.*;
|
||||||
import baritone.pathing.movement.MovementState.MovementTarget;
|
import baritone.pathing.movement.MovementState.MovementTarget;
|
||||||
import baritone.utils.*;
|
import baritone.utils.BlockStateInterface;
|
||||||
|
import baritone.utils.Helper;
|
||||||
|
import baritone.utils.InputOverrideHandler;
|
||||||
|
import baritone.utils.ToolSet;
|
||||||
import net.minecraft.block.*;
|
import net.minecraft.block.*;
|
||||||
import net.minecraft.block.properties.PropertyBool;
|
import net.minecraft.block.properties.PropertyBool;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
@ -41,16 +44,16 @@ import net.minecraft.world.chunk.EmptyChunk;
|
|||||||
*/
|
*/
|
||||||
public interface MovementHelper extends ActionCosts, Helper {
|
public interface MovementHelper extends ActionCosts, Helper {
|
||||||
|
|
||||||
static boolean avoidBreaking(int x, int y, int z, IBlockState state) {
|
static boolean avoidBreaking(CalculationContext context, int x, int y, int z, IBlockState state) {
|
||||||
Block b = state.getBlock();
|
Block b = state.getBlock();
|
||||||
return b == Blocks.ICE // ice becomes water, and water can mess up the path
|
return b == Blocks.ICE // ice becomes water, and water can mess up the path
|
||||||
|| b instanceof BlockSilverfish // obvious reasons
|
|| b instanceof BlockSilverfish // obvious reasons
|
||||||
// call BlockStateInterface.get directly with x,y,z. no need to make 5 new BlockPos for no reason
|
// call context.get directly with x,y,z. no need to make 5 new BlockPos for no reason
|
||||||
|| BlockStateInterface.get(x, y + 1, z).getBlock() instanceof BlockLiquid//don't break anything touching liquid on any side
|
|| context.get(x, y + 1, z).getBlock() instanceof BlockLiquid//don't break anything touching liquid on any side
|
||||||
|| BlockStateInterface.get(x + 1, y, z).getBlock() instanceof BlockLiquid
|
|| context.get(x + 1, y, z).getBlock() instanceof BlockLiquid
|
||||||
|| BlockStateInterface.get(x - 1, y, z).getBlock() instanceof BlockLiquid
|
|| context.get(x - 1, y, z).getBlock() instanceof BlockLiquid
|
||||||
|| BlockStateInterface.get(x, y, z + 1).getBlock() instanceof BlockLiquid
|
|| context.get(x, y, z + 1).getBlock() instanceof BlockLiquid
|
||||||
|| BlockStateInterface.get(x, y, z - 1).getBlock() instanceof BlockLiquid;
|
|| context.get(x, y, z - 1).getBlock() instanceof BlockLiquid;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -60,14 +63,14 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
static boolean canWalkThrough(BetterBlockPos pos) {
|
static boolean canWalkThrough(BetterBlockPos pos) {
|
||||||
return canWalkThrough(pos.x, pos.y, pos.z, BlockStateInterface.get(pos));
|
return canWalkThrough(new CalculationContext(), pos.x, pos.y, pos.z, BlockStateInterface.get(pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean canWalkThrough(int x, int y, int z) {
|
static boolean canWalkThrough(CalculationContext context, int x, int y, int z) {
|
||||||
return canWalkThrough(x, y, z, BlockStateInterface.get(x, y, z));
|
return canWalkThrough(context, x, y, z, context.get(x, y, z));
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean canWalkThrough(int x, int y, int z, IBlockState state) {
|
static boolean canWalkThrough(CalculationContext context, int x, int y, int z, IBlockState state) {
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
if (block == Blocks.AIR) { // early return for most common case
|
if (block == Blocks.AIR) { // early return for most common case
|
||||||
return true;
|
return true;
|
||||||
@ -108,7 +111,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
if (Baritone.settings().assumeWalkOnWater.get()) {
|
if (Baritone.settings().assumeWalkOnWater.get()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
IBlockState up = BlockStateInterface.get(x, y + 1, z);
|
IBlockState up = context.get(x, y + 1, z);
|
||||||
if (up.getBlock() instanceof BlockLiquid || up.getBlock() instanceof BlockLilyPad) {
|
if (up.getBlock() instanceof BlockLiquid || up.getBlock() instanceof BlockLilyPad) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -126,8 +129,8 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
static boolean fullyPassable(int x, int y, int z) {
|
static boolean fullyPassable(CalculationContext context, int x, int y, int z) {
|
||||||
return fullyPassable(BlockStateInterface.get(x, y, z));
|
return fullyPassable(context.get(x, y, z));
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean fullyPassable(IBlockState state) {
|
static boolean fullyPassable(IBlockState state) {
|
||||||
@ -242,7 +245,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
static boolean canWalkOn(int x, int y, int z, IBlockState state) {
|
static boolean canWalkOn(CalculationContext context, int x, int y, int z, IBlockState state) {
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
if (block == Blocks.AIR || block == Blocks.MAGMA) {
|
if (block == Blocks.AIR || block == Blocks.MAGMA) {
|
||||||
// early return for most common case (air)
|
// early return for most common case (air)
|
||||||
@ -264,7 +267,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
if (isWater(block)) {
|
if (isWater(block)) {
|
||||||
// since this is called literally millions of times per second, the benefit of not allocating millions of useless "pos.up()"
|
// since this is called literally millions of times per second, the benefit of not allocating millions of useless "pos.up()"
|
||||||
// BlockPos s that we'd just garbage collect immediately is actually noticeable. I don't even think its a decrease in readability
|
// BlockPos s that we'd just garbage collect immediately is actually noticeable. I don't even think its a decrease in readability
|
||||||
Block up = BlockStateInterface.get(x, y + 1, z).getBlock();
|
Block up = context.get(x, y + 1, z).getBlock();
|
||||||
if (up == Blocks.WATERLILY) {
|
if (up == Blocks.WATERLILY) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -292,19 +295,19 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static boolean canWalkOn(BetterBlockPos pos, IBlockState state) {
|
static boolean canWalkOn(BetterBlockPos pos, IBlockState state) {
|
||||||
return canWalkOn(pos.x, pos.y, pos.z, state);
|
return canWalkOn(new CalculationContext(), pos.x, pos.y, pos.z, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean canWalkOn(BetterBlockPos pos) {
|
static boolean canWalkOn(BetterBlockPos pos) {
|
||||||
return canWalkOn(pos.x, pos.y, pos.z, BlockStateInterface.get(pos));
|
return canWalkOn(new CalculationContext(), pos.x, pos.y, pos.z, BlockStateInterface.get(pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean canWalkOn(int x, int y, int z) {
|
static boolean canWalkOn(CalculationContext context, int x, int y, int z) {
|
||||||
return canWalkOn(x, y, z, BlockStateInterface.get(x, y, z));
|
return canWalkOn(context, x, y, z, context.get(x, y, z));
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean canPlaceAgainst(int x, int y, int z) {
|
static boolean canPlaceAgainst(CalculationContext context, int x, int y, int z) {
|
||||||
return canPlaceAgainst(BlockStateInterface.get(x, y, z));
|
return canPlaceAgainst(context.get(x, y, z));
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean canPlaceAgainst(BlockPos pos) {
|
static boolean canPlaceAgainst(BlockPos pos) {
|
||||||
@ -317,16 +320,16 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static double getMiningDurationTicks(CalculationContext context, int x, int y, int z, boolean includeFalling) {
|
static double getMiningDurationTicks(CalculationContext context, int x, int y, int z, boolean includeFalling) {
|
||||||
return getMiningDurationTicks(context, x, y, z, BlockStateInterface.get(x, y, z), includeFalling);
|
return getMiningDurationTicks(context, x, y, z, context.get(x, y, z), includeFalling);
|
||||||
}
|
}
|
||||||
|
|
||||||
static double getMiningDurationTicks(CalculationContext context, int x, int y, int z, IBlockState state, boolean includeFalling) {
|
static double getMiningDurationTicks(CalculationContext context, int x, int y, int z, IBlockState state, boolean includeFalling) {
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
if (!canWalkThrough(x, y, z, state)) {
|
if (!canWalkThrough(context, x, y, z, state)) {
|
||||||
if (!context.canBreakAt(x, y, z)) {
|
if (!context.canBreakAt(x, y, z)) {
|
||||||
return COST_INF;
|
return COST_INF;
|
||||||
}
|
}
|
||||||
if (avoidBreaking(x, y, z, state)) {
|
if (avoidBreaking(context, x, y, z, state)) {
|
||||||
return COST_INF;
|
return COST_INF;
|
||||||
}
|
}
|
||||||
if (block instanceof BlockLiquid) {
|
if (block instanceof BlockLiquid) {
|
||||||
@ -341,7 +344,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
double result = m / strVsBlock;
|
double result = m / strVsBlock;
|
||||||
result += context.breakBlockAdditionalCost();
|
result += context.breakBlockAdditionalCost();
|
||||||
if (includeFalling) {
|
if (includeFalling) {
|
||||||
IBlockState above = BlockStateInterface.get(x, y + 1, z);
|
IBlockState above = context.get(x, y + 1, z);
|
||||||
if (above.getBlock() instanceof BlockFalling) {
|
if (above.getBlock() instanceof BlockFalling) {
|
||||||
result += getMiningDurationTicks(context, x, y + 1, z, above, true);
|
result += getMiningDurationTicks(context, x, y + 1, z, above, true);
|
||||||
}
|
}
|
||||||
@ -357,10 +360,6 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
&& state.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.BOTTOM;
|
&& state.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.BOTTOM;
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean isBottomSlab(BlockPos pos) {
|
|
||||||
return isBottomSlab(BlockStateInterface.get(pos));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AutoTool
|
* AutoTool
|
||||||
*/
|
*/
|
||||||
|
@ -58,20 +58,20 @@ public class MovementAscend extends Movement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static double cost(CalculationContext context, int x, int y, int z, int destX, int destZ) {
|
public static double cost(CalculationContext context, int x, int y, int z, int destX, int destZ) {
|
||||||
IBlockState srcDown = BlockStateInterface.get(x, y - 1, z);
|
IBlockState srcDown = context.get(x, y - 1, z);
|
||||||
if (srcDown.getBlock() == Blocks.LADDER || srcDown.getBlock() == Blocks.VINE) {
|
if (srcDown.getBlock() == Blocks.LADDER || srcDown.getBlock() == Blocks.VINE) {
|
||||||
return COST_INF;
|
return COST_INF;
|
||||||
}
|
}
|
||||||
// we can jump from soul sand, but not from a bottom slab
|
// we can jump from soul sand, but not from a bottom slab
|
||||||
boolean jumpingFromBottomSlab = MovementHelper.isBottomSlab(srcDown);
|
boolean jumpingFromBottomSlab = MovementHelper.isBottomSlab(srcDown);
|
||||||
IBlockState toPlace = BlockStateInterface.get(destX, y, destZ);
|
IBlockState toPlace = context.get(destX, y, destZ);
|
||||||
boolean jumpingToBottomSlab = MovementHelper.isBottomSlab(toPlace);
|
boolean jumpingToBottomSlab = MovementHelper.isBottomSlab(toPlace);
|
||||||
|
|
||||||
if (jumpingFromBottomSlab && !jumpingToBottomSlab) {
|
if (jumpingFromBottomSlab && !jumpingToBottomSlab) {
|
||||||
return COST_INF;// the only thing we can ascend onto from a bottom slab is another bottom slab
|
return COST_INF;// the only thing we can ascend onto from a bottom slab is another bottom slab
|
||||||
}
|
}
|
||||||
boolean hasToPlace = false;
|
boolean hasToPlace = false;
|
||||||
if (!MovementHelper.canWalkOn(destX, y, destZ, toPlace)) {
|
if (!MovementHelper.canWalkOn(context, destX, y, destZ, toPlace)) {
|
||||||
if (!context.canPlaceThrowawayAt(destX, y, destZ)) {
|
if (!context.canPlaceThrowawayAt(destX, y, destZ)) {
|
||||||
return COST_INF;
|
return COST_INF;
|
||||||
}
|
}
|
||||||
@ -87,7 +87,7 @@ public class MovementAscend extends Movement {
|
|||||||
if (againstX == x && againstZ == z) {
|
if (againstX == x && againstZ == z) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (MovementHelper.canPlaceAgainst(againstX, y, againstZ)) {
|
if (MovementHelper.canPlaceAgainst(context, againstX, y, againstZ)) {
|
||||||
hasToPlace = true;
|
hasToPlace = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -97,7 +97,7 @@ public class MovementAscend extends Movement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
IBlockState srcUp2 = null;
|
IBlockState srcUp2 = null;
|
||||||
if (BlockStateInterface.get(x, y + 3, z).getBlock() instanceof BlockFalling && (MovementHelper.canWalkThrough(x, y + 1, z) || !((srcUp2 = BlockStateInterface.get(x, y + 2, z)).getBlock() instanceof BlockFalling))) {//it would fall on us and possibly suffocate us
|
if (context.get(x, y + 3, z).getBlock() instanceof BlockFalling && (MovementHelper.canWalkThrough(context, x, y + 1, z) || !((srcUp2 = context.get(x, y + 2, z)).getBlock() instanceof BlockFalling))) {//it would fall on us and possibly suffocate us
|
||||||
// HOWEVER, we assume that we're standing in the start position
|
// HOWEVER, we assume that we're standing in the start position
|
||||||
// that means that src and src.up(1) are both air
|
// that means that src and src.up(1) are both air
|
||||||
// maybe they aren't now, but they will be by the time this starts
|
// maybe they aren't now, but they will be by the time this starts
|
||||||
@ -138,7 +138,7 @@ public class MovementAscend extends Movement {
|
|||||||
totalCost += context.placeBlockCost();
|
totalCost += context.placeBlockCost();
|
||||||
}
|
}
|
||||||
if (srcUp2 == null) {
|
if (srcUp2 == null) {
|
||||||
srcUp2 = BlockStateInterface.get(x, y + 2, z);
|
srcUp2 = context.get(x, y + 2, z);
|
||||||
}
|
}
|
||||||
totalCost += MovementHelper.getMiningDurationTicks(context, x, y + 2, z, srcUp2, false); // TODO MAKE ABSOLUTELY SURE we don't need includeFalling here, from the falling check above
|
totalCost += MovementHelper.getMiningDurationTicks(context, x, y + 2, z, srcUp2, false); // TODO MAKE ABSOLUTELY SURE we don't need includeFalling here, from the falling check above
|
||||||
if (totalCost >= COST_INF) {
|
if (totalCost >= COST_INF) {
|
||||||
@ -204,7 +204,7 @@ public class MovementAscend extends Movement {
|
|||||||
return state.setStatus(MovementStatus.UNREACHABLE);
|
return state.setStatus(MovementStatus.UNREACHABLE);
|
||||||
}
|
}
|
||||||
MovementHelper.moveTowards(state, dest);
|
MovementHelper.moveTowards(state, dest);
|
||||||
if (MovementHelper.isBottomSlab(jumpingOnto) && !MovementHelper.isBottomSlab(src.down())) {
|
if (MovementHelper.isBottomSlab(jumpingOnto) && !MovementHelper.isBottomSlab(BlockStateInterface.get(src.down()))) {
|
||||||
return state; // don't jump while walking from a non double slab into a bottom slab
|
return state; // don't jump while walking from a non double slab into a bottom slab
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,6 @@ import baritone.pathing.movement.CalculationContext;
|
|||||||
import baritone.pathing.movement.Movement;
|
import baritone.pathing.movement.Movement;
|
||||||
import baritone.pathing.movement.MovementHelper;
|
import baritone.pathing.movement.MovementHelper;
|
||||||
import baritone.pathing.movement.MovementState;
|
import baritone.pathing.movement.MovementState;
|
||||||
import baritone.utils.BlockStateInterface;
|
|
||||||
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;
|
||||||
@ -58,13 +57,13 @@ public class MovementDescend extends Movement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void cost(CalculationContext context, int x, int y, int z, int destX, int destZ, MutableMoveResult res) {
|
public static void cost(CalculationContext context, int x, int y, int z, int destX, int destZ, MutableMoveResult res) {
|
||||||
Block fromDown = BlockStateInterface.get(x, y - 1, z).getBlock();
|
Block fromDown = context.get(x, y - 1, z).getBlock();
|
||||||
if (fromDown == Blocks.LADDER || fromDown == Blocks.VINE) {
|
if (fromDown == Blocks.LADDER || fromDown == Blocks.VINE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
double totalCost = 0;
|
double totalCost = 0;
|
||||||
IBlockState destDown = BlockStateInterface.get(destX, y - 1, destZ);
|
IBlockState destDown = context.get(destX, y - 1, destZ);
|
||||||
totalCost += MovementHelper.getMiningDurationTicks(context, destX, y - 1, destZ, destDown, false);
|
totalCost += MovementHelper.getMiningDurationTicks(context, destX, y - 1, destZ, destDown, false);
|
||||||
if (totalCost >= COST_INF) {
|
if (totalCost >= COST_INF) {
|
||||||
return;
|
return;
|
||||||
@ -88,8 +87,8 @@ public class MovementDescend extends Movement {
|
|||||||
//A is plausibly breakable by either descend or fall
|
//A is plausibly breakable by either descend or fall
|
||||||
//C, D, etc determine the length of the fall
|
//C, D, etc determine the length of the fall
|
||||||
|
|
||||||
IBlockState below = BlockStateInterface.get(destX, y - 2, destZ);
|
IBlockState below = context.get(destX, y - 2, destZ);
|
||||||
if (!MovementHelper.canWalkOn(destX, y - 2, destZ, below)) {
|
if (!MovementHelper.canWalkOn(context, destX, y - 2, destZ, below)) {
|
||||||
dynamicFallCost(context, x, y, z, destX, destZ, totalCost, below, res);
|
dynamicFallCost(context, x, y, z, destX, destZ, totalCost, below, res);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -112,13 +111,13 @@ public class MovementDescend extends Movement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void dynamicFallCost(CalculationContext context, int x, int y, int z, int destX, int destZ, double frontBreak, IBlockState below, MutableMoveResult res) {
|
public static void dynamicFallCost(CalculationContext context, int x, int y, int z, int destX, int destZ, double frontBreak, IBlockState below, MutableMoveResult res) {
|
||||||
if (frontBreak != 0 && BlockStateInterface.get(destX, y + 2, destZ).getBlock() instanceof BlockFalling) {
|
if (frontBreak != 0 && context.get(destX, y + 2, destZ).getBlock() instanceof BlockFalling) {
|
||||||
// if frontBreak is 0 we can actually get through this without updating the falling block and making it actually fall
|
// if frontBreak is 0 we can actually get through this without updating the falling block and making it actually fall
|
||||||
// but if frontBreak is nonzero, we're breaking blocks in front, so don't let anything fall through this column,
|
// but if frontBreak is nonzero, we're breaking blocks in front, so don't let anything fall through this column,
|
||||||
// and potentially replace the water we're going to fall into
|
// and potentially replace the water we're going to fall into
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!MovementHelper.canWalkThrough(destX, y - 2, destZ, below) && below.getBlock() != Blocks.WATER) {
|
if (!MovementHelper.canWalkThrough(context, destX, y - 2, destZ, below) && below.getBlock() != Blocks.WATER) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (int fallHeight = 3; true; fallHeight++) {
|
for (int fallHeight = 3; true; fallHeight++) {
|
||||||
@ -128,9 +127,9 @@ public class MovementDescend extends Movement {
|
|||||||
// this check prevents it from getting the block at y=-1 and crashing
|
// this check prevents it from getting the block at y=-1 and crashing
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IBlockState ontoBlock = BlockStateInterface.get(destX, newY, destZ);
|
IBlockState ontoBlock = context.get(destX, newY, destZ);
|
||||||
double tentativeCost = WALK_OFF_BLOCK_COST + FALL_N_BLOCKS_COST[fallHeight] + frontBreak;
|
double tentativeCost = WALK_OFF_BLOCK_COST + FALL_N_BLOCKS_COST[fallHeight] + frontBreak;
|
||||||
if (ontoBlock.getBlock() == Blocks.WATER && !MovementHelper.isFlowing(ontoBlock) && BlockStateInterface.getBlock(destX, newY + 1, destZ) != Blocks.WATERLILY) { // TODO flowing check required here?
|
if (ontoBlock.getBlock() == Blocks.WATER && !MovementHelper.isFlowing(ontoBlock) && context.getBlock(destX, newY + 1, destZ) != Blocks.WATERLILY) { // TODO flowing check required here?
|
||||||
// lilypads are canWalkThrough, but we can't end a fall that should be broken by water if it's covered by a lilypad
|
// lilypads are canWalkThrough, but we can't end a fall that should be broken by water if it's covered by a lilypad
|
||||||
// however, don't return impossible in the lilypad scenario, because we could still jump right on it (water that's below a lilypad is canWalkOn so it works)
|
// however, don't return impossible in the lilypad scenario, because we could still jump right on it (water that's below a lilypad is canWalkOn so it works)
|
||||||
if (Baritone.settings().assumeWalkOnWater.get()) {
|
if (Baritone.settings().assumeWalkOnWater.get()) {
|
||||||
@ -146,10 +145,10 @@ public class MovementDescend extends Movement {
|
|||||||
if (ontoBlock.getBlock() == Blocks.FLOWING_WATER) {
|
if (ontoBlock.getBlock() == Blocks.FLOWING_WATER) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (MovementHelper.canWalkThrough(destX, newY, destZ, ontoBlock)) {
|
if (MovementHelper.canWalkThrough(context, destX, newY, destZ, ontoBlock)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!MovementHelper.canWalkOn(destX, newY, destZ, ontoBlock)) {
|
if (!MovementHelper.canWalkOn(context, destX, newY, destZ, ontoBlock)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (MovementHelper.isBottomSlab(ontoBlock)) {
|
if (MovementHelper.isBottomSlab(ontoBlock)) {
|
||||||
|
@ -23,7 +23,6 @@ import baritone.pathing.movement.CalculationContext;
|
|||||||
import baritone.pathing.movement.Movement;
|
import baritone.pathing.movement.Movement;
|
||||||
import baritone.pathing.movement.MovementHelper;
|
import baritone.pathing.movement.MovementHelper;
|
||||||
import baritone.pathing.movement.MovementState;
|
import baritone.pathing.movement.MovementState;
|
||||||
import baritone.utils.BlockStateInterface;
|
|
||||||
import baritone.utils.InputOverrideHandler;
|
import baritone.utils.InputOverrideHandler;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
@ -57,16 +56,16 @@ public class MovementDiagonal extends Movement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static double cost(CalculationContext context, int x, int y, int z, int destX, int destZ) {
|
public static double cost(CalculationContext context, int x, int y, int z, int destX, int destZ) {
|
||||||
Block fromDown = BlockStateInterface.get(x, y - 1, z).getBlock();
|
Block fromDown = context.get(x, y - 1, z).getBlock();
|
||||||
if (fromDown == Blocks.LADDER || fromDown == Blocks.VINE) {
|
if (fromDown == Blocks.LADDER || fromDown == Blocks.VINE) {
|
||||||
return COST_INF;
|
return COST_INF;
|
||||||
}
|
}
|
||||||
IBlockState destInto = BlockStateInterface.get(destX, y, destZ);
|
IBlockState destInto = context.get(destX, y, destZ);
|
||||||
if (!MovementHelper.canWalkThrough(destX, y, destZ, destInto) || !MovementHelper.canWalkThrough(destX, y + 1, destZ)) {
|
if (!MovementHelper.canWalkThrough(context, destX, y, destZ, destInto) || !MovementHelper.canWalkThrough(context, destX, y + 1, destZ)) {
|
||||||
return COST_INF;
|
return COST_INF;
|
||||||
}
|
}
|
||||||
IBlockState destWalkOn = BlockStateInterface.get(destX, y - 1, destZ);
|
IBlockState destWalkOn = context.get(destX, y - 1, destZ);
|
||||||
if (!MovementHelper.canWalkOn(destX, y - 1, destZ, destWalkOn)) {
|
if (!MovementHelper.canWalkOn(context, destX, y - 1, destZ, destWalkOn)) {
|
||||||
return COST_INF;
|
return COST_INF;
|
||||||
}
|
}
|
||||||
double multiplier = WALK_ONE_BLOCK_COST;
|
double multiplier = WALK_ONE_BLOCK_COST;
|
||||||
@ -77,16 +76,16 @@ public class MovementDiagonal extends Movement {
|
|||||||
if (fromDown == Blocks.SOUL_SAND) {
|
if (fromDown == Blocks.SOUL_SAND) {
|
||||||
multiplier += (WALK_ONE_OVER_SOUL_SAND_COST - WALK_ONE_BLOCK_COST) / 2;
|
multiplier += (WALK_ONE_OVER_SOUL_SAND_COST - WALK_ONE_BLOCK_COST) / 2;
|
||||||
}
|
}
|
||||||
Block cuttingOver1 = BlockStateInterface.get(x, y - 1, destZ).getBlock();
|
Block cuttingOver1 = context.get(x, y - 1, destZ).getBlock();
|
||||||
if (cuttingOver1 == Blocks.MAGMA || MovementHelper.isLava(cuttingOver1)) {
|
if (cuttingOver1 == Blocks.MAGMA || MovementHelper.isLava(cuttingOver1)) {
|
||||||
return COST_INF;
|
return COST_INF;
|
||||||
}
|
}
|
||||||
Block cuttingOver2 = BlockStateInterface.get(destX, y - 1, z).getBlock();
|
Block cuttingOver2 = context.get(destX, y - 1, z).getBlock();
|
||||||
if (cuttingOver2 == Blocks.MAGMA || MovementHelper.isLava(cuttingOver2)) {
|
if (cuttingOver2 == Blocks.MAGMA || MovementHelper.isLava(cuttingOver2)) {
|
||||||
return COST_INF;
|
return COST_INF;
|
||||||
}
|
}
|
||||||
IBlockState pb0 = BlockStateInterface.get(x, y, destZ);
|
IBlockState pb0 = context.get(x, y, destZ);
|
||||||
IBlockState pb2 = BlockStateInterface.get(destX, y, z);
|
IBlockState pb2 = context.get(destX, y, z);
|
||||||
double optionA = MovementHelper.getMiningDurationTicks(context, x, y, destZ, pb0, false);
|
double optionA = MovementHelper.getMiningDurationTicks(context, x, y, destZ, pb0, false);
|
||||||
double optionB = MovementHelper.getMiningDurationTicks(context, destX, y, z, pb2, false);
|
double optionB = MovementHelper.getMiningDurationTicks(context, destX, y, z, pb2, false);
|
||||||
if (optionA != 0 && optionB != 0) {
|
if (optionA != 0 && optionB != 0) {
|
||||||
@ -94,13 +93,13 @@ public class MovementDiagonal extends Movement {
|
|||||||
// so no need to check pb1 as well, might as well return early here
|
// so no need to check pb1 as well, might as well return early here
|
||||||
return COST_INF;
|
return COST_INF;
|
||||||
}
|
}
|
||||||
IBlockState pb1 = BlockStateInterface.get(x, y + 1, destZ);
|
IBlockState pb1 = context.get(x, y + 1, destZ);
|
||||||
optionA += MovementHelper.getMiningDurationTicks(context, x, y + 1, destZ, pb1, true);
|
optionA += MovementHelper.getMiningDurationTicks(context, x, y + 1, destZ, pb1, true);
|
||||||
if (optionA != 0 && optionB != 0) {
|
if (optionA != 0 && optionB != 0) {
|
||||||
// same deal, if pb1 makes optionA nonzero and option B already was nonzero, pb3 can't affect the result
|
// same deal, if pb1 makes optionA nonzero and option B already was nonzero, pb3 can't affect the result
|
||||||
return COST_INF;
|
return COST_INF;
|
||||||
}
|
}
|
||||||
IBlockState pb3 = BlockStateInterface.get(destX, y + 1, z);
|
IBlockState pb3 = context.get(destX, y + 1, z);
|
||||||
if (optionA == 0 && ((MovementHelper.avoidWalkingInto(pb2.getBlock()) && pb2.getBlock() != Blocks.WATER) || (MovementHelper.avoidWalkingInto(pb3.getBlock()) && pb3.getBlock() != Blocks.WATER))) {
|
if (optionA == 0 && ((MovementHelper.avoidWalkingInto(pb2.getBlock()) && pb2.getBlock() != Blocks.WATER) || (MovementHelper.avoidWalkingInto(pb3.getBlock()) && pb3.getBlock() != Blocks.WATER))) {
|
||||||
// at this point we're done calculating optionA, so we can check if it's actually possible to edge around in that direction
|
// at this point we're done calculating optionA, so we can check if it's actually possible to edge around in that direction
|
||||||
return COST_INF;
|
return COST_INF;
|
||||||
@ -115,7 +114,7 @@ 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())) {
|
if (MovementHelper.isWater(context.getBlock(x, y, z)) || 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
|
||||||
|
@ -23,7 +23,6 @@ import baritone.pathing.movement.CalculationContext;
|
|||||||
import baritone.pathing.movement.Movement;
|
import baritone.pathing.movement.Movement;
|
||||||
import baritone.pathing.movement.MovementHelper;
|
import baritone.pathing.movement.MovementHelper;
|
||||||
import baritone.pathing.movement.MovementState;
|
import baritone.pathing.movement.MovementState;
|
||||||
import baritone.utils.BlockStateInterface;
|
|
||||||
import net.minecraft.block.Block;
|
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;
|
||||||
@ -48,10 +47,10 @@ public class MovementDownward extends Movement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static double cost(CalculationContext context, int x, int y, int z) {
|
public static double cost(CalculationContext context, int x, int y, int z) {
|
||||||
if (!MovementHelper.canWalkOn(x, y - 2, z)) {
|
if (!MovementHelper.canWalkOn(context, x, y - 2, z)) {
|
||||||
return COST_INF;
|
return COST_INF;
|
||||||
}
|
}
|
||||||
IBlockState d = BlockStateInterface.get(x, y - 1, z);
|
IBlockState d = context.get(x, y - 1, z);
|
||||||
Block td = d.getBlock();
|
Block td = d.getBlock();
|
||||||
boolean ladder = td == Blocks.LADDER || td == Blocks.VINE;
|
boolean ladder = td == Blocks.LADDER || td == Blocks.VINE;
|
||||||
if (ladder) {
|
if (ladder) {
|
||||||
|
@ -27,7 +27,9 @@ import baritone.pathing.movement.CalculationContext;
|
|||||||
import baritone.pathing.movement.Movement;
|
import baritone.pathing.movement.Movement;
|
||||||
import baritone.pathing.movement.MovementHelper;
|
import baritone.pathing.movement.MovementHelper;
|
||||||
import baritone.pathing.movement.MovementState;
|
import baritone.pathing.movement.MovementState;
|
||||||
import baritone.utils.*;
|
import baritone.utils.BlockStateInterface;
|
||||||
|
import baritone.utils.Helper;
|
||||||
|
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.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
@ -65,30 +67,30 @@ public class MovementParkour extends Movement {
|
|||||||
if (!Baritone.settings().allowParkour.get()) {
|
if (!Baritone.settings().allowParkour.get()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IBlockState standingOn = BlockStateInterface.get(x, y - 1, z);
|
IBlockState standingOn = context.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 || MovementHelper.isBottomSlab(standingOn)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int xDiff = dir.getXOffset();
|
int xDiff = dir.getXOffset();
|
||||||
int zDiff = dir.getZOffset();
|
int zDiff = dir.getZOffset();
|
||||||
IBlockState adj = BlockStateInterface.get(x + xDiff, y - 1, z + zDiff);
|
IBlockState adj = context.get(x + xDiff, y - 1, z + zDiff);
|
||||||
if (MovementHelper.avoidWalkingInto(adj.getBlock()) && adj.getBlock() != Blocks.WATER && adj.getBlock() != Blocks.FLOWING_WATER) { // magma sucks
|
if (MovementHelper.avoidWalkingInto(adj.getBlock()) && adj.getBlock() != Blocks.WATER && adj.getBlock() != Blocks.FLOWING_WATER) { // magma sucks
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (MovementHelper.canWalkOn(x + xDiff, y - 1, z + zDiff, adj)) { // don't parkour if we could just traverse (for now)
|
if (MovementHelper.canWalkOn(context,x + xDiff, y - 1, z + zDiff, adj)) { // don't parkour if we could just traverse (for now)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!MovementHelper.fullyPassable(x + xDiff, y, z + zDiff)) {
|
if (!MovementHelper.fullyPassable(context,x + xDiff, y, z + zDiff)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!MovementHelper.fullyPassable(x + xDiff, y + 1, z + zDiff)) {
|
if (!MovementHelper.fullyPassable(context,x + xDiff, y + 1, z + zDiff)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!MovementHelper.fullyPassable(x + xDiff, y + 2, z + zDiff)) {
|
if (!MovementHelper.fullyPassable(context,x + xDiff, y + 2, z + zDiff)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!MovementHelper.fullyPassable(x, y + 2, z)) {
|
if (!MovementHelper.fullyPassable(context,x, y + 2, z)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int maxJump;
|
int maxJump;
|
||||||
@ -104,11 +106,11 @@ public class MovementParkour extends Movement {
|
|||||||
for (int i = 2; i <= maxJump; i++) {
|
for (int i = 2; i <= maxJump; i++) {
|
||||||
// TODO perhaps dest.up(3) doesn't need to be fullyPassable, just canWalkThrough, possibly?
|
// TODO perhaps dest.up(3) doesn't need to be fullyPassable, just canWalkThrough, possibly?
|
||||||
for (int y2 = 0; y2 < 4; y2++) {
|
for (int y2 = 0; y2 < 4; y2++) {
|
||||||
if (!MovementHelper.fullyPassable(x + xDiff * i, y + y2, z + zDiff * i)) {
|
if (!MovementHelper.fullyPassable(context,x + xDiff * i, y + y2, z + zDiff * i)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (MovementHelper.canWalkOn(x + xDiff * i, y - 1, z + zDiff * i)) {
|
if (MovementHelper.canWalkOn(context,x + xDiff * i, y - 1, z + zDiff * i)) {
|
||||||
res.x = x + xDiff * i;
|
res.x = x + xDiff * i;
|
||||||
res.y = y;
|
res.y = y;
|
||||||
res.z = z + zDiff * i;
|
res.z = z + zDiff * i;
|
||||||
@ -128,7 +130,7 @@ public class MovementParkour extends Movement {
|
|||||||
}
|
}
|
||||||
int destX = x + 4 * xDiff;
|
int destX = x + 4 * xDiff;
|
||||||
int destZ = z + 4 * zDiff;
|
int destZ = z + 4 * zDiff;
|
||||||
IBlockState toPlace = BlockStateInterface.get(destX, y - 1, destZ);
|
IBlockState toPlace = context.get(destX, y - 1, destZ);
|
||||||
if (!context.canPlaceThrowawayAt(destX, y - 1, destZ)) {
|
if (!context.canPlaceThrowawayAt(destX, y - 1, destZ)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -141,7 +143,7 @@ public class MovementParkour extends Movement {
|
|||||||
if (againstX == x + xDiff * 3 && againstZ == z + zDiff * 3) { // we can't turn around that fast
|
if (againstX == x + xDiff * 3 && againstZ == z + zDiff * 3) { // we can't turn around that fast
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (MovementHelper.canPlaceAgainst(againstX, y - 1, againstZ)) {
|
if (MovementHelper.canPlaceAgainst(context,againstX, y - 1, againstZ)) {
|
||||||
res.x = destX;
|
res.x = destX;
|
||||||
res.y = y;
|
res.y = y;
|
||||||
res.z = destZ;
|
res.z = destZ;
|
||||||
@ -259,4 +261,4 @@ public class MovementParkour extends Movement {
|
|||||||
}
|
}
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ package baritone.pathing.movement.movements;
|
|||||||
import baritone.api.pathing.movement.MovementStatus;
|
import baritone.api.pathing.movement.MovementStatus;
|
||||||
import baritone.api.utils.BetterBlockPos;
|
import baritone.api.utils.BetterBlockPos;
|
||||||
import baritone.api.utils.Rotation;
|
import baritone.api.utils.Rotation;
|
||||||
|
import baritone.api.utils.RotationUtils;
|
||||||
import baritone.api.utils.VecUtils;
|
import baritone.api.utils.VecUtils;
|
||||||
import baritone.pathing.movement.CalculationContext;
|
import baritone.pathing.movement.CalculationContext;
|
||||||
import baritone.pathing.movement.Movement;
|
import baritone.pathing.movement.Movement;
|
||||||
@ -27,7 +28,6 @@ import baritone.pathing.movement.MovementHelper;
|
|||||||
import baritone.pathing.movement.MovementState;
|
import baritone.pathing.movement.MovementState;
|
||||||
import baritone.utils.BlockStateInterface;
|
import baritone.utils.BlockStateInterface;
|
||||||
import baritone.utils.InputOverrideHandler;
|
import baritone.utils.InputOverrideHandler;
|
||||||
import baritone.api.utils.RotationUtils;
|
|
||||||
import net.minecraft.block.*;
|
import net.minecraft.block.*;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
@ -46,9 +46,9 @@ public class MovementPillar extends Movement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static double cost(CalculationContext context, int x, int y, int z) {
|
public static double cost(CalculationContext context, int x, int y, int z) {
|
||||||
Block fromDown = BlockStateInterface.get(x, y, z).getBlock();
|
Block fromDown = context.get(x, y, z).getBlock();
|
||||||
boolean ladder = fromDown instanceof BlockLadder || fromDown instanceof BlockVine;
|
boolean ladder = fromDown instanceof BlockLadder || fromDown instanceof BlockVine;
|
||||||
IBlockState fromDownDown = BlockStateInterface.get(x, y - 1, z);
|
IBlockState fromDownDown = context.get(x, y - 1, z);
|
||||||
if (!ladder) {
|
if (!ladder) {
|
||||||
if (fromDownDown.getBlock() instanceof BlockLadder || fromDownDown.getBlock() instanceof BlockVine) {
|
if (fromDownDown.getBlock() instanceof BlockLadder || fromDownDown.getBlock() instanceof BlockVine) {
|
||||||
return COST_INF;
|
return COST_INF;
|
||||||
@ -57,17 +57,17 @@ public class MovementPillar extends Movement {
|
|||||||
return COST_INF; // can't pillar up from a bottom slab onto a non ladder
|
return COST_INF; // can't pillar up from a bottom slab onto a non ladder
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (fromDown instanceof BlockVine && !hasAgainst(x, y, z)) {
|
if (fromDown instanceof BlockVine && !hasAgainst(context, x, y, z)) {
|
||||||
return COST_INF;
|
return COST_INF;
|
||||||
}
|
}
|
||||||
IBlockState toBreak = BlockStateInterface.get(x, y + 2, z);
|
IBlockState toBreak = context.get(x, y + 2, z);
|
||||||
Block toBreakBlock = toBreak.getBlock();
|
Block toBreakBlock = toBreak.getBlock();
|
||||||
if (toBreakBlock instanceof BlockFenceGate) {
|
if (toBreakBlock instanceof BlockFenceGate) {
|
||||||
return COST_INF;
|
return COST_INF;
|
||||||
}
|
}
|
||||||
Block srcUp = null;
|
Block srcUp = null;
|
||||||
if (MovementHelper.isWater(toBreakBlock) && MovementHelper.isWater(fromDown)) {
|
if (MovementHelper.isWater(toBreakBlock) && MovementHelper.isWater(fromDown)) {
|
||||||
srcUp = BlockStateInterface.get(x, y + 1, z).getBlock();
|
srcUp = context.get(x, y + 1, z).getBlock();
|
||||||
if (MovementHelper.isWater(srcUp)) {
|
if (MovementHelper.isWater(srcUp)) {
|
||||||
return LADDER_UP_ONE_COST;
|
return LADDER_UP_ONE_COST;
|
||||||
}
|
}
|
||||||
@ -83,11 +83,11 @@ public class MovementPillar extends Movement {
|
|||||||
if (toBreakBlock instanceof BlockLadder || toBreakBlock instanceof BlockVine) {
|
if (toBreakBlock instanceof BlockLadder || toBreakBlock instanceof BlockVine) {
|
||||||
hardness = 0; // we won't actually need to break the ladder / vine because we're going to use it
|
hardness = 0; // we won't actually need to break the ladder / vine because we're going to use it
|
||||||
} else {
|
} else {
|
||||||
IBlockState check = BlockStateInterface.get(x, y + 3, z);
|
IBlockState check = context.get(x, y + 3, z);
|
||||||
if (check.getBlock() instanceof BlockFalling) {
|
if (check.getBlock() instanceof BlockFalling) {
|
||||||
// see MovementAscend's identical check for breaking a falling block above our head
|
// see MovementAscend's identical check for breaking a falling block above our head
|
||||||
if (srcUp == null) {
|
if (srcUp == null) {
|
||||||
srcUp = BlockStateInterface.get(x, y + 1, z).getBlock();
|
srcUp = context.get(x, y + 1, z).getBlock();
|
||||||
}
|
}
|
||||||
if (!(toBreakBlock instanceof BlockFalling) || !(srcUp instanceof BlockFalling)) {
|
if (!(toBreakBlock instanceof BlockFalling) || !(srcUp instanceof BlockFalling)) {
|
||||||
return COST_INF;
|
return COST_INF;
|
||||||
@ -112,24 +112,24 @@ public class MovementPillar extends Movement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasAgainst(int x, int y, int z) {
|
public static boolean hasAgainst(CalculationContext context, int x, int y, int z) {
|
||||||
return BlockStateInterface.get(x + 1, y, z).isBlockNormalCube() ||
|
return context.get(x + 1, y, z).isBlockNormalCube() ||
|
||||||
BlockStateInterface.get(x - 1, y, z).isBlockNormalCube() ||
|
context.get(x - 1, y, z).isBlockNormalCube() ||
|
||||||
BlockStateInterface.get(x, y, z + 1).isBlockNormalCube() ||
|
context.get(x, y, z + 1).isBlockNormalCube() ||
|
||||||
BlockStateInterface.get(x, y, z - 1).isBlockNormalCube();
|
context.get(x, y, z - 1).isBlockNormalCube();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BlockPos getAgainst(BlockPos vine) {
|
public static BlockPos getAgainst(CalculationContext context, BetterBlockPos vine) {
|
||||||
if (BlockStateInterface.get(vine.north()).isBlockNormalCube()) {
|
if (context.get(vine.north()).isBlockNormalCube()) {
|
||||||
return vine.north();
|
return vine.north();
|
||||||
}
|
}
|
||||||
if (BlockStateInterface.get(vine.south()).isBlockNormalCube()) {
|
if (context.get(vine.south()).isBlockNormalCube()) {
|
||||||
return vine.south();
|
return vine.south();
|
||||||
}
|
}
|
||||||
if (BlockStateInterface.get(vine.east()).isBlockNormalCube()) {
|
if (context.get(vine.east()).isBlockNormalCube()) {
|
||||||
return vine.east();
|
return vine.east();
|
||||||
}
|
}
|
||||||
if (BlockStateInterface.get(vine.west()).isBlockNormalCube()) {
|
if (context.get(vine.west()).isBlockNormalCube()) {
|
||||||
return vine.west();
|
return vine.west();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -166,7 +166,7 @@ public class MovementPillar extends Movement {
|
|||||||
|
|
||||||
boolean blockIsThere = MovementHelper.canWalkOn(src) || ladder;
|
boolean blockIsThere = MovementHelper.canWalkOn(src) || ladder;
|
||||||
if (ladder) {
|
if (ladder) {
|
||||||
BlockPos against = vine ? getAgainst(src) : src.offset(fromDown.getValue(BlockLadder.FACING).getOpposite());
|
BlockPos against = vine ? getAgainst(new CalculationContext(), src) : src.offset(fromDown.getValue(BlockLadder.FACING).getOpposite());
|
||||||
if (against == null) {
|
if (against == null) {
|
||||||
logDebug("Unable to climb vines");
|
logDebug("Unable to climb vines");
|
||||||
return state.setStatus(MovementStatus.UNREACHABLE);
|
return state.setStatus(MovementStatus.UNREACHABLE);
|
||||||
@ -175,7 +175,7 @@ public class MovementPillar extends Movement {
|
|||||||
if (playerFeet().equals(against.up()) || playerFeet().equals(dest)) {
|
if (playerFeet().equals(against.up()) || playerFeet().equals(dest)) {
|
||||||
return state.setStatus(MovementStatus.SUCCESS);
|
return state.setStatus(MovementStatus.SUCCESS);
|
||||||
}
|
}
|
||||||
if (MovementHelper.isBottomSlab(src.down())) {
|
if (MovementHelper.isBottomSlab(BlockStateInterface.get(src.down()))) {
|
||||||
state.setInput(InputOverrideHandler.Input.JUMP, true);
|
state.setInput(InputOverrideHandler.Input.JUMP, true);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@ -244,4 +244,4 @@ public class MovementPillar extends Movement {
|
|||||||
}
|
}
|
||||||
return super.prepared(state);
|
return super.prepared(state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,6 @@ import baritone.pathing.movement.MovementHelper;
|
|||||||
import baritone.pathing.movement.MovementState;
|
import baritone.pathing.movement.MovementState;
|
||||||
import baritone.utils.BlockStateInterface;
|
import baritone.utils.BlockStateInterface;
|
||||||
import baritone.utils.InputOverrideHandler;
|
import baritone.utils.InputOverrideHandler;
|
||||||
import baritone.api.utils.RayTraceUtils;
|
|
||||||
import baritone.api.utils.RotationUtils;
|
|
||||||
import net.minecraft.block.*;
|
import net.minecraft.block.*;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
@ -61,11 +59,11 @@ public class MovementTraverse extends Movement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static double cost(CalculationContext context, int x, int y, int z, int destX, int destZ) {
|
public static double cost(CalculationContext context, int x, int y, int z, int destX, int destZ) {
|
||||||
IBlockState pb0 = BlockStateInterface.get(destX, y + 1, destZ);
|
IBlockState pb0 = context.get(destX, y + 1, destZ);
|
||||||
IBlockState pb1 = BlockStateInterface.get(destX, y, destZ);
|
IBlockState pb1 = context.get(destX, y, destZ);
|
||||||
IBlockState destOn = BlockStateInterface.get(destX, y - 1, destZ);
|
IBlockState destOn = context.get(destX, y - 1, destZ);
|
||||||
Block srcDown = BlockStateInterface.getBlock(x, y - 1, z);
|
Block srcDown = context.getBlock(x, y - 1, z);
|
||||||
if (MovementHelper.canWalkOn(destX, y - 1, destZ, destOn)) {//this is a walk, not a bridge
|
if (MovementHelper.canWalkOn(context, destX, y - 1, destZ, destOn)) {//this is a walk, not a bridge
|
||||||
double WC = WALK_ONE_BLOCK_COST;
|
double WC = WALK_ONE_BLOCK_COST;
|
||||||
boolean water = false;
|
boolean water = false;
|
||||||
if (MovementHelper.isWater(pb0.getBlock()) || MovementHelper.isWater(pb1.getBlock())) {
|
if (MovementHelper.isWater(pb0.getBlock()) || MovementHelper.isWater(pb1.getBlock())) {
|
||||||
@ -123,7 +121,7 @@ public class MovementTraverse extends Movement {
|
|||||||
if (againstX == x && againstZ == z) {
|
if (againstX == x && againstZ == z) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (MovementHelper.canPlaceAgainst(againstX, y - 1, againstZ)) {
|
if (MovementHelper.canPlaceAgainst(context, againstX, y - 1, againstZ)) {
|
||||||
return WC + context.placeBlockCost() + hardness1 + hardness2;
|
return WC + context.placeBlockCost() + hardness1 + hardness2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,6 +97,6 @@ public class GetToBlockProcess extends BaritoneProcessHelper implements IGetToBl
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void rescan(List<BlockPos> known) {
|
private void rescan(List<BlockPos> known) {
|
||||||
knownLocations = MineProcess.searchWorld(Collections.singletonList(gettingTo), 64, world(), known);
|
knownLocations = MineProcess.searchWorld(Collections.singletonList(gettingTo), 64, baritone.getWorldProvider(), world(), known);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -22,15 +22,16 @@ import baritone.api.pathing.goals.*;
|
|||||||
import baritone.api.process.IMineProcess;
|
import baritone.api.process.IMineProcess;
|
||||||
import baritone.api.process.PathingCommand;
|
import baritone.api.process.PathingCommand;
|
||||||
import baritone.api.process.PathingCommandType;
|
import baritone.api.process.PathingCommandType;
|
||||||
|
import baritone.api.utils.RotationUtils;
|
||||||
import baritone.cache.CachedChunk;
|
import baritone.cache.CachedChunk;
|
||||||
import baritone.cache.ChunkPacker;
|
import baritone.cache.ChunkPacker;
|
||||||
import baritone.cache.WorldProvider;
|
import baritone.cache.WorldProvider;
|
||||||
import baritone.cache.WorldScanner;
|
import baritone.cache.WorldScanner;
|
||||||
|
import baritone.pathing.movement.CalculationContext;
|
||||||
import baritone.pathing.movement.MovementHelper;
|
import baritone.pathing.movement.MovementHelper;
|
||||||
import baritone.utils.BaritoneProcessHelper;
|
import baritone.utils.BaritoneProcessHelper;
|
||||||
import baritone.utils.BlockStateInterface;
|
import baritone.utils.BlockStateInterface;
|
||||||
import baritone.utils.Helper;
|
import baritone.utils.Helper;
|
||||||
import baritone.api.utils.RotationUtils;
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
import net.minecraft.entity.item.EntityItem;
|
||||||
@ -158,7 +159,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
if (Baritone.settings().legitMine.get()) {
|
if (Baritone.settings().legitMine.get()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<BlockPos> locs = searchWorld(mining, ORE_LOCATIONS_COUNT, world(), already);
|
List<BlockPos> locs = searchWorld(mining, ORE_LOCATIONS_COUNT, baritone.getWorldProvider(), world(), already);
|
||||||
locs.addAll(droppedItemsScan(mining, 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");
|
||||||
@ -216,13 +217,13 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
/*public static List<BlockPos> searchWorld(List<Block> mining, int max, World world) {
|
/*public static List<BlockPos> searchWorld(List<Block> mining, int max, World world) {
|
||||||
|
|
||||||
}*/
|
}*/
|
||||||
public static List<BlockPos> searchWorld(List<Block> mining, int max, World world, List<BlockPos> alreadyKnown) {
|
public static List<BlockPos> searchWorld(List<Block> mining, int max, WorldProvider provider, World world, List<BlockPos> alreadyKnown) {
|
||||||
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();
|
||||||
for (Block m : mining) {
|
for (Block m : mining) {
|
||||||
if (CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.contains(m)) {
|
if (CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.contains(m)) {
|
||||||
locs.addAll(WorldProvider.INSTANCE.getCurrentWorld().getCachedWorld().getLocationsOf(ChunkPacker.blockToString(m), 1, 1));
|
locs.addAll(provider.getCurrentWorld().getCachedWorld().getLocationsOf(ChunkPacker.blockToString(m), 1, 1));
|
||||||
} else {
|
} else {
|
||||||
uninteresting.add(m);
|
uninteresting.add(m);
|
||||||
}
|
}
|
||||||
@ -279,7 +280,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean plausibleToBreak(BlockPos pos) {
|
public static boolean plausibleToBreak(BlockPos pos) {
|
||||||
if (MovementHelper.avoidBreaking(pos.getX(), pos.getY(), pos.getZ(), BlockStateInterface.get(pos))) {
|
if (MovementHelper.avoidBreaking(new CalculationContext(), pos.getX(), pos.getY(), pos.getZ(), BlockStateInterface.get(pos))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// bedrock above and below makes it implausible, otherwise we're good
|
// bedrock above and below makes it implausible, otherwise we're good
|
||||||
|
@ -20,11 +20,12 @@ package baritone.utils;
|
|||||||
import baritone.Baritone;
|
import baritone.Baritone;
|
||||||
import baritone.cache.CachedRegion;
|
import baritone.cache.CachedRegion;
|
||||||
import baritone.cache.WorldData;
|
import baritone.cache.WorldData;
|
||||||
import baritone.cache.WorldProvider;
|
import baritone.pathing.movement.CalculationContext;
|
||||||
import net.minecraft.block.Block;
|
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.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.chunk.Chunk;
|
import net.minecraft.world.chunk.Chunk;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -43,7 +44,12 @@ public class BlockStateInterface implements Helper {
|
|||||||
return get(pos.getX(), pos.getY(), pos.getZ());
|
return get(pos.getX(), pos.getY(), pos.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static IBlockState get(int x, int y, int z) {
|
public static IBlockState get(int x, int y, int z) {
|
||||||
|
return get(Helper.HELPER.world(), x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IBlockState get(World world, int x, int y, int z) {
|
||||||
|
|
||||||
// Invalid vertical position
|
// Invalid vertical position
|
||||||
if (y < 0 || y >= 256) {
|
if (y < 0 || y >= 256) {
|
||||||
@ -61,7 +67,7 @@ public class BlockStateInterface implements Helper {
|
|||||||
if (cached != null && cached.x == x >> 4 && cached.z == z >> 4) {
|
if (cached != null && cached.x == x >> 4 && cached.z == z >> 4) {
|
||||||
return cached.getBlockState(x, y, z);
|
return cached.getBlockState(x, y, z);
|
||||||
}
|
}
|
||||||
Chunk chunk = mc.world.getChunk(x >> 4, z >> 4);
|
Chunk chunk = world.getChunk(x >> 4, z >> 4);
|
||||||
if (chunk.isLoaded()) {
|
if (chunk.isLoaded()) {
|
||||||
prev = chunk;
|
prev = chunk;
|
||||||
return chunk.getBlockState(x, y, z);
|
return chunk.getBlockState(x, y, z);
|
||||||
@ -71,11 +77,11 @@ public class BlockStateInterface implements Helper {
|
|||||||
// except here, it's 512x512 tiles instead of 16x16, so even better repetition
|
// except here, it's 512x512 tiles instead of 16x16, so even better repetition
|
||||||
CachedRegion cached = prevCached;
|
CachedRegion cached = prevCached;
|
||||||
if (cached == null || cached.getX() != x >> 9 || cached.getZ() != z >> 9) {
|
if (cached == null || cached.getX() != x >> 9 || cached.getZ() != z >> 9) {
|
||||||
WorldData world = WorldProvider.INSTANCE.getCurrentWorld();
|
WorldData worldData = Baritone.INSTANCE.getWorldProvider().getCurrentWorld();
|
||||||
if (world == null) {
|
if (worldData == null) {
|
||||||
return AIR;
|
return AIR;
|
||||||
}
|
}
|
||||||
CachedRegion region = world.cache.getRegion(x >> 9, z >> 9);
|
CachedRegion region = worldData.cache.getRegion(x >> 9, z >> 9);
|
||||||
if (region == null) {
|
if (region == null) {
|
||||||
return AIR;
|
return AIR;
|
||||||
}
|
}
|
||||||
@ -89,12 +95,12 @@ public class BlockStateInterface implements Helper {
|
|||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isLoaded(int x, int z) {
|
public static boolean isLoaded(CalculationContext context, int x, int z) {
|
||||||
Chunk prevChunk = prev;
|
Chunk prevChunk = prev;
|
||||||
if (prevChunk != null && prevChunk.x == x >> 4 && prevChunk.z == z >> 4) {
|
if (prevChunk != null && prevChunk.x == x >> 4 && prevChunk.z == z >> 4) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
prevChunk = mc.world.getChunk(x >> 4, z >> 4);
|
prevChunk = context.world().getChunk(x >> 4, z >> 4);
|
||||||
if (prevChunk.isLoaded()) {
|
if (prevChunk.isLoaded()) {
|
||||||
prev = prevChunk;
|
prev = prevChunk;
|
||||||
return true;
|
return true;
|
||||||
@ -103,7 +109,7 @@ public class BlockStateInterface implements Helper {
|
|||||||
if (prevRegion != null && prevRegion.getX() == x >> 9 && prevRegion.getZ() == z >> 9) {
|
if (prevRegion != null && prevRegion.getX() == x >> 9 && prevRegion.getZ() == z >> 9) {
|
||||||
return prevRegion.isCached(x & 511, z & 511);
|
return prevRegion.isCached(x & 511, z & 511);
|
||||||
}
|
}
|
||||||
WorldData world = WorldProvider.INSTANCE.getCurrentWorld();
|
WorldData world = Baritone.INSTANCE.getWorldProvider().getCurrentWorld();
|
||||||
if (world == null) {
|
if (world == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,6 @@ import baritone.behavior.Behavior;
|
|||||||
import baritone.behavior.PathingBehavior;
|
import baritone.behavior.PathingBehavior;
|
||||||
import baritone.cache.ChunkPacker;
|
import baritone.cache.ChunkPacker;
|
||||||
import baritone.cache.Waypoint;
|
import baritone.cache.Waypoint;
|
||||||
import baritone.cache.WorldProvider;
|
|
||||||
import baritone.pathing.calc.AbstractNodeCostSearch;
|
import baritone.pathing.calc.AbstractNodeCostSearch;
|
||||||
import baritone.pathing.movement.CalculationContext;
|
import baritone.pathing.movement.CalculationContext;
|
||||||
import baritone.pathing.movement.Movement;
|
import baritone.pathing.movement.Movement;
|
||||||
@ -215,7 +214,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
|
|||||||
Chunk chunk = cli.getLoadedChunk(x, z);
|
Chunk chunk = cli.getLoadedChunk(x, z);
|
||||||
if (chunk != null) {
|
if (chunk != null) {
|
||||||
count++;
|
count++;
|
||||||
WorldProvider.INSTANCE.getCurrentWorld().getCachedWorld().queueForPacking(chunk);
|
baritone.getWorldProvider().getCurrentWorld().getCachedWorld().queueForPacking(chunk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -291,18 +290,18 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (msg.equals("reloadall")) {
|
if (msg.equals("reloadall")) {
|
||||||
WorldProvider.INSTANCE.getCurrentWorld().getCachedWorld().reloadAllFromDisk();
|
baritone.getWorldProvider().getCurrentWorld().getCachedWorld().reloadAllFromDisk();
|
||||||
logDirect("ok");
|
logDirect("ok");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (msg.equals("saveall")) {
|
if (msg.equals("saveall")) {
|
||||||
WorldProvider.INSTANCE.getCurrentWorld().getCachedWorld().save();
|
baritone.getWorldProvider().getCurrentWorld().getCachedWorld().save();
|
||||||
logDirect("ok");
|
logDirect("ok");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (msg.startsWith("find")) {
|
if (msg.startsWith("find")) {
|
||||||
String blockType = msg.substring(4).trim();
|
String blockType = msg.substring(4).trim();
|
||||||
LinkedList<BlockPos> locs = WorldProvider.INSTANCE.getCurrentWorld().getCachedWorld().getLocationsOf(blockType, 1, 4);
|
LinkedList<BlockPos> locs = baritone.getWorldProvider().getCurrentWorld().getCachedWorld().getLocationsOf(blockType, 1, 4);
|
||||||
logDirect("Have " + locs.size() + " locations");
|
logDirect("Have " + locs.size() + " locations");
|
||||||
for (BlockPos pos : locs) {
|
for (BlockPos pos : locs) {
|
||||||
Block actually = BlockStateInterface.get(pos).getBlock();
|
Block actually = BlockStateInterface.get(pos).getBlock();
|
||||||
@ -354,7 +353,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
|
|||||||
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());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Set<IWaypoint> waypoints = WorldProvider.INSTANCE.getCurrentWorld().getWaypoints().getByTag(tag);
|
Set<IWaypoint> waypoints = baritone.getWorldProvider().getCurrentWorld().getWaypoints().getByTag(tag);
|
||||||
// might as well show them from oldest to newest
|
// might as well show them from oldest to newest
|
||||||
List<IWaypoint> sorted = new ArrayList<>(waypoints);
|
List<IWaypoint> sorted = new ArrayList<>(waypoints);
|
||||||
sorted.sort(Comparator.comparingLong(IWaypoint::getCreationTimestamp));
|
sorted.sort(Comparator.comparingLong(IWaypoint::getCreationTimestamp));
|
||||||
@ -382,7 +381,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
|
|||||||
}
|
}
|
||||||
name = parts[0];
|
name = parts[0];
|
||||||
}
|
}
|
||||||
WorldProvider.INSTANCE.getCurrentWorld().getWaypoints().addWaypoint(new Waypoint(name, Waypoint.Tag.USER, pos));
|
baritone.getWorldProvider().getCurrentWorld().getWaypoints().addWaypoint(new Waypoint(name, Waypoint.Tag.USER, pos));
|
||||||
logDirect("Saved user defined position " + pos + " under name '" + name + "'. Say 'goto " + name + "' to set goal, say 'list user' to list custom waypoints.");
|
logDirect("Saved user defined position " + pos + " under name '" + name + "'. Say 'goto " + name + "' to set goal, say 'list user' to list custom waypoints.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -399,7 +398,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
|
|||||||
Block block = ChunkPacker.stringToBlock(mining);
|
Block block = ChunkPacker.stringToBlock(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 = WorldProvider.INSTANCE.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);
|
||||||
if (waypoint == null) {
|
if (waypoint == null) {
|
||||||
logDirect("No locations for " + mining + " known, cancelling");
|
logDirect("No locations for " + mining + " known, cancelling");
|
||||||
return true;
|
return true;
|
||||||
@ -409,7 +408,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
waypoint = WorldProvider.INSTANCE.getCurrentWorld().getWaypoints().getMostRecentByTag(tag);
|
waypoint = baritone.getWorldProvider().getCurrentWorld().getWaypoints().getMostRecentByTag(tag);
|
||||||
if (waypoint == null) {
|
if (waypoint == null) {
|
||||||
logDirect("None saved for tag " + tag);
|
logDirect("None saved for tag " + tag);
|
||||||
return true;
|
return true;
|
||||||
@ -420,7 +419,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (msg.equals("spawn") || msg.equals("bed")) {
|
if (msg.equals("spawn") || msg.equals("bed")) {
|
||||||
IWaypoint waypoint = WorldProvider.INSTANCE.getCurrentWorld().getWaypoints().getMostRecentByTag(Waypoint.Tag.BED);
|
IWaypoint waypoint = baritone.getWorldProvider().getCurrentWorld().getWaypoints().getMostRecentByTag(Waypoint.Tag.BED);
|
||||||
if (waypoint == null) {
|
if (waypoint == null) {
|
||||||
BlockPos spawnPoint = player().getBedLocation();
|
BlockPos spawnPoint = player().getBedLocation();
|
||||||
// for some reason the default spawnpoint is underground sometimes
|
// for some reason the default spawnpoint is underground sometimes
|
||||||
@ -435,12 +434,12 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (msg.equals("sethome")) {
|
if (msg.equals("sethome")) {
|
||||||
WorldProvider.INSTANCE.getCurrentWorld().getWaypoints().addWaypoint(new Waypoint("", Waypoint.Tag.HOME, playerFeet()));
|
baritone.getWorldProvider().getCurrentWorld().getWaypoints().addWaypoint(new Waypoint("", Waypoint.Tag.HOME, playerFeet()));
|
||||||
logDirect("Saved. Say home to set goal.");
|
logDirect("Saved. Say home to set goal.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (msg.equals("home")) {
|
if (msg.equals("home")) {
|
||||||
IWaypoint waypoint = WorldProvider.INSTANCE.getCurrentWorld().getWaypoints().getMostRecentByTag(Waypoint.Tag.HOME);
|
IWaypoint waypoint = baritone.getWorldProvider().getCurrentWorld().getWaypoints().getMostRecentByTag(Waypoint.Tag.HOME);
|
||||||
if (waypoint == null) {
|
if (waypoint == null) {
|
||||||
logDirect("home not saved");
|
logDirect("home not saved");
|
||||||
} else {
|
} else {
|
||||||
|
@ -66,6 +66,9 @@ public interface Helper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
default WorldClient world() {
|
default WorldClient world() {
|
||||||
|
if (!mc.isCallingFromMinecraftThread()) {
|
||||||
|
throw new IllegalStateException("h00000000");
|
||||||
|
}
|
||||||
return mc.world;
|
return mc.world;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user