From d32c92cbde0b28f6bfaf142053a1e82be13a01ff Mon Sep 17 00:00:00 2001 From: Brady Date: Thu, 17 Jan 2019 18:01:05 -0600 Subject: [PATCH 01/42] Specificity time --- src/api/java/baritone/api/Settings.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 1b4f62e0..53690562 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -534,7 +534,7 @@ public class Settings { public Setting followOffsetDistance = new Setting<>(0D); /** - * The actual GoalNear is set in this direction from the entity you're following + * The actual GoalNear is set in this direction from the entity you're following. This value is in degrees. */ public Setting followOffsetDirection = new Setting<>(0F); From 69b1decbba34dcb3e5d0d8f0ef4ef5f5697edea8 Mon Sep 17 00:00:00 2001 From: Brady Date: Thu, 17 Jan 2019 18:04:12 -0600 Subject: [PATCH 02/42] leftClickWorkaround is no longer applicable --- src/api/java/baritone/api/Settings.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 53690562..89716a38 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -450,11 +450,6 @@ public class Settings { */ public Setting prefix = new Setting<>(false); - /** - * {@code true}: can mine blocks when in inventory, chat, or tabbed away in ESC menu - */ - public Setting leftClickWorkaround = new Setting<>(true); - /** * Don't stop walking forward when you need to break blocks in your way */ From 979b8b2663d08466ab9eea0835d9cdbeb017d04a Mon Sep 17 00:00:00 2001 From: Brady Date: Thu, 17 Jan 2019 18:20:27 -0600 Subject: [PATCH 03/42] Remove associatedWith in process and some more javadoc changes --- .../api/pathing/calc/IPathingControlManager.java | 16 ++++++++++++++++ .../baritone/api/process/IBaritoneProcess.java | 14 ++++---------- .../baritone/utils/BaritoneProcessHelper.java | 5 ----- .../utils/player/PrimaryPlayerContext.java | 2 +- .../utils/player/PrimaryPlayerController.java | 2 ++ 5 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/api/java/baritone/api/pathing/calc/IPathingControlManager.java b/src/api/java/baritone/api/pathing/calc/IPathingControlManager.java index ffaa18b8..dc729748 100644 --- a/src/api/java/baritone/api/pathing/calc/IPathingControlManager.java +++ b/src/api/java/baritone/api/pathing/calc/IPathingControlManager.java @@ -22,10 +22,26 @@ import baritone.api.process.PathingCommand; import java.util.Optional; +/** + * @author leijurv + */ public interface IPathingControlManager { + + /** + * Registers a process with this pathing control manager. See {@link IBaritoneProcess} for more details. + * + * @param process The process + * @see IBaritoneProcess + */ void registerProcess(IBaritoneProcess process); + /** + * @return The most recent {@link IBaritoneProcess} that had control + */ Optional mostRecentInControl(); + /** + * @return The most recent pathing command executed + */ Optional mostRecentCommand(); } diff --git a/src/api/java/baritone/api/process/IBaritoneProcess.java b/src/api/java/baritone/api/process/IBaritoneProcess.java index db7588ab..c2eb2f49 100644 --- a/src/api/java/baritone/api/process/IBaritoneProcess.java +++ b/src/api/java/baritone/api/process/IBaritoneProcess.java @@ -17,7 +17,6 @@ package baritone.api.process; -import baritone.api.IBaritone; import baritone.api.behavior.IPathingBehavior; import baritone.api.event.events.PathEvent; @@ -25,8 +24,10 @@ import baritone.api.event.events.PathEvent; * A process that can control the PathingBehavior. *

* Differences between a baritone process and a behavior: - * Only one baritone process can be active at a time - * PathingBehavior can only be controlled by a process + *

    + *
  • Only one baritone process can be active at a time
  • + *
  • PathingBehavior can only be controlled by a process
  • + *
*

* That's it actually * @@ -83,13 +84,6 @@ public interface IBaritoneProcess { */ double priority(); - /** - * Returns which bot this process is associated with. (5000000iq forward thinking) - * - * @return The Bot associated with this process - */ - IBaritone associatedWith(); - /** * Returns a user-friendly name for this process. Suitable for a HUD. * diff --git a/src/main/java/baritone/utils/BaritoneProcessHelper.java b/src/main/java/baritone/utils/BaritoneProcessHelper.java index c5e13619..1a66eaa5 100644 --- a/src/main/java/baritone/utils/BaritoneProcessHelper.java +++ b/src/main/java/baritone/utils/BaritoneProcessHelper.java @@ -34,11 +34,6 @@ public abstract class BaritoneProcessHelper implements IBaritoneProcess, Helper baritone.getPathingControlManager().registerProcess(this); } - @Override - public Baritone associatedWith() { - return baritone; - } - @Override public boolean isTemporary() { return false; diff --git a/src/main/java/baritone/utils/player/PrimaryPlayerContext.java b/src/main/java/baritone/utils/player/PrimaryPlayerContext.java index f0d7ee01..1eefc91f 100644 --- a/src/main/java/baritone/utils/player/PrimaryPlayerContext.java +++ b/src/main/java/baritone/utils/player/PrimaryPlayerContext.java @@ -27,7 +27,7 @@ import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; /** - * Implementation of {@link IPlayerContext} that provides information about the local player. + * Implementation of {@link IPlayerContext} that provides information about the primary player. * * @author Brady * @since 11/12/2018 diff --git a/src/main/java/baritone/utils/player/PrimaryPlayerController.java b/src/main/java/baritone/utils/player/PrimaryPlayerController.java index 7b998bb5..c0dc8798 100644 --- a/src/main/java/baritone/utils/player/PrimaryPlayerController.java +++ b/src/main/java/baritone/utils/player/PrimaryPlayerController.java @@ -27,6 +27,8 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.GameType; /** + * Implementation of {@link IPlayerController} that chains to the primary player controller's methods + * * @author Brady * @since 12/14/2018 */ From 20b03d00049dc3f4a75c8d8e9aa83eca1bd7ac55 Mon Sep 17 00:00:00 2001 From: Brady Date: Fri, 18 Jan 2019 13:43:19 -0600 Subject: [PATCH 04/42] No more setSprinting --- .../api/event/events/SprintStateEvent.java | 42 +++++++++++++++++++ .../listener/AbstractGameEventListener.java | 3 ++ .../event/listener/IGameEventListener.java | 8 ++++ .../launch/mixins/MixinEntityPlayerSP.java | 16 +++++++ .../baritone/behavior/PathingBehavior.java | 12 ++++-- .../java/baritone/event/GameEventHandler.java | 5 +++ .../baritone/pathing/path/PathExecutor.java | 38 +++++++---------- 7 files changed, 97 insertions(+), 27 deletions(-) create mode 100644 src/api/java/baritone/api/event/events/SprintStateEvent.java diff --git a/src/api/java/baritone/api/event/events/SprintStateEvent.java b/src/api/java/baritone/api/event/events/SprintStateEvent.java new file mode 100644 index 00000000..e7b8d193 --- /dev/null +++ b/src/api/java/baritone/api/event/events/SprintStateEvent.java @@ -0,0 +1,42 @@ +/* + * 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 . + */ + +package baritone.api.event.events; + +import baritone.api.event.events.type.ManagedPlayerEvent; +import net.minecraft.client.entity.EntityPlayerSP; + +/** + * @author Brady + * @since 1/18/2019 + */ +public class SprintStateEvent extends ManagedPlayerEvent { + + private Boolean state; + + public SprintStateEvent(EntityPlayerSP player) { + super(player); + } + + public final void setState(boolean state) { + this.state = state; + } + + public final Boolean getState() { + return this.state; + } +} diff --git a/src/api/java/baritone/api/event/listener/AbstractGameEventListener.java b/src/api/java/baritone/api/event/listener/AbstractGameEventListener.java index 135c29a7..71045768 100644 --- a/src/api/java/baritone/api/event/listener/AbstractGameEventListener.java +++ b/src/api/java/baritone/api/event/listener/AbstractGameEventListener.java @@ -57,6 +57,9 @@ public interface AbstractGameEventListener extends IGameEventListener { @Override default void onPlayerRotationMove(RotationMoveEvent event) {} + @Override + default void onPlayerSprintState(SprintStateEvent event) {} + @Override default void onBlockInteract(BlockInteractEvent event) {} diff --git a/src/api/java/baritone/api/event/listener/IGameEventListener.java b/src/api/java/baritone/api/event/listener/IGameEventListener.java index 0572cbe9..dc471e5f 100644 --- a/src/api/java/baritone/api/event/listener/IGameEventListener.java +++ b/src/api/java/baritone/api/event/listener/IGameEventListener.java @@ -109,6 +109,14 @@ public interface IGameEventListener { */ void onPlayerRotationMove(RotationMoveEvent event); + /** + * Called whenever the sprint keybind state is checked in {@link EntityPlayerSP#onLivingUpdate} + * + * @param event The event + * @see EntityPlayerSP#onLivingUpdate() + */ + void onPlayerSprintState(SprintStateEvent event); + /** * Called when the local player interacts with a block, whether it is breaking or opening/placing. * diff --git a/src/launch/java/baritone/launch/mixins/MixinEntityPlayerSP.java b/src/launch/java/baritone/launch/mixins/MixinEntityPlayerSP.java index 9c9509f0..2f87b72d 100644 --- a/src/launch/java/baritone/launch/mixins/MixinEntityPlayerSP.java +++ b/src/launch/java/baritone/launch/mixins/MixinEntityPlayerSP.java @@ -21,8 +21,10 @@ import baritone.api.BaritoneAPI; import baritone.api.behavior.IPathingBehavior; import baritone.api.event.events.ChatEvent; import baritone.api.event.events.PlayerUpdateEvent; +import baritone.api.event.events.SprintStateEvent; import baritone.api.event.events.type.EventState; import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.client.settings.KeyBinding; import net.minecraft.entity.player.PlayerCapabilities; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -87,4 +89,18 @@ public class MixinEntityPlayerSP { IPathingBehavior pathingBehavior = BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this).getPathingBehavior(); return !pathingBehavior.isPathing() && capabilities.allowFlying; } + + @Redirect( + method = "onLivingUpdate", + at = @At( + value = "INVOKE", + target = "net/minecraft/client/settings/KeyBinding.isKeyDown()Z" + ) + ) + private boolean isKeyDown(KeyBinding keyBinding) { + EntityPlayerSP self = (EntityPlayerSP) (Object) this; + SprintStateEvent event = new SprintStateEvent(self); + BaritoneAPI.getProvider().getBaritoneForPlayer(self).getGameEventHandler().onPlayerSprintState(event); + return event.getState() == null ? keyBinding.isKeyDown() : event.getState(); + } } diff --git a/src/main/java/baritone/behavior/PathingBehavior.java b/src/main/java/baritone/behavior/PathingBehavior.java index 8c5fb8a4..92eb242e 100644 --- a/src/main/java/baritone/behavior/PathingBehavior.java +++ b/src/main/java/baritone/behavior/PathingBehavior.java @@ -19,10 +19,7 @@ package baritone.behavior; import baritone.Baritone; import baritone.api.behavior.IPathingBehavior; -import baritone.api.event.events.PathEvent; -import baritone.api.event.events.PlayerUpdateEvent; -import baritone.api.event.events.RenderEvent; -import baritone.api.event.events.TickEvent; +import baritone.api.event.events.*; import baritone.api.pathing.calc.IPath; import baritone.api.pathing.goals.Goal; import baritone.api.pathing.goals.GoalXZ; @@ -98,6 +95,13 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior, dispatchEvents(); } + @Override + public void onPlayerSprintState(SprintStateEvent event) { + if (current != null) { + event.setState(current.isSprinting()); + } + } + private void tickPath() { if (pauseRequestedLastTick && safeToCancel) { pauseRequestedLastTick = false; diff --git a/src/main/java/baritone/event/GameEventHandler.java b/src/main/java/baritone/event/GameEventHandler.java index e85c46de..3b327002 100644 --- a/src/main/java/baritone/event/GameEventHandler.java +++ b/src/main/java/baritone/event/GameEventHandler.java @@ -121,6 +121,11 @@ public final class GameEventHandler implements IEventBus, Helper { listeners.forEach(l -> l.onPlayerRotationMove(event)); } + @Override + public void onPlayerSprintState(SprintStateEvent event) { + listeners.forEach(l -> l.onPlayerSprintState(event)); + } + @Override public void onBlockInteract(BlockInteractEvent event) { listeners.forEach(l -> l.onBlockInteract(event)); diff --git a/src/main/java/baritone/pathing/path/PathExecutor.java b/src/main/java/baritone/pathing/path/PathExecutor.java index cad144aa..ef856f42 100644 --- a/src/main/java/baritone/pathing/path/PathExecutor.java +++ b/src/main/java/baritone/pathing/path/PathExecutor.java @@ -79,6 +79,8 @@ public class PathExecutor implements IPathExecutor, Helper { private PathingBehavior behavior; private IPlayerContext ctx; + private boolean sprintNextTick; + public PathExecutor(PathingBehavior behavior, IPath path) { this.behavior = behavior; this.ctx = behavior.ctx; @@ -269,7 +271,7 @@ public class PathExecutor implements IPathExecutor, Helper { onTick(); return true; } else { - sprintIfRequested(); + sprintNextTick = shouldSprintNextTick(); ticksOnCurrent++; if (ticksOnCurrent > currentMovementOriginalCostEstimate + Baritone.settings().movementTimeoutTicks.get()) { // only cancel if the total time has exceeded the initial estimate @@ -371,21 +373,17 @@ public class PathExecutor implements IPathExecutor, Helper { return true; } - private void sprintIfRequested() { + private boolean shouldSprintNextTick() { // first and foremost, if allowSprint is off, or if we don't have enough hunger, don't try and sprint if (!new CalculationContext(behavior.baritone).canSprint) { behavior.baritone.getInputOverrideHandler().setInputForceState(Input.SPRINT, false); - ctx.player().setSprinting(false); - return; + return false; } // if the movement requested sprinting, then we're done if (behavior.baritone.getInputOverrideHandler().isInputForcedDown(Input.SPRINT)) { behavior.baritone.getInputOverrideHandler().setInputForceState(Input.SPRINT, false); - if (!ctx.player().isSprinting()) { - ctx.player().setSprinting(true); - } - return; + return true; } // we'll take it from here, no need for minecraft to see we're holding down control and sprint for us @@ -397,30 +395,23 @@ public class PathExecutor implements IPathExecutor, Helper { if (((MovementDescend) current).safeMode()) { logDebug("Sprinting would be unsafe"); - ctx.player().setSprinting(false); - return; + return false; } IMovement next = path.movements().get(pathPosition + 1); if (next instanceof MovementAscend && current.getDirection().up().equals(next.getDirection().down())) { // a descend then an ascend in the same direction - if (!ctx.player().isSprinting()) { - ctx.player().setSprinting(true); - } pathPosition++; // okay to skip clearKeys and / or onChangeInPathPosition here since this isn't possible to repeat, since it's asymmetric logDebug("Skipping descend to straight ascend"); - return; + return true; } if (canSprintInto(ctx, current, next)) { if (ctx.playerFeet().equals(current.getDest())) { pathPosition++; onChangeInPathPosition(); } - if (!ctx.player().isSprinting()) { - ctx.player().setSprinting(true); - } - return; + return true; } //logDebug("Turning off sprinting " + movement + " " + next + " " + movement.getDirection() + " " + next.getDirection().down() + " " + next.getDirection().down().equals(movement.getDirection())); } @@ -430,14 +421,11 @@ public class PathExecutor implements IPathExecutor, Helper { BlockPos center = current.getSrc().up(); if (ctx.player().posY >= center.getY()) { // playerFeet adds 0.1251 to account for soul sand behavior.baritone.getInputOverrideHandler().setInputForceState(Input.JUMP, false); - if (!ctx.player().isSprinting()) { - ctx.player().setSprinting(true); - } - return; + return true; } } } - ctx.player().setSprinting(false); + return false; } private static boolean canSprintInto(IPlayerContext ctx, IMovement current, IMovement next) { @@ -532,4 +520,8 @@ public class PathExecutor implements IPathExecutor, Helper { public Set toWalkInto() { return Collections.unmodifiableSet(toWalkInto); } + + public boolean isSprinting() { + return sprintNextTick; + } } From bc651cb774e20e7b398805348d786f0f5a6099b0 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 18 Jan 2019 20:12:40 -0800 Subject: [PATCH 05/42] add todo --- src/main/java/baritone/behavior/MemoryBehavior.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/baritone/behavior/MemoryBehavior.java b/src/main/java/baritone/behavior/MemoryBehavior.java index 696e107d..661c5712 100644 --- a/src/main/java/baritone/behavior/MemoryBehavior.java +++ b/src/main/java/baritone/behavior/MemoryBehavior.java @@ -48,6 +48,8 @@ import java.nio.file.Path; import java.util.*; /** + * doesn't work for horse inventories :^) + * * @author Brady * @since 8/6/2018 */ From aa2e6805682ae25597132d074ff444edff7e844a Mon Sep 17 00:00:00 2001 From: Brady Date: Sat, 19 Jan 2019 12:10:21 -0600 Subject: [PATCH 06/42] Remove ManagedPlayerEvent --- .../baritone/api/event/events/ChatEvent.java | 8 +-- .../api/event/events/PlayerUpdateEvent.java | 7 +-- .../api/event/events/RotationMoveEvent.java | 7 +-- .../event/events/type/ManagedPlayerEvent.java | 61 ------------------- .../baritone/launch/mixins/MixinEntity.java | 2 +- .../launch/mixins/MixinEntityLivingBase.java | 2 +- .../launch/mixins/MixinEntityPlayerSP.java | 6 +- 7 files changed, 12 insertions(+), 81 deletions(-) delete mode 100644 src/api/java/baritone/api/event/events/type/ManagedPlayerEvent.java diff --git a/src/api/java/baritone/api/event/events/ChatEvent.java b/src/api/java/baritone/api/event/events/ChatEvent.java index 5ab9f5bb..d91e87b0 100644 --- a/src/api/java/baritone/api/event/events/ChatEvent.java +++ b/src/api/java/baritone/api/event/events/ChatEvent.java @@ -17,22 +17,20 @@ package baritone.api.event.events; -import baritone.api.event.events.type.ManagedPlayerEvent; -import net.minecraft.client.entity.EntityPlayerSP; +import baritone.api.event.events.type.Cancellable; /** * @author Brady * @since 8/1/2018 */ -public final class ChatEvent extends ManagedPlayerEvent.Cancellable { +public final class ChatEvent extends Cancellable { /** * The message being sent */ private final String message; - public ChatEvent(EntityPlayerSP player, String message) { - super(player); + public ChatEvent(String message) { this.message = message; } diff --git a/src/api/java/baritone/api/event/events/PlayerUpdateEvent.java b/src/api/java/baritone/api/event/events/PlayerUpdateEvent.java index 99370552..6ac08bdd 100644 --- a/src/api/java/baritone/api/event/events/PlayerUpdateEvent.java +++ b/src/api/java/baritone/api/event/events/PlayerUpdateEvent.java @@ -18,22 +18,19 @@ package baritone.api.event.events; import baritone.api.event.events.type.EventState; -import baritone.api.event.events.type.ManagedPlayerEvent; -import net.minecraft.client.entity.EntityPlayerSP; /** * @author Brady * @since 8/21/2018 */ -public final class PlayerUpdateEvent extends ManagedPlayerEvent { +public final class PlayerUpdateEvent { /** * The state of the event */ private final EventState state; - public PlayerUpdateEvent(EntityPlayerSP player, EventState state) { - super(player); + public PlayerUpdateEvent(EventState state) { this.state = state; } diff --git a/src/api/java/baritone/api/event/events/RotationMoveEvent.java b/src/api/java/baritone/api/event/events/RotationMoveEvent.java index 790318e0..109061c7 100644 --- a/src/api/java/baritone/api/event/events/RotationMoveEvent.java +++ b/src/api/java/baritone/api/event/events/RotationMoveEvent.java @@ -17,8 +17,6 @@ package baritone.api.event.events; -import baritone.api.event.events.type.ManagedPlayerEvent; -import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; @@ -26,7 +24,7 @@ import net.minecraft.entity.EntityLivingBase; * @author Brady * @since 8/21/2018 */ -public final class RotationMoveEvent extends ManagedPlayerEvent { +public final class RotationMoveEvent { /** * The type of event @@ -38,8 +36,7 @@ public final class RotationMoveEvent extends ManagedPlayerEvent { */ private float yaw; - public RotationMoveEvent(EntityPlayerSP player, Type type, float yaw) { - super(player); + public RotationMoveEvent(Type type, float yaw) { this.type = type; this.yaw = yaw; } diff --git a/src/api/java/baritone/api/event/events/type/ManagedPlayerEvent.java b/src/api/java/baritone/api/event/events/type/ManagedPlayerEvent.java deleted file mode 100644 index a3487a67..00000000 --- a/src/api/java/baritone/api/event/events/type/ManagedPlayerEvent.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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 . - */ - -package baritone.api.event.events.type; - -import net.minecraft.client.entity.EntityPlayerSP; - -/** - * An event that has a reference to a locally managed player. - * - * @author Brady - * @since 10/11/2018 - */ -public class ManagedPlayerEvent { - - protected final EntityPlayerSP player; - - public ManagedPlayerEvent(EntityPlayerSP player) { - this.player = player; - } - - public final EntityPlayerSP getPlayer() { - return this.player; - } - - public static class Cancellable extends ManagedPlayerEvent implements ICancellable { - - /** - * Whether or not this event has been cancelled - */ - private boolean cancelled; - - public Cancellable(EntityPlayerSP player) { - super(player); - } - - @Override - public final void cancel() { - this.cancelled = true; - } - - @Override - public final boolean isCancelled() { - return this.cancelled; - } - } -} diff --git a/src/launch/java/baritone/launch/mixins/MixinEntity.java b/src/launch/java/baritone/launch/mixins/MixinEntity.java index fe498202..83655783 100644 --- a/src/launch/java/baritone/launch/mixins/MixinEntity.java +++ b/src/launch/java/baritone/launch/mixins/MixinEntity.java @@ -52,7 +52,7 @@ public class MixinEntity { private void preMoveRelative(float strafe, float up, float forward, float friction, CallbackInfo ci) { // noinspection ConstantConditions if (EntityPlayerSP.class.isInstance(this)) { - this.motionUpdateRotationEvent = new RotationMoveEvent((EntityPlayerSP) (Object) this, RotationMoveEvent.Type.MOTION_UPDATE, this.rotationYaw); + this.motionUpdateRotationEvent = new RotationMoveEvent(RotationMoveEvent.Type.MOTION_UPDATE, this.rotationYaw); BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this).getGameEventHandler().onPlayerRotationMove(this.motionUpdateRotationEvent); } } diff --git a/src/launch/java/baritone/launch/mixins/MixinEntityLivingBase.java b/src/launch/java/baritone/launch/mixins/MixinEntityLivingBase.java index 1a7d298f..c6d76634 100644 --- a/src/launch/java/baritone/launch/mixins/MixinEntityLivingBase.java +++ b/src/launch/java/baritone/launch/mixins/MixinEntityLivingBase.java @@ -55,7 +55,7 @@ public abstract class MixinEntityLivingBase extends Entity { private void preMoveRelative(CallbackInfo ci) { // noinspection ConstantConditions if (EntityPlayerSP.class.isInstance(this)) { - this.jumpRotationEvent = new RotationMoveEvent((EntityPlayerSP) (Object) this, RotationMoveEvent.Type.JUMP, this.rotationYaw); + this.jumpRotationEvent = new RotationMoveEvent(RotationMoveEvent.Type.JUMP, this.rotationYaw); BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this).getGameEventHandler().onPlayerRotationMove(this.jumpRotationEvent); } } diff --git a/src/launch/java/baritone/launch/mixins/MixinEntityPlayerSP.java b/src/launch/java/baritone/launch/mixins/MixinEntityPlayerSP.java index 2f87b72d..5ca3c839 100644 --- a/src/launch/java/baritone/launch/mixins/MixinEntityPlayerSP.java +++ b/src/launch/java/baritone/launch/mixins/MixinEntityPlayerSP.java @@ -45,7 +45,7 @@ public class MixinEntityPlayerSP { cancellable = true ) private void sendChatMessage(String msg, CallbackInfo ci) { - ChatEvent event = new ChatEvent((EntityPlayerSP) (Object) this, msg); + ChatEvent event = new ChatEvent(msg); BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this).getGameEventHandler().onSendChatMessage(event); if (event.isCancelled()) { ci.cancel(); @@ -62,7 +62,7 @@ public class MixinEntityPlayerSP { ) ) private void onPreUpdate(CallbackInfo ci) { - BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this).getGameEventHandler().onPlayerUpdate(new PlayerUpdateEvent((EntityPlayerSP) (Object) this, EventState.PRE)); + BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this).getGameEventHandler().onPlayerUpdate(new PlayerUpdateEvent(EventState.PRE)); } @Inject( @@ -75,7 +75,7 @@ public class MixinEntityPlayerSP { ) ) private void onPostUpdate(CallbackInfo ci) { - BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this).getGameEventHandler().onPlayerUpdate(new PlayerUpdateEvent((EntityPlayerSP) (Object) this, EventState.POST)); + BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this).getGameEventHandler().onPlayerUpdate(new PlayerUpdateEvent(EventState.POST)); } @Redirect( From f5446cc415789cde2d77a5992c1d62f9635d73e0 Mon Sep 17 00:00:00 2001 From: Brady Date: Sat, 19 Jan 2019 12:12:26 -0600 Subject: [PATCH 07/42] Fix SprintStateEvent --- .../java/baritone/api/event/events/SprintStateEvent.java | 9 +-------- .../java/baritone/launch/mixins/MixinEntityPlayerSP.java | 5 ++--- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/src/api/java/baritone/api/event/events/SprintStateEvent.java b/src/api/java/baritone/api/event/events/SprintStateEvent.java index e7b8d193..6027c79e 100644 --- a/src/api/java/baritone/api/event/events/SprintStateEvent.java +++ b/src/api/java/baritone/api/event/events/SprintStateEvent.java @@ -17,21 +17,14 @@ package baritone.api.event.events; -import baritone.api.event.events.type.ManagedPlayerEvent; -import net.minecraft.client.entity.EntityPlayerSP; - /** * @author Brady * @since 1/18/2019 */ -public class SprintStateEvent extends ManagedPlayerEvent { +public class SprintStateEvent { private Boolean state; - public SprintStateEvent(EntityPlayerSP player) { - super(player); - } - public final void setState(boolean state) { this.state = state; } diff --git a/src/launch/java/baritone/launch/mixins/MixinEntityPlayerSP.java b/src/launch/java/baritone/launch/mixins/MixinEntityPlayerSP.java index 5ca3c839..48ac8c94 100644 --- a/src/launch/java/baritone/launch/mixins/MixinEntityPlayerSP.java +++ b/src/launch/java/baritone/launch/mixins/MixinEntityPlayerSP.java @@ -98,9 +98,8 @@ public class MixinEntityPlayerSP { ) ) private boolean isKeyDown(KeyBinding keyBinding) { - EntityPlayerSP self = (EntityPlayerSP) (Object) this; - SprintStateEvent event = new SprintStateEvent(self); - BaritoneAPI.getProvider().getBaritoneForPlayer(self).getGameEventHandler().onPlayerSprintState(event); + SprintStateEvent event = new SprintStateEvent(); + BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this).getGameEventHandler().onPlayerSprintState(event); return event.getState() == null ? keyBinding.isKeyDown() : event.getState(); } } From 38c7f226cb4f6ffabfc90aceed289a4ddd4fd208 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 19 Jan 2019 16:36:24 -0800 Subject: [PATCH 08/42] brady is rart --- src/main/java/baritone/behavior/MemoryBehavior.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/baritone/behavior/MemoryBehavior.java b/src/main/java/baritone/behavior/MemoryBehavior.java index 661c5712..d371116c 100644 --- a/src/main/java/baritone/behavior/MemoryBehavior.java +++ b/src/main/java/baritone/behavior/MemoryBehavior.java @@ -109,7 +109,6 @@ public final class MemoryBehavior extends Behavior { } if (p instanceof CPacketCloseWindow) { - updateInventory(); getCurrent().save(); } } @@ -144,7 +143,6 @@ public final class MemoryBehavior extends Behavior { } if (p instanceof SPacketCloseWindow) { - updateInventory(); getCurrent().save(); } } From 39c6d81b9ec59355afaa9e34c7655a17254e9ccd Mon Sep 17 00:00:00 2001 From: babbaj Date: Sun, 20 Jan 2019 06:20:49 -0500 Subject: [PATCH 09/42] Never send chat message when using prefix --- .../utils/ExampleBaritoneControl.java | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index 508a5e1b..a207faf8 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -77,6 +77,8 @@ public class ExampleBaritoneControl extends Behavior implements Helper { "costs - (debug) all movement costs from current location\n" + "damn - Daniel "; + private static final String COMMAND_PREFIX = "#"; + public ExampleBaritoneControl(Baritone baritone) { super(baritone); } @@ -87,14 +89,17 @@ public class ExampleBaritoneControl extends Behavior implements Helper { return; } String msg = event.getMessage(); - if (Baritone.settings().prefix.get()) { - if (!msg.startsWith("#")) { - return; + if (Baritone.settings().prefix.get()) { + if (msg.startsWith(COMMAND_PREFIX)) { + if (!runCommand(msg.substring(COMMAND_PREFIX.length()))) { + logDirect("Invalid command"); + } + event.cancel(); // always cancel if using prefix + } + } else { + if (runCommand(msg)) { + event.cancel(); } - msg = msg.substring(1); - } - if (runCommand(msg)) { - event.cancel(); } } @@ -121,7 +126,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper { for (String line : HELP_MSG.split("\n")) { logDirect(line); } - return false; + return true; } if (msg.contains(" ")) { String[] data = msg.split(" "); From 5ab0bb3c0d32ffc12a7dcc621c42fcbd8cd2de38 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 20 Jan 2019 13:53:55 -0800 Subject: [PATCH 10/42] nice round number --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6bffdc24..f34b651d 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ A Minecraft pathfinder bot. Baritone is the pathfinding system used in [Impact](https://impactdevelopment.github.io/) since 4.4. There's a [showcase video](https://www.youtube.com/watch?v=yI8hgW_m6dQ) made by @Adovin#3153 on Baritone's integration into Impact. [Here's](https://www.youtube.com/watch?v=StquF69-_wI) a video I made showing off what it can do. This project is an updated version of [MineBot](https://github.com/leijurv/MineBot/), -the original version of the bot for Minecraft 1.8, rebuilt for 1.12.2. Baritone focuses on reliability and particularly performance (it's over [29x faster](https://github.com/cabaletta/baritone/pull/180#issuecomment-423822928) than MineBot at calculating paths). +the original version of the bot for Minecraft 1.8, rebuilt for 1.12.2. Baritone focuses on reliability and particularly performance (it's over [30x faster](https://github.com/cabaletta/baritone/pull/180#issuecomment-423822928) than MineBot at calculating paths). Here are some links to help to get started: From 30e30189663490e461d119a56309cbd18107d31b Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 20 Jan 2019 15:31:30 -0800 Subject: [PATCH 11/42] trigger brady --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f34b651d..ca5f995b 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,11 @@ [![Known Vulnerabilities](https://snyk.io/test/github/cabaletta/baritone/badge.svg?targetFile=build.gradle)](https://snyk.io/test/github/cabaletta/baritone?targetFile=build.gradle) [![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/cabaletta/baritone/issues) [![Minecraft](https://img.shields.io/badge/MC-1.12.2-green.svg)](https://minecraft.gamepedia.com/1.12.2) -[![Impact integration](https://img.shields.io/badge/Impact%20integration-v1.0.0--hotfix--4-brightgreen.svg)](https://impactdevelopment.github.io/) +[![Asuna integration](https://img.shields.io/badge/Asuna%20integration-builder%20branch-brightgreen.svg)](https://github.com/EmotionalLove/Asuna/) +[![Impact integration](https://img.shields.io/badge/Impact%20integration-v1.0.0--hotfix--4-green.svg)](https://impactdevelopment.github.io/) [![KAMI integration](https://img.shields.io/badge/KAMI%20integration-v1.0.0-orange.svg)](https://github.com/zeroeightysix/KAMI/) -[![Asuna integration](https://img.shields.io/badge/Asuna%20integration-v1.0.0-orange.svg)](https://github.com/EmotionalLove/Asuna/) -[![Future integration](https://img.shields.io/badge/Future%20integration-%3F%3F%3F-red.svg)](https://futureclient.net/) +[![WWE integration](https://img.shields.io/badge/WWE%20integration-v1.0.0%3F%3F-orange.svg)](https://wweclient.com/) +[![Future integration](https://img.shields.io/badge/Future%20integration-Soon™%3F%3F%3F-red.svg)](https://futureclient.net/) A Minecraft pathfinder bot. From 3c6c640f50cafc46a29164befe768fe7e816e125 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 20 Jan 2019 15:41:36 -0800 Subject: [PATCH 12/42] unused --- src/main/java/baritone/behavior/PathingBehavior.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/baritone/behavior/PathingBehavior.java b/src/main/java/baritone/behavior/PathingBehavior.java index 92eb242e..74cc46ee 100644 --- a/src/main/java/baritone/behavior/PathingBehavior.java +++ b/src/main/java/baritone/behavior/PathingBehavior.java @@ -36,7 +36,6 @@ import baritone.utils.Helper; import baritone.utils.PathRenderer; import baritone.utils.pathing.Favoring; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.chunk.EmptyChunk; import java.util.ArrayList; import java.util.Comparator; From eceba131642d502ef360523c98b465bd28067597 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 20 Jan 2019 16:26:23 -0800 Subject: [PATCH 13/42] diss wwe --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ca5f995b..173ee74a 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ [![Asuna integration](https://img.shields.io/badge/Asuna%20integration-builder%20branch-brightgreen.svg)](https://github.com/EmotionalLove/Asuna/) [![Impact integration](https://img.shields.io/badge/Impact%20integration-v1.0.0--hotfix--4-green.svg)](https://impactdevelopment.github.io/) [![KAMI integration](https://img.shields.io/badge/KAMI%20integration-v1.0.0-orange.svg)](https://github.com/zeroeightysix/KAMI/) -[![WWE integration](https://img.shields.io/badge/WWE%20integration-v1.0.0%3F%3F-orange.svg)](https://wweclient.com/) +[![WWE integration](https://img.shields.io/badge/WWE%20%22integration%22-v1.0.0%3F%3F%20smh%20license%20violations-orange.svg)](https://wweclient.com/) [![Future integration](https://img.shields.io/badge/Future%20integration-Soon™%3F%3F%3F-red.svg)](https://futureclient.net/) A Minecraft pathfinder bot. From 1753bc18c1f0e2122012985b01b39f2a1be45916 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 21 Jan 2019 23:32:41 -0800 Subject: [PATCH 14/42] forgehax --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 173ee74a..fb096630 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ [![KAMI integration](https://img.shields.io/badge/KAMI%20integration-v1.0.0-orange.svg)](https://github.com/zeroeightysix/KAMI/) [![WWE integration](https://img.shields.io/badge/WWE%20%22integration%22-v1.0.0%3F%3F%20smh%20license%20violations-orange.svg)](https://wweclient.com/) [![Future integration](https://img.shields.io/badge/Future%20integration-Soon™%3F%3F%3F-red.svg)](https://futureclient.net/) +[![ForgeHax integration](https://img.shields.io/badge/ForgeHax%20integration-Soon™-red.svg)](https://github.com/fr1kin/ForgeHax) A Minecraft pathfinder bot. From 253d67ce784f2f5a0481c2a5dc440b77470ffeea Mon Sep 17 00:00:00 2001 From: Brady Date: Tue, 22 Jan 2019 12:01:06 -0600 Subject: [PATCH 15/42] final final final final --- src/api/java/baritone/api/event/events/SprintStateEvent.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/java/baritone/api/event/events/SprintStateEvent.java b/src/api/java/baritone/api/event/events/SprintStateEvent.java index 6027c79e..60672801 100644 --- a/src/api/java/baritone/api/event/events/SprintStateEvent.java +++ b/src/api/java/baritone/api/event/events/SprintStateEvent.java @@ -21,7 +21,7 @@ package baritone.api.event.events; * @author Brady * @since 1/18/2019 */ -public class SprintStateEvent { +public final class SprintStateEvent { private Boolean state; From b75f4bf9a922b3d214dad526229d42185139136a Mon Sep 17 00:00:00 2001 From: Brady Date: Tue, 22 Jan 2019 13:32:37 -0600 Subject: [PATCH 16/42] Reformat --- src/api/java/baritone/api/process/IBaritoneProcess.java | 4 ++-- src/main/java/baritone/utils/ExampleBaritoneControl.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/api/java/baritone/api/process/IBaritoneProcess.java b/src/api/java/baritone/api/process/IBaritoneProcess.java index c2eb2f49..01e833c0 100644 --- a/src/api/java/baritone/api/process/IBaritoneProcess.java +++ b/src/api/java/baritone/api/process/IBaritoneProcess.java @@ -25,8 +25,8 @@ import baritone.api.event.events.PathEvent; *

* Differences between a baritone process and a behavior: *

    - *
  • Only one baritone process can be active at a time
  • - *
  • PathingBehavior can only be controlled by a process
  • + *
  • Only one baritone process can be active at a time
  • + *
  • PathingBehavior can only be controlled by a process
  • *
*

* That's it actually diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index a207faf8..245b4e9b 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -89,7 +89,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper { return; } String msg = event.getMessage(); - if (Baritone.settings().prefix.get()) { + if (Baritone.settings().prefix.get()) { if (msg.startsWith(COMMAND_PREFIX)) { if (!runCommand(msg.substring(COMMAND_PREFIX.length()))) { logDirect("Invalid command"); From 314f2804005785eab4d4685966cc8e4efe11c53c Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 22 Jan 2019 17:25:53 -0800 Subject: [PATCH 17/42] pigs --- .../baritone/launch/mixins/MixinEntityPlayerSP.java | 11 +++++++++++ src/main/java/baritone/behavior/LookBehavior.java | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/src/launch/java/baritone/launch/mixins/MixinEntityPlayerSP.java b/src/launch/java/baritone/launch/mixins/MixinEntityPlayerSP.java index 48ac8c94..bbf92011 100644 --- a/src/launch/java/baritone/launch/mixins/MixinEntityPlayerSP.java +++ b/src/launch/java/baritone/launch/mixins/MixinEntityPlayerSP.java @@ -23,6 +23,7 @@ import baritone.api.event.events.ChatEvent; import baritone.api.event.events.PlayerUpdateEvent; import baritone.api.event.events.SprintStateEvent; import baritone.api.event.events.type.EventState; +import baritone.behavior.LookBehavior; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.settings.KeyBinding; import net.minecraft.entity.player.PlayerCapabilities; @@ -102,4 +103,14 @@ public class MixinEntityPlayerSP { BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this).getGameEventHandler().onPlayerSprintState(event); return event.getState() == null ? keyBinding.isKeyDown() : event.getState(); } + + @Inject( + method = "updateRidden", + at = @At( + value = "HEAD" + ) + ) + private void updateRidden(CallbackInfo cb) { + ((LookBehavior) BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this).getLookBehavior()).pig(); + } } diff --git a/src/main/java/baritone/behavior/LookBehavior.java b/src/main/java/baritone/behavior/LookBehavior.java index 31e76913..c2d0326c 100644 --- a/src/main/java/baritone/behavior/LookBehavior.java +++ b/src/main/java/baritone/behavior/LookBehavior.java @@ -95,6 +95,12 @@ public final class LookBehavior extends Behavior implements ILookBehavior { } } + public void pig() { + if (this.target != null) { + ctx.player().rotationYaw = this.target.getYaw(); + } + } + @Override public void onPlayerRotationMove(RotationMoveEvent event) { if (this.target != null && !this.force) { From 863471b5f193e07ed6bff03f97cd8e0cbfd3b355 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 23 Jan 2019 21:25:38 -0800 Subject: [PATCH 18/42] don't create a new bsi for every selection box every tick --- src/main/java/baritone/utils/PathRenderer.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/baritone/utils/PathRenderer.java b/src/main/java/baritone/utils/PathRenderer.java index deca0951..9f07efdf 100644 --- a/src/main/java/baritone/utils/PathRenderer.java +++ b/src/main/java/baritone/utils/PathRenderer.java @@ -216,8 +216,9 @@ public final class PathRenderer implements Helper { double renderPosX = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double) partialTicks; double renderPosY = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double) partialTicks; double renderPosZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double) partialTicks; + BlockStateInterface bsi = new BlockStateInterface(BaritoneAPI.getProvider().getPrimaryBaritone().getPlayerContext()); // TODO this assumes same dimension between primary baritone and render view? is this safe? positions.forEach(pos -> { - IBlockState state = BlockStateInterface.get(BaritoneAPI.getProvider().getPrimaryBaritone().getPlayerContext(), pos); + IBlockState state = bsi.get0(pos); AxisAlignedBB toDraw; if (state.getBlock().equals(Blocks.AIR)) { toDraw = Blocks.DIRT.getDefaultState().getSelectedBoundingBox(player.world, pos); From 82ab79e915860f848018a53e6dd883a953df468a Mon Sep 17 00:00:00 2001 From: Brady Date: Thu, 24 Jan 2019 14:34:18 -0600 Subject: [PATCH 19/42] CLI setup --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index fb096630..4f386e00 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,13 @@ Here are some links to help to get started: ## Command Line On Mac OSX and Linux, use `./gradlew` instead of `gradlew`. +Setting up the Environment: + +``` +$ gradlew setupDecompWorkspace +$ gradlew --refresh-dependencies +``` + Running Baritone: ``` From 6b6f8cadb28835efb5528442d166772d430effa3 Mon Sep 17 00:00:00 2001 From: Brady Date: Thu, 24 Jan 2019 15:06:01 -0600 Subject: [PATCH 20/42] Image tutorial epic haha --- README.md | 62 ++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 54 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 4f386e00..8877ddf5 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,12 @@ Here are some links to help to get started: # Setup +- Clone or download Baritone + + ![Image](https://i.imgur.com/kbqBtoN.png) + - If you choose to download, make sure you extract the ZIP archive. +- Follow one of the instruction sets below, based on your preference + ## Command Line On Mac OSX and Linux, use `./gradlew` instead of `gradlew`. @@ -45,19 +51,59 @@ Running Baritone: $ gradlew runClient ``` -Building Baritone: +For information on how to build baritone, see [Building Baritone](#building-baritone) + +## IntelliJ +- Open the project in IntelliJ as a Gradle project + + ![Image](https://i.imgur.com/jw7Q6vY.png) + +- Run the Gradle tasks `setupDecompWorkspace` then `genIntellijRuns` + + ![Image](https://i.imgur.com/QEfVvWP.png) + +- Refresh the Gradle project (or, to be safe, just restart IntelliJ) + + ![Image](https://i.imgur.com/3V7EdWr.png) + +- Select the "Minecraft Client" launch config + + ![Image](https://i.imgur.com/1qz2QGV.png) + +- Click on ``Edit Configurations...`` from the same dropdown and select the "Minecraft Client" config + + ![Image](https://i.imgur.com/s4ly0ZF.png) + +- In `Edit Configurations...` you need to select `baritone_launch` for `Use classpath of module:`. + + ![Image](https://i.imgur.com/hrLhG9u.png) + +# Building + +## Command Line + ``` $ gradlew build ``` -To replace out Impact 4.4's Baritone build with a customized one, switch to the `impact4.4-compat` branch, build Baritone as above then copy `dist/baritone-api-$VERSION$.jar` into `minecraft/libraries/cabaletta/baritone-api/1.0.0/baritone-api-1.0.0.jar`, replacing the jar that was previously there. You also need to edit `minecraft/versions/1.12.2-Impact_4.4/1.12.2-Impact_4.4.json`, find the line `"name": "cabaletta:baritone-api:1.0.0"`, remove the comma from the end, and entirely remove the line that's immediately after (starts with `"url"`). +## IntelliJ -## IntelliJ's Gradle UI -- Open the project in IntelliJ as a Gradle project -- Run the Gradle tasks `setupDecompWorkspace` then `genIntellijRuns` -- Refresh the Gradle project (or, to be safe, just restart IntelliJ) -- Select the "Minecraft Client" launch config -- In `Edit Configurations...` you may need to select `baritone_launch` for `Use classpath of module:`. +- Navigate to the gradle tasks on the right tab as follows + + ![Image](https://i.imgur.com/PE6r9iN.png) + +- Right click on **build** and press **Run** + +## Artifacts + +Building Baritone will result in 3 artifacts created in the ``dist`` directory. + +- **API**: Only the non-api packages are obfuscated. This should be used in environments where other mods would like to use Baritone's features. +- **Standalone**: Everything is obfuscated. This should be used in environments where there are no other mods present that would like to use Baritone's features. +- **Unoptimized**: Nothing is obfuscated. This shouldn't be used ever in production. + +## More Info +To replace out Impact 4.4's Baritone build with a customized one, switch to the `impact4.4-compat` branch, build Baritone as above then copy `dist/baritone-api-$VERSION$.jar` into `minecraft/libraries/cabaletta/baritone-api/1.0.0/baritone-api-1.0.0.jar`, replacing the jar that was previously there. You also need to edit `minecraft/versions/1.12.2-Impact_4.4/1.12.2-Impact_4.4.json`, find the line `"name": "cabaletta:baritone-api:1.0.0"`, remove the comma from the end, and entirely remove the line that's immediately after (starts with `"url"`). # Chat control [Defined Here](src/main/java/baritone/utils/ExampleBaritoneControl.java) From 772d5fb0ccf332f2d52ada6d094601825f0a3723 Mon Sep 17 00:00:00 2001 From: Brady Date: Thu, 24 Jan 2019 15:09:04 -0600 Subject: [PATCH 21/42] SETUP.md --- README.md | 76 +----------------------------------------------------- SETUP.md | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 75 deletions(-) create mode 100644 SETUP.md diff --git a/README.md b/README.md index 8877ddf5..c24681e0 100644 --- a/README.md +++ b/README.md @@ -29,81 +29,7 @@ Here are some links to help to get started: # Setup -- Clone or download Baritone - - ![Image](https://i.imgur.com/kbqBtoN.png) - - If you choose to download, make sure you extract the ZIP archive. -- Follow one of the instruction sets below, based on your preference - -## Command Line -On Mac OSX and Linux, use `./gradlew` instead of `gradlew`. - -Setting up the Environment: - -``` -$ gradlew setupDecompWorkspace -$ gradlew --refresh-dependencies -``` - -Running Baritone: - -``` -$ gradlew runClient -``` - -For information on how to build baritone, see [Building Baritone](#building-baritone) - -## IntelliJ -- Open the project in IntelliJ as a Gradle project - - ![Image](https://i.imgur.com/jw7Q6vY.png) - -- Run the Gradle tasks `setupDecompWorkspace` then `genIntellijRuns` - - ![Image](https://i.imgur.com/QEfVvWP.png) - -- Refresh the Gradle project (or, to be safe, just restart IntelliJ) - - ![Image](https://i.imgur.com/3V7EdWr.png) - -- Select the "Minecraft Client" launch config - - ![Image](https://i.imgur.com/1qz2QGV.png) - -- Click on ``Edit Configurations...`` from the same dropdown and select the "Minecraft Client" config - - ![Image](https://i.imgur.com/s4ly0ZF.png) - -- In `Edit Configurations...` you need to select `baritone_launch` for `Use classpath of module:`. - - ![Image](https://i.imgur.com/hrLhG9u.png) - -# Building - -## Command Line - -``` -$ gradlew build -``` - -## IntelliJ - -- Navigate to the gradle tasks on the right tab as follows - - ![Image](https://i.imgur.com/PE6r9iN.png) - -- Right click on **build** and press **Run** - -## Artifacts - -Building Baritone will result in 3 artifacts created in the ``dist`` directory. - -- **API**: Only the non-api packages are obfuscated. This should be used in environments where other mods would like to use Baritone's features. -- **Standalone**: Everything is obfuscated. This should be used in environments where there are no other mods present that would like to use Baritone's features. -- **Unoptimized**: Nothing is obfuscated. This shouldn't be used ever in production. - -## More Info -To replace out Impact 4.4's Baritone build with a customized one, switch to the `impact4.4-compat` branch, build Baritone as above then copy `dist/baritone-api-$VERSION$.jar` into `minecraft/libraries/cabaletta/baritone-api/1.0.0/baritone-api-1.0.0.jar`, replacing the jar that was previously there. You also need to edit `minecraft/versions/1.12.2-Impact_4.4/1.12.2-Impact_4.4.json`, find the line `"name": "cabaletta:baritone-api:1.0.0"`, remove the comma from the end, and entirely remove the line that's immediately after (starts with `"url"`). +Information on how to setup baritone can be found [here](SETUP.md). # Chat control [Defined Here](src/main/java/baritone/utils/ExampleBaritoneControl.java) diff --git a/SETUP.md b/SETUP.md new file mode 100644 index 00000000..777b34da --- /dev/null +++ b/SETUP.md @@ -0,0 +1,77 @@ +# Setup + +- Clone or download Baritone + + ![Image](https://i.imgur.com/kbqBtoN.png) + - If you choose to download, make sure you extract the ZIP archive. +- Follow one of the instruction sets below, based on your preference + +## Command Line +On Mac OSX and Linux, use `./gradlew` instead of `gradlew`. + +Setting up the Environment: + +``` +$ gradlew setupDecompWorkspace +$ gradlew --refresh-dependencies +``` + +Running Baritone: + +``` +$ gradlew runClient +``` + +For information on how to build baritone, see [Building Baritone](#building-baritone) + +## IntelliJ +- Open the project in IntelliJ as a Gradle project + + ![Image](https://i.imgur.com/jw7Q6vY.png) + +- Run the Gradle tasks `setupDecompWorkspace` then `genIntellijRuns` + + ![Image](https://i.imgur.com/QEfVvWP.png) + +- Refresh the Gradle project (or, to be safe, just restart IntelliJ) + + ![Image](https://i.imgur.com/3V7EdWr.png) + +- Select the "Minecraft Client" launch config + + ![Image](https://i.imgur.com/1qz2QGV.png) + +- Click on ``Edit Configurations...`` from the same dropdown and select the "Minecraft Client" config + + ![Image](https://i.imgur.com/s4ly0ZF.png) + +- In `Edit Configurations...` you need to select `baritone_launch` for `Use classpath of module:`. + + ![Image](https://i.imgur.com/hrLhG9u.png) + +# Building + +## Command Line + +``` +$ gradlew build +``` + +## IntelliJ + +- Navigate to the gradle tasks on the right tab as follows + + ![Image](https://i.imgur.com/PE6r9iN.png) + +- Right click on **build** and press **Run** + +## Artifacts + +Building Baritone will result in 3 artifacts created in the ``dist`` directory. + +- **API**: Only the non-api packages are obfuscated. This should be used in environments where other mods would like to use Baritone's features. +- **Standalone**: Everything is obfuscated. This should be used in environments where there are no other mods present that would like to use Baritone's features. +- **Unoptimized**: Nothing is obfuscated. This shouldn't be used ever in production. + +## More Info +To replace out Impact 4.4's Baritone build with a customized one, switch to the `impact4.4-compat` branch, build Baritone as above then copy `dist/baritone-api-$VERSION$.jar` into `minecraft/libraries/cabaletta/baritone-api/1.0.0/baritone-api-1.0.0.jar`, replacing the jar that was previously there. You also need to edit `minecraft/versions/1.12.2-Impact_4.4/1.12.2-Impact_4.4.json`, find the line `"name": "cabaletta:baritone-api:1.0.0"`, remove the comma from the end, and entirely remove the line that's immediately after (starts with `"url"`). From aba48cca53a2007934fa6066270b6bf422cb6960 Mon Sep 17 00:00:00 2001 From: Brady Date: Thu, 24 Jan 2019 15:21:16 -0600 Subject: [PATCH 22/42] Organize some markdown files --- IMPACT.md | 1 - INSTALL.md | 12 ++---------- README.md | 6 ++---- SETUP.md | 2 ++ 4 files changed, 6 insertions(+), 15 deletions(-) delete mode 100644 IMPACT.md diff --git a/IMPACT.md b/IMPACT.md deleted file mode 100644 index cc12252e..00000000 --- a/IMPACT.md +++ /dev/null @@ -1 +0,0 @@ -Impact 4.4 is out. See INSTALL.md \ No newline at end of file diff --git a/INSTALL.md b/INSTALL.md index 9df3d6bf..f05e0280 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -1,11 +1,10 @@ # Integration between Baritone and Impact Impact 4.4 has Baritone included. -These instructions apply to Impact 4.3 (and potentially other hacked clients). +These instructions apply to Impact 4.3 (and potentially other "hacked clients"). To run Baritone on Vanilla, just follow the instructions in the README (it's `./gradlew runClient`). - ## An Introduction There are some basic steps to getting Baritone setup with Impact. - Acquiring a build of Baritone @@ -26,14 +25,7 @@ Any official release will be GPG signed by leijurv (44A3EA646EADAC6A) and ZeroMe The build is fully deterministic and reproducible, and you can verify Travis did it properly by running `docker build --no-cache -t cabaletta/baritone . && docker run --rm cabaletta/baritone cat /code/dist/checksums.txt` yourself and comparing the shasum. This works identically on Travis, Mac, and Linux (if you have docker on Windows, I'd be grateful if you could let me know if it works there too). ### Building Baritone yourself -There are a few steps to this -- Clone this repository -- Setup the project as instructed in the README -- Run the ``build`` gradle task. You can either do this using IntelliJ's gradle UI or through a -command line - - Windows: ``gradlew build`` - - Mac/Linux: ``./gradlew build`` -- The build should be exported into ``/build/libs/baritone-X.Y.Z.jar`` +You can either build Baritone through a command line or through IntelliJ's UI, information on that can be found [here](SETUP.md#building). ## Placing Baritone in the libraries directory ``/libraries`` is a neat directory in your Minecraft Installation Directory diff --git a/README.md b/README.md index c24681e0..df1422cc 100644 --- a/README.md +++ b/README.md @@ -25,12 +25,10 @@ Here are some links to help to get started: - [Features](FEATURES.md) +- [Setup](SETUP.md) + - [Installation](INSTALL.md) -# Setup - -Information on how to setup baritone can be found [here](SETUP.md). - # Chat control [Defined Here](src/main/java/baritone/utils/ExampleBaritoneControl.java) diff --git a/SETUP.md b/SETUP.md index 777b34da..6400990d 100644 --- a/SETUP.md +++ b/SETUP.md @@ -51,6 +51,8 @@ For information on how to build baritone, see [Building Baritone](#building-bari # Building +Make sure that you have properly [setup](#setup) the environment before trying to build it. + ## Command Line ``` From b1452c714ae4cd4ef94f92cfef36193b1d9b4f20 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 24 Jan 2019 16:06:53 -0800 Subject: [PATCH 23/42] b a d g e s --- FEATURES.md | 2 +- README.md | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/FEATURES.md b/FEATURES.md index cd2a90fe..e3714a8c 100644 --- a/FEATURES.md +++ b/FEATURES.md @@ -11,6 +11,7 @@ - **Avoiding dangerous blocks** Obviously, it knows not to walk through fire or on magma, not to corner over lava (that deals some damage), not to break any blocks touching a liquid (it might drown), etc. - **Parkour** Sprint jumping over 1, 2, or 3 block gaps - **Parkour place** Sprint jumping over a 3 block gap and placing the block to land on while executing the jump. It's really cool. +- **Pigs** It can sort of control pigs. I wouldn't rely on it though. # Pathing method Baritone uses A*, with some modifications: @@ -46,7 +47,6 @@ Things it doesn't have yet See issues for more. Things it may not ever have, from most likely to least likely =( -- Pigs - Boats - Horses (2x3 path instead of 1x2) - Elytra diff --git a/README.md b/README.md index df1422cc..d017113b 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,12 @@ [![HitCount](http://hits.dwyl.com/cabaletta/baritone.svg)](http://hits.dwyl.com/cabaletta/baritone) [![Known Vulnerabilities](https://snyk.io/test/github/cabaletta/baritone/badge.svg?targetFile=build.gradle)](https://snyk.io/test/github/cabaletta/baritone?targetFile=build.gradle) [![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/cabaletta/baritone/issues) +[![Issues](https://img.shields.io/github/issues/cabaletta/baritone.svg)](https://github.com/cabaletta/baritone/issues/) +[![Pull Requests](https://img.shields.io/github/issues-pr/cabaletta/baritone.svg)](https://github.com/cabaletta/baritone/pulls/) +![GitHub repo size](https://img.shields.io/github/repo-size/cabaletta/baritone.svg) [![Minecraft](https://img.shields.io/badge/MC-1.12.2-green.svg)](https://minecraft.gamepedia.com/1.12.2) +[![GitHub contributors](https://img.shields.io/github/contributors/cabaletta/baritone.svg)](https://github.com/cabaletta/baritone/graphs/contributors/) +[![GitHub commits](https://img.shields.io/github/commits-since/cabaletta/baritone/v1.0.0.svg)](https://github.com/cabaletta/baritone/commit/) [![Asuna integration](https://img.shields.io/badge/Asuna%20integration-builder%20branch-brightgreen.svg)](https://github.com/EmotionalLove/Asuna/) [![Impact integration](https://img.shields.io/badge/Impact%20integration-v1.0.0--hotfix--4-green.svg)](https://impactdevelopment.github.io/) [![KAMI integration](https://img.shields.io/badge/KAMI%20integration-v1.0.0-orange.svg)](https://github.com/zeroeightysix/KAMI/) From 4f355ed4a25798f6862b62c54c5fdd093fea2ace Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 24 Jan 2019 16:10:21 -0800 Subject: [PATCH 24/42] two more --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index d017113b..ebca5b20 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,9 @@ [![WWE integration](https://img.shields.io/badge/WWE%20%22integration%22-v1.0.0%3F%3F%20smh%20license%20violations-orange.svg)](https://wweclient.com/) [![Future integration](https://img.shields.io/badge/Future%20integration-Soon™%3F%3F%3F-red.svg)](https://futureclient.net/) [![ForgeHax integration](https://img.shields.io/badge/ForgeHax%20integration-Soon™-red.svg)](https://github.com/fr1kin/ForgeHax) +[![forthebadge](https://forthebadge.com/images/badges/built-with-swag.svg)](http://forthebadge.com) +[![forthebadge](https://forthebadge.com/images/badges/mom-made-pizza-rolls.svg)](http://forthebadge.com) + A Minecraft pathfinder bot. From fca5457ab93a040cbcfaa584e606c663395aba4d Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 24 Jan 2019 16:25:35 -0800 Subject: [PATCH 25/42] gotta have closed issues too --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index ebca5b20..df2f9394 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ [![Known Vulnerabilities](https://snyk.io/test/github/cabaletta/baritone/badge.svg?targetFile=build.gradle)](https://snyk.io/test/github/cabaletta/baritone?targetFile=build.gradle) [![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/cabaletta/baritone/issues) [![Issues](https://img.shields.io/github/issues/cabaletta/baritone.svg)](https://github.com/cabaletta/baritone/issues/) +[![GitHub issues-closed](https://img.shields.io/github/issues-closed/cabaletta/baritone.svg)](https://github.com/cabaletta/baritone/issues?q=is%3Aissue+is%3Aclosed) [![Pull Requests](https://img.shields.io/github/issues-pr/cabaletta/baritone.svg)](https://github.com/cabaletta/baritone/pulls/) ![GitHub repo size](https://img.shields.io/github/repo-size/cabaletta/baritone.svg) [![Minecraft](https://img.shields.io/badge/MC-1.12.2-green.svg)](https://minecraft.gamepedia.com/1.12.2) From bb4188307046c0daf54688196cd7d7a45d5733e4 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 24 Jan 2019 16:31:12 -0800 Subject: [PATCH 26/42] did someone say add another badge --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index df2f9394..8fa78e8c 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ [![Issues](https://img.shields.io/github/issues/cabaletta/baritone.svg)](https://github.com/cabaletta/baritone/issues/) [![GitHub issues-closed](https://img.shields.io/github/issues-closed/cabaletta/baritone.svg)](https://github.com/cabaletta/baritone/issues?q=is%3Aissue+is%3Aclosed) [![Pull Requests](https://img.shields.io/github/issues-pr/cabaletta/baritone.svg)](https://github.com/cabaletta/baritone/pulls/) +![Code size](https://img.shields.io/github/languages/code-size/cabaletta/baritone.svg) ![GitHub repo size](https://img.shields.io/github/repo-size/cabaletta/baritone.svg) [![Minecraft](https://img.shields.io/badge/MC-1.12.2-green.svg)](https://minecraft.gamepedia.com/1.12.2) [![GitHub contributors](https://img.shields.io/github/contributors/cabaletta/baritone.svg)](https://github.com/cabaletta/baritone/graphs/contributors/) From f274f5a0eface7f29bdab3ecf7d7c2c5836902e4 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 24 Jan 2019 21:00:44 -0800 Subject: [PATCH 27/42] windows is epic gamer --- src/main/java/baritone/cache/WorldProvider.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/baritone/cache/WorldProvider.java b/src/main/java/baritone/cache/WorldProvider.java index 83cf460d..fe2efa4e 100644 --- a/src/main/java/baritone/cache/WorldProvider.java +++ b/src/main/java/baritone/cache/WorldProvider.java @@ -24,6 +24,7 @@ import baritone.utils.accessor.IAnvilChunkLoader; import baritone.utils.accessor.IChunkProviderServer; import net.minecraft.server.integrated.IntegratedServer; import net.minecraft.world.WorldServer; +import org.apache.commons.lang3.SystemUtils; import java.io.File; import java.io.FileOutputStream; @@ -76,7 +77,11 @@ public class WorldProvider implements IWorldProvider, Helper { directory = new File(directory, "baritone"); readme = directory; } else { // Otherwise, the server must be remote... - directory = new File(Baritone.getDir(), mc.getCurrentServerData().serverIP); + String folderName = mc.getCurrentServerData().serverIP; + if (SystemUtils.IS_OS_WINDOWS) { + folderName = folderName.replace(":", "_"); + } + directory = new File(Baritone.getDir(), folderName); readme = Baritone.getDir(); } From 2a244f1e538353a889d50d7f4cfee80e1383d8e7 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 25 Jan 2019 11:51:54 -0800 Subject: [PATCH 28/42] those were a little over the top --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 8fa78e8c..b4b7187d 100644 --- a/README.md +++ b/README.md @@ -20,8 +20,6 @@ [![WWE integration](https://img.shields.io/badge/WWE%20%22integration%22-v1.0.0%3F%3F%20smh%20license%20violations-orange.svg)](https://wweclient.com/) [![Future integration](https://img.shields.io/badge/Future%20integration-Soon™%3F%3F%3F-red.svg)](https://futureclient.net/) [![ForgeHax integration](https://img.shields.io/badge/ForgeHax%20integration-Soon™-red.svg)](https://github.com/fr1kin/ForgeHax) -[![forthebadge](https://forthebadge.com/images/badges/built-with-swag.svg)](http://forthebadge.com) -[![forthebadge](https://forthebadge.com/images/badges/mom-made-pizza-rolls.svg)](http://forthebadge.com) A Minecraft pathfinder bot. From 396eaa148caf22703d633d0fc150534b16e8c2bd Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 26 Jan 2019 21:33:41 -0800 Subject: [PATCH 29/42] remove extra newline --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index b4b7187d..555c2c07 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,6 @@ [![Future integration](https://img.shields.io/badge/Future%20integration-Soon™%3F%3F%3F-red.svg)](https://futureclient.net/) [![ForgeHax integration](https://img.shields.io/badge/ForgeHax%20integration-Soon™-red.svg)](https://github.com/fr1kin/ForgeHax) - A Minecraft pathfinder bot. Baritone is the pathfinding system used in [Impact](https://impactdevelopment.github.io/) since 4.4. There's a [showcase video](https://www.youtube.com/watch?v=yI8hgW_m6dQ) made by @Adovin#3153 on Baritone's integration into Impact. [Here's](https://www.youtube.com/watch?v=StquF69-_wI) a video I made showing off what it can do. From 8d7841b069cbc0638cc3e8b8b6862419fb73b6c6 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 27 Jan 2019 19:34:12 -0800 Subject: [PATCH 30/42] privatize --- src/main/java/baritone/utils/ExampleBaritoneControl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index 245b4e9b..e26a352f 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -103,7 +103,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper { } } - public boolean runCommand(String msg0) { + private boolean runCommand(String msg0) { String msg = msg0.toLowerCase(Locale.US).trim(); // don't reassign the argument LOL PathingBehavior pathingBehavior = baritone.getPathingBehavior(); CustomGoalProcess customGoalProcess = baritone.getCustomGoalProcess(); From bf78a4dfad337a0966918302b78e81e9de77b07f Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 28 Jan 2019 10:32:28 -0800 Subject: [PATCH 31/42] whoops forgot that --- src/main/java/baritone/utils/ExampleBaritoneControl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index e26a352f..281351bd 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -103,7 +103,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper { } } - private boolean runCommand(String msg0) { + public boolean runCommand(String msg0) { // you may think this can be private, but impcat calls it from .b =) String msg = msg0.toLowerCase(Locale.US).trim(); // don't reassign the argument LOL PathingBehavior pathingBehavior = baritone.getPathingBehavior(); CustomGoalProcess customGoalProcess = baritone.getCustomGoalProcess(); From b0c475239726a68ad14ab739b7831efeaf0e5b70 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 28 Jan 2019 10:41:28 -0800 Subject: [PATCH 32/42] finalize all settings --- src/api/java/baritone/api/Settings.java | 188 ++++++++++++------------ 1 file changed, 94 insertions(+), 94 deletions(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 89716a38..a069d76b 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -33,67 +33,67 @@ import java.util.function.Consumer; * * @author leijurv */ -public class Settings { +public final class Settings { /** * Allow Baritone to break blocks */ - public Setting allowBreak = new Setting<>(true); + public final Setting allowBreak = new Setting<>(true); /** * Allow Baritone to sprint */ - public Setting allowSprint = new Setting<>(true); + public final Setting allowSprint = new Setting<>(true); /** * Allow Baritone to place blocks */ - public Setting allowPlace = new Setting<>(true); + public final Setting allowPlace = new Setting<>(true); /** * Allow Baritone to move items in your inventory to your hotbar */ - public Setting allowInventory = new Setting<>(false); + public final Setting allowInventory = new Setting<>(false); /** * It doesn't actually take twenty ticks to place a block, this cost is so high * because we want to generally conserve blocks which might be limited */ - public Setting blockPlacementPenalty = new Setting<>(20D); + public final Setting blockPlacementPenalty = new Setting<>(20D); /** * This is just a tiebreaker to make it less likely to break blocks if it can avoid it. * For example, fire has a break cost of 0, this makes it nonzero, so all else being equal * it will take an otherwise equivalent route that doesn't require it to put out fire. */ - public Setting blockBreakAdditionalPenalty = new Setting<>(2D); + public final Setting blockBreakAdditionalPenalty = new Setting<>(2D); /** * Additional penalty for hitting the space bar (ascend, pillar, or parkour) beacuse it uses hunger */ - public Setting jumpPenalty = new Setting<>(2D); + public final Setting jumpPenalty = new Setting<>(2D); /** * Walking on water uses up hunger really quick, so penalize it */ - public Setting walkOnWaterOnePenalty = new Setting<>(5D); + public final Setting walkOnWaterOnePenalty = new Setting<>(5D); /** * Allow Baritone to fall arbitrary distances and place a water bucket beneath it. * Reliability: questionable. */ - public Setting allowWaterBucketFall = new Setting<>(true); + public final Setting allowWaterBucketFall = new Setting<>(true); /** * Allow Baritone to assume it can walk on still water just like any other block. * This functionality is assumed to be provided by a separate library that might have imported Baritone. */ - public Setting assumeWalkOnWater = new Setting<>(false); + public final Setting assumeWalkOnWater = new Setting<>(false); /** * Assume step functionality; don't jump on an Ascend. */ - public Setting assumeStep = new Setting<>(false); + public final Setting assumeStep = new Setting<>(false); /** * Assume safe walk functionality; don't sneak on a backplace traverse. @@ -102,14 +102,14 @@ public class Settings { * it won't sneak right click, it'll just right click, which means it'll open the chest instead of placing * against it. That's why this defaults to off. */ - public Setting assumeSafeWalk = new Setting<>(false); + public final Setting assumeSafeWalk = new Setting<>(false); /** * If true, parkour is allowed to make jumps when standing on blocks at the maximum height, so player feet is y=256 *

* Defaults to false because this fails on NCP */ - public Setting allowJumpAt256 = new Setting<>(false); + public final Setting allowJumpAt256 = new Setting<>(false); /** * Allow descending diagonally @@ -118,12 +118,12 @@ public class Settings { *

* For a generic "take some risks" mode I'd turn on this one, parkour, and parkour place. */ - public Setting allowDiagonalDescend = new Setting<>(false); + public final Setting allowDiagonalDescend = new Setting<>(false); /** * Blocks that Baritone is allowed to place (as throwaway, for sneak bridging, pillaring, etc.) */ - public Setting> acceptableThrowawayItems = new Setting<>(new ArrayList<>(Arrays.asList( + public final Setting> acceptableThrowawayItems = new Setting<>(new ArrayList<>(Arrays.asList( Item.getItemFromBlock(Blocks.DIRT), Item.getItemFromBlock(Blocks.COBBLESTONE), Item.getItemFromBlock(Blocks.NETHERRACK) @@ -133,30 +133,30 @@ public class Settings { * Enables some more advanced vine features. They're honestly just gimmicks and won't ever be needed in real * pathing scenarios. And they can cause Baritone to get trapped indefinitely in a strange scenario. */ - public Setting allowVines = new Setting<>(false); + public final Setting allowVines = new Setting<>(false); /** * Slab behavior is complicated, disable this for higher path reliability. Leave enabled if you have bottom slabs * everywhere in your base. */ - public Setting allowWalkOnBottomSlab = new Setting<>(true); + public final Setting allowWalkOnBottomSlab = new Setting<>(true); /** * You know what it is *

* But it's very unreliable and falls off when cornering like all the time so. */ - public Setting allowParkour = new Setting<>(false); + public final Setting allowParkour = new Setting<>(false); /** * Like parkour, but even more unreliable! */ - public Setting allowParkourPlace = new Setting<>(false); + public final Setting allowParkourPlace = new Setting<>(false); /** * For example, if you have Mining Fatigue or Haste, adjust the costs of breaking blocks accordingly. */ - public Setting considerPotionEffects = new Setting<>(true); + public final Setting considerPotionEffects = new Setting<>(true); /** * This is the big A* setting. @@ -173,63 +173,63 @@ public class Settings { *

* Finding the optimal path is worth it, so it's the default. */ - public Setting costHeuristic = new Setting<>(3.563); + public final Setting costHeuristic = new Setting<>(3.563); // a bunch of obscure internal A* settings that you probably don't want to change /** * The maximum number of times it will fetch outside loaded or cached chunks before assuming that * pathing has reached the end of the known area, and should therefore stop. */ - public Setting pathingMaxChunkBorderFetch = new Setting<>(50); + public final Setting pathingMaxChunkBorderFetch = new Setting<>(50); /** * Set to 1.0 to effectively disable this feature * * @see Issue #18 */ - public Setting backtrackCostFavoringCoefficient = new Setting<>(0.5); + public final Setting backtrackCostFavoringCoefficient = new Setting<>(0.5); /** * Toggle the following 4 settings *

* They have a noticable performance impact, so they default off */ - public Setting avoidance = new Setting<>(false); + public final Setting avoidance = new Setting<>(false); /** * Set to 1.0 to effectively disable this feature *

* Set below 1.0 to go out of your way to walk near mob spawners */ - public Setting mobSpawnerAvoidanceCoefficient = new Setting<>(2.0); + public final Setting mobSpawnerAvoidanceCoefficient = new Setting<>(2.0); - public Setting mobSpawnerAvoidanceRadius = new Setting<>(16); + public final Setting mobSpawnerAvoidanceRadius = new Setting<>(16); /** * Set to 1.0 to effectively disable this feature *

* Set below 1.0 to go out of your way to walk near mobs */ - public Setting mobAvoidanceCoefficient = new Setting<>(1.5); + public final Setting mobAvoidanceCoefficient = new Setting<>(1.5); - public Setting mobAvoidanceRadius = new Setting<>(8); + public final Setting mobAvoidanceRadius = new Setting<>(8); /** * When running a goto towards a container block (chest, ender chest, furnace, etc), * right click and open it once you arrive. */ - public Setting rightClickContainerOnArrival = new Setting<>(true); + public final Setting rightClickContainerOnArrival = new Setting<>(true); /** * When running a goto towards a nether portal block, walk all the way into the portal * instead of stopping one block before. */ - public Setting enterPortal = new Setting<>(true); + public final Setting enterPortal = new Setting<>(true); /** * Don't repropagate cost improvements below 0.01 ticks. They're all just floating point inaccuracies, * and there's no point. */ - public Setting minimumImprovementRepropagation = new Setting<>(true); + public final Setting minimumImprovementRepropagation = new Setting<>(true); /** * After calculating a path (potentially through cached chunks), artificially cut it off to just the part that is @@ -237,67 +237,67 @@ public class Settings { * * @see Issue #144 */ - public Setting cutoffAtLoadBoundary = new Setting<>(false); + public final Setting cutoffAtLoadBoundary = new Setting<>(false); /** * If a movement's cost increases by more than this amount between calculation and execution (due to changes * in the environment / world), cancel and recalculate */ - public Setting maxCostIncrease = new Setting<>(10D); + public final Setting maxCostIncrease = new Setting<>(10D); /** * Stop 5 movements before anything that made the path COST_INF. * For example, if lava has spread across the path, don't walk right up to it then recalculate, it might * still be spreading lol */ - public Setting costVerificationLookahead = new Setting<>(5); + public final Setting costVerificationLookahead = new Setting<>(5); /** * Static cutoff factor. 0.9 means cut off the last 10% of all paths, regardless of chunk load state */ - public Setting pathCutoffFactor = new Setting<>(0.9); + public final Setting pathCutoffFactor = new Setting<>(0.9); /** * Only apply static cutoff for paths of at least this length (in terms of number of movements) */ - public Setting pathCutoffMinimumLength = new Setting<>(30); + public final Setting pathCutoffMinimumLength = new Setting<>(30); /** * Start planning the next path once the remaining movements tick estimates sum up to less than this value */ - public Setting planningTickLookAhead = new Setting<>(150); + public final Setting planningTickLookAhead = new Setting<>(150); /** * Default size of the Long2ObjectOpenHashMap used in pathing */ - public Setting pathingMapDefaultSize = new Setting<>(1024); + public final Setting pathingMapDefaultSize = new Setting<>(1024); /** * Load factor coefficient for the Long2ObjectOpenHashMap used in pathing *

* Decrease for faster map operations, but higher memory usage */ - public Setting pathingMapLoadFactor = new Setting<>(0.75f); + public final Setting pathingMapLoadFactor = new Setting<>(0.75f); /** * How far are you allowed to fall onto solid ground (without a water bucket)? * 3 won't deal any damage. But if you just want to get down the mountain quickly and you have * Feather Falling IV, you might set it a bit higher, like 4 or 5. */ - public Setting maxFallHeightNoWater = new Setting<>(3); + public final Setting maxFallHeightNoWater = new Setting<>(3); /** * How far are you allowed to fall onto solid ground (with a water bucket)? * It's not that reliable, so I've set it below what would kill an unarmored player (23) */ - public Setting maxFallHeightBucket = new Setting<>(20); + public final Setting maxFallHeightBucket = new Setting<>(20); /** * Is it okay to sprint through a descend followed by a diagonal? * The player overshoots the landing, but not enough to fall off. And the diagonal ensures that there isn't * lava or anything that's !canWalkInto in that space, so it's technically safe, just a little sketchy. */ - public Setting allowOvershootDiagonalDescend = new Setting<>(true); + public final Setting allowOvershootDiagonalDescend = new Setting<>(true); /** * If your goal is a GoalBlock in an unloaded chunk, assume it's far enough away that the Y coord @@ -306,131 +306,131 @@ public class Settings { * of considering the Y coord. The reasoning is that if your X and Z are 10,000 blocks away, * your Y coordinate's accuracy doesn't matter at all until you get much much closer. */ - public Setting simplifyUnloadedYCoord = new Setting<>(true); + public final Setting simplifyUnloadedYCoord = new Setting<>(true); /** * If a movement takes this many ticks more than its initial cost estimate, cancel it */ - public Setting movementTimeoutTicks = new Setting<>(100); + public final Setting movementTimeoutTicks = new Setting<>(100); /** * Pathing ends after this amount of time, but only if a path has been found *

* If no valid path (length above the minimum) has been found, pathing continues up until the failure timeout */ - public Setting primaryTimeoutMS = new Setting<>(500L); + public final Setting primaryTimeoutMS = new Setting<>(500L); /** * Pathing can never take longer than this, even if that means failing to find any path at all */ - public Setting failureTimeoutMS = new Setting<>(2000L); + public final Setting failureTimeoutMS = new Setting<>(2000L); /** * Planning ahead while executing a segment ends after this amount of time, but only if a path has been found *

* If no valid path (length above the minimum) has been found, pathing continues up until the failure timeout */ - public Setting planAheadPrimaryTimeoutMS = new Setting<>(4000L); + public final Setting planAheadPrimaryTimeoutMS = new Setting<>(4000L); /** * Planning ahead while executing a segment can never take longer than this, even if that means failing to find any path at all */ - public Setting planAheadFailureTimeoutMS = new Setting<>(5000L); + public final Setting planAheadFailureTimeoutMS = new Setting<>(5000L); /** * For debugging, consider nodes much much slower */ - public Setting slowPath = new Setting<>(false); + public final Setting slowPath = new Setting<>(false); /** * Milliseconds between each node */ - public Setting slowPathTimeDelayMS = new Setting<>(100L); + public final Setting slowPathTimeDelayMS = new Setting<>(100L); /** * The alternative timeout number when slowPath is on */ - public Setting slowPathTimeoutMS = new Setting<>(40000L); + public final Setting slowPathTimeoutMS = new Setting<>(40000L); /** * The big one. Download all chunks in simplified 2-bit format and save them for better very-long-distance pathing. */ - public Setting chunkCaching = new Setting<>(true); + public final Setting chunkCaching = new Setting<>(true); /** * On save, delete from RAM any cached regions that are more than 1024 blocks away from the player *

* Temporarily disabled, see issue #248 */ - public Setting pruneRegionsFromRAM = new Setting<>(false); + public final Setting pruneRegionsFromRAM = new Setting<>(false); /** * Print all the debug messages to chat */ - public Setting chatDebug = new Setting<>(true); + public final Setting chatDebug = new Setting<>(true); /** * Allow chat based control of Baritone. Most likely should be disabled when Baritone is imported for use in * something else */ - public Setting chatControl = new Setting<>(true); + public final Setting chatControl = new Setting<>(true); /** * A second override over chatControl to force it on */ - public Setting removePrefix = new Setting<>(false); + public final Setting removePrefix = new Setting<>(false); /** * Render the path */ - public Setting renderPath = new Setting<>(true); + public final Setting renderPath = new Setting<>(true); /** * Render the goal */ - public Setting renderGoal = new Setting<>(true); + public final Setting renderGoal = new Setting<>(true); /** * Ignore depth when rendering the goal */ - public Setting renderGoalIgnoreDepth = new Setting<>(true); + public final Setting renderGoalIgnoreDepth = new Setting<>(true); /** * Renders X/Z type Goals with the vanilla beacon beam effect. Combining this with * {@link #renderGoalIgnoreDepth} will cause strange render clipping. */ - public Setting renderGoalXZBeacon = new Setting<>(false); + public final Setting renderGoalXZBeacon = new Setting<>(false); /** * Ignore depth when rendering the selection boxes (to break, to place, to walk into) */ - public Setting renderSelectionBoxesIgnoreDepth = new Setting<>(true); + public final Setting renderSelectionBoxesIgnoreDepth = new Setting<>(true); /** * Ignore depth when rendering the path */ - public Setting renderPathIgnoreDepth = new Setting<>(true); + public final Setting renderPathIgnoreDepth = new Setting<>(true); /** * Line width of the path when rendered, in pixels */ - public Setting pathRenderLineWidthPixels = new Setting<>(5F); + public final Setting pathRenderLineWidthPixels = new Setting<>(5F); /** * Line width of the goal when rendered, in pixels */ - public Setting goalRenderLineWidthPixels = new Setting<>(3F); + public final Setting goalRenderLineWidthPixels = new Setting<>(3F); /** * Start fading out the path at 20 movements ahead, and stop rendering it entirely 30 movements ahead. * Improves FPS. */ - public Setting fadePath = new Setting<>(false); + public final Setting fadePath = new Setting<>(false); /** * Move without having to force the client-sided rotations */ - public Setting freeLook = new Setting<>(true); + public final Setting freeLook = new Setting<>(true); /** * Will cause some minor behavioral differences to ensure that Baritone works on anticheats. @@ -438,43 +438,43 @@ public class Settings { * At the moment this will silently set the player's rotations when using freeLook so you're not sprinting in * directions other than forward, which is picken up by more "advanced" anticheats like AAC, but not NCP. */ - public Setting antiCheatCompatibility = new Setting<>(true); + public final Setting antiCheatCompatibility = new Setting<>(true); /** * Exclusively use cached chunks for pathing */ - public Setting pathThroughCachedOnly = new Setting<>(false); + public final Setting pathThroughCachedOnly = new Setting<>(false); /** * Whether or not to use the "#" command prefix */ - public Setting prefix = new Setting<>(false); + public final Setting prefix = new Setting<>(false); /** * Don't stop walking forward when you need to break blocks in your way */ - public Setting walkWhileBreaking = new Setting<>(true); + public final Setting walkWhileBreaking = new Setting<>(true); /** * If we are more than 500 movements into the current path, discard the oldest segments, as they are no longer useful */ - public Setting maxPathHistoryLength = new Setting<>(300); + public final Setting maxPathHistoryLength = new Setting<>(300); /** * If the current path is too long, cut off this many movements from the beginning. */ - public Setting pathHistoryCutoffAmount = new Setting<>(50); + public final Setting pathHistoryCutoffAmount = new Setting<>(50); /** * Rescan for the goal once every 5 ticks. * Set to 0 to disable. */ - public Setting mineGoalUpdateInterval = new Setting<>(5); + public final Setting mineGoalUpdateInterval = new Setting<>(5); /** * While mining, should it also consider dropped items of the correct type as a pathing destination (as well as ore blocks)? */ - public Setting mineScanDroppedItems = new Setting<>(true); + public final Setting mineScanDroppedItems = new Setting<>(true); /** * Cancel the current path if the goal has changed, and the path originally ended in the goal but doesn't anymore. @@ -489,54 +489,54 @@ public class Settings { *

* Also on cosmic prisons this should be set to true since you don't actually mine the ore it just gets replaced with stone. */ - public Setting cancelOnGoalInvalidation = new Setting<>(true); + public final Setting cancelOnGoalInvalidation = new Setting<>(true); /** * The "axis" command (aka GoalAxis) will go to a axis, or diagonal axis, at this Y level. */ - public Setting axisHeight = new Setting<>(120); + public final Setting axisHeight = new Setting<>(120); /** * Allow MineBehavior to use X-Ray to see where the ores are. Turn this option off to force it to mine "legit" * where it will only mine an ore once it can actually see it, so it won't do or know anything that a normal player * couldn't. If you don't want it to look like you're X-Raying, turn this off */ - public Setting legitMine = new Setting<>(false); + public final Setting legitMine = new Setting<>(false); /** * What Y level to go to for legit strip mining */ - public Setting legitMineYLevel = new Setting<>(11); + public final Setting legitMineYLevel = new Setting<>(11); /** * When mining block of a certain type, try to mine two at once instead of one. * If the block above is also a goal block, set GoalBlock instead of GoalTwoBlocks * If the block below is also a goal block, set GoalBlock to the position one down instead of GoalTwoBlocks */ - public Setting forceInternalMining = new Setting<>(true); + public final Setting forceInternalMining = new Setting<>(true); /** * Modification to the previous setting, only has effect if forceInternalMining is true * If true, only apply the previous setting if the block adjacent to the goal isn't air. */ - public Setting internalMiningAirException = new Setting<>(true); + public final Setting internalMiningAirException = new Setting<>(true); /** * The actual GoalNear is set this distance away from the entity you're following *

* For example, set followOffsetDistance to 5 and followRadius to 0 to always stay precisely 5 blocks north of your follow target. */ - public Setting followOffsetDistance = new Setting<>(0D); + public final Setting followOffsetDistance = new Setting<>(0D); /** * The actual GoalNear is set in this direction from the entity you're following. This value is in degrees. */ - public Setting followOffsetDirection = new Setting<>(0F); + public final Setting followOffsetDirection = new Setting<>(0F); /** * The radius (for the GoalNear) of how close to your target position you actually have to be */ - public Setting followRadius = new Setting<>(3); + public final Setting followRadius = new Setting<>(3); /** * Cached chunks (regardless of if they're in RAM or saved to disk) expire and are deleted after this number of seconds @@ -558,54 +558,54 @@ public class Settings { * has to build up that cache from scratch. But after it's gone through an area just once, the next time will have zero * backtracking, since the entire area is now known and cached. */ - public Setting cachedChunksExpirySeconds = new Setting<>(-1L); + public final Setting cachedChunksExpirySeconds = new Setting<>(-1L); /** * The function that is called when Baritone will log to chat. This function can be added to * via {@link Consumer#andThen(Consumer)} or it can completely be overriden via setting * {@link Setting#value}; */ - public Setting> logger = new Setting<>(Minecraft.getMinecraft().ingameGUI.getChatGUI()::printChatMessage); + public final Setting> logger = new Setting<>(Minecraft.getMinecraft().ingameGUI.getChatGUI()::printChatMessage); /** * The color of the current path */ - public Setting colorCurrentPath = new Setting<>(Color.RED); + public final Setting colorCurrentPath = new Setting<>(Color.RED); /** * The color of the next path */ - public Setting colorNextPath = new Setting<>(Color.MAGENTA); + public final Setting colorNextPath = new Setting<>(Color.MAGENTA); /** * The color of the blocks to break */ - public Setting colorBlocksToBreak = new Setting<>(Color.RED); + public final Setting colorBlocksToBreak = new Setting<>(Color.RED); /** * The color of the blocks to place */ - public Setting colorBlocksToPlace = new Setting<>(Color.GREEN); + public final Setting colorBlocksToPlace = new Setting<>(Color.GREEN); /** * The color of the blocks to walk into */ - public Setting colorBlocksToWalkInto = new Setting<>(Color.MAGENTA); + public final Setting colorBlocksToWalkInto = new Setting<>(Color.MAGENTA); /** * The color of the best path so far */ - public Setting colorBestPathSoFar = new Setting<>(Color.BLUE); + public final Setting colorBestPathSoFar = new Setting<>(Color.BLUE); /** * The color of the path to the most recent considered node */ - public Setting colorMostRecentConsidered = new Setting<>(Color.CYAN); + public final Setting colorMostRecentConsidered = new Setting<>(Color.CYAN); /** * The color of the goal box */ - public Setting colorGoalBox = new Setting<>(Color.GREEN); + public final Setting colorGoalBox = new Setting<>(Color.GREEN); /** * A map of lowercase setting field names to their respective setting From b4a622d3196b6f8f5afecdda677e8af9a0e9124c Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 28 Jan 2019 10:59:08 -0800 Subject: [PATCH 33/42] editing settings --- README.md | 2 +- src/api/java/baritone/api/Settings.java | 33 ++++++++++++++++++------- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 555c2c07..224281c7 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ Quick start example: `thisway 1000` or `goal 70` to set the goal, `path` to actu ``` BaritoneAPI.getSettings().allowSprint.value = true; -BaritoneAPI.getSettings().pathTimeoutMS.value = 2000L; +BaritoneAPI.getSettings().primaryTimeoutMS.value = 2000L; BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAndPath(new GoalXZ(10000, 20000)); ``` diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index a069d76b..14cf6814 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -69,7 +69,7 @@ public final class Settings { public final Setting blockBreakAdditionalPenalty = new Setting<>(2D); /** - * Additional penalty for hitting the space bar (ascend, pillar, or parkour) beacuse it uses hunger + * Additional penalty for hitting the space bar (ascend, pillar, or parkour) because it uses hunger */ public final Setting jumpPenalty = new Setting<>(2D); @@ -107,7 +107,7 @@ public final class Settings { /** * If true, parkour is allowed to make jumps when standing on blocks at the maximum height, so player feet is y=256 *

- * Defaults to false because this fails on NCP + * Defaults to false because this fails on constantiam */ public final Setting allowJumpAt256 = new Setting<>(false); @@ -132,6 +132,8 @@ public final class Settings { /** * Enables some more advanced vine features. They're honestly just gimmicks and won't ever be needed in real * pathing scenarios. And they can cause Baritone to get trapped indefinitely in a strange scenario. + *

+ * Never turn this on lol */ public final Setting allowVines = new Setting<>(false); @@ -145,11 +147,15 @@ public final class Settings { * You know what it is *

* But it's very unreliable and falls off when cornering like all the time so. + *

+ * It also overshoots the landing pretty much always (making contact with the next block over), so be careful */ public final Setting allowParkour = new Setting<>(false); /** - * Like parkour, but even more unreliable! + * Actually pretty reliable. + *

+ * Doesn't make it any more dangerous compared to just normal allowParkour th */ public final Setting allowParkourPlace = new Setting<>(false); @@ -192,9 +198,13 @@ public final class Settings { /** * Toggle the following 4 settings *

- * They have a noticable performance impact, so they default off + * They have a noticeable performance impact, so they default off + *

+ * Specifically, building up the avoidance map on the main thread before pathing starts actually takes a noticeable + * amount of time, especially when there are a lot of mobs around, and your game jitters for like 200ms while doing so */ public final Setting avoidance = new Setting<>(false); + /** * Set to 1.0 to effectively disable this feature *

@@ -234,8 +244,10 @@ public final class Settings { /** * After calculating a path (potentially through cached chunks), artificially cut it off to just the part that is * entirely within currently loaded chunks. Improves path safety because cached chunks are heavily simplified. + *

+ * This is much safer to leave off now, and makes pathing more efficient. More explanation in the issue. * - * @see Issue #144 + * @see Issue #114 */ public final Setting cutoffAtLoadBoundary = new Setting<>(false); @@ -360,7 +372,9 @@ public final class Settings { /** * On save, delete from RAM any cached regions that are more than 1024 blocks away from the player *

- * Temporarily disabled, see issue #248 + * Temporarily disabled + * + * @see Issue #248 */ public final Setting pruneRegionsFromRAM = new Setting<>(false); @@ -456,7 +470,7 @@ public final class Settings { public final Setting walkWhileBreaking = new Setting<>(true); /** - * If we are more than 500 movements into the current path, discard the oldest segments, as they are no longer useful + * If we are more than 300 movements into the current path, discard the oldest segments, as they are no longer useful */ public final Setting maxPathHistoryLength = new Setting<>(300); @@ -497,9 +511,9 @@ public final class Settings { public final Setting axisHeight = new Setting<>(120); /** - * Allow MineBehavior to use X-Ray to see where the ores are. Turn this option off to force it to mine "legit" + * Disallow MineBehavior from using X-Ray to see where the ores are. Turn this option on to force it to mine "legit" * where it will only mine an ore once it can actually see it, so it won't do or know anything that a normal player - * couldn't. If you don't want it to look like you're X-Raying, turn this off + * couldn't. If you don't want it to look like you're X-Raying, turn this on */ public final Setting legitMine = new Setting<>(false); @@ -607,6 +621,7 @@ public final class Settings { */ public final Setting colorGoalBox = new Setting<>(Color.GREEN); + /** * A map of lowercase setting field names to their respective setting */ From 742256c1301922b3181a9c5346b7dde161800169 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 28 Jan 2019 11:30:33 -0800 Subject: [PATCH 34/42] more fun javadocs --- build.gradle | 4 ++-- src/main/java/baritone/utils/ToolSet.java | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 99a17a3b..ea265016 100755 --- a/build.gradle +++ b/build.gradle @@ -99,8 +99,8 @@ mixin { } javadoc { - source = sourceSets.api.allJava - classpath = sourceSets.api.compileClasspath + source += sourceSets.api.allJava + classpath += sourceSets.api.compileClasspath } jar { diff --git a/src/main/java/baritone/utils/ToolSet.java b/src/main/java/baritone/utils/ToolSet.java index fa71a6b0..bfa4e251 100644 --- a/src/main/java/baritone/utils/ToolSet.java +++ b/src/main/java/baritone/utils/ToolSet.java @@ -135,6 +135,7 @@ public class ToolSet { * Calculates how long would it take to mine the specified block given the best tool * in this toolset is used. A negative value is returned if the specified block is unbreakable. * + * @param item the item to mine it with * @param state the blockstate to be mined * @return how long it would take in ticks */ From f5f2e4970ef0fb9cf3d53bb15c2eb7f12e713581 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 28 Jan 2019 11:37:02 -0800 Subject: [PATCH 35/42] make travis fail when javadoc doesn't compile --- .travis.yml | 1 + src/main/java/baritone/utils/ToolSet.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a8344ba0..88fa7cf5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,7 @@ install: - travis_retry docker build -t cabaletta/baritone . script: +- docker run cabaletta/baritone ./gradlew javadoc - docker run --name baritone cabaletta/baritone /bin/sh -c "set -e; /sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -screen 0 128x128x24 -ac +extension GLX +render; DISPLAY=:99 BARITONE_AUTO_TEST=true ./gradlew runClient" - docker cp baritone:/code/dist dist - ls dist diff --git a/src/main/java/baritone/utils/ToolSet.java b/src/main/java/baritone/utils/ToolSet.java index bfa4e251..a05d838d 100644 --- a/src/main/java/baritone/utils/ToolSet.java +++ b/src/main/java/baritone/utils/ToolSet.java @@ -137,7 +137,7 @@ public class ToolSet { * * @param item the item to mine it with * @param state the blockstate to be mined - * @return how long it would take in ticks + * @rturn how long it would take in ticks */ public static double calculateSpeedVsBlock(ItemStack item, IBlockState state) { float hardness = state.getBlockHardness(null, null); From 96360ddb24eaa63a8524e9886448e72736cc29c4 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 28 Jan 2019 11:49:52 -0800 Subject: [PATCH 36/42] perhaps --- build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/build.gradle b/build.gradle index ea265016..5c711493 100755 --- a/build.gradle +++ b/build.gradle @@ -99,6 +99,7 @@ mixin { } javadoc { + options.addStringOption('Xwerror', '-quiet') source += sourceSets.api.allJava classpath += sourceSets.api.compileClasspath } From 177f5de2bdab38cbb8a7b07f0f150c166a982995 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 28 Jan 2019 11:56:44 -0800 Subject: [PATCH 37/42] yay travis checks javadocs now --- build.gradle | 2 +- src/main/java/baritone/utils/ToolSet.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 5c711493..c291b950 100755 --- a/build.gradle +++ b/build.gradle @@ -99,7 +99,7 @@ mixin { } javadoc { - options.addStringOption('Xwerror', '-quiet') + options.addStringOption('Xwerror', '-quiet') // makes the build fail on travis when there is a javadoc error source += sourceSets.api.allJava classpath += sourceSets.api.compileClasspath } diff --git a/src/main/java/baritone/utils/ToolSet.java b/src/main/java/baritone/utils/ToolSet.java index a05d838d..bfa4e251 100644 --- a/src/main/java/baritone/utils/ToolSet.java +++ b/src/main/java/baritone/utils/ToolSet.java @@ -137,7 +137,7 @@ public class ToolSet { * * @param item the item to mine it with * @param state the blockstate to be mined - * @rturn how long it would take in ticks + * @return how long it would take in ticks */ public static double calculateSpeedVsBlock(ItemStack item, IBlockState state) { float hardness = state.getBlockHardness(null, null); From 49148dfb7a869a0413f8e0c8f70c33a78934c542 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 28 Jan 2019 11:57:58 -0800 Subject: [PATCH 38/42] add javadocs link --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 224281c7..7782651a 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,8 @@ Here are some links to help to get started: - [Installation](INSTALL.md) +- [Javadocs](https://baritone.leijurv.com/) + # Chat control [Defined Here](src/main/java/baritone/utils/ExampleBaritoneControl.java) From c15f1e8276ee4e119fe31d55c1993477ff4717b4 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 28 Jan 2019 12:06:26 -0800 Subject: [PATCH 39/42] link source is cool --- build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/build.gradle b/build.gradle index c291b950..8583642d 100755 --- a/build.gradle +++ b/build.gradle @@ -100,6 +100,7 @@ mixin { javadoc { options.addStringOption('Xwerror', '-quiet') // makes the build fail on travis when there is a javadoc error + options.linkSource true source += sourceSets.api.allJava classpath += sourceSets.api.compileClasspath } From a87772c98c41478e502e5aac118b11f6b6b65626 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 28 Jan 2019 12:16:45 -0800 Subject: [PATCH 40/42] remove that image once done --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 88fa7cf5..371639be 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ install: - travis_retry docker build -t cabaletta/baritone . script: -- docker run cabaletta/baritone ./gradlew javadoc +- docker run --rm cabaletta/baritone ./gradlew javadoc - docker run --name baritone cabaletta/baritone /bin/sh -c "set -e; /sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -screen 0 128x128x24 -ac +extension GLX +render; DISPLAY=:99 BARITONE_AUTO_TEST=true ./gradlew runClient" - docker cp baritone:/code/dist dist - ls dist From 840b7e6987185f17c69439d8ce3db3557ab1efdf Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 28 Jan 2019 15:59:53 -0800 Subject: [PATCH 41/42] misc fixes #315 --- .../baritone/pathing/movement/Movement.java | 2 +- .../movement/movements/MovementDescend.java | 17 +++++---- .../movement/movements/MovementFall.java | 10 +++--- .../baritone/pathing/path/PathExecutor.java | 35 +++++++++++-------- 4 files changed, 36 insertions(+), 28 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/Movement.java b/src/main/java/baritone/pathing/movement/Movement.java index ce78c231..4599637a 100644 --- a/src/main/java/baritone/pathing/movement/Movement.java +++ b/src/main/java/baritone/pathing/movement/Movement.java @@ -123,7 +123,7 @@ public abstract class Movement implements IMovement, MovementHelper { baritone.getLookBehavior().updateTarget( rotation, currentState.getTarget().hasToForceRotations())); - + baritone.getInputOverrideHandler().clearAllKeys(); currentState.getInputStates().forEach((input, forced) -> { baritone.getInputOverrideHandler().setInputForceState(input, forced); }); diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java index d2d2c282..d54ffc51 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java @@ -177,13 +177,6 @@ public class MovementDescend extends Movement { if (MovementHelper.isBottomSlab(ontoBlock)) { return false; // falling onto a half slab is really glitchy, and can cause more fall damage than we'd expect } - if (context.hasWaterBucket && unprotectedFallHeight <= context.maxFallHeightBucket + 1) { - res.x = destX; - res.y = newY + 1;// this is the block we're falling onto, so dest is +1 - res.z = destZ; - res.cost = tentativeCost + context.placeBlockCost; - return true; - } if (unprotectedFallHeight <= context.maxFallHeightNoWater + 1) { // fallHeight = 4 means onto.up() is 3 blocks down, which is the max res.x = destX; @@ -191,6 +184,13 @@ public class MovementDescend extends Movement { res.z = destZ; res.cost = tentativeCost; return false; + } + if (context.hasWaterBucket && unprotectedFallHeight <= context.maxFallHeightBucket + 1) { + res.x = destX; + res.y = newY + 1;// this is the block we're falling onto, so dest is +1 + res.z = destZ; + res.cost = tentativeCost + context.placeBlockCost; + return true; } else { return false; } @@ -235,8 +235,7 @@ public class MovementDescend extends Movement { if (numTicks++ < 20) { MovementHelper.moveTowards(ctx, state, fakeDest); if (fromStart > 1.25) { - state.setInput(Input.MOVE_FORWARD, false); - state.setInput(Input.MOVE_BACK, true); + state.getTarget().rotation = new Rotation(state.getTarget().rotation.getYaw() + 180F, state.getTarget().rotation.getPitch()); } } else { MovementHelper.moveTowards(ctx, state, dest); diff --git a/src/main/java/baritone/pathing/movement/movements/MovementFall.java b/src/main/java/baritone/pathing/movement/movements/MovementFall.java index 6442d7d9..a82ad110 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementFall.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementFall.java @@ -30,6 +30,7 @@ import baritone.pathing.movement.MovementHelper; import baritone.pathing.movement.MovementState; import baritone.pathing.movement.MovementState.MovementTarget; import baritone.utils.pathing.MutableMoveResult; +import net.minecraft.block.Block; import net.minecraft.block.BlockLadder; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.InventoryPlayer; @@ -79,7 +80,8 @@ public class MovementFall extends Movement { BlockPos playerFeet = ctx.playerFeet(); Rotation toDest = RotationUtils.calcRotationFromVec3d(ctx.playerHead(), VecUtils.getBlockPosCenter(dest)); Rotation targetRotation = null; - if (!MovementHelper.isWater(ctx, dest) && willPlaceBucket() && !playerFeet.equals(dest)) { + Block destBlock = ctx.world().getBlockState(dest).getBlock(); + if (destBlock != Blocks.WATER && destBlock != Blocks.FLOWING_WATER && willPlaceBucket() && !playerFeet.equals(dest)) { if (!InventoryPlayer.isHotbar(ctx.player().inventory.getSlotFor(STACK_BUCKET_WATER)) || ctx.world().provider.isNether()) { return state.setStatus(MovementStatus.UNREACHABLE); } @@ -100,8 +102,8 @@ public class MovementFall extends Movement { } else { state.setTarget(new MovementTarget(toDest, false)); } - if (playerFeet.equals(dest) && (ctx.player().posY - playerFeet.getY() < 0.094 || MovementHelper.isWater(ctx, dest))) { // 0.094 because lilypads - if (MovementHelper.isWater(ctx, dest)) { + if (playerFeet.equals(dest) && (ctx.player().posY - playerFeet.getY() < 0.094 || destBlock == Blocks.WATER)) { // 0.094 because lilypads + if (destBlock == Blocks.WATER) { // only match water, not flowing water (which we cannot pick up with a bucket) if (InventoryPlayer.isHotbar(ctx.player().inventory.getSlotFor(STACK_BUCKET_EMPTY))) { ctx.player().inventory.currentItem = ctx.player().inventory.getSlotFor(STACK_BUCKET_EMPTY); if (ctx.player().motionY >= 0) { @@ -132,7 +134,7 @@ public class MovementFall extends Movement { double dist = Math.abs(avoid.getX() * (destCenter.x - avoid.getX() / 2.0 - ctx.player().posX)) + Math.abs(avoid.getZ() * (destCenter.z - avoid.getZ() / 2.0 - ctx.player().posZ)); if (dist < 0.6) { state.setInput(Input.MOVE_FORWARD, true); - } else { + } else if (!ctx.player().onGround) { state.setInput(Input.SNEAK, false); } } diff --git a/src/main/java/baritone/pathing/path/PathExecutor.java b/src/main/java/baritone/pathing/path/PathExecutor.java index ef856f42..b5b621e8 100644 --- a/src/main/java/baritone/pathing/path/PathExecutor.java +++ b/src/main/java/baritone/pathing/path/PathExecutor.java @@ -272,6 +272,9 @@ public class PathExecutor implements IPathExecutor, Helper { return true; } else { sprintNextTick = shouldSprintNextTick(); + if (!sprintNextTick) { + ctx.player().setSprinting(false); // letting go of control doesn't make you stop sprinting actually + } ticksOnCurrent++; if (ticksOnCurrent > currentMovementOriginalCostEstimate + Baritone.settings().movementTimeoutTicks.get()) { // only cancel if the total time has exceeded the initial estimate @@ -391,29 +394,33 @@ public class PathExecutor implements IPathExecutor, Helper { // however, descend doesn't request sprinting, beceause it doesn't know the context of what movement comes after it IMovement current = path.movements().get(pathPosition); - if (current instanceof MovementDescend && pathPosition < path.length() - 2) { + if (current instanceof MovementDescend) { if (((MovementDescend) current).safeMode()) { logDebug("Sprinting would be unsafe"); return false; } - IMovement next = path.movements().get(pathPosition + 1); - if (next instanceof MovementAscend && current.getDirection().up().equals(next.getDirection().down())) { - // a descend then an ascend in the same direction - pathPosition++; - // okay to skip clearKeys and / or onChangeInPathPosition here since this isn't possible to repeat, since it's asymmetric - logDebug("Skipping descend to straight ascend"); - return true; - } - if (canSprintInto(ctx, current, next)) { - if (ctx.playerFeet().equals(current.getDest())) { + if (pathPosition < path.length() - 2) { + IMovement next = path.movements().get(pathPosition + 1); + if (next instanceof MovementAscend && current.getDirection().up().equals(next.getDirection().down())) { + // a descend then an ascend in the same direction pathPosition++; - onChangeInPathPosition(); + // okay to skip clearKeys and / or onChangeInPathPosition here since this isn't possible to repeat, since it's asymmetric + logDebug("Skipping descend to straight ascend"); + return true; } - return true; + if (canSprintInto(ctx, current, next)) { + if (ctx.playerFeet().equals(current.getDest())) { + pathPosition++; + onChangeInPathPosition(); + logDirect("skip lol"); + onTick(); + } + return true; + } + //logDebug("Turning off sprinting " + movement + " " + next + " " + movement.getDirection() + " " + next.getDirection().down() + " " + next.getDirection().down().equals(movement.getDirection())); } - //logDebug("Turning off sprinting " + movement + " " + next + " " + movement.getDirection() + " " + next.getDirection().down() + " " + next.getDirection().down().equals(movement.getDirection())); } if (current instanceof MovementAscend && pathPosition != 0) { IMovement prev = path.movements().get(pathPosition - 1); From 056742479e517d4a85ce2de5aa3f146cda8c9a77 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 28 Jan 2019 16:06:34 -0800 Subject: [PATCH 42/42] except without that --- src/main/java/baritone/pathing/path/PathExecutor.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/baritone/pathing/path/PathExecutor.java b/src/main/java/baritone/pathing/path/PathExecutor.java index b5b621e8..6f161cc0 100644 --- a/src/main/java/baritone/pathing/path/PathExecutor.java +++ b/src/main/java/baritone/pathing/path/PathExecutor.java @@ -414,7 +414,6 @@ public class PathExecutor implements IPathExecutor, Helper { if (ctx.playerFeet().equals(current.getDest())) { pathPosition++; onChangeInPathPosition(); - logDirect("skip lol"); onTick(); } return true;