diff options
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/dungeon')
3 files changed, 55 insertions, 3 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 f9069670..b998fb27 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/DungeonRoomInfo.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/DungeonRoomInfo.java @@ -26,4 +26,6 @@ public class DungeonRoomInfo implements Serializable { private UUID uuid; private String name; + + private String processorId = "default"; } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/DungeonDoor.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/DungeonDoor.java index 30908ef8..f13ab33f 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/DungeonDoor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/DungeonDoor.java @@ -18,20 +18,55 @@ public class DungeonDoor { private static final Set<Block> legalBlocks = Sets.newHashSet(Blocks.coal_block, Blocks.barrier, Blocks.monster_egg, Blocks.air, Blocks.stained_hardened_clay); + private boolean requiresKey = false; + private boolean opened = false; public DungeonDoor(World world, BlockPos pos) { this.w = world; this.position = pos; + Block itshouldbeall = world.getChunkFromBlockCoords(pos).getBlock(pos); + if (!legalBlocks.contains(itshouldbeall)) { + exist = false; + return; + } for (int x = -1; x<=1; x++) for (int y = -1; y<=1; y++) for (int z = -1; z<=1; z++) { BlockPos pos2 = pos.add(x,y,z); Block block = world.getChunkFromBlockCoords(pos2).getBlock(pos2); - if (!legalBlocks.contains(block)) exist = false; + if (itshouldbeall != block) exist = false; } if (exist) { BlockPos ZCheck = pos.add(0,0,2); isZDir = world.getChunkFromBlockCoords(ZCheck).getBlock(ZCheck) == Blocks.air; + + if (isZDir) { + for (int x = -1; x<=1; x++) + for (int y = -1; y<=1; y++) + for (int z = -2; z<=2; z+=4) { + BlockPos pos2 = pos.add(x,y,z); + Block block = world.getChunkFromBlockCoords(pos2).getBlock(pos2); + if (block != Blocks.air) exist = false; + } + } else { + for (int x = -2; x<=2; x+=4) + for (int y = -1; y<=1; y++) + for (int z = -1; z<=1; z++) { + BlockPos pos2 = pos.add(x,y,z); + Block block = world.getChunkFromBlockCoords(pos2).getBlock(pos2); + if (block != Blocks.air) exist = false; + } + } + } + if (!exist) { + isZDir = false; + return; + } + + if (itshouldbeall == Blocks.stained_hardened_clay || itshouldbeall == Blocks.coal_block) { + requiresKey = true; + } else if (itshouldbeall == Blocks.barrier) { + opened = true; } } } 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 cd174660..7e8c43e0 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java @@ -5,6 +5,9 @@ import kr.syeyoung.dungeonsguide.dungeon.DungeonContext; import kr.syeyoung.dungeonsguide.dungeon.MapProcessor; import kr.syeyoung.dungeonsguide.dungeon.data.DungeonRoomInfo; import kr.syeyoung.dungeonsguide.dungeon.doorfinder.DungeonDoor; +import kr.syeyoung.dungeonsguide.roomprocessor.ProcessorFactory; +import kr.syeyoung.dungeonsguide.roomprocessor.RoomProcessor; +import kr.syeyoung.dungeonsguide.roomprocessor.RoomProcessorGenerator; import lombok.Getter; import net.minecraft.block.Block; import net.minecraft.util.BlockPos; @@ -33,6 +36,9 @@ public class DungeonRoom { private final int unitWidth; // X private final int unitHeight; // Z + + private RoomProcessor roomProcessor; + public DungeonRoom(List<Point> points, short shape, byte color, BlockPos min, BlockPos max, DungeonContext context) { this.unitPoints = points; this.shape = shape; @@ -40,8 +46,6 @@ public class DungeonRoom { this.min = min; this.max = max; this.context = context; - buildDoors(); - buildRoom(); minRoomPt = new Point(Integer.MAX_VALUE, Integer.MAX_VALUE); for (Point pt : unitPoints) { @@ -50,6 +54,11 @@ public class DungeonRoom { } unitWidth = (int) Math.ceil(max.getX() - min.getX() / 32.0); unitHeight = (int) Math.ceil(max.getZ() - min.getZ() / 32.0); + + + buildDoors(); + buildRoom(); + updateRoomProcessor(); } private static final Set<Vector2d> directions = Sets.newHashSet(new Vector2d(0,16), new Vector2d(0, -16), new Vector2d(16, 0), new Vector2d(-16 , 0)); @@ -81,6 +90,12 @@ public class DungeonRoom { this.dungeonRoomInfo = dungeonRoomInfo; } + public void updateRoomProcessor() { + RoomProcessorGenerator roomProcessorGenerator = ProcessorFactory.getRoomProcessorGenerator(dungeonRoomInfo.getProcessorId()); + if (roomProcessorGenerator == null) this.roomProcessor = null; + else this.roomProcessor = roomProcessorGenerator.createNew(this); + } + public Block getAbsoluteBlockAt(int x, int y, int z) { // validate x y z's BlockPos pos = new BlockPos(x,y,z); |
