diff --git a/docs/wiki/Commands.md b/docs/wiki/Commands.md index d3cad1dbc..5b13e37b8 100644 --- a/docs/wiki/Commands.md +++ b/docs/wiki/Commands.md @@ -1992,6 +1992,22 @@ Baritone pathfinder ```pathfinder elytra ``` + ```pathfinder elytra autoSwap on/off``` + + ```pathfinder elytra minimumDurability ``` + + ```pathfinder elytra minFireworksBeforeLanding ``` + + ```pathfinder elytra allowEmergencyLand on/off``` + + ```pathfinder elytra conserveFireworks on/off``` + + ```pathfinder elytra fireworkSpeed ``` + + ```pathfinder elytra autoJump on/off``` + + ```pathfinder elytra verboseLogging on/off``` + ```pathfinder stop``` ```pathfinder follow``` diff --git a/src/main/java/com/zenith/command/impl/PathfinderCommand.java b/src/main/java/com/zenith/command/impl/PathfinderCommand.java index 244d44677..2f2c0bf70 100644 --- a/src/main/java/com/zenith/command/impl/PathfinderCommand.java +++ b/src/main/java/com/zenith/command/impl/PathfinderCommand.java @@ -61,6 +61,14 @@ public CommandUsage commandUsage() { "goto ", "elytra ", "elytra ", + "elytra autoSwap on/off", + "elytra minimumDurability ", + "elytra minFireworksBeforeLanding ", + "elytra allowEmergencyLand on/off", + "elytra conserveFireworks on/off", + "elytra fireworkSpeed ", + "elytra autoJump on/off", + "elytra verboseLogging on/off", "stop", "follow", "follow ", @@ -198,7 +206,63 @@ public LiteralArgumentBuilder register() { : "Coords disabled") .primaryColor(); return OK; + })) + .then(literal("autoSwap").then(argument("toggle", toggle()).executes(c -> { + CONFIG.client.extra.pathfinder.elytra.autoSwap = getToggle(c, "toggle"); + c.getSource().getEmbed() + .title("Pathfinder") + .addField("Elytra Auto Swap", CONFIG.client.extra.pathfinder.elytra.autoSwap) + .primaryColor(); + }))) + .then(literal("minimumDurability").then(argument("durability", integer(0, 432)).executes(c -> { + CONFIG.client.extra.pathfinder.elytra.minimumDurability = getInteger(c, "durability"); + c.getSource().getEmbed() + .title("Pathfinder") + .addField("Elytra Minimum Durability", CONFIG.client.extra.pathfinder.elytra.minimumDurability) + .primaryColor(); + }))) + .then(literal("minFireworksBeforeLanding").then(argument("count", integer(0)).executes(c -> { + CONFIG.client.extra.pathfinder.elytra.minFireworksBeforeLanding = getInteger(c, "count"); + c.getSource().getEmbed() + .title("Pathfinder") + .addField("Elytra Min Fireworks Before Landing", CONFIG.client.extra.pathfinder.elytra.minFireworksBeforeLanding) + .primaryColor(); + }))) + .then(literal("allowEmergencyLand").then(argument("toggle", toggle()).executes(c -> { + CONFIG.client.extra.pathfinder.elytra.allowEmergencyLand = getToggle(c, "toggle"); + c.getSource().getEmbed() + .title("Pathfinder") + .addField("Elytra Allow Emergency Land", CONFIG.client.extra.pathfinder.elytra.allowEmergencyLand) + .primaryColor(); }))) + .then(literal("conserveFireworks").then(argument("toggle", toggle()).executes(c -> { + CONFIG.client.extra.pathfinder.elytra.conserveFireworks = getToggle(c, "toggle"); + c.getSource().getEmbed() + .title("Pathfinder") + .addField("Elytra Conserve Fireworks", CONFIG.client.extra.pathfinder.elytra.conserveFireworks) + .primaryColor(); + }))) + .then(literal("fireworkSpeed").then(argument("speed", doubleArg(0.0, 10.0)).executes(c -> { + CONFIG.client.extra.pathfinder.elytra.fireworkSpeed = getDouble(c, "speed"); + c.getSource().getEmbed() + .title("Pathfinder") + .addField("Elytra Firework Speed", CONFIG.client.extra.pathfinder.elytra.fireworkSpeed) + .primaryColor(); + }))) + .then(literal("autoJump").then(argument("toggle", toggle()).executes(c -> { + CONFIG.client.extra.pathfinder.elytra.autoJump = getToggle(c, "toggle"); + c.getSource().getEmbed() + .title("Pathfinder") + .addField("Elytra Auto Jump", CONFIG.client.extra.pathfinder.elytra.autoJump) + .primaryColor(); + }))) + .then(literal("verboseLogging").then(argument("toggle", toggle()).executes(c -> { + CONFIG.client.extra.pathfinder.elytra.verboseLogging = getToggle(c, "toggle"); + c.getSource().getEmbed() + .title("Pathfinder") + .addField("Elytra Verbose Logging", CONFIG.client.extra.pathfinder.elytra.verboseLogging) + .primaryColor(); + })))) .then(literal("stop").executes(c -> { BARITONE.stop(); c.getSource().getEmbed() @@ -1134,6 +1198,14 @@ private Map getSettingsMap() { settingsMap.put("placeBlockVerifyAbleToPlace", toggleStr(CONFIG.client.extra.pathfinder.placeBlockVerifyAbleToPlace)); settingsMap.put("placeBlockSneak", toggleStr(CONFIG.client.extra.pathfinder.placeBlockSneak)); settingsMap.put("mineProcessExitLavaGoal", toggleStr(CONFIG.client.extra.pathfinder.mineProcessExitLavaGoal)); + settingsMap.put("elytra autoSwap", toggleStr(CONFIG.client.extra.pathfinder.elytra.autoSwap)); + settingsMap.put("elytra minimumDurability", String.valueOf(CONFIG.client.extra.pathfinder.elytra.minimumDurability)); + settingsMap.put("elytra minFireworksBeforeLanding", String.valueOf(CONFIG.client.extra.pathfinder.elytra.minFireworksBeforeLanding)); + settingsMap.put("elytra allowEmergencyLand", toggleStr(CONFIG.client.extra.pathfinder.elytra.allowEmergencyLand)); + settingsMap.put("elytra conserveFireworks", toggleStr(CONFIG.client.extra.pathfinder.elytra.conserveFireworks)); + settingsMap.put("elytra fireworkSpeed", String.valueOf(CONFIG.client.extra.pathfinder.elytra.fireworkSpeed)); + settingsMap.put("elytra autoJump", toggleStr(CONFIG.client.extra.pathfinder.elytra.autoJump)); + settingsMap.put("elytra verboseLogging", toggleStr(CONFIG.client.extra.pathfinder.elytra.verboseLogging)); return settingsMap; } diff --git a/src/main/java/com/zenith/feature/pathfinder/process/ElytraProcess.java b/src/main/java/com/zenith/feature/pathfinder/process/ElytraProcess.java index d7e818129..bdac09ef2 100644 --- a/src/main/java/com/zenith/feature/pathfinder/process/ElytraProcess.java +++ b/src/main/java/com/zenith/feature/pathfinder/process/ElytraProcess.java @@ -24,6 +24,7 @@ import java.util.concurrent.TimeUnit; import static com.zenith.Globals.CACHE; +import static com.zenith.Globals.CONFIG; public class ElytraProcess extends BaritoneProcessHelper { public State state; @@ -96,11 +97,11 @@ public synchronized PathingCommand onTick(boolean calcFailed, boolean isSafeToCa boolean safetyLanding = false; if (ctx.player().isFallFlying() && shouldLandForSafety()) { - if (true /* Baritone.settings().elytraAllowEmergencyLand */) { + if (CONFIG.client.extra.pathfinder.elytra.allowEmergencyLand) { info("Emergency landing - almost out of elytra durability or fireworks"); safetyLanding = true; } else { - info("almost out of elytra durability or fireworks, but I'm going to continue since elytraAllowEmergencyLand is false"); + info("almost out of elytra durability or fireworks, but I'm going to continue since elytra allowEmergencyLand is off"); } } if (ctx.player().isFallFlying() && this.state != State.LANDING && (this.behavior.pathManager.isComplete() || safetyLanding)) { @@ -183,7 +184,7 @@ public synchronized PathingCommand onTick(boolean calcFailed, boolean isSafeToCa } if (this.state == State.FLYING || this.state == State.START_FLYING) { - this.state = ctx.player().isOnGround() && true /* Baritone.settings().elytraAutoJump */ + this.state = ctx.player().isOnGround() && CONFIG.client.extra.pathfinder.elytra.autoJump ? State.JUMP : State.START_FLYING; } @@ -409,7 +410,7 @@ private boolean isSupportedPos(BlockPos pos) { private boolean shouldLandForSafety() { var chest = CACHE.getPlayerCache().getEquipment(EquipmentSlot.CHESTPLATE); - if ((chest == null || chest.getId() != ItemRegistry.ELYTRA.id()) || ItemUtil.getDamageUntilBreak(chest) < 5 /* Baritone.settings().elytraMinimumDurability */) { + if ((chest == null || chest.getId() != ItemRegistry.ELYTRA.id()) || ItemUtil.getDamageUntilBreak(chest) < CONFIG.client.extra.pathfinder.elytra.minimumDurability) { // elytrabehavior replaces when durability <= minimumDurability, so if durability < minimumDurability then we can reasonably assume that the elytra will soon be broken without replacement return true; } @@ -421,7 +422,7 @@ private boolean shouldLandForSafety() { qty += inv.get(i).getAmount(); } } - if (qty <= 5 /* Baritone.settings().elytraMinFireworksBeforeLanding */) { + if (qty <= CONFIG.client.extra.pathfinder.elytra.minFireworksBeforeLanding) { return true; } return false; diff --git a/src/main/java/com/zenith/feature/pathfinder/process/elytra/ElytraBehavior.java b/src/main/java/com/zenith/feature/pathfinder/process/elytra/ElytraBehavior.java index 2726e9b4b..971c75c88 100644 --- a/src/main/java/com/zenith/feature/pathfinder/process/elytra/ElytraBehavior.java +++ b/src/main/java/com/zenith/feature/pathfinder/process/elytra/ElytraBehavior.java @@ -36,6 +36,7 @@ import java.util.function.UnaryOperator; import static com.zenith.Globals.CACHE; +import static com.zenith.Globals.CONFIG; import static com.zenith.Globals.INVENTORY; import static com.zenith.util.math.MathHelper.ceilI; import static com.zenith.util.math.MathHelper.floorI; @@ -704,7 +705,7 @@ private void tickUseFireworks(final Vector3d start, final Vector3d goingTo, fina if (this.landingMode) { return; } - final boolean useOnDescend = !false /* Baritone.settings().elytraConserveFireworks */ || ctx.playerFeetAsVec().getY() < goingTo.getY() + 5; + final boolean useOnDescend = !CONFIG.client.extra.pathfinder.elytra.conserveFireworks || ctx.playerFeetAsVec().getY() < goingTo.getY() + 5; final double currentSpeed = Vector3d.from( ctx.playerMotion().getX(), // ignore y component if we are BOTH below where we want to be AND descending @@ -712,7 +713,7 @@ private void tickUseFireworks(final Vector3d start, final Vector3d goingTo, fina ctx.playerMotion().getZ() ).lengthSquared(); - final double elytraFireworkSpeed = 1.2 /* Baritone.settings().elytraFireworkSpeed */; + final double elytraFireworkSpeed = CONFIG.client.extra.pathfinder.elytra.fireworkSpeed; if (this.remainingFireworkTicks <= 0 && (forceUseFirework || (!isBoosted && useOnDescend && (ctx.playerFeetAsVec().getY() < goingTo.getY() - 5 || start.distance(Vector3d.from(goingTo.getX() + 0.5, ctx.playerFeetAsVec().getY(), goingTo.getZ() + 0.5)) > 5) // UGH!!!!!!! @@ -1254,7 +1255,7 @@ private int findGoodElytra() { for (int i = 9; i < 45; i++) { var slot = invy.get(i); if (slot != null && slot.getId() == ItemRegistry.ELYTRA.id() - && ItemUtil.getDamageUntilBreak(slot) > 5 /* Baritone.settings().elytraMinimumDurability */) { + && ItemUtil.getDamageUntilBreak(slot) > CONFIG.client.extra.pathfinder.elytra.minimumDurability) { return i; } } @@ -1262,11 +1263,11 @@ private int findGoodElytra() { } private void trySwapElytra() { - if (!true /* Baritone.settings().elytraAutoSwap */ || inventoryRequest != null + if (!CONFIG.client.extra.pathfinder.elytra.autoSwap || inventoryRequest != null || CACHE.getPlayerCache().getInventoryCache().getOpenContainerId() != 0) return; var chest = CACHE.getPlayerCache().getEquipment(EquipmentSlot.CHESTPLATE); if (chest == null || chest.getId() != ItemRegistry.ELYTRA.id() - || ItemUtil.getDamageUntilBreak(chest) > 5 /* Baritone.settings().elytraMinimumDurability */) return; + || ItemUtil.getDamageUntilBreak(chest) > CONFIG.client.extra.pathfinder.elytra.minimumDurability) return; int goodElytraSlot = findGoodElytra(); if (goodElytraSlot != -1) { inventoryRequest = INVENTORY.submit(InventoryActionRequest.builder() @@ -1281,7 +1282,7 @@ private void trySwapElytra() { } void logVerbose(String message) { - if (false /* Baritone.settings().elytraChatSpam */) { + if (CONFIG.client.extra.pathfinder.elytra.verboseLogging) { debug(message); } } diff --git a/src/main/java/com/zenith/util/config/Config.java b/src/main/java/com/zenith/util/config/Config.java index b48216167..4fce7a97e 100644 --- a/src/main/java/com/zenith/util/config/Config.java +++ b/src/main/java/com/zenith/util/config/Config.java @@ -256,6 +256,18 @@ public static final class Pathfinder { public final Set allowBreakAnyway = new ObjectArraySet<>(); public final Set blocksToDisallowBreaking = new ObjectArraySet<>(); public final Set blocksToAvoid = new ObjectArraySet<>(); + public final Elytra elytra = new Elytra(); + + public static final class Elytra { + public boolean autoSwap = true; + public int minimumDurability = 5; + public int minFireworksBeforeLanding = 5; + public boolean allowEmergencyLand = true; + public boolean conserveFireworks = false; + public double fireworkSpeed = 1.2; + public boolean autoJump = true; + public boolean verboseLogging = false; + } } public static class SessionTimeLimit {