Merge pull request #3239 from scorbett123/world_border_checks

Add some world border checks
This commit is contained in:
Leijurv 2022-02-08 10:49:00 -08:00 committed by GitHub
commit d2b62e2d21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 1 deletions

View File

@ -143,7 +143,6 @@ public class CalculationContext {
return COST_INF; return COST_INF;
} }
if (!worldBorder.canPlaceAt(x, z)) { if (!worldBorder.canPlaceAt(x, z)) {
// TODO perhaps MovementHelper.canPlaceAgainst could also use this?
return COST_INF; return COST_INF;
} }
return placeBlockCost; return placeBlockCost;

View File

@ -49,6 +49,9 @@ import static baritone.pathing.movement.Movement.HORIZONTALS_BUT_ALSO_DOWN_____S
public interface MovementHelper extends ActionCosts, Helper { public interface MovementHelper extends ActionCosts, Helper {
static boolean avoidBreaking(BlockStateInterface bsi, int x, int y, int z, IBlockState state) { 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(); Block b = state.getBlock();
return Baritone.settings().blocksToDisallowBreaking.value.contains(b) return Baritone.settings().blocksToDisallowBreaking.value.contains(b)
|| b == Blocks.ICE // ice becomes water, and water can mess up the path || 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) { 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? // 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) // (thats how this check is used)
// therefore dont include weird things that we technically could place against (like carpet) but practically can't // therefore dont include weird things that we technically could place against (like carpet) but practically can't

View File

@ -22,6 +22,7 @@ import baritone.api.utils.IPlayerContext;
import baritone.cache.CachedRegion; import baritone.cache.CachedRegion;
import baritone.cache.WorldData; import baritone.cache.WorldData;
import baritone.utils.accessor.IChunkProviderClient; import baritone.utils.accessor.IChunkProviderClient;
import baritone.utils.pathing.BetterWorldBorder;
import it.unimi.dsi.fastutil.longs.Long2ObjectMap; import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@ -46,6 +47,7 @@ public class BlockStateInterface {
protected final IBlockAccess world; protected final IBlockAccess world;
public final BlockPos.MutableBlockPos isPassableBlockPos; public final BlockPos.MutableBlockPos isPassableBlockPos;
public final IBlockAccess access; public final IBlockAccess access;
public final BetterWorldBorder worldBorder;
private Chunk prev = null; private Chunk prev = null;
private CachedRegion prevCached = null; private CachedRegion prevCached = null;
@ -64,6 +66,7 @@ public class BlockStateInterface {
public BlockStateInterface(World world, WorldData worldData, boolean copyLoadedChunks) { public BlockStateInterface(World world, WorldData worldData, boolean copyLoadedChunks) {
this.world = world; this.world = world;
this.worldBorder = new BetterWorldBorder(world.getWorldBorder());
this.worldData = worldData; this.worldData = worldData;
Long2ObjectMap<Chunk> worldLoaded = ((IChunkProviderClient) world.getChunkProvider()).loadedChunks(); Long2ObjectMap<Chunk> worldLoaded = ((IChunkProviderClient) world.getChunkProvider()).loadedChunks();
if (copyLoadedChunks) { if (copyLoadedChunks) {