diff options
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/dungeon')
-rw-r--r-- | src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/OffsetPoint.java | 23 | ||||
-rw-r--r-- | src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java | 5 |
2 files changed, 27 insertions, 1 deletions
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 49775537..05bc7138 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/OffsetPoint.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/OffsetPoint.java @@ -11,12 +11,16 @@ import javax.vecmath.Vector2d; @Data @AllArgsConstructor -public class OffsetPoint { +public class OffsetPoint implements Cloneable { private int x; private int y; private int z; public OffsetPoint(DungeonRoom dungeonRoom, BlockPos pos) { + setPosInWorld(dungeonRoom, pos); + } + + public void setPosInWorld(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); @@ -47,6 +51,10 @@ public class OffsetPoint { Block b = dungeonRoom.getRelativeBlockAt(relBp.getX(), relBp.getY(), relBp.getZ()); return b; } + public BlockPos getBlockPos(DungeonRoom dungeonRoom) { + BlockPos relBp = toRotatedRelBlockPos(dungeonRoom); + return dungeonRoom.getRelativeBlockPosAt(relBp.getX(), relBp.getY(), relBp.getZ()); + } public int getData(DungeonRoom dungeonRoom) { BlockPos relBp = toRotatedRelBlockPos(dungeonRoom); @@ -54,4 +62,17 @@ public class OffsetPoint { int b = dungeonRoom.getRelativeBlockDataAt(relBp.getX(), relBp.getY(), relBp.getZ()); return b; } + + @Override + public Object clone() throws CloneNotSupportedException { + return new OffsetPoint(x,y,z); + } + + @Override + public String toString() { + return "OffsetPoint{x=" + x + + ", y=" + y + + ", z=" + z + + '}'; + } } 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 41e2fb6f..2b56b139 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java @@ -114,6 +114,11 @@ public class DungeonRoom { return null; } + public BlockPos getRelativeBlockPosAt(int x, int y, int z) { + BlockPos pos = new BlockPos(x,y,z).add(min.getX(),min.getZ(),min.getZ()); + return pos; + } + public int getRelativeBlockDataAt(int x, int y, int z) { // validate x y z's if (canAccessRelative(x,z)) { |