aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--options.txt4
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/EventListener.java1
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java7
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/ProcessorFactory.java6
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorCreeperSolver.java52
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorIcePath.java241
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorIcePath2.java125
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorRiddle.java35
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTeleportMazeSolver.java26
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java73
10 files changed, 515 insertions, 55 deletions
diff --git a/options.txt b/options.txt
index 9db0f045..e4415bfd 100644
--- a/options.txt
+++ b/options.txt
@@ -5,7 +5,7 @@ gamma:0.0
saturation:0.0
renderDistance:12
guiScale:2
-particles:0
+particles:2
bobView:true
anaglyph3d:false
maxFps:120
@@ -24,7 +24,7 @@ chatLinks:true
chatLinksPrompt:true
chatOpacity:1.0
snooperEnabled:true
-fullscreen:true
+fullscreen:false
enableVsync:true
useVbo:false
hideServerAddress:false
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/EventListener.java b/src/main/java/kr/syeyoung/dungeonsguide/EventListener.java
index 8856dd81..c8a7b664 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/EventListener.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/EventListener.java
@@ -103,6 +103,7 @@ public class EventListener {
@SubscribeEvent
public void onChatReceived(ClientChatReceivedEvent clientChatReceivedEvent) {
+ if (clientChatReceivedEvent.type == 2) return;
SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus();
if (!skyblockStatus.isOnDungeon()) return;
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java
index a88c0e43..32124452 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java
@@ -40,6 +40,7 @@ public class MapProcessor {
private static final Set<Vector2d> directions = Sets.newHashSet(new Vector2d(0,1), new Vector2d(0, -1), new Vector2d(1, 0), new Vector2d(-1 , 0));
+ private int waitCnt = 0;
private void buildMap(final byte[] mapData) {
final Point startroom = MapUtils.findFirstColorWithIn(mapData, (byte) 30, new Rectangle(0,0,128,128));
if (startroom == null){
@@ -243,10 +244,14 @@ public class MapProcessor {
pt.translate(xOff, yOff);
byte unit3 = MapUtils.getMapColorAt(mapData, pt.x, pt.y);
- return unit1 == unit2 && unit2 == unit3;
+ return unit1 == unit2 && unit2 == unit3 && unit1 != 0;
}
public void tick() {
+ if (waitCnt < 5) {
+ waitCnt++;
+ return;
+ }
if (bugged) return;
ItemStack stack = Minecraft.getMinecraft().thePlayer.inventory.getStackInSlot(8);
byte[] mapData;
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/ProcessorFactory.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/ProcessorFactory.java
index d3b685c8..a73e542b 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/ProcessorFactory.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/ProcessorFactory.java
@@ -31,5 +31,11 @@ public class ProcessorFactory {
registerRoomProcessor("puzzle_tictactoe_solver", new RoomProcessorTicTacToeSolver.Generator());
registerRoomProcessor("puzzle_blaze_solver", new RoomProcessorBlazeSolver.Generator());
+
+
+ registerRoomProcessor("puzzle_silverfish", new RoomProcessorIcePath.Generator()); // done
+
+
+ registerRoomProcessor("puzzle_icefill", new RoomProcessorIcePath2.Generator());
}
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorCreeperSolver.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorCreeperSolver.java
index af075f2b..0b49fcf2 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorCreeperSolver.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorCreeperSolver.java
@@ -12,9 +12,11 @@ import net.minecraft.entity.item.EntityArmorStand;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.init.Blocks;
import net.minecraft.util.BlockPos;
+import net.minecraft.util.EnumFacing;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
+import scala.actors.threadpool.Arrays;
import java.awt.*;
import java.util.ArrayList;
@@ -30,20 +32,20 @@ public class RoomProcessorCreeperSolver extends GeneralRoomProcessor {
super(dungeonRoom);
World w = dungeonRoom.getContext().getWorld();
Set<BlockPos> prismarines = new HashSet<BlockPos>();
- final BlockPos low = dungeonRoom.getMin();
- final BlockPos high = dungeonRoom.getMax();
+ final BlockPos low = dungeonRoom.getMin().add(0,-3,0);
+ final BlockPos high = dungeonRoom.getMax().add(0,15,0);
List<EntityCreeper> creeepr = w.getEntities(EntityCreeper.class, new Predicate<EntityCreeper>() {
@Override
public boolean apply(@Nullable EntityCreeper input) {
if (input.isInvisible()) return false;
BlockPos pos = input.getPosition();
return low.getX() < pos.getX() && pos.getX() < high.getX()
- && low.getZ() < pos.getZ() && pos.getZ() < high.getZ() && input.getName().toLowerCase().contains("blaze");
+ && low.getZ() < pos.getZ() && pos.getZ() < high.getZ();
}
});
if (creeepr.isEmpty()) return;
EntityCreeper creeper = creeepr.get(0);
- Vec3 position = creeper.getPositionVector().addVector(0,1.5,0);
+ Vec3 position = creeper.getPositionVector().addVector(0,1,0);
for (BlockPos allInBox : BlockPos.getAllInBox(low, high)) {
Block b = w.getChunkFromBlockCoords(allInBox).getBlock(allInBox);
@@ -53,12 +55,11 @@ public class RoomProcessorCreeperSolver extends GeneralRoomProcessor {
Vec3 vector = new Vec3(allInBox.getX() +0.5, allInBox.getY() +0.5, allInBox.getZ() +0.5);
Vec3 pos = position.subtract(vector).normalize();
-
BlockPos opposite = null;
- for (int i = 0; i < 28;i++) {
+ for (int i = 5; i < 28;i++) {
Vec3 result = vector.addVector(pos.xCoord * i, pos.yCoord * i, pos.zCoord * i);
BlockPos pos3 = new BlockPos(result);
- if (w.getChunkFromBlockCoords(pos3).getBlock(pos3) != Blocks.air) {
+ if (w.getChunkFromBlockCoords(pos3).getBlock(pos3) != Blocks.air && pos3.distanceSq(creeper.getPosition()) > 5) {
opposite = pos3;
}
}
@@ -66,16 +67,28 @@ public class RoomProcessorCreeperSolver extends GeneralRoomProcessor {
BlockPos otherPrismarine = null;
for (BlockPos inBox : BlockPos.getAllInBox(opposite.add(-2, -3, -2), opposite.add(2, 3, 2))) {
- Block b3 = w.getChunkFromBlockCoords(inBox).getBlock(inBox);
- if (b3 == Blocks.prismarine ||b == Blocks.sea_lantern) {
- otherPrismarine = inBox;
- break;
+ if (prismarines.contains(inBox)) continue;
+ if ( low.getX() < inBox.getX() && inBox.getX() < high.getX()
+ && low.getZ() < inBox.getZ() && inBox.getZ() < high.getZ()) {
+ Block b3 = w.getChunkFromBlockCoords(inBox).getBlock(inBox);
+ if (b3 == Blocks.prismarine || b3 == Blocks.sea_lantern) {
+// for (EnumFacing ef : EnumFacing.values()) {
+// BlockPos b4 = inBox.offset(ef);
+// if (w.getChunkFromBlockCoords(b4).getBlock(b4) == Blocks.air) {
+// otherPrismarine = inBox;
+// }
+// }
+// break;
+ otherPrismarine = inBox;
+ break;
+ }
}
}
if (otherPrismarine == null) continue;
prismarines.add(otherPrismarine);
poses.add(new BlockPos[] {allInBox, otherPrismarine});
+ System.out.println("Found Set :: "+allInBox + " / "+otherPrismarine + " / "+opposite+" / "+pos +" / "+position);
}
}
@@ -87,12 +100,19 @@ public class RoomProcessorCreeperSolver extends GeneralRoomProcessor {
public void drawWorld(float partialTicks) {
super.drawWorld(partialTicks);
World w = getDungeonRoom().getContext().getWorld();
+ int index = 0;
for (BlockPos[] poset:poses) {
-// if (w.getChunkFromBlockCoords(poset[0]).getBlock(poset[0]) != Blocks.sea_lantern &&
-// w.getChunkFromBlockCoords(poset[1]).getBlock(poset[1]) != Blocks.sea_lantern) {
-// continue;
-// }
- RenderUtils.drawLine(poset[0], poset[1], new Color(0,255,255,255), partialTicks);
+ index ++;
+ if (w.getChunkFromBlockCoords(poset[0]).getBlock(poset[0]) != Blocks.sea_lantern &&
+ w.getChunkFromBlockCoords(poset[1]).getBlock(poset[1]) != Blocks.sea_lantern) {
+ continue;
+ }
+ RenderUtils.drawLine(new Vec3(poset[0].getX() +0.5, poset[0].getY() +0.5, poset[0].getZ()+0.5),
+ new Vec3(poset[1].getX() +0.5, poset[1].getY() +0.5, poset[1].getZ()+0.5), new Color(index * 10,255,255,255), partialTicks);
+//Re
+// RenderUtils.highlightBlock(poset[0], new Color(0,255,255,50), partialTicks);
+// RenderUtils.highlightBlock(poset[1], new Color(255,0,0,50), partialTicks);
+ // RenderUtils.drawLines(Arrays.asList(new BlockPos[] {poset[0], poset[1], poset[0]}), new Color(0,255,255,255), partialTicks);
}
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorIcePath.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorIcePath.java
new file mode 100644
index 00000000..d2962b31
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorIcePath.java
@@ -0,0 +1,241 @@
+package kr.syeyoung.dungeonsguide.roomprocessor;
+
+import com.google.common.base.Predicate;
+import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint;
+import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet;
+import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom;
+import kr.syeyoung.dungeonsguide.utils.RenderUtils;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.monster.EntitySilverfish;
+import net.minecraft.init.Blocks;
+import net.minecraft.util.BlockPos;
+import org.jetbrains.annotations.Nullable;
+
+import java.awt.*;
+import java.util.*;
+import java.util.List;
+
+public class RoomProcessorIcePath extends GeneralRoomProcessor {
+
+ private int[][] map;
+ private OffsetPoint[][] map2;
+ private Set<OffsetPoint> endNode = new HashSet<OffsetPoint>();
+
+ private final List<BlockPos> solution = new ArrayList<BlockPos>();
+
+ private BlockPos lastSilverfishLoc;
+ private int sameTick;
+
+ private Entity silverfish;
+
+ private boolean err;
+
+ public RoomProcessorIcePath(DungeonRoom dungeonRoom) {
+ super(dungeonRoom);
+ final BlockPos low = dungeonRoom.getMin();
+ final BlockPos high = dungeonRoom.getMax();
+ List<EntitySilverfish> silverfishs = dungeonRoom.getContext().getWorld().getEntities(EntitySilverfish.class, new Predicate<EntitySilverfish>() {
+ @Override
+ public boolean apply(@Nullable EntitySilverfish input) {
+ if (input.isInvisible()) return false;
+ BlockPos pos = input.getPosition();
+ return low.getX() < pos.getX() && pos.getX() < high.getX()
+ && low.getZ() < pos.getZ() && pos.getZ() < high.getZ();
+ }
+ });
+
+ if (!silverfishs.isEmpty()) silverfish = silverfishs.get(0);
+ if (silverfishs.isEmpty()) {
+ err = true;
+ return;
+ }
+ try {
+ buildMap();
+ } catch (Exception e) {
+ e.printStackTrace();;
+ err = true;
+ }
+ }
+
+ private void buildMap() {
+ int width = (Integer) getDungeonRoom().getDungeonRoomInfo().getProperties().get("width");
+ int height = (Integer) getDungeonRoom().getDungeonRoomInfo().getProperties().get("height");
+ OffsetPointSet ops = (OffsetPointSet) getDungeonRoom().getDungeonRoomInfo().getProperties().get("board");
+ OffsetPointSet endNodes = (OffsetPointSet) getDungeonRoom().getDungeonRoomInfo().getProperties().get("endnodes");
+ map2 = new OffsetPoint[width][height];
+ map = new int[width][height];
+ for (int y = 0; y < height; y ++) {
+ for (int x =0; x < width; x++) {
+ OffsetPoint op = ops.getOffsetPointList().get(y * width + x);
+ map2[y][x] = op;
+ map[y][x] = op.getBlock(getDungeonRoom()) == Blocks.air ? 0 : 1;
+ }
+ }
+ endNode.addAll(endNodes.getOffsetPointList());
+ }
+
+ public void tick() {
+ super.tick();
+ if (err) return;
+ if (silverfish.getPosition().equals(lastSilverfishLoc)) {
+ if (sameTick < 10) {
+ sameTick ++;
+ return;
+ } else if (sameTick == 10) {
+ sameTick ++;
+ Point silverfish = getPointOfSilverFishOnMap(this.silverfish.getPosition());
+ List<Point> tempSol = solve(map, silverfish.x, silverfish.y, new Predicate<Point>() {
+ @Override
+ public boolean apply(@Nullable Point input) {
+ return endNode.contains(map2[input.getY()][input.getX()]);
+ }
+ });
+ {
+ solution.clear();
+ for (Point point : tempSol) {
+ solution.add(map2[point.getY()][point.getX()].getBlockPos(getDungeonRoom()));
+ }
+ }
+
+ }
+ } else {
+ sameTick = 0;
+ }
+
+ lastSilverfishLoc = silverfish.getPosition();
+ }
+
+
+ @Override
+ public void drawWorld(float partialTicks) {
+ super.drawWorld(partialTicks);
+ if (!err)
+ RenderUtils.drawLines(solution, new Color(0,255,0, 255), partialTicks);
+ }
+
+ public Point getPointOfSilverFishOnMap(BlockPos blockPos) {
+ for (int y = 0; y < map.length; y ++) {
+ for (int x = 0; x < map[0].length; x++) {
+ if (map2[y][x].getBlockPos(getDungeonRoom()).equals(blockPos))
+ return new Point(x,y);
+ }
+ }
+ return null;
+ }
+
+
+
+ public static List<Point> solve(int[][] iceCave, int startX, int startY, Predicate<Point> isEnd) {
+ Point startPoint = new Point(startX, startY);
+
+ LinkedList<Point> queue = new LinkedList<Point>();
+ Point[][] iceCaveColors = new Point[iceCave.length][iceCave[0].length];
+
+ queue.addLast(new Point(startX, startY));
+ iceCaveColors[startY][startX] = startPoint;
+
+ for (int y = 0; y < iceCave.length; y ++) {
+ for (int x = 0; x < iceCave[y].length; x++) {
+ System.out.print((startX == x && startY == y)? "S\t":iceCave[y][x]+"\t");
+ }
+ System.out.println();
+ }
+
+ while (queue.size() != 0) {
+ Point currPos = queue.pollFirst();
+// System.out.println(currPos);
+ // traverse adjacent nodes while sliding on the ice
+ for (Direction dir : Direction.values()) {
+ Point nextPos = move(iceCave, iceCaveColors, currPos, dir);
+ if (nextPos != null) {
+ queue.addLast(nextPos);
+ iceCaveColors[nextPos.getY()][nextPos.getX()] = new Point(currPos.getX(), currPos.getY());
+ if (isEnd.apply(nextPos)) {
+ // we found the end point
+ List<Point> route = new ArrayList<Point>();
+ Point tmp = currPos; // if we start from nextPos we will count one too many edges
+ int count = 0;
+ route.add(nextPos);
+ route.add(currPos);
+ while (tmp != startPoint) {
+ count++;
+ tmp = iceCaveColors[tmp.getY()][tmp.getX()];
+ route.add(tmp);
+ }
+ System.out.println(route);
+ return route;
+ }
+ }
+ }
+ }
+ return Collections.emptyList();
+ }
+
+ public static Point move(int[][] iceCave, Point[][] iceCaveColors, Point currPos, Direction dir) {
+ int x = currPos.getX();
+ int y = currPos.getY();
+
+ int diffX = (dir == Direction.LEFT ? -1 : (dir == Direction.RIGHT ? 1 : 0));
+ int diffY = (dir == Direction.UP ? -1 : (dir == Direction.DOWN ? 1 : 0));
+
+ int i = 1;
+ while (x + i * diffX >= 0
+ && x + i * diffX < iceCave[0].length
+ && y + i * diffY >= 0
+ && y + i * diffY < iceCave.length
+ && iceCave[y + i * diffY][x + i * diffX] != 1) {
+ i++;
+ }
+
+ i--; // reverse the last step
+
+ if (iceCaveColors[y + i * diffY][x + i * diffX] != null) {
+ // we've already seen this point
+ return null;
+ }
+
+ return new Point(x + i * diffX, y + i * diffY);
+ }
+
+ public static class Point {
+ int x;
+ int y;
+
+ public Point(int x, int y) {
+ this.x = x;
+ this.y = y;
+ }
+
+ public int getX() {
+ return x;
+ }
+
+ public int getY() {
+ return y;
+ }
+
+ @Override
+ public String toString() {
+ return "Point{" +
+ "x=" + x +
+ ", y=" + y +
+ '}';
+ }
+ }
+
+ public enum Direction {
+ LEFT,
+ RIGHT,
+ UP,
+ DOWN
+ }
+
+
+ public static class Generator implements RoomProcessorGenerator<RoomProcessorIcePath> {
+ @Override
+ public RoomProcessorIcePath createNew(DungeonRoom dungeonRoom) {
+ RoomProcessorIcePath defaultRoomProcessor = new RoomProcessorIcePath(dungeonRoom);
+ return defaultRoomProcessor;
+ }
+ }
+}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorIcePath2.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorIcePath2.java
new file mode 100644
index 00000000..6e0553a7
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorIcePath2.java
@@ -0,0 +1,125 @@
+package kr.syeyoung.dungeonsguide.roomprocessor;
+
+import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint;
+import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet;
+import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom;
+import kr.syeyoung.dungeonsguide.utils.RenderUtils;
+import kr.syeyoung.dungeonsguide.utils.TextUtils;
+import net.minecraft.client.Minecraft;
+import net.minecraft.init.Blocks;
+import net.minecraft.util.BlockPos;
+import net.minecraft.util.ChatComponentText;
+import net.minecraft.util.IChatComponent;
+
+import java.awt.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.regex.Pattern;
+
+public class RoomProcessorIcePath2 extends GeneralRoomProcessor {
+ private boolean bugged = false;
+
+ private List<List<BlockPos>> solution = new ArrayList<List<BlockPos>>();
+
+ public RoomProcessorIcePath2(DungeonRoom dungeonRoom) {
+
+ super(dungeonRoom);
+
+ String levels = (String) dungeonRoom.getDungeonRoomInfo().getProperties().get("levels");
+ if (levels == null) {
+ bugged = true;
+ return;
+ }
+
+ for (String s : levels.split(",")) {
+ try {
+ OffsetPointSet level = (OffsetPointSet) dungeonRoom.getDungeonRoomInfo().getProperties().get(s + "-board");
+ String data = (String) dungeonRoom.getDungeonRoomInfo().getProperties().get(s + "-level");
+ int width = Integer.parseInt(data.split(":")[0]);
+ int height = Integer.parseInt(data.split(":")[1]);
+ int startX = Integer.parseInt(data.split(":")[2]);
+ int startY = Integer.parseInt(data.split(":")[3]);
+ int endX = Integer.parseInt(data.split(":")[4]);
+ int endY = Integer.parseInt(data.split(":")[5]);
+
+ int[][] map = new int[height][width];
+ BlockPos[][] map2 = new BlockPos[height][width];
+ for (int y = 0; y < height; y++) {
+ for (int x = 0; x < width; x++) {
+ map2[y][x] = level.getOffsetPointList().get(y * width + x).getBlockPos(dungeonRoom);
+ map[y][x] = level.getOffsetPointList().get(y * width + x).getBlock(dungeonRoom) == Blocks.air ? 0 : 1;
+ }
+ }
+
+ List<Point> hamiltonianPath = findFirstHamiltonianPath(map, startX, startY, endX, endY);
+ if (hamiltonianPath == null) continue;
+ hamiltonianPath.add(0,new Point(startX, startY));
+ List<BlockPos> poses = new LinkedList<BlockPos>();
+ for (int i = 0; i < hamiltonianPath.size(); i++) {
+ Point p = hamiltonianPath.get(i);
+ poses.add(map2[p.y][p.x]);
+ }
+ solution.add(poses);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+
+
+ @Override
+ public void drawWorld(float partialTicks) {
+ for (List<BlockPos> solution:this.solution)
+ RenderUtils.drawLines(solution, new Color(0,255,0, 255), partialTicks);
+ }
+
+ public static class Generator implements RoomProcessorGenerator<RoomProcessorIcePath2> {
+ @Override
+ public RoomProcessorIcePath2 createNew(DungeonRoom dungeonRoom) {
+ RoomProcessorIcePath2 defaultRoomProcessor = new RoomProcessorIcePath2(dungeonRoom);
+ return defaultRoomProcessor;
+ }
+ }
+
+ private static List<Point> findFirstHamiltonianPath(int[][] map, int startX, int startY, int endX, int endY) {
+ int emptySpace =0;
+ for (int y = 0; y < map.length; y++)
+ for (int x = 0; x < map[y].length; x++)
+ if (map[y][x] == 0) emptySpace++;
+
+ map[startY][startX] = 2;
+
+ return findHamiltonianPath(map, startX, startY, endX, endY, 0, emptySpace-1);
+ }
+
+
+ private static final List<Point> directions = Arrays.asList(new Point(0,-1), new Point(-1,0), new Point(1,0), new Point(0,1));
+ private static LinkedList<Point> findHamiltonianPath(int[][] map, int startX, int startY, int endX, int endY, int depth, int reqDepth) {
+ if (endX == startX && endY == startY) {
+ if (depth != reqDepth) return null;
+ LinkedList<Point> path = new LinkedList<Point>();
+ path.add(new Point(startX, startY));
+ return path;
+ }
+
+ for (Point p : directions) {
+ int y = p.y +startY,x=p.x + startX;
+ if (y <0 || y >= map.length || x <0 || x >= map[0].length || map[y][x] != 0) continue;
+
+ int[][] copiedMap = new int[map.length][map[0].length];
+ for (int y2 = 0; y2 < copiedMap.length; y2++)
+ copiedMap[y2] = map[y2].clone();
+ copiedMap[y][x] = 2;
+
+ LinkedList<Point> potentialRoute = findHamiltonianPath(copiedMap, x,y,endX,endY, depth +1, reqDepth);
+ if (potentialRoute != null) {
+ potentialRoute.addFirst(new Point(x,y));
+ return potentialRoute;
+ }
+ }
+ return null;
+ }
+}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorRiddle.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorRiddle.java
index 01c04d60..a186bce7 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorRiddle.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorRiddle.java
@@ -1,21 +1,50 @@
package kr.syeyoung.dungeonsguide.roomprocessor;
import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom;
+import kr.syeyoung.dungeonsguide.roomedit.Parameter;
+import kr.syeyoung.dungeonsguide.utils.TextUtils;
+import net.minecraft.client.Minecraft;
+import net.minecraft.util.ChatComponentText;
import net.minecraft.util.IChatComponent;
+import java.util.Arrays;
+import java.util.List;
+import java.util.regex.Pattern;
+
public class RoomProcessorRiddle extends GeneralRoomProcessor {
public RoomProcessorRiddle(DungeonRoom dungeonRoom) {
super(dungeonRoom);
}
+ private static final List<Pattern> patternList = Arrays.asList(
+ Pattern.compile("My chest doesn't have the reward. We are all telling the truth.*"),
+ Pattern.compile("The reward isn't in any of our chests.*"),
+ Pattern.compile("The reward is not in my chest!.*"),
+ Pattern.compile("At least one of them is lying, and the reward is not in .+'s chest.*"),
+ Pattern.compile("Both of them are telling the truth. Also,.+has the reward in their chest.*"),
+ Pattern.compile("My chest has the reward and I'm telling the truth.*")
+ );
+
@Override
public void chatReceived(IChatComponent chat) {
- System.out.println("event! +"+chat);
super.chatReceived(chat);
String ch2 = chat.getUnformattedText();
- System.out.println("hey::"+ch2);
-
+ if (!ch2.startsWith("§e[NPC] ")) {
+ return;
+ }
+ String watsaid = TextUtils.stripColor(ch2.split(":")[1]).trim();
+ System.out.println(watsaid);
+ boolean foundMatch = false;
+ for (Pattern p:patternList) {
+ if (p.matcher(watsaid).matches()) {
+ foundMatch = true;
+ break;
+ }
+ }
+ if (foundMatch) {
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("§eDungeons Guide :::: "+ch2.split(":")[0].trim()+" §fhas the reward!"));
+ }
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTeleportMazeSolver.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTeleportMazeSolver.java
index 3d3083c5..6aaf2ba8 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTeleportMazeSolver.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTeleportMazeSolver.java
@@ -4,6 +4,7 @@ import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom;
import kr.syeyoung.dungeonsguide.utils.RenderUtils;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
+import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.init.Blocks;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
@@ -26,7 +27,8 @@ public class RoomProcessorTeleportMazeSolver extends GeneralRoomProcessor {
super.tick();
World w = getDungeonRoom().getContext().getWorld();
- BlockPos pos2 = Minecraft.getMinecraft().thePlayer.getPosition();
+ 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);
if (b == Blocks.stone_slab || b == Blocks.stone_slab2) {
boolean teleport = false;
@@ -36,16 +38,20 @@ public class RoomProcessorTeleportMazeSolver extends GeneralRoomProcessor {
break;
}
}
- 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) {
- visitedPortals.add(allInBox);
- break;
+ if (teleport) {
+ 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))
+ visitedPortals.add(allInBox);
+ break;
+ }
}
- }
- for (BlockPos allInBox : BlockPos.getAllInBox(lastPlayerLocation.add(-1, -1, -1), lastPlayerLocation.add(1, 1, 1))) {
- if (w.getChunkFromBlockCoords(allInBox).getBlock(allInBox) == Blocks.end_portal_frame) {
- visitedPortals.add(allInBox);
- break;
+ for (BlockPos allInBox : BlockPos.getAllInBox(lastPlayerLocation.add(-1, -1, -1), lastPlayerLocation.add(1, 1, 1))) {
+ if (w.getChunkFromBlockCoords(allInBox).getBlock(allInBox) == Blocks.end_portal_frame) {
+ if (!visitedPortals.contains(allInBox))
+ visitedPortals.add(allInBox);
+ break;
+ }
}
}
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java
index 158793b3..71517260 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java
@@ -16,6 +16,7 @@ import org.lwjgl.opengl.GL11;
import javax.vecmath.Vector3f;
import java.awt.*;
+import java.util.List;
public class RenderUtils {
public static void renderDoor(DungeonDoor dungeonDoor, float partialTicks) {
@@ -93,43 +94,69 @@ public class RenderUtils {
}
- public static void drawLine(BlockPos pos1, BlockPos pos2, Color c, float partialTicks) {
+ public static void drawLine(Vec3 pos1, Vec3 pos2, Color colour, float partialTicks) {
+ Entity render = Minecraft.getMinecraft().getRenderViewEntity();
+ WorldRenderer worldRenderer = Tessellator.getInstance().getWorldRenderer();
- Entity viewing_from = Minecraft.getMinecraft().getRenderViewEntity();
-
- double x_fix = viewing_from.lastTickPosX + ((viewing_from.posX - viewing_from.lastTickPosX) * partialTicks);
- double y_fix = viewing_from.lastTickPosY + ((viewing_from.posY - viewing_from.lastTickPosY) * partialTicks);
- double z_fix = viewing_from.lastTickPosZ + ((viewing_from.posZ - viewing_from.lastTickPosZ) * partialTicks);
+ double realX = render.lastTickPosX + (render.posX - render.lastTickPosX) * partialTicks;
+ double realY = render.lastTickPosY + (render.posY - render.lastTickPosY) * partialTicks;
+ double realZ = render.lastTickPosZ + (render.posZ - render.lastTickPosZ) * partialTicks;
GlStateManager.pushMatrix();
- GlStateManager.pushAttrib();
- GlStateManager.translate(-x_fix, -y_fix, -z_fix);
-
- GlStateManager.disableLighting();
- GlStateManager.enableBlend();
- GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ GlStateManager.translate(-realX, -realY, -realZ);
GlStateManager.disableTexture2D();
-
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glDepthMask(false);
- GL11.glColor4ub((byte)c.getRed(), (byte)c.getGreen(), (byte)c.getBlue(), (byte)c.getAlpha());
+ GlStateManager.enableBlend();
+ GlStateManager.disableAlpha();
+ GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
+ GL11.glLineWidth(2);
+ GlStateManager.color(colour.getRed() / 255f, colour.getGreen() / 255f, colour.getBlue()/ 255f, colour.getAlpha() / 255f);
+ worldRenderer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION);
- GL11.glBegin(GL11.GL_LINES);
+ worldRenderer.pos(pos1.xCoord, pos1.yCoord, pos1.zCoord).endVertex();
+ worldRenderer.pos(pos2.xCoord, pos2.yCoord, pos2.zCoord).endVertex();
+ Tessellator.getInstance().draw();
- GL11.glVertex3f(pos1.getX(), pos1.getY(), pos1.getZ());
- GL11.glVertex3f(pos1.getX(),pos1.getY(),pos1.getZ());
+ GlStateManager.translate(realX, realY, realZ);
+ GlStateManager.disableBlend();
+ GL11.glEnable(GL11.GL_DEPTH_TEST);
+ GL11.glDepthMask(true);
+ GlStateManager.enableAlpha();
+ GlStateManager.enableTexture2D();
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+ GlStateManager.popMatrix();
+ }
+ public static void drawLines(List<BlockPos> poses, Color colour, float partialTicks) {
+ Entity render = Minecraft.getMinecraft().getRenderViewEntity();
+ WorldRenderer worldRenderer = Tessellator.getInstance().getWorldRenderer();
- GL11.glEnd();
+ double realX = render.lastTickPosX + (render.posX - render.lastTickPosX) * partialTicks;
+ double realY = render.lastTickPosY + (render.posY - render.lastTickPosY) * partialTicks;
+ double realZ = render.lastTickPosZ + (render.posZ - render.lastTickPosZ) * partialTicks;
+ GlStateManager.pushMatrix();
+ GlStateManager.translate(-realX, -realY, -realZ);
+ GlStateManager.disableTexture2D();
+ GlStateManager.enableBlend();
+ GlStateManager.disableAlpha();
+
+ GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
+ GL11.glLineWidth(2);
+ GlStateManager.color(colour.getRed() / 255f, colour.getGreen() / 255f, colour.getBlue()/ 255f, colour.getAlpha() / 255f);
+ worldRenderer.begin(GL11.GL_LINE_STRIP, DefaultVertexFormats.POSITION);
+ for (BlockPos pos:poses) {
+ worldRenderer.pos(pos.getX() +0.5, pos.getY() +0.5, pos.getZ() +0.5).endVertex();
+ }
+ Tessellator.getInstance().draw();
- GL11.glEnable(GL11.GL_DEPTH_TEST);
- GL11.glDepthMask(true);
- GlStateManager.enableTexture2D();
+ GlStateManager.translate(realX, realY, realZ);
GlStateManager.disableBlend();
- GlStateManager.enableLighting();
+ GlStateManager.enableAlpha();
+ GlStateManager.enableTexture2D();
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.popMatrix();
- GlStateManager.popAttrib();
}
public static void highlightBlock(BlockPos blockpos, Color c, float partialTicks) {