aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java3
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java65
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMove.java13
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMoveNearestAir.java10
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/tree/ActionRoute.java2
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java11
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/eventlistener/PathfindListener.java67
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java8
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureActions.java4
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/mechanicbrowser/PanelMechanicBrowser.java8
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/pathfinding/CachedWorld.java97
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/pathfinding/JPSPathfinder.java368
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java74
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java211
14 files changed, 873 insertions, 68 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java b/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java
index 4875029d..7554c6b5 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java
@@ -26,6 +26,7 @@ import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoomInfoRegistry;
import kr.syeyoung.dungeonsguide.eventlistener.DungeonListener;
import kr.syeyoung.dungeonsguide.eventlistener.FeatureListener;
import kr.syeyoung.dungeonsguide.eventlistener.PacketListener;
+import kr.syeyoung.dungeonsguide.eventlistener.PathfindListener;
import kr.syeyoung.dungeonsguide.events.StompConnectedEvent;
import kr.syeyoung.dungeonsguide.features.FeatureRegistry;
import kr.syeyoung.dungeonsguide.features.impl.discord.inviteViewer.PartyInviteViewer;
@@ -120,6 +121,8 @@ public class DungeonsGuide implements DGInterface, CloseListener {
MinecraftForge.EVENT_BUS.register(new PacketListener());
MinecraftForge.EVENT_BUS.register(new Keybinds());
+ MinecraftForge.EVENT_BUS.register(PathfindListener.INSTANCE);
+
MinecraftForge.EVENT_BUS.register(PartyManager.INSTANCE);
MinecraftForge.EVENT_BUS.register(StaticResourceCache.INSTANCE);
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java b/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java
index 08f01248..82f5af4f 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java
@@ -21,8 +21,10 @@ package kr.syeyoung.dungeonsguide.commands;
import com.google.gson.JsonObject;
import com.sun.jna.Pointer;
import kr.syeyoung.dungeonsguide.DungeonsGuide;
+import kr.syeyoung.dungeonsguide.eventlistener.PathfindListener;
import kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration.EDiscordActivityActionType;
import kr.syeyoung.dungeonsguide.gamesdk.jna.interfacestruct.IDiscordOverlayManager;
+import kr.syeyoung.dungeonsguide.pathfinding.JPSPathfinder;
import kr.syeyoung.dungeonsguide.rpc.JDiscordRelation;
import kr.syeyoung.dungeonsguide.rpc.RichPresenceManager;
import kr.syeyoung.dungeonsguide.SkyblockStatus;
@@ -63,10 +65,7 @@ import net.minecraft.command.ICommandSender;
import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.server.MinecraftServer;
-import net.minecraft.util.BlockPos;
-import net.minecraft.util.ChatComponentText;
-import net.minecraft.util.ChatStyle;
-import net.minecraft.util.Tuple;
+import net.minecraft.util.*;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
@@ -173,7 +172,7 @@ public class CommandDungeonsGuide extends CommandBase {
DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt);
GeneralRoomProcessor grp = (GeneralRoomProcessor) dungeonRoom.getRoomProcessor();
- grp.pathfind(args[1], args[2]);
+ grp.pathfind("COMMAND", args[1], args[2]);
} catch (Throwable t) {
t.printStackTrace();
}
@@ -216,7 +215,7 @@ public class CommandDungeonsGuide extends CommandBase {
if (value instanceof DungeonSecret &&
(((DungeonSecret) value).getSecretType() == DungeonSecret.SecretType.BAT
|| ((DungeonSecret) value).getSecretType() == DungeonSecret.SecretType.CHEST)
- && ((DungeonSecret) value).getSecretPoint().getY() == 0 ) {
+ && ((DungeonSecret) value).getSecretPoint().getY() == 0) {
OffsetPoint offsetPoint = ((DungeonSecret) value).getSecretPoint();
if (dri.getBlocks()[offsetPoint.getZ()][offsetPoint.getX()] != -1) {
dri.getBlocks()[offsetPoint.getZ()][offsetPoint.getX()] = -1;
@@ -224,21 +223,21 @@ public class CommandDungeonsGuide extends CommandBase {
}
} else if (value instanceof DungeonOnewayDoor) {
for (OffsetPoint offsetPoint : ((DungeonOnewayDoor) value).getSecretPoint().getOffsetPointList()) {
- if (offsetPoint.getY() == 0&& dri.getBlocks()[offsetPoint.getZ()][offsetPoint.getX()] != -1) {
+ if (offsetPoint.getY() == 0 && dri.getBlocks()[offsetPoint.getZ()][offsetPoint.getX()] != -1) {
dri.getBlocks()[offsetPoint.getZ()][offsetPoint.getX()] = -1;
System.out.println("Fixing " + value2.getKey() + " - o-door - at " + offsetPoint);
}
}
} else if (value instanceof DungeonDoor) {
for (OffsetPoint offsetPoint : ((DungeonDoor) value).getSecretPoint().getOffsetPointList()) {
- if (offsetPoint.getY() == 0&& dri.getBlocks()[offsetPoint.getZ()][offsetPoint.getX()] != -1) {
+ if (offsetPoint.getY() == 0 && dri.getBlocks()[offsetPoint.getZ()][offsetPoint.getX()] != -1) {
dri.getBlocks()[offsetPoint.getZ()][offsetPoint.getX()] = -1;
System.out.println("Fixing " + value2.getKey() + " - door - at " + offsetPoint);
}
}
} else if (value instanceof DungeonBreakableWall) {
for (OffsetPoint offsetPoint : ((DungeonBreakableWall) value).getSecretPoint().getOffsetPointList()) {
- if (offsetPoint.getY() == 0&& dri.getBlocks()[offsetPoint.getZ()][offsetPoint.getX()] != -1) {
+ if (offsetPoint.getY() == 0 && dri.getBlocks()[offsetPoint.getZ()][offsetPoint.getX()] != -1) {
dri.getBlocks()[offsetPoint.getZ()][offsetPoint.getX()] = -1;
System.out.println("Fixing " + value2.getKey() + " - wall - at " + offsetPoint);
}
@@ -276,7 +275,7 @@ public class CommandDungeonsGuide extends CommandBase {
.thenAccept(a -> {
if (a == null) return;
ApiFetchur.fetchMostRecentProfileAsync(a.get(), FeatureRegistry.PARTYKICKER_APIKEY.getAPIKey());
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §e"+s+"§f's Profile ").appendSibling(new ChatComponentText("§7view").setChatStyle(new ChatStyle().setChatHoverEvent(new FeatureViewPlayerOnJoin.HoverEventRenderPlayer(a.orElse(null))))));
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §e" + s + "§f's Profile ").appendSibling(new ChatComponentText("§7view").setChatStyle(new ChatStyle().setChatHoverEvent(new FeatureViewPlayerOnJoin.HoverEventRenderPlayer(a.orElse(null))))));
});
}
});
@@ -420,12 +419,12 @@ public class CommandDungeonsGuide extends CommandBase {
} else if (args[0].equals("requeststaticresource")) {
UUID uid = UUID.fromString(args[1]);
StaticResourceCache.INSTANCE.getResource(uid).thenAccept(a -> {
- sender.addChatMessage(new ChatComponentText(a.getResourceID()+": "+a.getValue()+": "+a.isExists()));
+ sender.addChatMessage(new ChatComponentText(a.getResourceID() + ": " + a.getValue() + ": " + a.isExists()));
});
- } else if (args[0].equals("createFakeRoom")&& Minecraft.getMinecraft().getSession().getPlayerID().replace("-", "").equals("e686fe0aab804a71ac7011dc8c2b534c")) {
+ } else if (args[0].equals("createFakeRoom") && Minecraft.getMinecraft().getSession().getPlayerID().replace("-", "").equals("e686fe0aab804a71ac7011dc8c2b534c")) {
// load schematic
- File f=new File(DungeonsGuide.getDungeonsGuide().getConfigDir(), "schematics/new roonm-b2df250c-4af2-4201-963c-0ee1cb6bd3de-5efb1f0c-c05f-4064-bde7-cad0874fdf39.schematic");
+ File f = new File(DungeonsGuide.getDungeonsGuide().getConfigDir(), "schematics/new roonm-b2df250c-4af2-4201-963c-0ee1cb6bd3de-5efb1f0c-c05f-4064-bde7-cad0874fdf39.schematic");
NBTTagCompound compound;
try {
compound = CompressedStreamTools.readCompressed(new FileInputStream(f));
@@ -437,10 +436,10 @@ public class CommandDungeonsGuide extends CommandBase {
byte[] blocks = compound.getByteArray("Blocks");
byte[] meta = compound.getByteArray("Data");
for (int x = 0; x < compound.getShort("Width"); x++) {
- for (int y = 0; y < compound.getShort("Height"); y++) {
+ for (int y = 0; y < compound.getShort("Height"); y++) {
for (int z = 0; z < compound.getShort("Length"); z++) {
int index = x + (y * compound.getShort("Length") + z) * compound.getShort("Width");
- BlockPos pos = new BlockPos(x,y,z);
+ BlockPos pos = new BlockPos(x, y, z);
World w = MinecraftServer.getServer().getEntityWorld();
w.setBlockState(pos, Block.getBlockById(blocks[index] & 0xFF).getStateFromMeta(meta[index] & 0xFF), 2);
}
@@ -451,7 +450,7 @@ public class CommandDungeonsGuide extends CommandBase {
DungeonSpecificDataProviderRegistry.doorFinders.put(Pattern.compile("TEST DG"), new DungeonSpecificDataProvider() {
@Override
public BlockPos findDoor(World w, String dungeonName) {
- return new BlockPos(0,0,0);
+ return new BlockPos(0, 0, 0);
}
@Override
@@ -475,16 +474,16 @@ public class CommandDungeonsGuide extends CommandBase {
skyblockStatus.setContext(fakeContext);
skyblockStatus.setForceIsOnDungeon(true);
MapProcessor mapProcessor = fakeContext.getMapProcessor();
- mapProcessor.setUnitRoomDimension(new Dimension(16,16));
+ mapProcessor.setUnitRoomDimension(new Dimension(16, 16));
mapProcessor.setBugged(false);
- mapProcessor.setDoorDimension(new Dimension(4,4));
- mapProcessor.setTopLeftMapPoint(new Point(0,0));
- fakeContext.setDungeonMin(new BlockPos(0,70,0));
+ mapProcessor.setDoorDimension(new Dimension(4, 4));
+ mapProcessor.setTopLeftMapPoint(new Point(0, 0));
+ fakeContext.setDungeonMin(new BlockPos(0, 70, 0));
- DungeonRoom dungeonRoom = new DungeonRoom(Arrays.asList(new Point(0,0)), ShortUtils.topLeftifyInt((short) 1), (byte) 63, new BlockPos(0,70,0), new BlockPos(31,70,31), fakeContext);
+ DungeonRoom dungeonRoom = new DungeonRoom(Arrays.asList(new Point(0, 0)), ShortUtils.topLeftifyInt((short) 1), (byte) 63, new BlockPos(0, 70, 0), new BlockPos(31, 70, 31), fakeContext);
fakeContext.getDungeonRoomList().add(dungeonRoom);
- for (Point p:Arrays.asList(new Point(0,0))) {
+ for (Point p : Arrays.asList(new Point(0, 0))) {
fakeContext.getRoomMapper().put(p, dungeonRoom);
}
@@ -503,7 +502,7 @@ public class CommandDungeonsGuide extends CommandBase {
if (currentRoot.children().containsKey(s))
currentRoot = currentRoot.children().get(s);
else {
- currentRoot.child(currentRoot = new NestedCategory(finalCurrentRoot.categoryFull()+"."+s));
+ currentRoot.child(currentRoot = new NestedCategory(finalCurrentRoot.categoryFull() + "." + s));
}
}
}
@@ -525,7 +524,7 @@ public class CommandDungeonsGuide extends CommandBase {
if (n.getFirst().categoryFull().equals("ROOT")) continue;
String prefix = "";
- for (int i = 0; i < n.getSecond()-1; i++) {
+ for (int i = 0; i < n.getSecond() - 1; i++) {
prefix += " ";
}
@@ -538,6 +537,24 @@ public class CommandDungeonsGuide extends CommandBase {
}
System.out.println(stringBuilder.toString());
System.out.println(stringBuilder2.toString());
+ } else if (args[0].equalsIgnoreCase("pathfindtest")) {
+ if (args[1].equalsIgnoreCase("setbounds")) {
+ PathfindListener.INSTANCE.jpsPathfinder = new JPSPathfinder(Minecraft.getMinecraft().theWorld, new BlockPos(Integer.parseInt(args[2]), Integer.parseInt(args[3]), Integer.parseInt(args[4])),
+ new BlockPos(Integer.parseInt(args[5]), Integer.parseInt(args[6]),Integer.parseInt(args[7])));
+ } else {
+ new Thread(){
+ @Override
+ public void run() {
+ try {
+ boolean res = PathfindListener.INSTANCE.jpsPathfinder.pathfind(new Vec3(Float.parseFloat(args[2]), Float.parseFloat(args[3]), Float.parseFloat(args[4])),
+ new Vec3(Float.parseFloat(args[5]), Float.parseFloat(args[6]), Float.parseFloat(args[7])));
+ System.out.println("done-"+res);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }.start();
+ }
} else{
sender.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §e/dg §7-§fOpens configuration gui"));
sender.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §e/dg gui §7-§fOpens configuration gui"));
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 3f03cb86..26ab9176 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMove.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMove.java
@@ -26,6 +26,7 @@ import kr.syeyoung.dungeonsguide.utils.RenderUtils;
import lombok.Data;
import net.minecraft.client.Minecraft;
import net.minecraft.pathfinding.PathEntity;
+import net.minecraft.pathfinding.PathFinder;
import net.minecraft.pathfinding.PathPoint;
import net.minecraft.util.BlockPos;
import net.minecraft.util.MathHelper;
@@ -68,16 +69,20 @@ public class ActionMove extends AbstractAction {
RenderUtils.drawTextAtWorld("Destination", pos.getX() + 0.5f, 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 (poses != null){
- RenderUtils.drawLines(poses, FeatureRegistry.SECRET_BROWSE.getColor(), FeatureRegistry.SECRET_BROWSE.getThickness(), partialTicks, true);
+ if (!FeatureRegistry.SECRET_TOGGLE_KEY.isEnabled() || !Keybinds.togglePathfindStatus) {
+ if (poses != null){
+ RenderUtils.drawLines(poses, FeatureRegistry.SECRET_BROWSE.getColor(), FeatureRegistry.SECRET_BROWSE.getThickness(), partialTicks, true);
+ }
+ }
+ if (FeatureRegistry.SECRET_BEACONS.isEnabled()) {
+ RenderUtils.renderBeaconBeam(pos.getX(), pos.getY(), pos.getZ(), FeatureRegistry.SECRET_BROWSE.getColor(), partialTicks);
}
}
private int tick = -1;
private List<BlockPos> poses;
private Future<List<BlockPos>> latestFuture;
+
@Override
public void onTick(DungeonRoom dungeonRoom) {
tick = (tick+1) % Math.max(1, FeatureRegistry.SECRET_BROWSE.getRefreshRate());
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 a657bbe3..beaa4076 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMoveNearestAir.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMoveNearestAir.java
@@ -67,9 +67,13 @@ public class ActionMoveNearestAir extends AbstractAction {
RenderUtils.drawTextAtWorld("Destination", pos.getX() + 0.5f, 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 (poses != null){
- RenderUtils.drawLines(poses, FeatureRegistry.SECRET_BROWSE.getColor(), FeatureRegistry.SECRET_BROWSE.getThickness(), partialTicks, true);
+ if (!FeatureRegistry.SECRET_TOGGLE_KEY.isEnabled() || !Keybinds.togglePathfindStatus) {
+ if (poses != null){
+ RenderUtils.drawLines(poses, FeatureRegistry.SECRET_BROWSE.getColor(), FeatureRegistry.SECRET_BROWSE.getThickness(), partialTicks, true);
+ }
+ }
+ if (FeatureRegistry.SECRET_BEACONS.isEnabled()) {
+ RenderUtils.renderBeaconBeam(pos.getX(), pos.getY(), pos.getZ(), FeatureRegistry.SECRET_BROWSE.getColor(), partialTicks);
}
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/tree/ActionRoute.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/tree/ActionRoute.java
index c38990a0..cdfc5040 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/tree/ActionRoute.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/tree/ActionRoute.java
@@ -21,6 +21,7 @@ package kr.syeyoung.dungeonsguide.dungeon.actions.tree;
import kr.syeyoung.dungeonsguide.dungeon.actions.Action;
import kr.syeyoung.dungeonsguide.dungeon.actions.ActionChangeState;
import kr.syeyoung.dungeonsguide.dungeon.actions.ActionComplete;
+import kr.syeyoung.dungeonsguide.dungeon.actions.ActionMove;
import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom;
import kr.syeyoung.dungeonsguide.events.PlayerInteractEntityEvent;
import lombok.Getter;
@@ -79,6 +80,7 @@ public class ActionRoute {
getCurrentAction().onLivingDeath(dungeonRoom, event);
}
public void onRenderWorld(float partialTicks) {
+ if (current -1 >= 0 && actions.get(current-1) instanceof ActionMove) actions.get(current-1).onRenderScreen(dungeonRoom, partialTicks);
getCurrentAction().onRenderWorld(dungeonRoom, partialTicks);
}
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 5c6a7023..85970fa3 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java
@@ -91,11 +91,9 @@ public class DungeonRoom {
this.currentState = currentState;
}
- @Getter
- private final PathFinder pathFinder;
-
public ScheduledFuture<List<BlockPos>> createEntityPathTo(IBlockAccess blockaccess, Entity entityIn, BlockPos targetPos, float dist) {
- return asyncPathFinder.schedule(() -> {
+ ScheduledFuture<List<BlockPos>> sf = asyncPathFinder.schedule(() -> {
+ PathFinder pathFinder = new PathFinder(nodeProcessorDungeonRoom);
PathEntity latest = pathFinder.createEntityPathTo(blockaccess, entityIn, targetPos, dist);
if (latest != null) {
List<BlockPos> poses = new ArrayList<>();
@@ -107,9 +105,11 @@ public class DungeonRoom {
}
return new ArrayList<>();
}, 0, TimeUnit.MILLISECONDS);
+ asyncPathFinder.schedule(() -> sf.cancel(true), 10, TimeUnit.SECONDS);
+ return sf;
}
- private static final ScheduledExecutorService asyncPathFinder = Executors.newScheduledThreadPool(2);
+ private static final ScheduledExecutorService asyncPathFinder = Executors.newScheduledThreadPool(4);
@Getter
private final NodeProcessorDungeonRoom nodeProcessorDungeonRoom;
@@ -144,7 +144,6 @@ public class DungeonRoom {
buildDoors();
buildRoom();
nodeProcessorDungeonRoom = new NodeProcessorDungeonRoom(this);
- pathFinder = new PathFinder(nodeProcessorDungeonRoom);
updateRoomProcessor();
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/PathfindListener.java b/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/PathfindListener.java
new file mode 100644
index 00000000..fb19063d
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/PathfindListener.java
@@ -0,0 +1,67 @@
+/*
+ * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod
+ * Copyright (C) 2021 cyoung06
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package kr.syeyoung.dungeonsguide.eventlistener;
+
+import kr.syeyoung.dungeonsguide.DungeonsGuide;
+import kr.syeyoung.dungeonsguide.SkyblockStatus;
+import kr.syeyoung.dungeonsguide.config.types.AColor;
+import kr.syeyoung.dungeonsguide.features.AbstractFeature;
+import kr.syeyoung.dungeonsguide.features.FeatureRegistry;
+import kr.syeyoung.dungeonsguide.features.listener.WorldRenderListener;
+import kr.syeyoung.dungeonsguide.pathfinding.JPSPathfinder;
+import kr.syeyoung.dungeonsguide.utils.RenderUtils;
+import net.minecraft.client.renderer.GlStateManager;
+import net.minecraft.util.AxisAlignedBB;
+import net.minecraft.util.BlockPos;
+import net.minecraft.util.Tuple;
+import net.minecraft.util.Vec3;
+import net.minecraftforge.client.event.RenderWorldLastEvent;
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
+
+import java.awt.*;
+
+public class PathfindListener {
+ public JPSPathfinder jpsPathfinder;
+
+ public static final PathfindListener INSTANCE = new PathfindListener();
+
+ private void renderBox(Vec3 node, Color c, float partialTicks) {
+ if (node == null) return;
+ RenderUtils.highlightBox(AxisAlignedBB.fromBounds(node.xCoord - 0.25f, node.yCoord, node.zCoord - 0.25f, node.xCoord + 0.25f, node.yCoord + 0.5f, node.zCoord + 0.25f),c, partialTicks, false);
+
+ }
+
+ @SubscribeEvent
+ public void onRenderWorld(RenderWorldLastEvent postRender) {
+ try {
+ if (jpsPathfinder == null) return;
+ GlStateManager.pushMatrix();
+ for (JPSPathfinder.Node node : jpsPathfinder.getOpen()) {
+ renderBox(new Vec3(node.getX() / 2.0, node.getY() / 2.0, node.getZ() / 2.0), new Color(255,0,0,50), postRender.partialTicks);
+ }
+
+ RenderUtils.drawLinesVec3(jpsPathfinder.getRoute(), new AColor(0, 255, 0, 255), 1, postRender.partialTicks, false);
+ for (Vec3 vec3 : jpsPathfinder.getRoute()) {
+ renderBox(vec3, new Color(0, 255,0, 50), postRender.partialTicks);
+ }
+ GlStateManager.popMatrix();
+ } catch (Throwable t) {
+ }
+ }
+}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java
index 0fac0dba..72eb809b 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java
@@ -161,10 +161,12 @@ public class FeatureRegistry {
public static final FeatureMechanicBrowse SECRET_BROWSE = register(new FeatureMechanicBrowse());
public static final FeatureActions SECRET_ACTIONS = register(new FeatureActions());
public static final FeatureSoulRoomWarning SECRET_FAIRYSOUL = register(new FeatureSoulRoomWarning());
- public static final SimpleFeature SECRET_AUTO_BROWSE_NEXT = register(new SimpleFeature("Dungeon Secret.Secret Pathfind", "Auto Pathfind to 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("Dungeon Secret.Secret Pathfind", "Auto pathfind to new secret", "Auto browse best secret upon entering the room.", "secret.autouponenter", false));
- public static final SimpleFeature SECRET_NEXT_KEY = register(new SimpleFeature("Dungeon Secret.Secret Pathfind", "Auto Pathfind to new 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_AUTO_BROWSE_NEXT = register(new SimpleFeature("Dungeon Secret.Secret Pathfind.Legacy AutoPathfind", "Auto Pathfind to 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("Dungeon Secret.Secret Pathfind.Legacy AutoPathfind", "Auto pathfind to new secret", "Auto browse best secret upon entering the room.", "secret.autouponenter", false));
+ public static final SimpleFeature SECRET_NEXT_KEY = register(new SimpleFeature("Dungeon Secret.Secret Pathfind.Legacy AutoPathfind", "Auto Pathfind to new 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_PATHFIND_ALL = register(new SimpleFeature("Dungeon Secret.Secret Pathfind", "Start pathfind to all secrets upon entering a room", "Auto browse to all secrets in the room", "secret.secretpathfind.allbrowse", false));
public static final SimpleFeature SECRET_TOGGLE_KEY = register(new SimpleFeature("Dungeon Secret.Pathfind Display", "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_BEACONS = register(new SimpleFeature("Dungeon Secret.Pathfind Display", "Beacons on pathfind", "When pathfinding, display beacons as well as lines", "secret.beacons"));
public static final SimpleFeature SECRET_FREEZE_LINES = register(new FeatureFreezePathfind());
public static final FeatureNicknamePrefix COSMETIC_PREFIX = register(new FeatureNicknamePrefix());
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureActions.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureActions.java
index b62a168f..0ae1e668 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureActions.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureActions.java
@@ -115,9 +115,7 @@ public class FeatureActions extends TextHUDFeature {
Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition());
DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt);
- ActionRoute path = ((GeneralRoomProcessor)dungeonRoom.getRoomProcessor()).getPath();
-
- if (path != null) {
+ for (ActionRoute path : ((GeneralRoomProcessor) dungeonRoom.getRoomProcessor()).getPath().values()) {
actualBit.add(new StyledText("Pathfinding ","pathfinding"));
actualBit.add(new StyledText(path.getMechanic()+" ","mechanic"));
actualBit.add(new StyledText("-> ","separator"));
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/mechanicbrowser/PanelMechanicBrowser.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/mechanicbrowser/PanelMechanicBrowser.java
index 72ce5e01..5a558a1e 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/mechanicbrowser/PanelMechanicBrowser.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/mechanicbrowser/PanelMechanicBrowser.java
@@ -93,10 +93,10 @@ public class PanelMechanicBrowser extends MPanelScaledGUI {
GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
fr.drawString("Selected: ", 2,2, 0xFFAAAAAA);
- if (grp.getPath() == null)
+ if (grp.getPath("MECH-BROWSER") == null)
fr.drawString("Nothing", fr.getStringWidth("Selected: ") + 2,2, 0xFFAA0000);
else {
- ActionRoute route = grp.getPath();
+ ActionRoute route = grp.getPath("MECH-BROWSER");
fr.drawString(route.getMechanic()+" -> "+route.getState(), fr.getStringWidth("Selected: ") + 2,2, 0xFFFFFF00);
}
fr.drawString("Open Chat to Select Secrets", 2, fr.FONT_HEIGHT + 5, 0xFFAAAAAA);
@@ -256,7 +256,7 @@ public class PanelMechanicBrowser extends MPanelScaledGUI {
for (String state : states) {
mechanicBrowserTooltip.getMList().add(new MechanicBrowserElement(() -> state, false, (m2, pt2) -> {
if (dungeonRoom.getRoomProcessor() instanceof GeneralRoomProcessor)
- ((GeneralRoomProcessor)dungeonRoom.getRoomProcessor()).pathfind(id, state);
+ ((GeneralRoomProcessor)dungeonRoom.getRoomProcessor()).pathfind("MECH-BROWSER", id, state);
mechanicBrowserTooltip.close();
mechanicBrowserTooltip = null;
}));
@@ -276,7 +276,7 @@ public class PanelMechanicBrowser extends MPanelScaledGUI {
if (!dungeonRoomOpt.isPresent()) return;
DungeonRoom dungeonRoom = dungeonRoomOpt.get();
if (!(dungeonRoom.getRoomProcessor() instanceof GeneralRoomProcessor)) return;
- ((GeneralRoomProcessor) dungeonRoom.getRoomProcessor()).cancel();
+ ((GeneralRoomProcessor) dungeonRoom.getRoomProcessor()).cancel("MECH-BROWSER");
}
public void toggleTooltip(boolean open) {
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/pathfinding/CachedWorld.java b/src/main/java/kr/syeyoung/dungeonsguide/pathfinding/CachedWorld.java
new file mode 100644
index 00000000..ac9234c6
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/pathfinding/CachedWorld.java
@@ -0,0 +1,97 @@
+/*
+ * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod
+ * Copyright (C) 2021 cyoung06
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package kr.syeyoung.dungeonsguide.pathfinding;
+
+import lombok.AllArgsConstructor;
+import net.minecraft.block.state.IBlockState;
+import net.minecraft.entity.EnumCreatureType;
+import net.minecraft.profiler.Profiler;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.BlockPos;
+import net.minecraft.util.EnumFacing;
+import net.minecraft.util.IProgressUpdate;
+import net.minecraft.world.*;
+import net.minecraft.world.biome.BiomeGenBase;
+import net.minecraft.world.chunk.Chunk;
+import net.minecraft.world.chunk.IChunkProvider;
+import net.minecraft.world.storage.ISaveHandler;
+import net.minecraft.world.storage.WorldInfo;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.util.List;
+
+public class CachedWorld extends World {
+ private ChunkCache chunkCache;
+
+ public CachedWorld(ChunkCache chunkCache) {
+ super(null, null, new WorldProviderSurface(), null, true);
+ this.chunkCache = chunkCache;
+ }
+
+ @Override
+ protected IChunkProvider createChunkProvider() {
+ return null;
+ }
+
+ @Override
+ protected int getRenderDistanceChunks() {
+ return 999;
+ }
+
+ @Override
+ public boolean extendedLevelsInChunkCache() {
+ return chunkCache.extendedLevelsInChunkCache();
+ }
+
+ @Override
+ public TileEntity getTileEntity(BlockPos pos) {
+ return chunkCache.getTileEntity(pos);
+ }
+
+ @Override
+ public int getCombinedLight(BlockPos pos, int lightValue) {
+ return chunkCache.getCombinedLight(pos, lightValue);
+ }
+
+ @Override
+ public IBlockState getBlockState(BlockPos pos) {
+ return chunkCache.getBlockState(pos);
+ }
+
+ @Override
+ public int getLightFor(EnumSkyBlock type, BlockPos pos) {
+ return chunkCache.getLightFor(type, pos);
+ }
+
+ @Override
+ public boolean isAirBlock(BlockPos pos) {
+ return chunkCache.isAirBlock(pos);
+ }
+
+ @Override
+ public int getStrongPower(BlockPos pos, EnumFacing direction) {
+ return chunkCache.getStrongPower(pos, direction);
+ }
+
+ @Override
+ public boolean isSideSolid(BlockPos pos, EnumFacing side, boolean _default) {
+ return chunkCache.isSideSolid(pos, side, _default);
+ }
+}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/pathfinding/JPSPathfinder.java b/src/main/java/kr/syeyoung/dungeonsguide/pathfinding/JPSPathfinder.java
new file mode 100644
index 00000000..8ee1251f
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/pathfinding/JPSPathfinder.java
@@ -0,0 +1,368 @@
+/*
+ * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod
+ * Copyright (C) 2021 cyoung06
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ *