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 | |
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')
12 files changed, 143 insertions, 30 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/EventListener.java b/src/main/java/kr/syeyoung/dungeonsguide/EventListener.java index b563fcfc..2dd1646b 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/EventListener.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/EventListener.java @@ -112,6 +112,20 @@ public class EventListener { } } + + if (skyblockStatus.getContext() != null) { + EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; + Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); + + DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); + FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj; + if (dungeonRoom != null) { + if (dungeonRoom.getRoomProcessor() != null) + dungeonRoom.getRoomProcessor().drawWorld(renderWorldLastEvent.partialTicks); + } + + } + if (EditingContext.getEditingContext() != null) { GuiScreen guiScreen = EditingContext.getEditingContext().getCurrent(); if (guiScreen instanceof GuiDungeonParameterEdit) { diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/OffsetPoint.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/OffsetPoint.java index b6497872..5a333143 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/OffsetPoint.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/OffsetPoint.java @@ -23,11 +23,14 @@ public class OffsetPoint implements Cloneable, Serializable { public void setPosInWorld(DungeonRoom dungeonRoom, BlockPos pos) { Vector2d vector2d = new Vector2d(pos.getX() - dungeonRoom.getMin().getX(), pos.getZ() - dungeonRoom.getMin().getZ()); - for (int i = 0; i < dungeonRoom.getRoomMatcher().getRotation(); i++) + for (int i = 0; i < dungeonRoom.getRoomMatcher().getRotation(); i++) { vector2d = VectorUtils.rotateClockwise(vector2d); - - if (vector2d.x < 0) vector2d.x += dungeonRoom.getDungeonRoomInfo().getBlocks()[0].length - 1; - if (vector2d.y < 0) vector2d.y += dungeonRoom.getDungeonRoomInfo().getBlocks().length - 1; + if (i % 2 == 0) { + vector2d.x += dungeonRoom.getDungeonRoomInfo().getBlocks().length - 1; + } else { + vector2d.x += dungeonRoom.getDungeonRoomInfo().getBlocks()[0].length - 1; + } + } this.x = (int) vector2d.x; this.z = (int) vector2d.y; @@ -37,11 +40,16 @@ public class OffsetPoint implements Cloneable, Serializable { public BlockPos toRotatedRelBlockPos(DungeonRoom dungeonRoom) { int rot = dungeonRoom.getRoomMatcher().getRotation(); Vector2d rot2 = new Vector2d(x,z); +// System.out.println("Before rot " +rot2); for (int i = 0; i < dungeonRoom.getRoomMatcher().getRotation(); i++) { rot2 = VectorUtils.rotateCounterClockwise(rot2); + if (i % 2 == 0) { + rot2.y += dungeonRoom.getMax().getX() - dungeonRoom.getMin().getX() + 1; + } else { + rot2.y += dungeonRoom.getMax().getZ() - dungeonRoom.getMin().getZ() + 1; + } } - if (rot2.x < 0) rot2.x += dungeonRoom.getMax().getX() - dungeonRoom.getMin().getX() + 2; - if (rot2.y < 0) rot2.y += dungeonRoom.getMax().getZ() - dungeonRoom.getMin().getZ() + 2; +// System.out.println("After rot "+rot+" / "+rot2); return new BlockPos(rot2.x, y, rot2.y); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditOffsetPointSet.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditOffsetPointSet.java index cf617143..6eadbff7 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditOffsetPointSet.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditOffsetPointSet.java @@ -66,6 +66,35 @@ public class ValueEditOffsetPointSet extends MPanel implements ValueEdit<OffsetP } @Override + public boolean mouseClicked0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int mouseButton) { + if (!bounds.contains(relMouseX0, relMouseY0)) { + return false; + } + + int relMousex = relMouseX0 - bounds.x; + int relMousey = relMouseY0 - bounds.y; + + boolean noClip = true; + boolean focusedOverall = false; + for (MPanel childComponent : getChildComponents()) { + if (childComponent.mouseClicked0(absMouseX, absMouseY, relMousex, relMousey, mouseButton)) { + noClip = false; + focusedOverall = true; + } + } + + if (bounds.contains(relMouseX0, relMouseY0) && noClip) { + isFocused = true; + focusedOverall = true; + } else { + isFocused = false; + } + + mouseClicked(absMouseX, absMouseY, relMousex, relMousey, mouseButton); + return focusedOverall; + } + + @Override public void onBoundsUpdate() { for (MPanel panel :getChildComponents()){ panel.setSize(new Dimension(bounds.width, 20)); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorBlazeSolver.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorBlazeSolver.java index 54f09010..27062e26 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorBlazeSolver.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorBlazeSolver.java @@ -79,7 +79,7 @@ public class RoomProcessorBlazeSolver extends GeneralRoomProcessor { super.drawWorld(partialTicks); if (next == null) return; Vec3 pos = next.getPositionEyes(partialTicks); - RenderUtils.drawTextAtWorld("NEXT", (float)pos.xCoord, (float)pos.yCoord, (float)pos.zCoord, 0xFFFF0000, 3, true, false, partialTicks); + RenderUtils.drawTextAtWorld("NEXT", (float)pos.xCoord, (float)pos.yCoord, (float)pos.zCoord, 0xFF00ff00, 0.5f, true, false, partialTicks); RenderUtils.highlightBlock(next.getPosition(), new Color(0,255,0,50), partialTicks); } 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"; + } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/VectorUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/VectorUtils.java index 89a4e7d1..14d3b7c1 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/utils/VectorUtils.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/utils/VectorUtils.java @@ -4,9 +4,9 @@ import javax.vecmath.Vector2d; public class VectorUtils { public static Vector2d rotateCounterClockwise(Vector2d vector2d) { - return new Vector2d(-vector2d.y, vector2d.x); + return new Vector2d(vector2d.y, -vector2d.x); } public static Vector2d rotateClockwise(Vector2d vector2d) { - return new Vector2d(vector2d.y, -vector2d.x); + return new Vector2d(-vector2d.y, vector2d.x); } } |