From 4d5276d8523e5c4771bdde386c9a538ec544d4c5 Mon Sep 17 00:00:00 2001 From: syeyoung <42869671+cyoung06@users.noreply.github.com> Date: Thu, 26 Nov 2020 13:02:20 +0900 Subject: value edit stuff --- .../dungeonsguide/dungeon/data/OffsetPoint.java | 23 +++++++++++++++++++++- .../dungeon/roomfinder/DungeonRoom.java | 5 +++++ 2 files changed, 27 insertions(+), 1 deletion(-) (limited to 'src/main/java/kr/syeyoung/dungeonsguide/dungeon') 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)) { -- cgit