diff options
author | syeyoung <42869671+cyoung06@users.noreply.github.com> | 2020-11-27 22:24:48 +0900 |
---|---|---|
committer | syeyoung <42869671+cyoung06@users.noreply.github.com> | 2020-11-27 22:24:48 +0900 |
commit | 314be153363dbf4d457363b70e7af77fd13d19c9 (patch) | |
tree | 8e7bd94e7623ce3193e13d6a7c6b1502448749cb /src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle | |
parent | b446655945ba1d9b92155f7fc43b37f0f2821c2a (diff) | |
download | Skyblock-Dungeons-Guide-314be153363dbf4d457363b70e7af77fd13d19c9.tar.gz Skyblock-Dungeons-Guide-314be153363dbf4d457363b70e7af77fd13d19c9.tar.bz2 Skyblock-Dungeons-Guide-314be153363dbf4d457363b70e7af77fd13d19c9.zip |
WATER PUZZLE SOLVER DONE. PERIOD.
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle')
7 files changed, 83 insertions, 21 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/RoomProcessorWaterPuzzle.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/RoomProcessorWaterPuzzle.java index 5cb5502a..0eaadf43 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/RoomProcessorWaterPuzzle.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/RoomProcessorWaterPuzzle.java @@ -62,28 +62,36 @@ public class RoomProcessorWaterPuzzle extends GeneralRoomProcessor { super.drawScreen(partialTicks); if (!argumentsFulfilled) return; FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - fr.drawString("To Open: "+waterBoard.getReqOpen(),0,200, 0xFFFFFF); - fr.drawString("Target: "+waterBoard.getTarget2(),0,200, 0xFFFFFF); + if (waterBoard == null) return; + fr.drawString("To Open: "+waterBoard.getReqOpen(),0,160, 0xFFFFFF); + fr.drawString("Target: "+waterBoard.getTarget2(),0,180, 0xFFFFFF); } @Override public void drawWorld(float partialTicks) { super.drawWorld(partialTicks); if (!argumentsFulfilled) return; - BlockPos target = waterBoard.getTarget(); - if (target != null) { - RenderUtils.highlightBlock(target, new Color(0,255,255,255), partialTicks); - } + if (waterBoard == null) return; + Route route = waterBoard.getCurrentRoute(); if (route != null) { for (WaterCondition condition : route.getConditionList()) { + if (condition == null) continue; SwitchData switchData = waterBoard.getValidSwitches().get(condition.getBlockId()); if (switchData.getCurrentState() != condition.isRequiredState()) { RenderUtils.highlightBlock(switchData.getSwitchLoc(), new Color(0,255,0,50), partialTicks); - RenderUtils.drawTextAtWorld(condition.isRequiredState() ? "on":"off",switchData.getSwitchLoc().getX(), switchData.getSwitchLoc().getY(), switchData.getSwitchLoc().getZ(), 0xFF000000,1.0f, false, false, partialTicks); + RenderUtils.drawTextAtWorld(condition.isRequiredState() ? "on":"off",switchData.getSwitchLoc().getX(), switchData.getSwitchLoc().getY(), switchData.getSwitchLoc().getZ(), 0xFF000000,0.1f, false, false, partialTicks); } } + for (WaterNode node : route.getNodes()) { + RenderUtils.highlightBlock(node.getBlockPos(), new Color(0,255,255,50), partialTicks); + } + } + BlockPos target = waterBoard.getTarget(); + if (target != null) { + RenderUtils.highlightBlock(target, new Color(0,255,255,255), partialTicks); } +// RenderUtils.highlightBlock(waterBoard.get); } public static class Generator implements RoomProcessorGenerator<RoomProcessorWaterPuzzle> { diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/WaterBoard.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/WaterBoard.java index f0f30f0a..7894af26 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/WaterBoard.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/WaterBoard.java @@ -11,6 +11,7 @@ import net.minecraft.init.Blocks; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.world.World; +import org.lwjgl.Sys; import javax.vecmath.Vector2d; import java.awt.*; @@ -18,6 +19,7 @@ import java.util.*; import java.util.List; public class WaterBoard { + @Getter WaterNode[][] board; RoomProcessorWaterPuzzle waterPuzzle; @@ -64,7 +66,7 @@ public class WaterBoard { World w= waterPuzzle.getDungeonRoom().getContext().getWorld(); BlockLever.EnumOrientation enumOrientation = w.getBlockState(pos).getValue(BlockLever.FACING); EnumFacing enumFacing = enumOrientation.getFacing(); - BlockPos newPos = pos.add(enumFacing.getDirectionVec()); + BlockPos newPos = pos.add(-enumFacing.getDirectionVec().getX(),0,-enumFacing.getDirectionVec().getZ()); int id = Block.getIdFromBlock(w.getChunkFromBlockCoords(newPos).getBlock(newPos)); int data = w.getChunkFromBlockCoords(newPos).getBlockMetadata(newPos); @@ -87,7 +89,6 @@ public class WaterBoard { doorsToOpen.add(Block.getIdFromBlock(b)+":"+offsetPoint.getData(waterPuzzle.getDungeonRoom())); } } - if (!(reqOpen.containsAll(doorsToOpen) && doorsToOpen.containsAll(reqOpen))) { reqOpen = doorsToOpen; if (doorsToOpen.size() != 0) { @@ -101,6 +102,7 @@ public class WaterBoard { private final Set<Point> possibleDir = Sets.newHashSet(new Point(0,-1), new Point(1,0), new Point(-1, 0)); public Route pathFind(WaterNodeEnd endNode) { + Route start = new Route(); start.setX(endNode.getX()); start.setY(endNode.getY()); @@ -112,21 +114,21 @@ public class WaterBoard { Route r2 = routes.poll(); int x = r2.getX(); int y = r2.getY(); - int size = 0; for (Point vec:possibleDir) { WaterNode node = getNodeAt(x + vec.x, y + vec.y); + if (node == null) continue; - if (r2.getNodes().contains(node)) continue;; + if (r2.getNodes().contains(node)) continue; if (!node.canWaterGoThrough()) continue; - size ++; + Route r = r2.clone(); r.getNodes().add(node); r.getConditionList().add(node.getCondition()); - r.setX(node.getX()); - r.setY(node.getY()); + r.setX(x + vec.x); + r.setY(y + vec.y); WaterNode void2 = getNodeAt(r.getX(), r.getY() + 1); - if ((void2 == null || void2.getCondition() == null) && !r.getNodes().contains(void2)) { + if ((void2 == null || (void2.canWaterGoThrough() && void2.getCondition() == null)) && !r.getNodes().contains(void2)) { continue; } @@ -166,21 +168,50 @@ public class WaterBoard { int end = node.getX() + offset; int y = node.getY() + 2; int y2 = node.getY() + 1; + System.out.println("Y Change detected :: offset: "+offset+" start: "+start+" end" + end + " detect X"+node.getX()); + boolean visited_offsetPt = false; for (int x = start; (start < end) ? (x <= end) : (x >= end); x += (start < end) ?1:-1){ WaterNode node2 = getNodeAt(x, y2); + if (node2 == null || !node2.canWaterGoThrough()) break; + + if (node2.canWaterGoThrough() && node2.getCondition() != null) { + WaterCondition condition = node2.getCondition().invert(); + if (visited_offsetPt) { + boolean isConditionContradicting = false; + for (WaterCondition wc : r.getConditionList()) { + if (wc ==null) continue; + if (!wc.getBlockId().equals(condition.getBlockId())) continue; + if (wc.isRequiredState() == condition.isRequiredState()) continue; + isConditionContradicting = true; + break; + } + if (!isConditionContradicting) { + System.out.println("Found midBlock, exiting check"); + r.getConditionList().add(condition); + break; + } + } + } node2 = getNodeAt(x, y); - if (node2 == null || node2.getCondition() == null) { + System.out.println("Checking "+x+","+y+"to me non water go throughable:: "+node2); + if ((node2.canWaterGoThrough() && node2.getCondition() == null)) { + System.out.println("Contradiction found!"); r.getConditionList().add(new WaterConditionContradict()); return; } else { - r.getConditionList().add(node2.getCondition().invert()); + if (node2.getCondition() != null) { + System.out.println("Adding Condition:: " + node2.getCondition().invert()); + r.getConditionList().add(node2.getCondition().invert()); + } } + if (x == node.getX()) visited_offsetPt = true; } } } startX = node.getX(); + prevY = currY; } } } @@ -195,7 +226,7 @@ public class WaterBoard { List<OffsetPoint> frontPoints = frontPlate.getOffsetPointList(); List<OffsetPoint> backPoints = backPlate.getOffsetPointList(); - board = new WaterNode[19][25]; + board = new WaterNode[25][19]; for (int x = 0; x < 19; x++) { for (int y = 0; y < 25; y++) { OffsetPoint front = frontPoints.get(x *25 +y); @@ -205,13 +236,13 @@ public class WaterBoard { int frontData = front.getData(waterPuzzle.getDungeonRoom()); int backData = back.getData(waterPuzzle.getDungeonRoom()); WaterNode node; - if (validSwitches.containsKey(backId +":"+backData) && frontId == 0) { + if (validSwitches.containsKey(backId +":"+backData)) { String resId = backId + ":"+backData; node = new WaterNodeToggleable(resId, isSwitchActive(validSwitches.get(resId)), front.getBlockPos(waterPuzzle.getDungeonRoom()),x,y); } else if (validSwitches.containsKey(frontId +":"+frontData)) { String resId = frontId +":"+frontData; node = new WaterNodeToggleable(resId, !isSwitchActive(validSwitches.get(resId)), front.getBlockPos(waterPuzzle.getDungeonRoom()),x,y); - } else if (frontId == 0) { + } else if (frontId == 0 || frontId == 8 || frontId == 9) { if (y == 24) { OffsetPoint pos; if (x != 0) { @@ -224,7 +255,7 @@ public class WaterBoard { int data= pos.getData(waterPuzzle.getDungeonRoom()); node = new WaterNodeEnd(id+":"+data, front.getBlockPos(waterPuzzle.getDungeonRoom()),x,y); waterNodeEndMap.put(id+":"+data, (WaterNodeEnd) node); - } else if (y == 0) { + } else if (y == 3) { waterNodeStart = (WaterNodeStart) (node = new WaterNodeStart(front.getBlockPos(waterPuzzle.getDungeonRoom()),x,y)); } else { node = new WaterNodeAir(front.getBlockPos(waterPuzzle.getDungeonRoom()),x,y); @@ -241,6 +272,7 @@ public class WaterBoard { private boolean checkContradiction(Set<WaterCondition> conditions) { Map<String, Boolean> conditionMap = new HashMap<String, Boolean>(); for (WaterCondition condition : conditions) { + if (condition == null) continue; if (condition instanceof WaterConditionContradict) return true; if (conditionMap.containsKey(condition.getBlockId())) { if (conditionMap.get(condition.getBlockId()) != condition.isRequiredState()) diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeAir.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeAir.java index d22fde2e..265bebbe 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeAir.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeAir.java @@ -34,4 +34,8 @@ public class WaterNodeAir implements WaterNode { } private int x,y; + + public String toString() { + return "A"; + } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeEnd.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeEnd.java index 1cc079e2..2c047358 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeEnd.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeEnd.java @@ -35,4 +35,8 @@ public class WaterNodeEnd implements WaterNode { return blockPos; } private int x,y; + + public String toString() { + return "E"; + } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeStart.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeStart.java index 11661fcc..7c7d8e91 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeStart.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeStart.java @@ -36,4 +36,8 @@ public class WaterNodeStart implements WaterNode { return blockPos; } private int x,y; + + public String toString() { + return "S"; + } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeToggleable.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeToggleable.java index cc714129..6870f3c4 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeToggleable.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeToggleable.java @@ -39,4 +39,9 @@ public class WaterNodeToggleable implements WaterNode { public BlockPos getBlockPos() { return blockPos; } + + + public String toString() { + return "T:"+blockId+(invert ? ":Y":":N"); + } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeWall.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeWall.java index 18260adf..68b68df7 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeWall.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeWall.java @@ -36,4 +36,9 @@ public class WaterNodeWall implements WaterNode { public BlockPos getBlockPos() { return blockPos; } + + + public String toString() { + return "W"; + } } |