diff options
author | syeyoung <cyoung06@naver.com> | 2021-09-18 16:46:07 +0900 |
---|---|---|
committer | syeyoung <cyoung06@naver.com> | 2021-09-18 16:46:07 +0900 |
commit | 07f74480447495e6cd42237e4740fb082cb4b821 (patch) | |
tree | 0b1f61eac4e424f5adf924b94f67dfe71d57ba98 /src/main/java/kr/syeyoung/dungeonsguide/dungeon | |
parent | 44eef4302880c031465aae4d712f57ca366e2b44 (diff) | |
download | Skyblock-Dungeons-Guide-07f74480447495e6cd42237e4740fb082cb4b821.tar.gz Skyblock-Dungeons-Guide-07f74480447495e6cd42237e4740fb082cb4b821.tar.bz2 Skyblock-Dungeons-Guide-07f74480447495e6cd42237e4740fb082cb4b821.zip |
Waypoints!
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/dungeon')
4 files changed, 48 insertions, 32 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 26ab9176..f0b694b0 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMove.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMove.java @@ -30,6 +30,7 @@ import net.minecraft.pathfinding.PathFinder; import net.minecraft.pathfinding.PathPoint; import net.minecraft.util.BlockPos; import net.minecraft.util.MathHelper; +import net.minecraft.util.Vec3; import java.awt.*; import java.util.ArrayList; @@ -66,22 +67,23 @@ public class ActionMove extends AbstractAction { float multiplier = distance / 120f; //mobs only render ~120 blocks away float scale = 0.45f * multiplier; scale *= 25.0 / 6.0; + if (FeatureRegistry.SECRET_BEACONS.isEnabled()) { + RenderUtils.renderBeaconBeam(pos.getX(), pos.getY(), pos.getZ(), FeatureRegistry.SECRET_BROWSE.getColor(), partialTicks); + RenderUtils.highlightBlock(pos, FeatureRegistry.SECRET_BROWSE.getColor(), partialTicks); + } 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) { if (poses != null){ - RenderUtils.drawLines(poses, FeatureRegistry.SECRET_BROWSE.getColor(), FeatureRegistry.SECRET_BROWSE.getThickness(), partialTicks, true); + RenderUtils.drawLinesVec3(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; + private List<Vec3> poses; + private Future<List<Vec3>> latestFuture; @Override public void onTick(DungeonRoom dungeonRoom) { 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 beaa4076..b2746157 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMoveNearestAir.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMoveNearestAir.java @@ -29,6 +29,7 @@ import net.minecraft.pathfinding.PathEntity; import net.minecraft.pathfinding.PathPoint; import net.minecraft.util.BlockPos; import net.minecraft.util.MathHelper; +import net.minecraft.util.Vec3; import java.awt.*; import java.util.ArrayList; @@ -64,22 +65,23 @@ public class ActionMoveNearestAir extends AbstractAction { float multiplier = distance / 120f; //mobs only render ~120 blocks away float scale = 0.45f * multiplier; scale *= 25.0 / 6.0; + if (FeatureRegistry.SECRET_BEACONS.isEnabled()) { + RenderUtils.renderBeaconBeam(pos.getX(), pos.getY(), pos.getZ(), FeatureRegistry.SECRET_BROWSE.getColor(), partialTicks); + RenderUtils.highlightBlock(pos, FeatureRegistry.SECRET_BROWSE.getColor(), partialTicks); + } 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) { if (poses != null){ - RenderUtils.drawLines(poses, FeatureRegistry.SECRET_BROWSE.getColor(), FeatureRegistry.SECRET_BROWSE.getThickness(), partialTicks, true); + RenderUtils.drawLinesVec3(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; + private List<Vec3> poses; + private Future<List<Vec3>> 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/tree/ActionRoute.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/tree/ActionRoute.java index cdfc5040..76fe5c85 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 @@ -18,10 +18,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.actions.*; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.events.PlayerInteractEntityEvent; import lombok.Getter; @@ -80,7 +77,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); + if (current -1 >= 0 && (actions.get(current-1) instanceof ActionMove || actions.get(current-1) instanceof ActionMoveNearestAir)) actions.get(current-1).onRenderWorld(dungeonRoom, partialTicks); getCurrentAction().onRenderWorld(dungeonRoom, partialTicks); } @@ -92,6 +89,7 @@ public class ActionRoute { Action current = getCurrentAction(); current.onTick(dungeonRoom); + if (this.current -1 >= 0 && (actions.get(this.current-1) instanceof ActionMove || actions.get(this.current-1) instanceof ActionMoveNearestAir)) actions.get(this.current-1).onTick(dungeonRoom); if (dungeonRoom.getMechanics().get(mechanic).getCurrentState(dungeonRoom).equals(state)) { this.current = actions.size() - 1; 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 85970fa3..c68cb511 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java @@ -26,6 +26,8 @@ import kr.syeyoung.dungeonsguide.dungeon.doorfinder.DungeonDoor; import kr.syeyoung.dungeonsguide.dungeon.events.DungeonStateChangeEvent; import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonMechanic; import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonRoomDoor; +import kr.syeyoung.dungeonsguide.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.pathfinding.JPSPathfinder; import kr.syeyoung.dungeonsguide.pathfinding.NodeProcessorDungeonRoom; import kr.syeyoung.dungeonsguide.roomedit.EditingContext; import kr.syeyoung.dungeonsguide.roomprocessor.ProcessorFactory; @@ -40,6 +42,7 @@ import net.minecraft.pathfinding.PathEntity; import net.minecraft.pathfinding.PathFinder; import net.minecraft.pathfinding.PathPoint; import net.minecraft.util.BlockPos; +import net.minecraft.util.Vec3; import net.minecraft.world.IBlockAccess; import javax.vecmath.Vector2d; @@ -91,22 +94,33 @@ public class DungeonRoom { this.currentState = currentState; } - public ScheduledFuture<List<BlockPos>> createEntityPathTo(IBlockAccess blockaccess, Entity entityIn, BlockPos targetPos, float dist) { - 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<>(); - for (int i = 0; i < latest.getCurrentPathLength(); i++) { - PathPoint pathPoint = latest.getPathPointFromIndex(i); - poses.add(getMin().add(pathPoint.xCoord, pathPoint.yCoord, pathPoint.zCoord)); + public ScheduledFuture<List<Vec3>> createEntityPathTo(IBlockAccess blockaccess, Entity entityIn, BlockPos targetPos, float dist) { + if (FeatureRegistry.SECRET_PATHFIND_STRATEGY.isEnabled()) { + ScheduledFuture<List<Vec3>> sf = asyncPathFinder.schedule(() -> { + BlockPos min = new BlockPos(getMin().getX(), 0, getMin().getZ()); + BlockPos max= new BlockPos(getMax().getX(), 255, getMax().getZ()); + JPSPathfinder pathFinder = new JPSPathfinder(context.getWorld(), min, max); + pathFinder.pathfind(entityIn.getPositionVector(), new Vec3(targetPos).addVector(0.5, 0.5, 0.5), 1.5f,1000); + return pathFinder.getRoute(); + }, 0, TimeUnit.MILLISECONDS); + return sf; + } else { + ScheduledFuture<List<Vec3>> sf = asyncPathFinder.schedule(() -> { + PathFinder pathFinder = new PathFinder(nodeProcessorDungeonRoom); + PathEntity latest = pathFinder.createEntityPathTo(blockaccess, entityIn, targetPos, dist); + if (latest != null) { + List<Vec3> poses = new ArrayList<>(); + for (int i = 0; i < latest.getCurrentPathLength(); i++) { + PathPoint pathPoint = latest.getPathPointFromIndex(i); + poses.add(new Vec3(getMin().add(pathPoint.xCoord, pathPoint.yCoord, pathPoint.zCoord)).addVector(0.5,0.5,0.5)); + } + return poses; } - return poses; - } - return new ArrayList<>(); - }, 0, TimeUnit.MILLISECONDS); - asyncPathFinder.schedule(() -> sf.cancel(true), 10, TimeUnit.SECONDS); - return sf; + return new ArrayList<>(); + }, 0, TimeUnit.MILLISECONDS); + asyncPathFinder.schedule(() -> sf.cancel(true), 10, TimeUnit.SECONDS); + return sf; + } } private static final ScheduledExecutorService asyncPathFinder = Executors.newScheduledThreadPool(4); |