diff options
author | syeyoung <cyong06@naver.com> | 2021-02-22 13:37:15 +0900 |
---|---|---|
committer | syeyoung <cyong06@naver.com> | 2021-02-22 13:37:15 +0900 |
commit | 4d0beb048ef798656cf4db5b340daae4a3ddd8de (patch) | |
tree | 7e42cc5e62ce8e7652412a8d903bf04ee185e37c /src/main/java/kr/syeyoung/dungeonsguide | |
parent | 4f289db303d4e68e68789767b91e3106ff1866d7 (diff) | |
download | Skyblock-Dungeons-Guide-4d0beb048ef798656cf4db5b340daae4a3ddd8de.tar.gz Skyblock-Dungeons-Guide-4d0beb048ef798656cf4db5b340daae4a3ddd8de.tar.bz2 Skyblock-Dungeons-Guide-4d0beb048ef798656cf4db5b340daae4a3ddd8de.zip |
a bit better pathfinding and a toggle
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide')
6 files changed, 33 insertions, 6 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/Keybinds.java b/src/main/java/kr/syeyoung/dungeonsguide/Keybinds.java index 0ef54a04..c139dc73 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/Keybinds.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/Keybinds.java @@ -2,6 +2,8 @@ package kr.syeyoung.dungeonsguide; import net.minecraft.client.settings.KeyBinding; import net.minecraftforge.fml.client.registry.ClientRegistry; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.InputEvent; import org.lwjgl.input.Keyboard; public class Keybinds @@ -9,6 +11,7 @@ public class Keybinds public static KeyBinding editingSession; public static KeyBinding sendBombdefuse; public static KeyBinding nextSecret; + public static KeyBinding togglePathfind; public static void register() { @@ -18,5 +21,15 @@ public class Keybinds ClientRegistry.registerKeyBinding(sendBombdefuse); nextSecret = new KeyBinding("navigate to next secret. (Req option enabled at /dg)", Keyboard.KEY_NONE, "key.categories.misc"); ClientRegistry.registerKeyBinding(nextSecret); + togglePathfind = new KeyBinding("toggle Pathfind. (Req option enabled at /dg)", Keyboard.KEY_NONE, "key.categories.misc"); + ClientRegistry.registerKeyBinding(togglePathfind); + } + + public static boolean togglePathfindStatus = false; + + @SubscribeEvent + public void onTogglePathfindStatus(InputEvent.KeyInputEvent keyInputEvent) { + if (togglePathfind.isKeyDown()) + togglePathfindStatus = !togglePathfindStatus; } } 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 2fc86b8e..f0e77c55 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMove.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMove.java @@ -1,7 +1,9 @@ package kr.syeyoung.dungeonsguide.dungeon.actions; +import kr.syeyoung.dungeonsguide.Keybinds; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.features.FeatureRegistry; import kr.syeyoung.dungeonsguide.utils.RenderUtils; import lombok.Data; import net.minecraft.client.Minecraft; @@ -46,6 +48,7 @@ public class ActionMove extends AbstractAction { RenderUtils.drawTextAtWorld("Destination", pos.getX() + 0.5f, (float) (pos.getY() + 0.5f + scale), pos.getZ() + 0.5f, 0xFF00FF00, 1f, true, false, partialTicks); RenderUtils.drawTextAtWorld(String.format("%.2f",MathHelper.sqrt_double(pos.distanceSq(Minecraft.getMinecraft().thePlayer.getPosition())))+"m", pos.getX() + 0.5f, pos.getY() + 0.5f - scale, pos.getZ() + 0.5f, 0xFFFFFF00, 1f, true, false, partialTicks); + if (FeatureRegistry.SECRET_TOGGLE_KEY.isEnabled() && Keybinds.togglePathfindStatus) return; if (latest != null){ List<BlockPos> poses = new ArrayList<BlockPos>(); 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 3f8e4061..01822292 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMoveNearestAir.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMoveNearestAir.java @@ -1,7 +1,9 @@ package kr.syeyoung.dungeonsguide.dungeon.actions; +import kr.syeyoung.dungeonsguide.Keybinds; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.features.FeatureRegistry; import kr.syeyoung.dungeonsguide.utils.RenderUtils; import lombok.Data; import net.minecraft.client.Minecraft; @@ -38,8 +40,14 @@ public class ActionMoveNearestAir extends AbstractAction { @Override public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks) { BlockPos pos = target.getBlockPos(dungeonRoom); - RenderUtils.drawTextAtWorld("Destination", pos.getX() + 0.5f, pos.getY() + 0.6f, pos.getZ() + 0.5f, 0xFF00FF00, 1f, true, false, partialTicks); - RenderUtils.drawTextAtWorld(String.format("%.2f",MathHelper.sqrt_double(pos.distanceSq(Minecraft.getMinecraft().thePlayer.getPosition())))+"m", pos.getX() + 0.5f, pos.getY() + 0.3f, pos.getZ() + 0.5f, 0xFFFFFF00, 1f, true, false, partialTicks); + float distance = MathHelper.sqrt_double(pos.distanceSq(Minecraft.getMinecraft().thePlayer.getPosition())); + float multiplier = distance / 120f; //mobs only render ~120 blocks away + float scale = 0.45f * multiplier; + scale *= 25.0 / 6.0; + RenderUtils.drawTextAtWorld("Destination", pos.getX() + 0.5f, (float) (pos.getY() + 0.5f + scale), pos.getZ() + 0.5f, 0xFF00FF00, 1f, true, false, partialTicks); + RenderUtils.drawTextAtWorld(String.format("%.2f",MathHelper.sqrt_double(pos.distanceSq(Minecraft.getMinecraft().thePlayer.getPosition())))+"m", pos.getX() + 0.5f, pos.getY() + 0.5f - scale, pos.getZ() + 0.5f, 0xFFFFFF00, 1f, true, false, partialTicks); + + if (FeatureRegistry.SECRET_TOGGLE_KEY.isEnabled() && Keybinds.togglePathfindStatus) return; if (latest != null){ List<BlockPos> poses = new ArrayList<BlockPos>(); for (int i = 0; i < latest.getCurrentPathLength(); i++) { diff --git a/src/main/java/kr/syeyoung/dungeonsguide/e.java b/src/main/java/kr/syeyoung/dungeonsguide/e.java index 70d7310f..624b9ab0 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/e.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/e.java @@ -68,6 +68,7 @@ public class e implements c { MinecraftForge.EVENT_BUS.register(commandReparty); MinecraftForge.EVENT_BUS.register(new FeatureListener()); MinecraftForge.EVENT_BUS.register(new PacketListener()); + MinecraftForge.EVENT_BUS.register(new Keybinds()); AhUtils.registerTimer(); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java index 4712f8aa..b3c22c2b 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java @@ -94,5 +94,6 @@ public class FeatureRegistry { 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 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)); + 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")); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java index 1386fb72..7b1e3433 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java @@ -35,9 +35,7 @@ import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.fml.common.gameevent.InputEvent; import java.awt.*; -import java.util.Map; -import java.util.PriorityQueue; -import java.util.UUID; +import java.util.*; public class GeneralRoomProcessor implements RoomProcessor { @@ -64,6 +62,7 @@ public class GeneralRoomProcessor implements RoomProcessor { } } } + private Set<String> visited = new HashSet<String>(); public void searchForNextTarget() { BlockPos pos = Minecraft.getMinecraft().thePlayer.getPosition(); @@ -72,6 +71,7 @@ public class GeneralRoomProcessor implements RoomProcessor { Map.Entry<String, DungeonMechanic> lowestWeightMechanic = null; for (Map.Entry<String, DungeonMechanic> mech: dungeonRoom.getDungeonRoomInfo().getMechanics().entrySet()) { if (!(mech.getValue() instanceof DungeonSecret)) continue; + if (visited.contains(mech.getKey())) continue; if (((DungeonSecret) mech.getValue()).getSecretStatus(getDungeonRoom()) != DungeonSecret.SecretStatus.FOUND) { double cost = 0; if (((DungeonSecret) mech.getValue()).getSecretType() == DungeonSecret.SecretType.BAT && @@ -91,6 +91,7 @@ public class GeneralRoomProcessor implements RoomProcessor { } } if (lowestWeightMechanic != null) { + visited.add(lowestWeightMechanic.getKey()); pathfind(lowestWeightMechanic.getKey(), "found"); } } |