destroy async

This commit is contained in:
Leijurv 2023-07-30 22:56:33 -07:00
parent 7e9cf2e1e9
commit 36df7b17f8
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
1 changed files with 9 additions and 5 deletions

View File

@ -252,8 +252,13 @@ public class ElytraProcess extends BaritoneProcessHelper implements IBaritonePro
this.landingSpot = null;
this.reachedGoal = false;
this.state = State.START_FLYING; // TODO: null state?
if (this.behavior != null) {
this.behavior.destroy();
destroyBehaviorAsync();
}
private void destroyBehaviorAsync() {
ElytraBehavior behavior = this.behavior;
if (behavior != null) {
Baritone.getExecutor().execute(behavior::destroy);
this.behavior = null;
}
}
@ -353,10 +358,9 @@ public class ElytraProcess extends BaritoneProcessHelper implements IBaritonePro
@Override
public void onWorldEvent(WorldEvent event) {
if (event.getWorld() != null && event.getState() == EventState.POST && this.behavior != null) {
if (event.getWorld() != null && event.getState() == EventState.POST) {
// Exiting the world, just destroy
this.behavior.destroy();
this.behavior = null;
destroyBehaviorAsync();
}
}