mirror of https://github.com/cabaletta/baritone
Merge pull request #4063 from babbaj/elytra
make elytra play nice with CustomGoalProcess
This commit is contained in:
commit
684fda2d1b
|
@ -17,6 +17,7 @@
|
|||
|
||||
package baritone.api.process;
|
||||
|
||||
import baritone.api.pathing.goals.Goal;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public interface IElytraProcess extends IBaritoneProcess {
|
||||
|
@ -30,6 +31,8 @@ public interface IElytraProcess extends IBaritoneProcess {
|
|||
|
||||
void pathTo(BlockPos destination);
|
||||
|
||||
void pathTo(Goal destination);
|
||||
|
||||
/**
|
||||
* Resets the state of the process but will maintain the same destination and will try to keep flying
|
||||
*/
|
||||
|
|
|
@ -59,26 +59,11 @@ public class ElytraCommand extends Command {
|
|||
if (iGoal == null) {
|
||||
throw new CommandInvalidStateException("No goal has been set");
|
||||
}
|
||||
final int x;
|
||||
final int y;
|
||||
final int z;
|
||||
if (iGoal instanceof GoalXZ) {
|
||||
GoalXZ goal = (GoalXZ) iGoal;
|
||||
x = goal.getX();
|
||||
y = 64;
|
||||
z = goal.getZ();
|
||||
} else if (iGoal instanceof GoalBlock) {
|
||||
GoalBlock goal = (GoalBlock) iGoal;
|
||||
x = goal.x;
|
||||
y = goal.y;
|
||||
z = goal.z;
|
||||
} else {
|
||||
throw new CommandInvalidStateException("The goal must be a GoalXZ or GoalBlock");
|
||||
try {
|
||||
elytra.pathTo(iGoal);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
throw new CommandInvalidStateException(ex.getMessage());
|
||||
}
|
||||
if (y <= 0 || y >= 128) {
|
||||
throw new CommandInvalidStateException("The y of the goal is not between 0 and 128");
|
||||
}
|
||||
elytra.pathTo(new BlockPos(x, y, z));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,6 +56,9 @@ public final class CustomGoalProcess extends BaritoneProcessHelper implements IC
|
|||
public void setGoal(Goal goal) {
|
||||
this.goal = goal;
|
||||
this.mostRecentGoal = goal;
|
||||
if (baritone.getElytraProcess().isActive()) {
|
||||
baritone.getElytraProcess().pathTo(goal);
|
||||
}
|
||||
if (this.state == State.NONE) {
|
||||
this.state = State.GOAL_SET;
|
||||
}
|
||||
|
|
|
@ -23,6 +23,8 @@ import baritone.api.event.events.*;
|
|||
import baritone.api.event.events.type.EventState;
|
||||
import baritone.api.event.listener.AbstractGameEventListener;
|
||||
import baritone.api.pathing.goals.Goal;
|
||||
import baritone.api.pathing.goals.GoalBlock;
|
||||
import baritone.api.pathing.goals.GoalXZ;
|
||||
import baritone.api.pathing.goals.GoalYLevel;
|
||||
import baritone.api.pathing.movement.IMovement;
|
||||
import baritone.api.pathing.path.IPathExecutor;
|
||||
|
@ -53,7 +55,6 @@ import java.util.*;
|
|||
import static baritone.api.pathing.movement.ActionCosts.COST_INF;
|
||||
|
||||
public class ElytraProcess extends BaritoneProcessHelper implements IBaritoneProcess, IElytraProcess, AbstractGameEventListener {
|
||||
|
||||
public State state;
|
||||
private boolean goingToLandingSpot;
|
||||
private BetterBlockPos landingSpot;
|
||||
|
@ -234,6 +235,11 @@ public class ElytraProcess extends BaritoneProcessHelper implements IBaritonePro
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double priority() {
|
||||
return 0; // higher priority than CustomGoalProcess
|
||||
}
|
||||
|
||||
@Override
|
||||
public String displayName0() {
|
||||
return "Elytra - " + this.state.description;
|
||||
|
@ -261,6 +267,30 @@ public class ElytraProcess extends BaritoneProcessHelper implements IBaritonePro
|
|||
this.behavior.pathTo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pathTo(Goal iGoal) {
|
||||
final int x;
|
||||
final int y;
|
||||
final int z;
|
||||
if (iGoal instanceof GoalXZ) {
|
||||
GoalXZ goal = (GoalXZ) iGoal;
|
||||
x = goal.getX();
|
||||
y = 64;
|
||||
z = goal.getZ();
|
||||
} else if (iGoal instanceof GoalBlock) {
|
||||
GoalBlock goal = (GoalBlock) iGoal;
|
||||
x = goal.x;
|
||||
y = goal.y;
|
||||
z = goal.z;
|
||||
} else {
|
||||
throw new IllegalArgumentException("The goal must be a GoalXZ or GoalBlock");
|
||||
}
|
||||
if (y <= 0 || y >= 128) {
|
||||
throw new IllegalArgumentException("The y of the goal is not between 0 and 128");
|
||||
}
|
||||
this.pathTo(new BlockPos(x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLoaded() {
|
||||
return true;
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
package baritone.process.elytra;
|
||||
|
||||
import baritone.Baritone;
|
||||
import baritone.api.pathing.goals.Goal;
|
||||
import baritone.api.process.IElytraProcess;
|
||||
import baritone.api.process.PathingCommand;
|
||||
import baritone.utils.BaritoneProcessHelper;
|
||||
|
@ -49,6 +50,11 @@ public final class NullElytraProcess extends BaritoneProcessHelper implements IE
|
|||
throw new UnsupportedOperationException("Called pathTo() on NullElytraBehavior");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pathTo(Goal destination) {
|
||||
throw new UnsupportedOperationException("Called pathTo() on NullElytraBehavior");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetState() {
|
||||
|
||||
|
|
|
@ -27,6 +27,8 @@ import baritone.api.process.PathingCommand;
|
|||
import baritone.api.process.PathingCommandType;
|
||||
import baritone.behavior.PathingBehavior;
|
||||
import baritone.pathing.path.PathExecutor;
|
||||
import baritone.process.CustomGoalProcess;
|
||||
import baritone.process.ElytraProcess;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import java.util.*;
|
||||
|
@ -109,10 +111,6 @@ public class PathingControlManager implements IPathingControlManager {
|
|||
p.cancelSegmentIfSafe();
|
||||
break;
|
||||
case FORCE_REVALIDATE_GOAL_AND_PATH:
|
||||
if (!p.isPathing() && !p.getInProgress().isPresent()) {
|
||||
p.secretInternalSetGoalAndPath(command);
|
||||
}
|
||||
break;
|
||||
case REVALIDATE_GOAL_AND_PATH:
|
||||
if (!p.isPathing() && !p.getInProgress().isPresent()) {
|
||||
p.secretInternalSetGoalAndPath(command);
|
||||
|
|
Loading…
Reference in New Issue