diff options
author | syeyoung <cyong06@naver.com> | 2021-02-03 17:51:25 +0900 |
---|---|---|
committer | syeyoung <cyong06@naver.com> | 2021-02-03 17:51:25 +0900 |
commit | 216bf76d3375f315962878cae03a73d4f1c11cea (patch) | |
tree | 05c4112ac4a76824d03bf96d64d3f7206cb284b1 /src/main/java/kr/syeyoung/dungeonsguide | |
parent | 246268a03f302bbcbe0dbf1c9c7f6042edb2bfd2 (diff) | |
download | Skyblock-Dungeons-Guide-216bf76d3375f315962878cae03a73d4f1c11cea.tar.gz Skyblock-Dungeons-Guide-216bf76d3375f315962878cae03a73d4f1c11cea.tar.bz2 Skyblock-Dungeons-Guide-216bf76d3375f315962878cae03a73d4f1c11cea.zip |
Actually do calculation for teleport
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide')
-rwxr-xr-x | src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTeleportMazeSolver.java | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTeleportMazeSolver.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTeleportMazeSolver.java index 257a0bee..4949f0f9 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTeleportMazeSolver.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTeleportMazeSolver.java @@ -9,38 +9,84 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.init.Blocks; import net.minecraft.util.BlockPos; +import net.minecraft.util.Vec3; import net.minecraft.world.World; import java.awt.*; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; public class RoomProcessorTeleportMazeSolver extends GeneralRoomProcessor { private BlockPos lastPlayerLocation; public RoomProcessorTeleportMazeSolver(DungeonRoom dungeonRoom) { super(dungeonRoom); + yLevel = dungeonRoom.getMin().getY() - 1; } private List<BlockPos> visitedPortals = new ArrayList<BlockPos>(); + private int yLevel = 0; + private double slope1, slope2; + private double posX1, posZ1, posX2, posZ2; + private int times=0 ; + + private double intersectionX, intersectionZ; + private BlockPos intersection; + @Override public void tick() { super.tick(); + + World w = getDungeonRoom().getContext().getWorld(); EntityPlayerSP entityPlayerSP = Minecraft.getMinecraft().thePlayer; BlockPos pos2 = new BlockPos(Math.floor(entityPlayerSP.posX), Math.floor(entityPlayerSP.posY), Math.floor(entityPlayerSP.posZ)); Block b = w.getChunkFromBlockCoords(pos2).getBlock(pos2); + Vec3 lookVec = entityPlayerSP.getLookVec(); + + if (times % 4 == 1) { + posX1 = entityPlayerSP.posX; + posZ1 = entityPlayerSP.posZ; + slope1 = lookVec.zCoord / lookVec.xCoord; + times ++; + } else if (times % 4 == 3 && intersection == null) { + posX2 = entityPlayerSP.posX; + posZ2 = entityPlayerSP.posZ; + slope2 = lookVec.zCoord / lookVec.xCoord; + + double yInt1 = posZ1 - posX1 * slope1; + double yInt2 = posZ2 - posX2 * slope2; + + System.out.println("pos1 (" + posX1 + "," + posZ1 + ") pos2 (" + posX2 + "," + posZ2 + ") slope (" + slope1 + "," + slope2 + ") intercept (" + yInt1 + "," + yInt2 + ")"); + + intersectionX = (yInt2 - yInt1) / (slope1 - slope2); + intersectionZ = (slope1 * intersectionX + yInt1); + intersection = new BlockPos((int) intersectionX, yLevel, (int) intersectionZ); + times++; + } + if (b == Blocks.stone_slab || b == Blocks.stone_slab2) { boolean teleport = false; + if (lastPlayerLocation.distanceSq(pos2) < 3) return; for (BlockPos allInBox : BlockPos.getAllInBox(lastPlayerLocation, pos2)) { if (w.getChunkFromBlockCoords(allInBox).getBlock(allInBox) == Blocks.iron_bars) { teleport = true; break; } } + if (teleport) { + System.out.println(lookVec +" - "+ (times %2)); + if (times % 4 == 0) { + times ++; + } else if (times % 4 == 2){ + times++; + } + for (BlockPos allInBox : BlockPos.getAllInBox(pos2.add(-1, 0, -1), pos2.add(1, 0, 1))) { if (w.getChunkFromBlockCoords(allInBox).getBlock(allInBox) == Blocks.end_portal_frame) { if (!visitedPortals.contains(allInBox)) @@ -68,6 +114,10 @@ public class RoomProcessorTeleportMazeSolver extends GeneralRoomProcessor { for (BlockPos bpos:visitedPortals) { RenderUtils.highlightBlock(bpos, new Color(255,0,0,100), partialTicks, true); } + + if (intersection != null) { + RenderUtils.highlightBlock(intersection, new Color(0, 255, 0, 100), partialTicks, false); + } } public static class Generator implements RoomProcessorGenerator<RoomProcessorTeleportMazeSolver> { @Override |