diff options
author | syeyoung <cyong06@naver.com> | 2021-02-20 03:02:16 +0900 |
---|---|---|
committer | syeyoung <cyong06@naver.com> | 2021-02-20 03:02:16 +0900 |
commit | c59bec09ffaedd85d3fa973abe4295137368ad7e (patch) | |
tree | beb36945c84b5e2318ac96f939290705e05617f6 /src | |
parent | 16bbf7aadb8352090005f4fb0e68b2121bceb12e (diff) | |
download | Skyblock-Dungeons-Guide-c59bec09ffaedd85d3fa973abe4295137368ad7e.tar.gz Skyblock-Dungeons-Guide-c59bec09ffaedd85d3fa973abe4295137368ad7e.tar.bz2 Skyblock-Dungeons-Guide-c59bec09ffaedd85d3fa973abe4295137368ad7e.zip |
the secrets
Diffstat (limited to 'src')
4 files changed, 44 insertions, 12 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/Keybinds.java b/src/main/java/kr/syeyoung/dungeonsguide/Keybinds.java index 9a9451e5..0ef54a04 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/Keybinds.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/Keybinds.java @@ -8,7 +8,7 @@ public class Keybinds { public static KeyBinding editingSession; public static KeyBinding sendBombdefuse; - public static KeyBinding ringMenuForSecretEdit; + public static KeyBinding nextSecret; public static void register() { @@ -16,5 +16,7 @@ public class Keybinds ClientRegistry.registerKeyBinding(editingSession); sendBombdefuse = new KeyBinding("send and save bombdefuse solution", Keyboard.KEY_F, "key.categories.misc"); ClientRegistry.registerKeyBinding(sendBombdefuse); + nextSecret = new KeyBinding("navigate to next secret. (Req option enabled at /dg)", Keyboard.KEY_NONE, "key.categories.misc"); + ClientRegistry.registerKeyBinding(nextSecret); } } 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 eb6e3934..691926f7 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java @@ -80,9 +80,9 @@ public class DungeonRoom { buildDoors(); buildRoom(); - updateRoomProcessor(); nodeProcessorDungeonRoom = new NodeProcessorDungeonRoom(this); pathFinder = new PathFinder(nodeProcessorDungeonRoom); + updateRoomProcessor(); } private static final Set<Vector2d> directions = Sets.newHashSet(new Vector2d(0,16), new Vector2d(0, -16), new Vector2d(16, 0), new Vector2d(-16 , 0)); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java index 30591e28..7abea6b8 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java @@ -91,5 +91,7 @@ public class FeatureRegistry { public static final FeatureMechanicBrowse SECRET_BROWSE = register(new FeatureMechanicBrowse()); public static final FeatureActions SECRET_ACTIONS = register(new FeatureActions()); - public static final SimpleFeature SECRET_AUTO_BROWSE_NEXT = register(new SimpleFeature("Secret", "Auto browse next secret.", "Auto browse next secret after current one completes.\nYou still need to trigger first pathfinding of first secret, after that this option would start working", "secret.autobrowse", false)); + public static final SimpleFeature SECRET_AUTO_BROWSE_NEXT = register(new SimpleFeature("Secret", "Auto browse next secret.", "Auto browse best next secret after current one completes.\nthe first pathfinding of first secret needs to be triggered first in order for this option to work", "secret.autobrowse", false)); + 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. Change key at your key settings (Settings -> Controls)", "secret.keyfornext", false)); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java index ad8f866e..508cc93d 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java @@ -1,5 +1,6 @@ package kr.syeyoung.dungeonsguide.roomprocessor; +import kr.syeyoung.dungeonsguide.Keybinds; import kr.syeyoung.dungeonsguide.dungeon.DungeonContext; import kr.syeyoung.dungeonsguide.dungeon.DungeonActionManager; import kr.syeyoung.dungeonsguide.dungeon.actions.ActionComplete; @@ -35,6 +36,7 @@ import net.minecraftforge.fml.common.gameevent.InputEvent; import java.awt.*; import java.util.Map; +import java.util.PriorityQueue; import java.util.UUID; public class GeneralRoomProcessor implements RoomProcessor { @@ -44,6 +46,8 @@ public class GeneralRoomProcessor implements RoomProcessor { private DungeonRoom dungeonRoom; public GeneralRoomProcessor(DungeonRoom dungeonRoom) { this.dungeonRoom = dungeonRoom; + if (FeatureRegistry.SECRET_AUTO_START.isEnabled()) + searchForNextTarget(); } @Override @@ -53,17 +57,39 @@ public class GeneralRoomProcessor implements RoomProcessor { if (FeatureRegistry.SECRET_AUTO_BROWSE_NEXT.isEnabled() && path.getCurrentAction() instanceof ActionComplete) { if (!path.getState().equals("found")) return; if (!(dungeonRoom.getDungeonRoomInfo().getMechanics().get(path.getMechanic()) instanceof DungeonSecret)) return; - boolean foundcurr = false; - for (Map.Entry<String, DungeonMechanic> mech: dungeonRoom.getDungeonRoomInfo().getMechanics().entrySet()) { - if (!(mech.getValue() instanceof DungeonSecret)) continue; - if (foundcurr && ((DungeonSecret) mech.getValue()).getSecretStatus(getDungeonRoom()) != DungeonSecret.SecretStatus.FOUND) { - pathfind(mech.getKey(), "found"); - break; - } - if (mech.getKey().equals(path.getMechanic())) foundcurr = true; + searchForNextTarget(); + } + } + } + + public void searchForNextTarget() { + BlockPos pos = Minecraft.getMinecraft().thePlayer.getPosition(); + + double lowestCost = 99999999999999.0; + Map.Entry<String, DungeonMechanic> lowestWeightMechanic = null; + for (Map.Entry<String, DungeonMechanic> mech: dungeonRoom.getDungeonRoomInfo().getMechanics().entrySet()) { + if (!(mech.getValue() instanceof DungeonSecret)) continue; + if (((DungeonSecret) mech.getValue()).getSecretStatus(getDungeonRoom()) != DungeonSecret.SecretStatus.FOUND) { + double cost = 0; + if (((DungeonSecret) mech.getValue()).getSecretType() == DungeonSecret.SecretType.BAT && + ((DungeonSecret) mech.getValue()).getPreRequisite().size() == 0) { + cost += -100000000; + } + if (mech.getValue().getRepresentingPoint() == null) continue; + BlockPos blockpos = mech.getValue().getRepresentingPoint().getBlockPos(getDungeonRoom()); + + cost += blockpos.distanceSq(pos); + cost += ((DungeonSecret) mech.getValue()).getPreRequisite().size() * 100; + + if (cost < lowestCost) { + lowestCost = cost; + lowestWeightMechanic = mech; } } } + if (lowestWeightMechanic != null) { + pathfind(lowestWeightMechanic.getKey(), "found"); + } } @Override @@ -177,7 +203,9 @@ public class GeneralRoomProcessor implements RoomProcessor { @Override public void onKeyPress(InputEvent.KeyInputEvent keyInputEvent) { - + if (FeatureRegistry.SECRET_NEXT_KEY.isEnabled() && Keybinds.nextSecret.isKeyDown()) { + searchForNextTarget(); + } } @Override |