mirror of https://github.com/cabaletta/baritone
Compare commits
18 Commits
38465ee02d
...
46aa6332f0
Author | SHA1 | Date |
---|---|---|
RacoonDog | 46aa6332f0 | |
leijurv | 62b2f81ba1 | |
ZacSharp | 5826931eea | |
leijurv | a8119366a1 | |
leijurv | b0575fbe0c | |
leijurv | 866cf34f50 | |
leijurv | 23908ad14f | |
rfresh2 | 18d3c4c2bd | |
rfresh2 | faece77e8c | |
rfresh2 | 413c11a23e | |
ZacSharp | 4c9253fa5e | |
ZacSharp | d86a34a527 | |
ZacSharp | 92aba1b78e | |
ZacSharp | 28ba97c3de | |
ZacSharp | 24c23e28ec | |
ZacSharp | 2a2842361b | |
ZacSharp | 632e05c4c2 | |
RacoonDog | abb432848f |
|
@ -13,12 +13,12 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v3
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: '17'
|
||||
distribution: 'temurin'
|
||||
|
@ -31,13 +31,13 @@ jobs:
|
|||
run: ./gradlew build -Pmod_version="$(git describe --always --tags --first-parent | cut -c2-)"
|
||||
|
||||
- name: Archive Artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: Artifacts
|
||||
path: dist/
|
||||
|
||||
- name: Archive mapping.txt
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: Mappings
|
||||
path: mapping/
|
||||
|
|
|
@ -11,9 +11,9 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v3
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: '17'
|
||||
distribution: 'temurin'
|
||||
|
|
|
@ -25,6 +25,7 @@ import baritone.api.event.listener.IEventBus;
|
|||
import baritone.api.pathing.calc.IPathingControlManager;
|
||||
import baritone.api.process.*;
|
||||
import baritone.api.selection.ISelectionManager;
|
||||
import baritone.api.utils.IExecutionControl;
|
||||
import baritone.api.utils.IInputOverrideHandler;
|
||||
import baritone.api.utils.IPlayerContext;
|
||||
|
||||
|
@ -139,6 +140,15 @@ public interface IBaritone {
|
|||
*/
|
||||
ICommandManager getCommandManager();
|
||||
|
||||
/**
|
||||
* @param name a user-friendly name for the underlying {@link IBaritoneProcess}
|
||||
* @param priority the priority. Default for {@link IBaritoneProcess} instance is {@link IBaritoneProcess#DEFAULT_PRIORITY}.
|
||||
* Any Baritone process with a higher priority will not be paused by this {@link IExecutionControl}.
|
||||
* @return A newly created {@link IExecutionControl} instance
|
||||
* @see IExecutionControl
|
||||
*/
|
||||
IExecutionControl createExecutionControl(String name, double priority);
|
||||
|
||||
/**
|
||||
* Open click
|
||||
*/
|
||||
|
|
|
@ -385,6 +385,12 @@ public final class Settings {
|
|||
*/
|
||||
public final Setting<Float> blockReachDistance = new Setting<>(4.5f);
|
||||
|
||||
/**
|
||||
* How many ticks between breaking a block and starting to break the next block. Default in game is 6 ticks.
|
||||
* Values under 2 will be clamped.
|
||||
*/
|
||||
public final Setting<Integer> blockBreakSpeed = new Setting<>(6);
|
||||
|
||||
/**
|
||||
* How many degrees to randomize the pitch and yaw every tick. Set to 0 to disable
|
||||
*/
|
||||
|
@ -1058,6 +1064,11 @@ public final class Settings {
|
|||
*/
|
||||
public final Setting<Double> breakCorrectBlockPenaltyMultiplier = new Setting<>(10d);
|
||||
|
||||
/**
|
||||
* Multiply the cost of placing a block that's incorrect in the builder's schematic by this coefficient
|
||||
*/
|
||||
public final Setting<Double> placeIncorrectBlockPenaltyMultiplier = new Setting<>(2d);
|
||||
|
||||
/**
|
||||
* When this setting is true, build a schematic with the highest X coordinate being the origin, instead of the lowest
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.utils;
|
||||
|
||||
/**
|
||||
* Wrapper around a {@link baritone.api.process.IBaritoneProcess} used exclusively for pausing the Baritone.
|
||||
*
|
||||
* @author Crosby
|
||||
*/
|
||||
public interface IExecutionControl {
|
||||
/**
|
||||
* Tells Baritone to temporarily stop whatever it's doing until you resume.
|
||||
*/
|
||||
void pause();
|
||||
|
||||
/**
|
||||
* Resumes Baritone, resuming what it was doing when it was paused.
|
||||
*/
|
||||
void resume();
|
||||
|
||||
/**
|
||||
* Whether this instance of {@link IExecutionControl} is currently blocking Baritone from executing lower priority processes.
|
||||
*
|
||||
* @return whether Baritone is currently paused by this {@link IExecutionControl}.
|
||||
*/
|
||||
boolean paused();
|
||||
|
||||
/**
|
||||
* Cancels whatever Baritone is currently doing.
|
||||
*/
|
||||
void stop();
|
||||
}
|
|
@ -24,6 +24,7 @@ import baritone.api.behavior.IBehavior;
|
|||
import baritone.api.event.listener.IEventBus;
|
||||
import baritone.api.process.IBaritoneProcess;
|
||||
import baritone.api.process.IElytraProcess;
|
||||
import baritone.api.utils.IExecutionControl;
|
||||
import baritone.api.utils.IPlayerContext;
|
||||
import baritone.behavior.*;
|
||||
import baritone.cache.WorldProvider;
|
||||
|
@ -31,10 +32,7 @@ import baritone.command.manager.CommandManager;
|
|||
import baritone.event.GameEventHandler;
|
||||
import baritone.process.*;
|
||||
import baritone.selection.SelectionManager;
|
||||
import baritone.utils.BlockStateInterface;
|
||||
import baritone.utils.GuiClick;
|
||||
import baritone.utils.InputOverrideHandler;
|
||||
import baritone.utils.PathingControlManager;
|
||||
import baritone.utils.*;
|
||||
import baritone.utils.player.BaritonePlayerContext;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
|
@ -235,6 +233,11 @@ public class Baritone implements IBaritone {
|
|||
return this.commandManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IExecutionControl createExecutionControl(String name, double priority) {
|
||||
return new ExecutionControl(name, priority, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IElytraProcess getElytraProcess() {
|
||||
return this.elytraProcess;
|
||||
|
|
|
@ -23,8 +23,8 @@ import baritone.api.command.argument.IArgConsumer;
|
|||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.process.IBaritoneProcess;
|
||||
import baritone.api.process.PathingCommand;
|
||||
import baritone.api.process.PathingCommandType;
|
||||
import baritone.api.utils.IExecutionControl;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
@ -33,9 +33,8 @@ import java.util.stream.Stream;
|
|||
/**
|
||||
* Contains the pause, resume, and paused commands.
|
||||
* <p>
|
||||
* This thing is scoped to hell, private so far you can't even access it using reflection, because you AREN'T SUPPOSED
|
||||
* TO USE THIS to pause and resume Baritone. Make your own process that returns {@link PathingCommandType#REQUEST_PAUSE
|
||||
* REQUEST_PAUSE} as needed.
|
||||
* Instead of trying to access this in order to pause and resume Baritone, you should instead create your own using
|
||||
* {@link IBaritone#createExecutionControl(String, double)}.
|
||||
*/
|
||||
public class ExecutionControlCommands {
|
||||
|
||||
|
@ -45,49 +44,15 @@ public class ExecutionControlCommands {
|
|||
Command cancelCommand;
|
||||
|
||||
public ExecutionControlCommands(IBaritone baritone) {
|
||||
// array for mutability, non-field so reflection can't touch it
|
||||
final boolean[] paused = {false};
|
||||
baritone.getPathingControlManager().registerProcess(
|
||||
new IBaritoneProcess() {
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return paused[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public PathingCommand onTick(boolean calcFailed, boolean isSafeToCancel) {
|
||||
baritone.getInputOverrideHandler().clearAllKeys();
|
||||
return new PathingCommand(null, PathingCommandType.REQUEST_PAUSE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTemporary() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLostControl() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public double priority() {
|
||||
return DEFAULT_PRIORITY + 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String displayName0() {
|
||||
return "Pause/Resume Commands";
|
||||
}
|
||||
}
|
||||
);
|
||||
IExecutionControl executionControl = baritone.createExecutionControl("Pause/Resume Commands", IBaritoneProcess.DEFAULT_PRIORITY + 1);
|
||||
pauseCommand = new Command(baritone, "pause", "p", "paws") {
|
||||
@Override
|
||||
public void execute(String label, IArgConsumer args) throws CommandException {
|
||||
args.requireMax(0);
|
||||
if (paused[0]) {
|
||||
if (executionControl.paused()) {
|
||||
throw new CommandInvalidStateException("Already paused");
|
||||
}
|
||||
paused[0] = true;
|
||||
executionControl.pause();
|
||||
logDirect("Paused");
|
||||
}
|
||||
|
||||
|
@ -118,10 +83,10 @@ public class ExecutionControlCommands {
|
|||
public void execute(String label, IArgConsumer args) throws CommandException {
|
||||
args.requireMax(0);
|
||||
baritone.getBuilderProcess().resume();
|
||||
if (!paused[0]) {
|
||||
if (!executionControl.paused()) {
|
||||
throw new CommandInvalidStateException("Not paused");
|
||||
}
|
||||
paused[0] = false;
|
||||
executionControl.resume();
|
||||
logDirect("Resumed");
|
||||
}
|
||||
|
||||
|
@ -149,7 +114,7 @@ public class ExecutionControlCommands {
|
|||
@Override
|
||||
public void execute(String label, IArgConsumer args) throws CommandException {
|
||||
args.requireMax(0);
|
||||
logDirect(String.format("Baritone is %spaused", paused[0] ? "" : "not "));
|
||||
logDirect(String.format("Baritone is %spaused", executionControl.paused() ? "" : "not "));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -176,10 +141,7 @@ public class ExecutionControlCommands {
|
|||
@Override
|
||||
public void execute(String label, IArgConsumer args) throws CommandException {
|
||||
args.requireMax(0);
|
||||
if (paused[0]) {
|
||||
paused[0] = false;
|
||||
}
|
||||
baritone.getPathingBehavior().cancelEverything();
|
||||
executionControl.stop();
|
||||
logDirect("ok canceled");
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ import baritone.api.process.PathingCommandType;
|
|||
import baritone.api.schematic.FillSchematic;
|
||||
import baritone.api.schematic.ISchematic;
|
||||
import baritone.api.schematic.IStaticSchematic;
|
||||
import baritone.api.schematic.MaskSchematic;
|
||||
import baritone.api.schematic.SubstituteSchematic;
|
||||
import baritone.api.schematic.format.ISchematicFormat;
|
||||
import baritone.api.utils.*;
|
||||
|
@ -84,6 +85,14 @@ import static baritone.api.pathing.movement.ActionCosts.COST_INF;
|
|||
|
||||
public final class BuilderProcess extends BaritoneProcessHelper implements IBuilderProcess {
|
||||
|
||||
private static final Set<Property<?>> ORIENTATION_PROPS =
|
||||
ImmutableSet.of(
|
||||
RotatedPillarBlock.AXIS, HorizontalDirectionalBlock.FACING,
|
||||
StairBlock.FACING, StairBlock.HALF, StairBlock.SHAPE,
|
||||
PipeBlock.NORTH, PipeBlock.EAST, PipeBlock.SOUTH, PipeBlock.WEST, PipeBlock.UP,
|
||||
TrapDoorBlock.OPEN, TrapDoorBlock.HALF
|
||||
);
|
||||
|
||||
private HashSet<BetterBlockPos> incorrectPositions;
|
||||
private LongOpenHashSet observedCompleted; // positions that are completed even if they're out of render distance and we can't make sure right now
|
||||
private String name;
|
||||
|
@ -110,6 +119,14 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||
if (!Baritone.settings().buildSubstitutes.value.isEmpty()) {
|
||||
this.schematic = new SubstituteSchematic(this.schematic, Baritone.settings().buildSubstitutes.value);
|
||||
}
|
||||
// TODO this preserves the old behavior, but maybe we should bake the setting value right here
|
||||
this.schematic = new MaskSchematic(this.schematic) {
|
||||
@Override
|
||||
public boolean partOfMask(int x, int y, int z, BlockState current) {
|
||||
// partOfMask is only called inside the schematic so desiredState is not null
|
||||
return !Baritone.settings().buildSkipBlocks.value.contains(this.desiredState(x, y, z, current, Collections.emptyList()).getBlock());
|
||||
}
|
||||
};
|
||||
int x = origin.getX();
|
||||
int y = origin.getY();
|
||||
int z = origin.getZ();
|
||||
|
@ -168,15 +185,15 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||
if (!format.isPresent()) {
|
||||
return false;
|
||||
}
|
||||
ISchematic parsed;
|
||||
IStaticSchematic parsed;
|
||||
try {
|
||||
parsed = format.get().parse(new FileInputStream(schematic));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
parsed = applyMapArtAndSelection(origin, (IStaticSchematic) parsed);
|
||||
build(name, parsed, origin);
|
||||
ISchematic schem = applyMapArtAndSelection(origin, parsed);
|
||||
build(name, schem, origin);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -196,17 +213,10 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||
if (SchematicaHelper.isSchematicaPresent()) {
|
||||
Optional<Tuple<IStaticSchematic, BlockPos>> schematic = SchematicaHelper.getOpenSchematic();
|
||||
if (schematic.isPresent()) {
|
||||
IStaticSchematic s = schematic.get().getA();
|
||||
IStaticSchematic raw = schematic.get().getA();
|
||||
BlockPos origin = schematic.get().getB();
|
||||
ISchematic schem = Baritone.settings().mapArtMode.value ? new MapArtSchematic(s) : s;
|
||||
if (Baritone.settings().buildOnlySelection.value) {
|
||||
schem = new SelectionSchematic(schem, origin, baritone.getSelectionManager().getSelections());
|
||||
}
|
||||
this.build(
|
||||
schematic.get().getA().toString(),
|
||||
schem,
|
||||
origin
|
||||
);
|
||||
ISchematic schem = applyMapArtAndSelection(origin, raw);
|
||||
this.build(raw.toString(), schem, origin);
|
||||
} else {
|
||||
logDirect("No schematic currently open");
|
||||
}
|
||||
|
@ -438,8 +448,8 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||
return onTick(calcFailed, isSafeToCancel, 0);
|
||||
}
|
||||
|
||||
public PathingCommand onTick(boolean calcFailed, boolean isSafeToCancel, int recursions) {
|
||||
if (recursions > 1000) { // onTick calls itself, don't crash
|
||||
private PathingCommand onTick(boolean calcFailed, boolean isSafeToCancel, int recursions) {
|
||||
if (recursions > 100) { // onTick calls itself, don't crash
|
||||
return new PathingCommand(null, PathingCommandType.SET_GOAL_AND_PATH);
|
||||
}
|
||||
approxPlaceable = approxPlaceable(36);
|
||||
|
@ -683,8 +693,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||
continue;
|
||||
}
|
||||
// this is not in render distance
|
||||
if (!observedCompleted.contains(BetterBlockPos.longHash(blockX, blockY, blockZ))
|
||||
&& !Baritone.settings().buildSkipBlocks.value.contains(schematic.desiredState(x, y, z, current, this.approxPlaceable).getBlock())) {
|
||||
if (!observedCompleted.contains(BetterBlockPos.longHash(blockX, blockY, blockZ))) {
|
||||
// and we've never seen this position be correct
|
||||
// therefore mark as incorrect
|
||||
incorrectPositions.add(new BetterBlockPos(blockX, blockY, blockZ));
|
||||
|
@ -1009,15 +1018,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||
return result;
|
||||
}
|
||||
|
||||
public static final Set<Property<?>> orientationProps =
|
||||
ImmutableSet.of(
|
||||
RotatedPillarBlock.AXIS, HorizontalDirectionalBlock.FACING,
|
||||
StairBlock.FACING, StairBlock.HALF, StairBlock.SHAPE,
|
||||
PipeBlock.NORTH, PipeBlock.EAST, PipeBlock.SOUTH, PipeBlock.WEST, PipeBlock.UP,
|
||||
TrapDoorBlock.OPEN, TrapDoorBlock.HALF
|
||||
);
|
||||
|
||||
private boolean sameBlockstate(BlockState first, BlockState second) {
|
||||
private static boolean sameBlockstate(BlockState first, BlockState second) {
|
||||
if (first.getBlock() != second.getBlock()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1030,7 +1031,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||
ImmutableMap<Property<?>, Comparable<?>> map2 = second.getValues();
|
||||
for (Property<?> prop : map1.keySet()) {
|
||||
if (map1.get(prop) != map2.get(prop)
|
||||
&& !(ignoreDirection && orientationProps.contains(prop))
|
||||
&& !(ignoreDirection && ORIENTATION_PROPS.contains(prop))
|
||||
&& !ignoredProps.contains(prop.getName())) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1038,7 +1039,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||
return true;
|
||||
}
|
||||
|
||||
private boolean containsBlockState(Collection<BlockState> states, BlockState state) {
|
||||
private static boolean containsBlockState(Collection<BlockState> states, BlockState state) {
|
||||
for (BlockState testee : states) {
|
||||
if (sameBlockstate(testee, state)) {
|
||||
return true;
|
||||
|
@ -1047,7 +1048,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||
return false;
|
||||
}
|
||||
|
||||
private boolean valid(BlockState current, BlockState desired, boolean itemVerify) {
|
||||
private static boolean valid(BlockState current, BlockState desired, boolean itemVerify) {
|
||||
if (desired == null) {
|
||||
return true;
|
||||
}
|
||||
|
@ -1066,9 +1067,6 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||
if (!(current.getBlock() instanceof AirBlock) && Baritone.settings().buildIgnoreExisting.value && !itemVerify) {
|
||||
return true;
|
||||
}
|
||||
if (Baritone.settings().buildSkipBlocks.value.contains(desired.getBlock()) && !itemVerify) {
|
||||
return true;
|
||||
}
|
||||
if (Baritone.settings().buildValidSubstitutes.value.getOrDefault(desired.getBlock(), Collections.emptyList()).contains(current.getBlock()) && !itemVerify) {
|
||||
return true;
|
||||
}
|
||||
|
@ -1112,12 +1110,12 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||
return COST_INF;
|
||||
}
|
||||
BlockState sch = getSchematic(x, y, z, current);
|
||||
if (sch != null && !Baritone.settings().buildSkipBlocks.value.contains(sch.getBlock())) {
|
||||
if (sch != null) {
|
||||
// TODO this can return true even when allowPlace is off.... is that an issue?
|
||||
if (sch.getBlock() instanceof AirBlock) {
|
||||
// we want this to be air, but they're asking if they can place here
|
||||
// this won't be a schematic block, this will be a throwaway
|
||||
return placeBlockCost * 2; // we're going to have to break it eventually
|
||||
return placeBlockCost * Baritone.settings().placeIncorrectBlockPenaltyMultiplier.value; // we're going to have to break it eventually
|
||||
}
|
||||
if (placeable.contains(sch)) {
|
||||
return 0; // thats right we gonna make it FREE to place a block where it should go in a structure
|
||||
|
@ -1130,7 +1128,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||
}
|
||||
// we want it to be something that we don't have
|
||||
// even more of a pain to place something wrong
|
||||
return placeBlockCost * 3;
|
||||
return placeBlockCost * 1.5 * Baritone.settings().placeIncorrectBlockPenaltyMultiplier.value;
|
||||
} else {
|
||||
if (hasThrowaway) {
|
||||
return placeBlockCost;
|
||||
|
@ -1146,7 +1144,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||
return COST_INF;
|
||||
}
|
||||
BlockState sch = getSchematic(x, y, z, current);
|
||||
if (sch != null && !Baritone.settings().buildSkipBlocks.value.contains(sch.getBlock())) {
|
||||
if (sch != null) {
|
||||
if (sch.getBlock() instanceof AirBlock) {
|
||||
// it should be air
|
||||
// regardless of current contents, we can break it
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
package baritone.utils;
|
||||
|
||||
import baritone.api.BaritoneAPI;
|
||||
import baritone.api.utils.IPlayerContext;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
|
@ -27,9 +28,12 @@ import net.minecraft.world.phys.HitResult;
|
|||
* @since 8/25/2018
|
||||
*/
|
||||
public final class BlockBreakHelper {
|
||||
// base ticks between block breaks caused by tick logic
|
||||
private static final int BASE_BREAK_DELAY = 2;
|
||||
|
||||
private final IPlayerContext ctx;
|
||||
private boolean didBreakLastTick;
|
||||
private int breakDelayTimer = 0;
|
||||
|
||||
BlockBreakHelper(IPlayerContext ctx) {
|
||||
this.ctx = ctx;
|
||||
|
@ -48,6 +52,10 @@ public final class BlockBreakHelper {
|
|||
}
|
||||
|
||||
public void tick(boolean isLeftClick) {
|
||||
if (breakDelayTimer > 0) {
|
||||
breakDelayTimer--;
|
||||
return;
|
||||
}
|
||||
HitResult trace = ctx.objectMouseOver();
|
||||
boolean isBlockTrace = trace != null && trace.getType() == HitResult.Type.BLOCK;
|
||||
|
||||
|
@ -68,6 +76,7 @@ public final class BlockBreakHelper {
|
|||
didBreakLastTick = true;
|
||||
} else if (didBreakLastTick) {
|
||||
stopBreakingBlock();
|
||||
breakDelayTimer = BaritoneAPI.getSettings().blockBreakSpeed.value - BASE_BREAK_DELAY;
|
||||
didBreakLastTick = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,8 @@ import net.minecraft.world.phys.BlockHitResult;
|
|||
import net.minecraft.world.phys.HitResult;
|
||||
|
||||
public class BlockPlaceHelper {
|
||||
// base ticks between places caused by tick logic
|
||||
private static final int BASE_PLACE_DELAY = 1;
|
||||
|
||||
private final IPlayerContext ctx;
|
||||
private int rightClickTimer;
|
||||
|
@ -42,7 +44,7 @@ public class BlockPlaceHelper {
|
|||
if (!rightClickRequested || ctx.player().isHandsBusy() || mouseOver == null || mouseOver.getType() != HitResult.Type.BLOCK) {
|
||||
return;
|
||||
}
|
||||
rightClickTimer = Baritone.settings().rightClickSpeed.value;
|
||||
rightClickTimer = Baritone.settings().rightClickSpeed.value - BASE_PLACE_DELAY;
|
||||
for (InteractionHand hand : InteractionHand.values()) {
|
||||
if (ctx.playerController().processRightClickBlock(ctx.player(), ctx.world(), hand, (BlockHitResult) mouseOver) == InteractionResult.SUCCESS) {
|
||||
ctx.player().swing(hand);
|
||||
|
|
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.utils;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.process.IBaritoneProcess;
|
||||
import baritone.api.process.PathingCommand;
|
||||
import baritone.api.process.PathingCommandType;
|
||||
import baritone.api.utils.IExecutionControl;
|
||||
|
||||
public class ExecutionControl implements IExecutionControl {
|
||||
private final IBaritone baritone;
|
||||
private boolean active;
|
||||
|
||||
public ExecutionControl(String name, double priority, IBaritone baritone) {
|
||||
this.baritone = baritone;
|
||||
baritone.getPathingControlManager().registerProcess(new IBaritoneProcess() {
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PathingCommand onTick(boolean calcFailed, boolean isSafeToCancel) {
|
||||
baritone.getInputOverrideHandler().clearAllKeys();
|
||||
return new PathingCommand(null, PathingCommandType.REQUEST_PAUSE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTemporary() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLostControl() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public double priority() {
|
||||
return priority;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String displayName0() {
|
||||
return name;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pause() {
|
||||
active = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resume() {
|
||||
active = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean paused() {
|
||||
return active;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
active = false;
|
||||
baritone.getPathingBehavior().cancelEverything();
|
||||
}
|
||||
}
|
|
@ -41,6 +41,7 @@ public class MapArtSchematic extends MaskSchematic {
|
|||
private static int[][] generateHeightMap(IStaticSchematic schematic) {
|
||||
int[][] heightMap = new int[schematic.widthX()][schematic.lengthZ()];
|
||||
|
||||
int missingColumns = 0;
|
||||
for (int x = 0; x < schematic.widthX(); x++) {
|
||||
for (int z = 0; z < schematic.lengthZ(); z++) {
|
||||
BlockState[] column = schematic.getColumn(x, z);
|
||||
|
@ -48,12 +49,14 @@ public class MapArtSchematic extends MaskSchematic {
|
|||
if (lowestBlockY.isPresent()) {
|
||||
heightMap[x][z] = lowestBlockY.getAsInt();
|
||||
} else {
|
||||
System.out.println("Column " + x + "," + z + " has no blocks, but it's apparently map art? wtf");
|
||||
System.out.println("Letting it be whatever");
|
||||
heightMap[x][z] = 256;
|
||||
missingColumns++;
|
||||
heightMap[x][z] = Integer.MAX_VALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (missingColumns != 0) {
|
||||
System.out.println(missingColumns + " columns had no block despite being in a map art, letting them be whatever");
|
||||
}
|
||||
return heightMap;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue