diff options
author | syeyoung <42869671+cyoung06@users.noreply.github.com> | 2020-11-22 22:58:40 +0900 |
---|---|---|
committer | syeyoung <42869671+cyoung06@users.noreply.github.com> | 2020-11-22 22:58:40 +0900 |
commit | b46d3d8ce98b112d8c4f1b3ad5eed81b234b1892 (patch) | |
tree | ec852c4883effa2f961bd896db17bbca923bb595 /src/main/java/kr/syeyoung/dungeonsguide/dungeon | |
parent | 70a753c2a0aac9bd7e7e21ca081c4ee994bc4891 (diff) | |
download | Skyblock-Dungeons-Guide-b46d3d8ce98b112d8c4f1b3ad5eed81b234b1892.tar.gz Skyblock-Dungeons-Guide-b46d3d8ce98b112d8c4f1b3ad5eed81b234b1892.tar.bz2 Skyblock-Dungeons-Guide-b46d3d8ce98b112d8c4f1b3ad5eed81b234b1892.zip |
room building and door rendering
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/dungeon')
3 files changed, 65 insertions, 0 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java index 4ed8c7b5..a3e0d961 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java @@ -149,6 +149,7 @@ public class MapProcessor { private void processMap(byte[] mapData) { int height = (int)((128.0 - topLeftMapPoint.y) / (unitRoomDimension.height + doorDimension.height)); int width = (int) ((128.0 - topLeftMapPoint.x) / (unitRoomDimension.width + doorDimension.height)); + if (MapUtils.getMapColorAt(mapData,0,0) != 0) return; for (int y = 0; y <= height; y++){ for (int x = 0; x <= width; x++) { if (roomsFound.contains(new Point(x,y))) continue; @@ -159,6 +160,7 @@ public class MapProcessor { if (color != 0 && color != 85) { MapUtils.record(mapData, mapPoint.x, mapPoint.y, new Color(0,255,255,80)); DungeonRoom rooms = buildRoom(mapData, new Point(x,y)); + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("New Map discovered! shape: "+rooms.getShape()+ " color: "+rooms.getColor()+" min: "+rooms.getMin()+" / "+x+","+y)); context.getDungeonRoomList().add(rooms); for (Point p:rooms.getUnitPoints()) { roomsFound.add(p); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/DungeonDoor.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/DungeonDoor.java new file mode 100644 index 00000000..4dea9cdb --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/DungeonDoor.java @@ -0,0 +1,37 @@ +package kr.syeyoung.dungeonsguide.dungeon.data; + +import com.google.common.collect.Sets; +import lombok.Getter; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.util.BlockPos; +import net.minecraft.world.World; + +import java.util.Set; + +@Getter +public class DungeonDoor { + private final World w; + private final BlockPos position; + private boolean exist = true; + private boolean isZDir; + + private static final Set<Block> legalBlocks = Sets.newHashSet(Blocks.coal_block, Blocks.barrier, Blocks.monster_egg, Blocks.air, Blocks.hardened_clay); + + + public DungeonDoor(World world, BlockPos pos) { + this.w = world; + this.position = pos; + 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 (exist) { + BlockPos ZCheck = pos.add(0,0,2); + isZDir = world.getChunkFromBlockCoords(ZCheck).getBlock(ZCheck) == Blocks.air; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/DungeonRoom.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/DungeonRoom.java index 9cf22ebb..5d79b119 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/DungeonRoom.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/DungeonRoom.java @@ -1,11 +1,16 @@ package kr.syeyoung.dungeonsguide.dungeon.data; +import com.google.common.collect.Sets; import kr.syeyoung.dungeonsguide.dungeon.DungeonContext; import lombok.Getter; import net.minecraft.util.BlockPos; +import javax.vecmath.Vector2d; import java.awt.*; +import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; @Getter public class DungeonRoom { @@ -17,11 +22,32 @@ public class DungeonRoom { private final DungeonContext context; + private final List<DungeonDoor> doors = new ArrayList<DungeonDoor>(); + public DungeonRoom(List<Point> points, short shape, byte color, BlockPos min, DungeonContext context) { this.unitPoints = points; this.shape = shape; this.color = color; this.min = min; this.context = context; + buildDoors(); + } + + private static final Set<Vector2d> directions = Sets.newHashSet(new Vector2d(0,16), new Vector2d(0, -16), new Vector2d(16, 0), new Vector2d(-16 , 0)); + + private void buildDoors() { + Set<BlockPos> positions = new HashSet<BlockPos>(); + for (Point p:unitPoints) { + BlockPos pos = context.getMapProcessor().roomPointToWorldPoint(p).add(16,0,16); + for (Vector2d vector2d : directions){ + BlockPos doorLoc = pos.add(vector2d.x, 0, vector2d.y); + if (positions.contains(doorLoc)) positions.remove(doorLoc); + else positions.add(doorLoc); + } + } + + for (BlockPos door : positions) { + doors.add(new DungeonDoor(context.getWorld(), door)); + } } } |