mirror of https://github.com/cabaletta/baritone
Merge branch 'master' into 1.13.2
This commit is contained in:
commit
0cbe9f81c8
|
@ -50,4 +50,6 @@ public interface IPlayerController {
|
|||
}
|
||||
|
||||
EnumActionResult processRightClickBlock(EntityPlayerSP player, World world, BlockPos pos, EnumFacing direction, Vec3d vec, EnumHand hand);
|
||||
|
||||
EnumActionResult processRightClick(EntityPlayerSP player, World world, EnumHand hand);
|
||||
}
|
||||
|
|
|
@ -237,7 +237,7 @@ public class MovementTraverse extends Movement {
|
|||
}
|
||||
Block low = BlockStateInterface.get(ctx, src).getBlock();
|
||||
Block high = BlockStateInterface.get(ctx, src.up()).getBlock();
|
||||
if (!ctx.player().onGround && (low == Blocks.VINE || low == Blocks.LADDER || high == Blocks.VINE || high == Blocks.LADDER)) {
|
||||
if (ctx.player().posY > src.y + 0.1D && !ctx.player().onGround && (low == Blocks.VINE || low == Blocks.LADDER || high == Blocks.VINE || high == Blocks.LADDER)) {
|
||||
// hitting W could cause us to climb the ladder instead of going forward
|
||||
// wait until we're on the ground
|
||||
return state;
|
||||
|
|
|
@ -19,6 +19,8 @@ package baritone.process;
|
|||
|
||||
import baritone.Baritone;
|
||||
import baritone.api.cache.ICachedWorld;
|
||||
import baritone.api.pathing.goals.Goal;
|
||||
import baritone.api.pathing.goals.GoalComposite;
|
||||
import baritone.api.pathing.goals.GoalXZ;
|
||||
import baritone.api.process.PathingCommand;
|
||||
import baritone.api.process.PathingCommandType;
|
||||
|
@ -26,6 +28,9 @@ import baritone.cache.CachedWorld;
|
|||
import baritone.utils.BaritoneProcessHelper;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ExploreProcess extends BaritoneProcessHelper {
|
||||
|
||||
private BlockPos explorationOrigin;
|
||||
|
@ -50,23 +55,24 @@ public class ExploreProcess extends BaritoneProcessHelper {
|
|||
onLostControl();
|
||||
return null;
|
||||
}
|
||||
BlockPos closestUncached = closestUncachedChunk(explorationOrigin);
|
||||
Goal[] closestUncached = closestUncachedChunks(explorationOrigin);
|
||||
if (closestUncached == null) {
|
||||
logDebug("awaiting region load from disk");
|
||||
return new PathingCommand(null, PathingCommandType.REQUEST_PAUSE);
|
||||
}
|
||||
System.out.println("Closest uncached: " + closestUncached);
|
||||
return new PathingCommand(new GoalXZ(closestUncached.getX(), closestUncached.getZ()), PathingCommandType.FORCE_REVALIDATE_GOAL_AND_PATH);
|
||||
return new PathingCommand(new GoalComposite(closestUncached), PathingCommandType.FORCE_REVALIDATE_GOAL_AND_PATH);
|
||||
}
|
||||
|
||||
private BlockPos closestUncachedChunk(BlockPos pos) {
|
||||
int chunkX = pos.getX() >> 4;
|
||||
int chunkZ = pos.getZ() >> 4;
|
||||
private Goal[] closestUncachedChunks(BlockPos center) {
|
||||
int chunkX = center.getX() >> 4;
|
||||
int chunkZ = center.getZ() >> 4;
|
||||
ICachedWorld cache = baritone.getWorldProvider().getCurrentWorld().getCachedWorld();
|
||||
for (int dist = 0; ; dist++) {
|
||||
List<BlockPos> centers = new ArrayList<>();
|
||||
for (int dx = -dist; dx <= dist; dx++) {
|
||||
for (int dz = -dist; dz <= dist; dz++) {
|
||||
int trueDist = Baritone.settings().exploreUsePythagorean.value ? dx * dx + dz + dz : Math.abs(dx) + Math.abs(dz);
|
||||
int trueDist = Baritone.settings().exploreUsePythagorean.value ? dx * dx + dz * dz : Math.abs(dx) + Math.abs(dz);
|
||||
if (trueDist != dist) {
|
||||
continue; // not considering this one just yet in our expanding search
|
||||
}
|
||||
|
@ -82,9 +88,12 @@ public class ExploreProcess extends BaritoneProcessHelper {
|
|||
});
|
||||
return null; // we still need to load regions from disk in order to decide properly
|
||||
}
|
||||
return new BlockPos(centerX, 0, centerZ);
|
||||
centers.add(new BlockPos(centerX, 0, centerZ));
|
||||
}
|
||||
}
|
||||
if (!centers.isEmpty()) {
|
||||
return centers.stream().map(pos -> new GoalXZ(pos.getX(), pos.getZ())).toArray(Goal[]::new);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,6 +104,6 @@ public class ExploreProcess extends BaritoneProcessHelper {
|
|||
|
||||
@Override
|
||||
public String displayName0() {
|
||||
return "Exploring around " + explorationOrigin + ", currently going to " + closestUncachedChunk(explorationOrigin);
|
||||
return "Exploring around " + explorationOrigin + ", currently going to " + new GoalComposite(closestUncachedChunks(explorationOrigin));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,6 +46,9 @@ public class BlockPlaceHelper implements Helper {
|
|||
ctx.player().swingArm(hand);
|
||||
return;
|
||||
}
|
||||
if (!ctx.player().getHeldItem(hand).isEmpty() && ctx.playerController().processRightClick(ctx.player(), ctx.world(), hand) == EnumActionResult.SUCCESS) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,4 +72,9 @@ public enum PrimaryPlayerController implements IPlayerController, Helper {
|
|||
// primaryplayercontroller is always in a WorldClient so this is ok
|
||||
return mc.playerController.processRightClickBlock(player, (WorldClient) world, pos, direction, vec, hand);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumActionResult processRightClick(EntityPlayerSP player, World world, EnumHand hand) {
|
||||
return mc.playerController.processRightClick(player, world, hand);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue