Skip to content

Commit 68dc110

Browse files
committed
fix #elytra reset bypassing y checks
1 parent 20c1631 commit 68dc110

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

src/main/java/baritone/command/defaults/ElytraCommand.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,11 @@ public void execute(String label, IArgConsumer args) throws CommandException {
8282
final String action = args.getString();
8383
switch (action) {
8484
case "reset": {
85-
elytra.resetState();
85+
try {
86+
elytra.resetState();
87+
} catch (IllegalArgumentException ex) {
88+
throw new CommandInvalidStateException(ex.getMessage());
89+
}
8690
logDirect("Reset state but still flying to same goal");
8791
break;
8892
}

src/main/java/baritone/process/ElytraProcess.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,17 @@ public BlockPos currentDestination() {
331331

332332
@Override
333333
public void pathTo(BlockPos destination) {
334+
int minY = ctx.world().dimensionType().minY();
335+
int maxY = (ctx.world().dimension() == Level.NETHER && !Baritone.settings().elytraAllowAboveRoof.value) ? 127 : Math.min(minY + 384, ctx.world().dimensionType().height() + minY);
336+
if (destination.getY() < minY || destination.getY() >= maxY) {
337+
throw new IllegalArgumentException("The goal must have a y value between " + minY + " and " + maxY);
338+
}
339+
340+
int playerY = (int)ctx.player().getY();
341+
if (playerY < minY || playerY >= maxY) {
342+
throw new IllegalArgumentException("The player must have a y value between " + minY + " and " + maxY);
343+
}
344+
334345
this.pathTo0(destination, false);
335346
}
336347

@@ -368,17 +379,6 @@ public void pathTo(Goal iGoal) {
368379
throw new IllegalArgumentException("The goal must be a GoalXZ or GoalBlock");
369380
}
370381

371-
int minY = ctx.world().dimensionType().minY();
372-
int maxY = (ctx.world().dimension() == Level.NETHER && !Baritone.settings().elytraAllowAboveRoof.value) ? 127 : Math.min(minY + 384, ctx.world().dimensionType().height() + minY);
373-
if (y < minY || y >= maxY) {
374-
throw new IllegalArgumentException("The goal must have a y value between " + minY + " and " + maxY);
375-
}
376-
377-
int playerY = (int)ctx.player().getY();
378-
if (playerY < minY || playerY >= maxY) {
379-
throw new IllegalArgumentException("The player must have a y value between " + minY + " and " + maxY);
380-
}
381-
382382
this.pathTo(new BlockPos(x, y, z));
383383
}
384384

0 commit comments

Comments
 (0)