mirror of https://github.com/cabaletta/baritone
Remove `getMinecraft()` from `BlockStateInterface`
This commit is contained in:
parent
2db2d8be59
commit
5b39c0dd96
|
@ -51,6 +51,7 @@ public interface IBuilderProcess extends IBaritoneProcess {
|
|||
*/
|
||||
boolean build(String name, File schematic, Vec3i origin);
|
||||
|
||||
@Deprecated
|
||||
default boolean build(String schematicFile, BlockPos origin) {
|
||||
File file = new File(new File(Minecraft.getMinecraft().gameDir, "schematics"), schematicFile);
|
||||
return build(schematicFile, file, origin);
|
||||
|
|
|
@ -36,7 +36,6 @@ import baritone.pathing.path.PathExecutor;
|
|||
import baritone.utils.PathRenderer;
|
||||
import baritone.utils.PathingCommandContext;
|
||||
import baritone.utils.pathing.Favoring;
|
||||
import net.minecraft.client.settings.GameSettings;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
|
@ -91,8 +91,8 @@ public class CalculationContext {
|
|||
this.baritone = baritone;
|
||||
EntityPlayerSP player = baritone.getPlayerContext().player();
|
||||
this.world = baritone.getPlayerContext().world();
|
||||
this.worldData = (WorldData) baritone.getWorldProvider().getCurrentWorld();
|
||||
this.bsi = new BlockStateInterface(world, worldData, forUseOnAnotherThread);
|
||||
this.worldData = (WorldData) baritone.getPlayerContext().worldData();
|
||||
this.bsi = new BlockStateInterface(baritone.getPlayerContext(), forUseOnAnotherThread);
|
||||
this.toolSet = new ToolSet(player);
|
||||
this.hasThrowaway = Baritone.settings().allowPlace.value && ((Baritone) baritone).getInventoryBehavior().hasGenericThrowaway();
|
||||
this.hasWaterBucket = Baritone.settings().allowWaterBucketFall.value && InventoryPlayer.isHotbar(player.inventory.getSlotFor(STACK_BUCKET_WATER)) && !world.provider.isNether();
|
||||
|
|
|
@ -27,7 +27,6 @@ import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
|
|||
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
|
@ -44,7 +43,6 @@ public class BlockStateInterface {
|
|||
|
||||
private final Long2ObjectMap<Chunk> loadedChunks;
|
||||
private final WorldData worldData;
|
||||
protected final IBlockAccess world;
|
||||
public final BlockPos.MutableBlockPos isPassableBlockPos;
|
||||
public final IBlockAccess access;
|
||||
public final BetterWorldBorder worldBorder;
|
||||
|
@ -61,13 +59,9 @@ public class BlockStateInterface {
|
|||
}
|
||||
|
||||
public BlockStateInterface(IPlayerContext ctx, boolean copyLoadedChunks) {
|
||||
this(ctx.world(), (WorldData) ctx.worldData(), copyLoadedChunks);
|
||||
}
|
||||
|
||||
public BlockStateInterface(World world, WorldData worldData, boolean copyLoadedChunks) {
|
||||
this.world = world;
|
||||
final World world = ctx.world();
|
||||
this.worldBorder = new BetterWorldBorder(world.getWorldBorder());
|
||||
this.worldData = worldData;
|
||||
this.worldData = (WorldData) ctx.worldData();
|
||||
Long2ObjectMap<Chunk> worldLoaded = ((IChunkProviderClient) world.getChunkProvider()).loadedChunks();
|
||||
if (copyLoadedChunks) {
|
||||
this.loadedChunks = new Long2ObjectOpenHashMap<>(worldLoaded); // make a copy that we can safely access from another thread
|
||||
|
@ -75,11 +69,11 @@ public class BlockStateInterface {
|
|||
this.loadedChunks = worldLoaded; // this will only be used on the main thread
|
||||
}
|
||||
this.useTheRealWorld = !Baritone.settings().pathThroughCachedOnly.value;
|
||||
if (!Minecraft.getMinecraft().isCallingFromMinecraftThread()) {
|
||||
if (!ctx.minecraft().isCallingFromMinecraftThread()) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
this.isPassableBlockPos = new BlockPos.MutableBlockPos();
|
||||
this.access = new BlockStateInterfaceAccessWrapper(this);
|
||||
this.access = new BlockStateInterfaceAccessWrapper(this, world);
|
||||
}
|
||||
|
||||
public boolean worldContainsLoadedChunk(int blockX, int blockZ) {
|
||||
|
|
|
@ -37,9 +37,11 @@ import javax.annotation.Nullable;
|
|||
public final class BlockStateInterfaceAccessWrapper implements IBlockAccess {
|
||||
|
||||
private final BlockStateInterface bsi;
|
||||
private final IBlockAccess world;
|
||||
|
||||
BlockStateInterfaceAccessWrapper(BlockStateInterface bsi) {
|
||||
BlockStateInterfaceAccessWrapper(BlockStateInterface bsi, IBlockAccess world) {
|
||||
this.bsi = bsi;
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@ -76,6 +78,6 @@ public final class BlockStateInterfaceAccessWrapper implements IBlockAccess {
|
|||
|
||||
@Override
|
||||
public WorldType getWorldType() {
|
||||
return this.bsi.world.getWorldType();
|
||||
return this.world.getWorldType();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@ import net.minecraft.client.entity.EntityPlayerSP;
|
|||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue