MCPcopy Create free account
hub / github.com/cabaletta/baritone / onTick

Method onTick

src/main/java/baritone/process/ElytraProcess.java:112–286  ·  view source on GitHub ↗
(boolean calcFailed, boolean isSafeToCancel)

Source from the content-addressed store, hash-verified

110 private static final String AUTO_JUMP_FAILURE_MSG = "Failed to compute a walking path to a spot to jump off from. Consider starting from a higher location, near an overhang. Or, you can disable elytraAutoJump and just manually begin gliding.";
111
112 @Override
113 public PathingCommand onTick(boolean calcFailed, boolean isSafeToCancel) {
114 final long seedSetting = Baritone.settings().elytraNetherSeed.value;
115 if (seedSetting != this.behavior.context.getSeed()) {
116 logDirect("Nether seed changed, recalculating path");
117 this.resetState();
118 }
119 if (predictingTerrain != Baritone.settings().elytraPredictTerrain.value) {
120 logDirect("elytraPredictTerrain setting changed, recalculating path");
121 predictingTerrain = Baritone.settings().elytraPredictTerrain.value;
122 this.resetState();
123 }
124
125 this.behavior.onTick();
126
127 if (calcFailed) {
128 onLostControl();
129 logDirect(AUTO_JUMP_FAILURE_MSG);
130 return new PathingCommand(null, PathingCommandType.CANCEL_AND_SET_GOAL);
131 }
132
133 boolean safetyLanding = false;
134 if (ctx.player().isFallFlying() && shouldLandForSafety()) {
135 if (Baritone.settings().elytraAllowEmergencyLand.value) {
136 logDirect("Emergency landing - almost out of elytra durability or fireworks");
137 safetyLanding = true;
138 } else {
139 logDirect("almost out of elytra durability or fireworks, but I'm going to continue since elytraAllowEmergencyLand is false");
140 }
141 }
142 if (ctx.player().isFallFlying() && this.state != State.LANDING && (this.behavior.pathManager.isComplete() || safetyLanding)) {
143 final BetterBlockPos last = this.behavior.pathManager.path.getLast();
144 if (last != null && (ctx.player().position().distanceToSqr(last.getCenter()) < (48 * 48) || safetyLanding) && (!goingToLandingSpot || (safetyLanding && this.landingSpot == null))) {
145 logDirect("Path complete, picking a nearby safe landing spot...");
146 BetterBlockPos landingSpot = findSafeLandingSpot(ctx.playerFeet());
147 // if this fails we will just keep orbiting the last node until we run out of rockets or the user intervenes
148 if (landingSpot != null) {
149 this.pathTo0(landingSpot, true);
150 this.landingSpot = landingSpot;
151 }
152 this.goingToLandingSpot = true;
153 }
154
155 if (last != null && ctx.player().position().distanceToSqr(last.getCenter()) < 1) {
156 if (Baritone.settings().notificationOnPathComplete.value && !reachedGoal) {
157 logNotification("Pathing complete", false);
158 }
159 if (Baritone.settings().disconnectOnArrival.value && !reachedGoal) {
160 // don't be active when the user logs back in
161 this.onLostControl();
162 if (ctx.world() instanceof ClientLevel clientLevel) {
163 clientLevel.disconnect(Component.literal("[Baritone] Arrived at goal!"));
164 }
165 return new PathingCommand(null, PathingCommandType.CANCEL_AND_SET_GOAL);
166 }
167 reachedGoal = true;
168
169 // we are goingToLandingSpot and we are in the last node of the path

Callers

nothing calls this directly

Calls 15

settingsMethod · 0.95
resetStateMethod · 0.95
onLostControlMethod · 0.95
shouldLandForSafetyMethod · 0.95
findSafeLandingSpotMethod · 0.95
pathTo0Method · 0.95
calcRotationFromVec3dMethod · 0.95
getYawMethod · 0.95
landingSpotIsBadMethod · 0.95
getPathMethod · 0.95
getSrcMethod · 0.95
getDestMethod · 0.95

Tested by

no test coverage detected