diff options
Diffstat (limited to 'src')
6 files changed, 108 insertions, 22 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/Keybinds.java b/src/main/java/kr/syeyoung/dungeonsguide/Keybinds.java index c139dc73..451f8c41 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/Keybinds.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/Keybinds.java @@ -1,6 +1,9 @@ package kr.syeyoung.dungeonsguide; +import kr.syeyoung.dungeonsguide.features.FeatureRegistry; +import net.minecraft.client.Minecraft; import net.minecraft.client.settings.KeyBinding; +import net.minecraft.util.ChatComponentText; import net.minecraftforge.fml.client.registry.ClientRegistry; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.InputEvent; @@ -12,17 +15,20 @@ public class Keybinds public static KeyBinding sendBombdefuse; public static KeyBinding nextSecret; public static KeyBinding togglePathfind; + public static KeyBinding freezeLines; public static void register() { - editingSession = new KeyBinding("start editing session", Keyboard.KEY_NONE, "key.categories.misc"); + editingSession = new KeyBinding("start editing session", Keyboard.KEY_NONE, "key.categories.dungeonsguide"); ClientRegistry.registerKeyBinding(editingSession); - sendBombdefuse = new KeyBinding("send and save bombdefuse solution", Keyboard.KEY_F, "key.categories.misc"); + sendBombdefuse = new KeyBinding("send and save bombdefuse solution", Keyboard.KEY_F, "key.categories.dungeonsguide"); ClientRegistry.registerKeyBinding(sendBombdefuse); - nextSecret = new KeyBinding("navigate to next secret. (Req option enabled at /dg)", Keyboard.KEY_NONE, "key.categories.misc"); + nextSecret = new KeyBinding("navigate to next secret. (Req option enabled at /dg)", Keyboard.KEY_NONE, "key.categories.dungeonsguide"); ClientRegistry.registerKeyBinding(nextSecret); - togglePathfind = new KeyBinding("toggle Pathfind. (Req option enabled at /dg)", Keyboard.KEY_NONE, "key.categories.misc"); + togglePathfind = new KeyBinding("toggle Pathfind. (Req option enabled at /dg)", Keyboard.KEY_NONE, "key.categories.dungeonsguide"); ClientRegistry.registerKeyBinding(togglePathfind); + freezeLines = new KeyBinding("Toggle freeze pathfind lines", Keyboard.KEY_NONE, "key.categories.dungeonsguide"); + ClientRegistry.registerKeyBinding(freezeLines); } public static boolean togglePathfindStatus = false; @@ -31,5 +37,12 @@ public class Keybinds public void onTogglePathfindStatus(InputEvent.KeyInputEvent keyInputEvent) { if (togglePathfind.isKeyDown()) togglePathfindStatus = !togglePathfindStatus; + + if (freezeLines.isKeyDown()) { + FeatureRegistry.SECRET_FREEZE_LINES.setEnabled(!FeatureRegistry.SECRET_FREEZE_LINES.isEnabled()); + try { + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §fToggled Pathfind Freeze to §e"+(FeatureRegistry.SECRET_FREEZE_LINES.isEnabled() ? "on":"off"))); + } catch (Exception ignored) {} + } } } 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(); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java index 208d25b6..ffc9ca6d 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java @@ -17,13 +17,21 @@ import lombok.AllArgsConstructor; import lombok.Getter; import lombok.Setter; import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.pathfinding.PathEntity; import net.minecraft.pathfinding.PathFinder; +import net.minecraft.pathfinding.PathPoint; import net.minecraft.util.BlockPos; +import net.minecraft.world.IBlockAccess; import javax.vecmath.Vector2d; import java.awt.*; import java.util.*; import java.util.List; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.TimeUnit; @Getter public class DungeonRoom { @@ -67,6 +75,23 @@ public class DungeonRoom { @Getter private PathFinder pathFinder; + + public ScheduledFuture<List<BlockPos>> createEntityPathTo(IBlockAccess blockaccess, Entity entityIn, BlockPos targetPos, float dist) { + return asyncPathFinder.schedule(() -> { + PathEntity latest = pathFinder.createEntityPathTo(blockaccess, entityIn, targetPos, dist); + if (latest != null) { + List<BlockPos> poses = new ArrayList<>(); + for (int i = 0; i < latest.getCurrentPathLength(); i++) { + PathPoint pathPoint = latest.getPathPointFromIndex(i); + poses.add(getMin().add(pathPoint.xCoord, pathPoint.yCoord, pathPoint.zCoord)); + } + return poses; + } + return new ArrayList<>(); + }, 0, TimeUnit.MILLISECONDS); + } + + private static final ScheduledExecutorService asyncPathFinder = Executors.newScheduledThreadPool(2); @Getter private NodeProcessorDungeonRoom nodeProcessorDungeonRoom; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java index adc0d879..f2046130 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java @@ -11,6 +11,7 @@ import kr.syeyoung.dungeonsguide.features.impl.dungeon.*; import kr.syeyoung.dungeonsguide.features.impl.etc.*; import kr.syeyoung.dungeonsguide.features.impl.etc.ability.FeatureAbilityCooldown; import kr.syeyoung.dungeonsguide.features.impl.secret.FeatureActions; +import kr.syeyoung.dungeonsguide.features.impl.secret.FeatureFreezePathfind; import kr.syeyoung.dungeonsguide.features.impl.secret.FeatureMechanicBrowse; import kr.syeyoung.dungeonsguide.features.impl.secret.FeatureSoulRoomWarning; import lombok.Getter; @@ -119,4 +120,5 @@ public class FeatureRegistry { public static final SimpleFeature SECRET_AUTO_START = register(new SimpleFeature("Secret", "Auto browse secret upon entering room", "Auto browse best secret upon entering the room.", "secret.autouponenter", false)); public static final SimpleFeature SECRET_NEXT_KEY = register(new SimpleFeature("Secret", "Auto browse next secret upon pressing a key", "Auto browse the best next secret when you press key.\nChange key at your key settings (Settings -> Controls)", "secret.keyfornext", false)); public static final SimpleFeature SECRET_TOGGLE_KEY = register(new SimpleFeature("Secret", "Press a key to toggle pathfind lines", "A key for toggling pathfound line visibility.\nChange key at your key settings (Settings -> Controls)", "secret.togglePathfind")); + public static final SimpleFeature SECRET_FREEZE_LINES = register(new FeatureFreezePathfind()); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureFreezePathfind.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureFreezePathfind.java new file mode 100644 index 00000000..1ef3be9d --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureFreezePathfind.java @@ -0,0 +1,29 @@ +package kr.syeyoung.dungeonsguide.features.impl.secret; + +import kr.syeyoung.dungeonsguide.SkyblockStatus; +import kr.syeyoung.dungeonsguide.config.types.AColor; +import kr.syeyoung.dungeonsguide.dungeon.DungeonContext; +import kr.syeyoung.dungeonsguide.dungeon.actions.Action; +import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionRoute; +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.e; +import kr.syeyoung.dungeonsguide.features.SimpleFeature; +import kr.syeyoung.dungeonsguide.features.text.StyledText; +import kr.syeyoung.dungeonsguide.features.text.TextHUDFeature; +import kr.syeyoung.dungeonsguide.features.text.TextStyle; +import kr.syeyoung.dungeonsguide.roomprocessor.GeneralRoomProcessor; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityPlayerSP; + +import java.awt.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class FeatureFreezePathfind extends SimpleFeature { + public FeatureFreezePathfind() { + super("Secret", "Freeze Pathfind", "Freeze Pathfind, meaning the pathfind lines won't change when you move", "secret.freezepathfind", false); + } + + SkyblockStatus skyblockStatus = e.getDungeonsGuide().getSkyblockStatus(); +} |