diff options
Diffstat (limited to 'src/main/java/kr')
10 files changed, 72 insertions, 130 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java b/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java index 7554c6b5..9c4357be 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java @@ -26,10 +26,8 @@ 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; import kr.syeyoung.dungeonsguide.party.PartyManager; import kr.syeyoung.dungeonsguide.resources.DGTexturePack; import kr.syeyoung.dungeonsguide.rpc.RichPresenceManager; @@ -121,8 +119,6 @@ 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 82f5af4f..8ef26e1e 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java @@ -19,13 +19,8 @@ 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; import kr.syeyoung.dungeonsguide.config.guiconfig.GuiConfigV2; @@ -46,7 +41,6 @@ import kr.syeyoung.dungeonsguide.features.AbstractFeature; import kr.syeyoung.dungeonsguide.features.FeatureRegistry; import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.FeatureViewPlayerOnJoin; import kr.syeyoung.dungeonsguide.features.impl.party.api.ApiFetchur; -import kr.syeyoung.dungeonsguide.features.impl.discord.inviteViewer.PartyInviteViewer; import kr.syeyoung.dungeonsguide.party.PartyManager; import kr.syeyoung.dungeonsguide.roomedit.EditingContext; import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonRoomEdit; @@ -537,24 +531,6 @@ 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 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); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/PathfindListener.java b/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/PathfindListener.java deleted file mode 100644 index fb19063d..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/PathfindListener.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * 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 72eb809b..be20aa8e 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java @@ -165,6 +165,8 @@ public class FeatureRegistry { 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_PATHFIND_STRATEGY = register(new SimpleFeature("Dungeon Secret.Secret Pathfind", "Use NEW JPS Optimization instead of standard A Star", "Faster, and accurate routes.", "secret.secretpathfind.algorithm", true)); + 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()); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/pathfinding/JPSPathfinder.java b/src/main/java/kr/syeyoung/dungeonsguide/pathfinding/JPSPathfinder.java index 42595d2f..b824c731 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/pathfinding/JPSPathfinder.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/pathfinding/JPSPathfinder.java @@ -103,9 +103,14 @@ public class JPSPathfinder { long arr[]; - public boolean pathfind(Vec3 from, Vec3 to) { + public boolean pathfind(Vec3 from, Vec3 to, float within, long timeout) { route.clear(); nodeMap.clearMap(); + { + from = new Vec3(((int)(from.xCoord * 2)) / 2.0, ((int)(from.yCoord * 2)) / 2.0, ((int)(from.zCoord* 2)) / 2.0); + to = new Vec3(((int)(to.xCoord * 2)) / 2.0, ((int)(to.yCoord * 2)) / 2.0, ((int)(to.zCoord* 2)) / 2.0); + } + this.start = from; this.destination = to; tx = (int)(to.xCoord * 2); ty = (int)(to.yCoord * 2); @@ -113,14 +118,14 @@ public class JPSPathfinder { arr = new long[lenx *leny * lenz * 2 / 8]; - destinationBB = AxisAlignedBB.fromBounds((to.xCoord - 0.6)* 2, (to.yCoord - 0.6) * 2, (to.zCoord - 0.6) * 2, (to.xCoord + 0.6) * 2, (to.yCoord + 0.6)* 2, (to.zCoord + 0.6) *2); + destinationBB = AxisAlignedBB.fromBounds((to.xCoord - within)* 2, (to.yCoord - within) * 2, (to.zCoord - within) * 2, (to.xCoord + within) * 2, (to.yCoord + within)* 2, (to.zCoord + within) *2); open.clear(); Node start; open.add(start = openNode((int)from.xCoord* 2 + 1, (int)from.yCoord* 2 + 1, (int)from.zCoord * 2 + 1)); start.g = 0; start.f = 0; start.h = (float) from.squareDistanceTo(to); Node end = null; float minDist = Float.MAX_VALUE; - long forceEnd = System.currentTimeMillis() + 5000; + long forceEnd = System.currentTimeMillis() + timeout; while(!open.isEmpty()) { if (forceEnd < System.currentTimeMillis()) break; Node n = open.poll(); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java index b0c54e17..9efb7a78 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java @@ -55,6 +55,15 @@ public class RenderUtils { * @author Moulberry */ public static void renderBeaconBeam(double x, double y, double z, AColor aColor, float partialTicks) { + Entity player = Minecraft.getMinecraft().thePlayer; + double playerX = player.prevPosX + (player.posX - player.prevPosX) * partialTicks; + double playerY = player.prevPosY + (player.posY - player.prevPosY) * partialTicks; + double playerZ = player.prevPosZ + (player.posZ - player.prevPosZ) * partialTicks; +//because of the way 3D rendering is done, all coordinates are relative to the camera. This "resets" the "0,0,0" position to the location that is (0,0,0) in the world. + + + GlStateManager.pushMatrix(); + GlStateManager.translate(-playerX, -playerY, -playerZ); int height = 300; int bottomOffset = 0; int topOffset = bottomOffset + height; @@ -66,6 +75,7 @@ public class RenderUtils { GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, 10497.0F); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, 10497.0F); GlStateManager.disableLighting(); + GlStateManager.disableDepth(); GlStateManager.enableCull(); GlStateManager.enableTexture2D(); GlStateManager.tryBlendFuncSeparate(770, 1, 1, 0); @@ -133,6 +143,10 @@ public class RenderUtils { worldrenderer.pos(x + 0.2D, y + bottomOffset, z + 0.2D).tex(0.0D, d12).color(r, g, b, 0.25F).endVertex(); worldrenderer.pos(x + 0.2D, y + topOffset, z + 0.2D).tex(0.0D, d13).color(r, g, b, 0.25F*alpha).endVertex(); tessellator.draw(); + + GlStateManager.enableDepth(); + + GlStateManager.popMatrix(); } |