Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions docs/wiki/Commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -1992,6 +1992,22 @@ Baritone pathfinder

```pathfinder elytra <x> <y> <z>```

```pathfinder elytra autoSwap on/off```

```pathfinder elytra minimumDurability <durability>```

```pathfinder elytra minFireworksBeforeLanding <count>```

```pathfinder elytra allowEmergencyLand on/off```

```pathfinder elytra conserveFireworks on/off```

```pathfinder elytra fireworkSpeed <speed>```

```pathfinder elytra autoJump on/off```

```pathfinder elytra verboseLogging on/off```

```pathfinder stop```

```pathfinder follow```
Expand Down
72 changes: 72 additions & 0 deletions src/main/java/com/zenith/command/impl/PathfinderCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ public CommandUsage commandUsage() {
"goto <waypointId>",
"elytra <x> <z>",
"elytra <x> <y> <z>",
"elytra autoSwap on/off",
"elytra minimumDurability <durability>",
"elytra minFireworksBeforeLanding <count>",
"elytra allowEmergencyLand on/off",
"elytra conserveFireworks on/off",
"elytra fireworkSpeed <speed>",
"elytra autoJump on/off",
"elytra verboseLogging on/off",
"stop",
"follow",
"follow <playerName>",
Expand Down Expand Up @@ -198,7 +206,63 @@ public LiteralArgumentBuilder<CommandContext> 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()
Expand Down Expand Up @@ -1134,6 +1198,14 @@ private Map<String, String> 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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -704,15 +705,15 @@ 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
ctx.playerFeetAsVec().getY() < goingTo.getY() ? Math.max(0, ctx.playerMotion().getY()) : ctx.playerMotion().getY(),
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!!!!!!!
Expand Down Expand Up @@ -1254,19 +1255,19 @@ 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;
}
}
return -1;
}

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()
Expand All @@ -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);
}
}
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/com/zenith/util/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,18 @@ public static final class Pathfinder {
public final Set<String> allowBreakAnyway = new ObjectArraySet<>();
public final Set<String> blocksToDisallowBreaking = new ObjectArraySet<>();
public final Set<String> 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 {
Expand Down
Loading