diff options
| author | syeyoung <cyong06@naver.com> | 2021-04-17 21:59:15 +0900 |
|---|---|---|
| committer | syeyoung <cyong06@naver.com> | 2021-04-17 21:59:15 +0900 |
| commit | 57c8cb923c68ccc6fe0448ccb15f62de2f014019 (patch) | |
| tree | 3859fb80371c220ae57abf1d4d9e47648c2f2996 /src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions | |
| parent | fbcfc4a5f43a93db3afd0bc0a6b308c653e21a32 (diff) | |
| download | Skyblock-Dungeons-Guide-57c8cb923c68ccc6fe0448ccb15f62de2f014019.tar.gz Skyblock-Dungeons-Guide-57c8cb923c68ccc6fe0448ccb15f62de2f014019.tar.bz2 Skyblock-Dungeons-Guide-57c8cb923c68ccc6fe0448ccb15f62de2f014019.zip | |
freeze
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions')
| -rwxr-xr-x | src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMove.java | 26 | ||||
| -rwxr-xr-x | src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMoveNearestAir.java | 27 |
2 files changed, 35 insertions, 18 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMove.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMove.java index fae91d26..e64751b1 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMove.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMove.java @@ -17,6 +17,8 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.Set; import java.util.List; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; @Data public class ActionMove extends AbstractAction { @@ -56,21 +58,27 @@ public class ActionMove extends AbstractAction { } private int tick = -1; - private PathEntity latest; private List<BlockPos> poses; + private Future<List<BlockPos>> latestFuture; @Override public void onTick(DungeonRoom dungeonRoom) { tick = (tick+1) % 10; + if (latestFuture != null && latestFuture.isDone()) { + try { + poses = latestFuture.get(); + latestFuture = null; + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + } + } + if (tick == 0) { - latest = dungeonRoom.getPathFinder().createEntityPathTo(dungeonRoom.getContext().getWorld(), + try { + if (latestFuture != null) latestFuture.cancel(true); + } catch (Exception ignored) {} + if (!FeatureRegistry.SECRET_FREEZE_LINES.isEnabled()) + latestFuture = dungeonRoom.createEntityPathTo(dungeonRoom.getContext().getWorld(), Minecraft.getMinecraft().thePlayer, target.getBlockPos(dungeonRoom), Integer.MAX_VALUE); - if (latest != null) { - poses = new ArrayList<>(); - for (int i = 0; i < latest.getCurrentPathLength(); i++) { - PathPoint pathPoint = latest.getPathPointFromIndex(i); - poses.add(dungeonRoom.getMin().add(pathPoint.xCoord, pathPoint.yCoord, pathPoint.zCoord)); - } - } } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMoveNearestAir.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMoveNearestAir.java index d9e9251d..ef4e9062 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMoveNearestAir.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMoveNearestAir.java @@ -17,6 +17,8 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; @Data public class ActionMoveNearestAir extends AbstractAction { @@ -54,24 +56,31 @@ public class ActionMoveNearestAir extends AbstractAction { } private int tick = -1; - private PathEntity latest; private List<BlockPos> poses; + private Future<List<BlockPos>> latestFuture; @Override public void onTick(DungeonRoom dungeonRoom) { tick = (tick+1) % 10; + if (latestFuture != null && latestFuture.isDone()) { + try { + poses = latestFuture.get(); + latestFuture = null; + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + } + } + if (tick == 0) { - latest = dungeonRoom.getPathFinder().createEntityPathTo(dungeonRoom.getContext().getWorld(), + try { + if (latestFuture != null) latestFuture.cancel(true); + } catch (Exception ignored) {} + if (!FeatureRegistry.SECRET_FREEZE_LINES.isEnabled()) + latestFuture = dungeonRoom.createEntityPathTo(dungeonRoom.getContext().getWorld(), Minecraft.getMinecraft().thePlayer, target.getBlockPos(dungeonRoom), Integer.MAX_VALUE); - if (latest != null) { - poses = new ArrayList<>(); - for (int i = 0; i < latest.getCurrentPathLength(); i++) { - PathPoint pathPoint = latest.getPathPointFromIndex(i); - poses.add(dungeonRoom.getMin().add(pathPoint.xCoord, pathPoint.yCoord, pathPoint.zCoord)); - } - } } } + @Override public String toString() { return "MoveNearestAir\n- target: "+target.toString(); |
