mirror of https://github.com/cabaletta/baritone
Merge pull request #3239 from scorbett123/world_border_checks
Add some world border checks
This commit is contained in:
commit
d2b62e2d21
|
@ -143,7 +143,6 @@ public class CalculationContext {
|
|||
return COST_INF;
|
||||
}
|
||||
if (!worldBorder.canPlaceAt(x, z)) {
|
||||
// TODO perhaps MovementHelper.canPlaceAgainst could also use this?
|
||||
return COST_INF;
|
||||
}
|
||||
return placeBlockCost;
|
||||
|
|
|
@ -49,6 +49,9 @@ import static baritone.pathing.movement.Movement.HORIZONTALS_BUT_ALSO_DOWN_____S
|
|||
public interface MovementHelper extends ActionCosts, Helper {
|
||||
|
||||
static boolean avoidBreaking(BlockStateInterface bsi, int x, int y, int z, IBlockState state) {
|
||||
if (!bsi.worldBorder.canPlaceAt(x, y)) {
|
||||
return true;
|
||||
}
|
||||
Block b = state.getBlock();
|
||||
return Baritone.settings().blocksToDisallowBreaking.value.contains(b)
|
||||
|| b == Blocks.ICE // ice becomes water, and water can mess up the path
|
||||
|
@ -370,6 +373,9 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||
}
|
||||
|
||||
static boolean canPlaceAgainst(BlockStateInterface bsi, int x, int y, int z, IBlockState state) {
|
||||
if (!bsi.worldBorder.canPlaceAt(x, z)) {
|
||||
return false;
|
||||
}
|
||||
// can we look at the center of a side face of this block and likely be able to place?
|
||||
// (thats how this check is used)
|
||||
// therefore dont include weird things that we technically could place against (like carpet) but practically can't
|
||||
|
|
|
@ -22,6 +22,7 @@ import baritone.api.utils.IPlayerContext;
|
|||
import baritone.cache.CachedRegion;
|
||||
import baritone.cache.WorldData;
|
||||
import baritone.utils.accessor.IChunkProviderClient;
|
||||
import baritone.utils.pathing.BetterWorldBorder;
|
||||
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
|
||||
import net.minecraft.block.Block;
|
||||
|
@ -46,6 +47,7 @@ public class BlockStateInterface {
|
|||
protected final IBlockAccess world;
|
||||
public final BlockPos.MutableBlockPos isPassableBlockPos;
|
||||
public final IBlockAccess access;
|
||||
public final BetterWorldBorder worldBorder;
|
||||
|
||||
private Chunk prev = null;
|
||||
private CachedRegion prevCached = null;
|
||||
|
@ -64,6 +66,7 @@ public class BlockStateInterface {
|
|||
|
||||
public BlockStateInterface(World world, WorldData worldData, boolean copyLoadedChunks) {
|
||||
this.world = world;
|
||||
this.worldBorder = new BetterWorldBorder(world.getWorldBorder());
|
||||
this.worldData = worldData;
|
||||
Long2ObjectMap<Chunk> worldLoaded = ((IChunkProviderClient) world.getChunkProvider()).loadedChunks();
|
||||
if (copyLoadedChunks) {
|
||||
|
|
Loading…
Reference in New Issue