From 0ce4107d569d996136b3ceef2cb1108e9a150d03 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 11 Nov 2018 18:23:18 -0800 Subject: [PATCH] "fix" it --- .../pathing/movement/CalculationContext.java | 16 +++++++++++----- .../java/baritone/utils/BlockStateInterface.java | 7 ++++--- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/CalculationContext.java b/src/main/java/baritone/pathing/movement/CalculationContext.java index f2ac133d..e419bb72 100644 --- a/src/main/java/baritone/pathing/movement/CalculationContext.java +++ b/src/main/java/baritone/pathing/movement/CalculationContext.java @@ -19,6 +19,7 @@ package baritone.pathing.movement; import baritone.Baritone; import baritone.api.pathing.movement.ActionCosts; +import baritone.cache.WorldData; import baritone.utils.BlockStateInterface; import baritone.utils.Helper; import baritone.utils.ToolSet; @@ -43,6 +44,7 @@ public class CalculationContext { private final EntityPlayerSP player; private final World world; + private final WorldData worldData; private final BlockStateInterface bsi; private final ToolSet toolSet; private final boolean hasWaterBucket; @@ -59,7 +61,8 @@ public class CalculationContext { public CalculationContext() { this.player = Helper.HELPER.player(); this.world = Helper.HELPER.world(); - this.bsi = new BlockStateInterface(world, Baritone.INSTANCE.getWorldProvider().getCurrentWorld()); // TODO TODO TODO + this.worldData = Baritone.INSTANCE.getWorldProvider().getCurrentWorld(); + this.bsi = new BlockStateInterface(world, worldData); // TODO TODO TODO // new CalculationContext() needs to happen, can't add an argument (i'll beat you), can we get the world provider from currentlyTicking? this.toolSet = new ToolSet(player); this.hasThrowaway = Baritone.settings().allowPlace.get() && MovementHelper.throwaway(false); @@ -90,10 +93,6 @@ public class CalculationContext { return bsi.isLoaded(x, z); } - public BlockStateInterface bsi() { - return bsi; - } - public IBlockState get(BlockPos pos) { return get(pos.getX(), pos.getY(), pos.getZ()); } @@ -132,6 +131,13 @@ public class CalculationContext { return player; } + public BlockStateInterface bsi() { + return bsi; + } + + public WorldData worldData() { + return worldData; + } public ToolSet getToolSet() { return toolSet; diff --git a/src/main/java/baritone/utils/BlockStateInterface.java b/src/main/java/baritone/utils/BlockStateInterface.java index b3ee52a4..547e40c3 100644 --- a/src/main/java/baritone/utils/BlockStateInterface.java +++ b/src/main/java/baritone/utils/BlockStateInterface.java @@ -20,6 +20,7 @@ package baritone.utils; import baritone.Baritone; import baritone.cache.CachedRegion; import baritone.cache.WorldData; +import baritone.pathing.movement.CalculationContext; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; @@ -53,9 +54,9 @@ public class BlockStateInterface implements Helper { } public static IBlockState get(BlockPos pos) { - // this is the version thats called from updatestate and stuff, not from cost calculation - // doesn't need to be fast or cached actually - return Helper.HELPER.world().getBlockState(pos); + return new CalculationContext().get(pos); // immense iq + // can't just do world().get because that doesn't work for out of bounds + // and toBreak and stuff fails when the movement is instantiated out of load range but it's not able to BlockStateInterface.get what it's going to walk on } public IBlockState get0(int x, int y, int z) {