aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kr/syeyoung/dungeonsguide/dungeon
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/dungeon')
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/DungeonRoomInfo.java4
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/OffsetPoint.java57
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/OffsetPointSet.java11
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java2
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/RoomMatcher.java6
5 files changed, 75 insertions, 5 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/DungeonRoomInfo.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/DungeonRoomInfo.java
index b998fb27..abe3e263 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/DungeonRoomInfo.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/DungeonRoomInfo.java
@@ -4,6 +4,8 @@ import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
import java.util.UUID;
@Getter
@@ -28,4 +30,6 @@ public class DungeonRoomInfo implements Serializable {
private String name;
private String processorId = "default";
+
+ private Map<String, Object> properties = new HashMap<String, Object>();
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/OffsetPoint.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/OffsetPoint.java
new file mode 100644
index 00000000..49775537
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/OffsetPoint.java
@@ -0,0 +1,57 @@
+package kr.syeyoung.dungeonsguide.dungeon.data;
+
+import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom;
+import kr.syeyoung.dungeonsguide.utils.VectorUtils;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import net.minecraft.block.Block;
+import net.minecraft.util.BlockPos;
+
+import javax.vecmath.Vector2d;
+
+@Data
+@AllArgsConstructor
+public class OffsetPoint {
+ private int x;
+ private int y;
+ private int z;
+
+ public OffsetPoint(DungeonRoom dungeonRoom, BlockPos pos) {
+ Vector2d vector2d = new Vector2d(pos.getX(), pos.getZ());
+ 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;
+
+ this.x = (int) vector2d.x;
+ this.z = (int) vector2d.y;
+ this.y = dungeonRoom.getMin().getY() + pos.getY();
+ }
+
+ public BlockPos toRotatedRelBlockPos(DungeonRoom dungeonRoom) {
+ int rot = dungeonRoom.getRoomMatcher().getRotation();
+ Vector2d rot2 = new Vector2d(x,z);
+ for (int i = 0; i < dungeonRoom.getRoomMatcher().getRotation(); i++) {
+ rot2 = VectorUtils.rotateCounterClockwise(rot2);
+ }
+ 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;
+
+ return new BlockPos(rot2.x, y, rot2.y);
+ }
+
+ public Block getBlock(DungeonRoom dungeonRoom) {
+ BlockPos relBp = toRotatedRelBlockPos(dungeonRoom);
+
+ Block b = dungeonRoom.getRelativeBlockAt(relBp.getX(), relBp.getY(), relBp.getZ());
+ return b;
+ }
+
+ public int getData(DungeonRoom dungeonRoom) {
+ BlockPos relBp = toRotatedRelBlockPos(dungeonRoom);
+
+ int b = dungeonRoom.getRelativeBlockDataAt(relBp.getX(), relBp.getY(), relBp.getZ());
+ return b;
+ }
+}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/OffsetPointSet.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/OffsetPointSet.java
new file mode 100644
index 00000000..a381ac49
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/OffsetPointSet.java
@@ -0,0 +1,11 @@
+package kr.syeyoung.dungeonsguide.dungeon.data;
+
+import lombok.Data;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Data
+public class OffsetPointSet {
+ private List<OffsetPoint> offsetPointList = new ArrayList<OffsetPoint>();
+}
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 7e8c43e0..41e2fb6f 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java
@@ -108,7 +108,7 @@ public class DungeonRoom {
public Block getRelativeBlockAt(int x, int y, int z) {
// validate x y z's
if (canAccessRelative(x,z)) {
- BlockPos pos = new BlockPos(x,y,z).add(min.getX(),0,min.getZ());
+ BlockPos pos = new BlockPos(x,y,z).add(min.getX(),min.getZ(),min.getZ());
return this.context.getWorld().getChunkFromBlockCoords(pos).getBlock(pos);
}
return null;
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/RoomMatcher.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/RoomMatcher.java
index 626b75b4..46337480 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/RoomMatcher.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/RoomMatcher.java
@@ -51,12 +51,11 @@ public class RoomMatcher {
System.out.println("Trying to match "+dungeonRoomInfo.getUuid().toString()+" / "+dungeonRoomInfo.getName()+"... at rotation "+rotation);
- int y = dungeonRoom.getMin().getY();
for (int z = 0; z < res.length; z ++) {
for (int x = 0; x < res[0].length; x++) {
int data = res[z][x];
if (data == -1) continue;
- Block b = dungeonRoom.getRelativeBlockAt(x,y,z);
+ Block b = dungeonRoom.getRelativeBlockAt(x,0,z);
if (b == null || Block.getIdFromBlock(b) != data) {
System.out.println("Match failed at offset X"+x+" / Z"+z+". expected "+data+" but found "+b +" ("+Block.getIdFromBlock(b)+")");
return false;
@@ -74,7 +73,6 @@ public class RoomMatcher {
int maxZ = dungeonRoom.getMax().getZ();
int minX = dungeonRoom.getMin().getX();
int minZ = dungeonRoom.getMin().getZ();
- int y = dungeonRoom.getMin().getY();
int widthX = maxX - minX + 2;
int heightZ = maxZ - minZ + 2;
int[][] data = new int[dungeonRoom.getMax().getZ() - dungeonRoom.getMin().getZ() +2][dungeonRoom.getMax().getX() - dungeonRoom.getMin().getX() + 2];
@@ -90,7 +88,7 @@ public class RoomMatcher {
continue;
}
- Block b = dungeonRoom.getRelativeBlockAt(x,y,z);
+ Block b = dungeonRoom.getRelativeBlockAt(x,0,z);
if (b == null) {
data[z][x] = -1;
} else {