diff options
author | syeyoung <42869671+cyoung06@users.noreply.github.com> | 2020-11-23 11:39:30 +0900 |
---|---|---|
committer | syeyoung <42869671+cyoung06@users.noreply.github.com> | 2020-11-23 11:39:30 +0900 |
commit | 17b3b9ce29495b554d38c1de4af38904be0fcc23 (patch) | |
tree | 117e3c2a4d2ab1f2a3a770527a22b533f647a45d | |
parent | 46a86f18ebd62a3771ca4fcb7d1cf17f69b80c73 (diff) | |
download | Skyblock-Dungeons-Guide-17b3b9ce29495b554d38c1de4af38904be0fcc23.tar.gz Skyblock-Dungeons-Guide-17b3b9ce29495b554d38c1de4af38904be0fcc23.tar.bz2 Skyblock-Dungeons-Guide-17b3b9ce29495b554d38c1de4af38904be0fcc23.zip |
room data!
-rw-r--r-- | build.gradle | 2 | ||||
-rw-r--r-- | src/main/java/kr/syeyoung/dungeonsguide/EventListener.java | 7 | ||||
-rw-r--r-- | src/main/java/kr/syeyoung/dungeonsguide/dungeon/DungeonContext.java | 8 | ||||
-rw-r--r-- | src/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java | 3 | ||||
-rw-r--r-- | src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/DungeonRoomInfo.java | 21 | ||||
-rw-r--r-- | src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/DungeonDoor.java (renamed from src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/DungeonDoor.java) | 2 | ||||
-rw-r--r-- | src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java (renamed from src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/DungeonRoom.java) | 18 | ||||
-rw-r--r-- | src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoomInfoRegistry.java | 41 | ||||
-rw-r--r-- | src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/RoomMatcher.java | 18 | ||||
-rw-r--r-- | src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java | 4 |
10 files changed, 107 insertions, 17 deletions
diff --git a/build.gradle b/build.gradle index 7da254c6..6ed97f83 100644 --- a/build.gradle +++ b/build.gradle @@ -39,6 +39,8 @@ minecraft { } dependencies { + implementation 'org.jetbrains:annotations-java5:19.0.0' + // you may put jars on which you depend on in ./libs // or you may define them like so.. //compile "some.group:artifact:version:classifier" diff --git a/src/main/java/kr/syeyoung/dungeonsguide/EventListener.java b/src/main/java/kr/syeyoung/dungeonsguide/EventListener.java index 42705f78..9bdd2d41 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/EventListener.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/EventListener.java @@ -1,8 +1,8 @@ package kr.syeyoung.dungeonsguide; import kr.syeyoung.dungeonsguide.dungeon.DungeonContext; -import kr.syeyoung.dungeonsguide.dungeon.data.DungeonDoor; -import kr.syeyoung.dungeonsguide.dungeon.data.DungeonRoom; +import kr.syeyoung.dungeonsguide.dungeon.doorfinder.DungeonDoor; +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.utils.MapUtils; import kr.syeyoung.dungeonsguide.utils.RenderUtils; import net.minecraft.client.Minecraft; @@ -18,7 +18,6 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; import java.awt.*; -import java.util.Map; public class EventListener { private int timerTick = 0; @@ -68,6 +67,8 @@ public class EventListener { fontRenderer.drawString("Where are you?!", 5, 128, 0xFFFFFF); } else { fontRenderer.drawString("you're in the room... "+dungeonRoom.getColor()+" / "+dungeonRoom.getShape(), 5, 128, 0xFFFFFF); + fontRenderer.drawString("room uuid: "+dungeonRoom.getDungeonRoomInfo().getUuid() + (dungeonRoom.getDungeonRoomInfo().isRegistered() ?"":" (not registered)"), 5, 148, 0xFFFFFF); + fontRenderer.drawString("room name: "+dungeonRoom.getDungeonRoomInfo().getName(), 5, 148, 0xFFFFFF); } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/DungeonContext.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/DungeonContext.java index 543cca6f..30250107 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/DungeonContext.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/DungeonContext.java @@ -1,16 +1,10 @@ package kr.syeyoung.dungeonsguide.dungeon; -import kr.syeyoung.dungeonsguide.dungeon.data.DungeonRoom; +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import lombok.Getter; import lombok.Setter; -import net.minecraft.block.BlockPackedIce; -import net.minecraft.client.Minecraft; -import net.minecraft.init.Items; -import net.minecraft.item.ItemMap; -import net.minecraft.item.ItemStack; import net.minecraft.util.BlockPos; import net.minecraft.world.World; -import net.minecraft.world.storage.MapData; import java.awt.*; import java.util.ArrayList; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java index 7cfbdfba..490af242 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java @@ -1,9 +1,8 @@ package kr.syeyoung.dungeonsguide.dungeon; import com.google.common.collect.Sets; -import jdk.nashorn.internal.ir.Block; import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.dungeon.data.DungeonRoom; +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.dungeon.doorfinder.DoorFinderRegistry; import kr.syeyoung.dungeonsguide.dungeon.doorfinder.StartDoorFinder; import kr.syeyoung.dungeonsguide.utils.MapUtils; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/DungeonRoomInfo.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/DungeonRoomInfo.java new file mode 100644 index 00000000..c3d0a65d --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/DungeonRoomInfo.java @@ -0,0 +1,21 @@ +package kr.syeyoung.dungeonsguide.dungeon.data; + +import lombok.Getter; +import lombok.Setter; + +import java.util.UUID; + +@Getter +@Setter +public class DungeonRoomInfo { + + private transient boolean registered; + + private short shape; + private byte color; + + private int[][] blocks; + + private UUID uuid; + private String name; +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/DungeonDoor.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/DungeonDoor.java index 4dea9cdb..2855b05f 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/DungeonDoor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/DungeonDoor.java @@ -1,4 +1,4 @@ -package kr.syeyoung.dungeonsguide.dungeon.data; +package kr.syeyoung.dungeonsguide.dungeon.doorfinder; import com.google.common.collect.Sets; import lombok.Getter; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/DungeonRoom.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java index 5d79b119..91761c7c 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/DungeonRoom.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java @@ -1,7 +1,9 @@ -package kr.syeyoung.dungeonsguide.dungeon.data; +package kr.syeyoung.dungeonsguide.dungeon.roomfinder; import com.google.common.collect.Sets; import kr.syeyoung.dungeonsguide.dungeon.DungeonContext; +import kr.syeyoung.dungeonsguide.dungeon.data.DungeonRoomInfo; +import kr.syeyoung.dungeonsguide.dungeon.doorfinder.DungeonDoor; import lombok.Getter; import net.minecraft.util.BlockPos; @@ -24,6 +26,8 @@ public class DungeonRoom { private final List<DungeonDoor> doors = new ArrayList<DungeonDoor>(); + private DungeonRoomInfo dungeonRoomInfo; + public DungeonRoom(List<Point> points, short shape, byte color, BlockPos min, DungeonContext context) { this.unitPoints = points; this.shape = shape; @@ -31,6 +35,7 @@ public class DungeonRoom { this.min = min; this.context = context; buildDoors(); + buildRoom(); } private static final Set<Vector2d> directions = Sets.newHashSet(new Vector2d(0,16), new Vector2d(0, -16), new Vector2d(16, 0), new Vector2d(-16 , 0)); @@ -50,4 +55,15 @@ public class DungeonRoom { doors.add(new DungeonDoor(context.getWorld(), door)); } } + + private RoomMatcher roomMatcher = null; + private void buildRoom() { + if (roomMatcher == null) + roomMatcher = new RoomMatcher(this); + DungeonRoomInfo dungeonRoomInfo = roomMatcher.match(); + if (dungeonRoomInfo == null) + dungeonRoomInfo = roomMatcher.createNew(); + + this.dungeonRoomInfo = dungeonRoomInfo; + } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoomInfoRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoomInfoRegistry.java new file mode 100644 index 00000000..a382273c --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoomInfoRegistry.java @@ -0,0 +1,41 @@ +package kr.syeyoung.dungeonsguide.dungeon.roomfinder; + +import kr.syeyoung.dungeonsguide.dungeon.data.DungeonRoomInfo; + +import java.util.*; + +public class DungeonRoomInfoRegistry { + private static List<DungeonRoomInfo> registered = new ArrayList<DungeonRoomInfo>(); + private static Map<Short, List<DungeonRoomInfo>> shapeMap = new HashMap<Short, List<DungeonRoomInfo>>(); + private static Map<UUID, DungeonRoomInfo> uuidMap = new HashMap<UUID, DungeonRoomInfo>(); + + public static void register(DungeonRoomInfo dungeonRoomInfo) { + if (dungeonRoomInfo == null) throw new NullPointerException("what the fak parameter is noll?"); + dungeonRoomInfo.setRegistered(true); + registered.add(dungeonRoomInfo); + uuidMap.put(dungeonRoomInfo.getUuid(), dungeonRoomInfo); + List<DungeonRoomInfo> roomInfos = shapeMap.get(dungeonRoomInfo.getShape()); + if (roomInfos == null) roomInfos = new ArrayList<DungeonRoomInfo>(); + roomInfos.add(dungeonRoomInfo); + shapeMap.put(dungeonRoomInfo.getShape(), roomInfos); + } + + + public static List<DungeonRoomInfo> getByShape(Short shape) { + List<DungeonRoomInfo> dungeonRoomInfos = shapeMap.get(shape); + return dungeonRoomInfos == null ? Collections.<DungeonRoomInfo>emptyList() : dungeonRoomInfos; + } + + public static DungeonRoomInfo getByUUID(UUID uid) { + return uuidMap.get(uid); + } + + public static void unregister(DungeonRoomInfo dungeonRoomInfo) { + if (!dungeonRoomInfo.isRegistered()) throw new IllegalStateException("what tha fak? that is not registered one"); + if (!uuidMap.containsKey(dungeonRoomInfo.getUuid())) throw new IllegalStateException("what tha fak? that is not registered one, but you desperately wanted to trick this program"); + dungeonRoomInfo.setRegistered(false); + registered.remove(dungeonRoomInfo); + shapeMap.get(dungeonRoomInfo.getShape()).remove(dungeonRoomInfo); + uuidMap.remove(dungeonRoomInfo.getUuid()); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/RoomMatcher.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/RoomMatcher.java new file mode 100644 index 00000000..197348bf --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/RoomMatcher.java @@ -0,0 +1,18 @@ +package kr.syeyoung.dungeonsguide.dungeon.roomfinder; + +import kr.syeyoung.dungeonsguide.dungeon.data.DungeonRoomInfo; + +public class RoomMatcher { + private DungeonRoom dungeonRoom; + public RoomMatcher(DungeonRoom dungeonRoom) { + this.dungeonRoom = dungeonRoom; + } + + public DungeonRoomInfo match() { + return null; + } + + public DungeonRoomInfo createNew() { + return new DungeonRoomInfo(); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java index 269629e2..659e25ca 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java @@ -1,10 +1,8 @@ package kr.syeyoung.dungeonsguide.utils; -import kr.syeyoung.dungeonsguide.dungeon.data.DungeonDoor; +import kr.syeyoung.dungeonsguide.dungeon.doorfinder.DungeonDoor; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.WorldRenderer; import net.minecraft.entity.Entity; import net.minecraft.util.BlockPos; import net.minecraft.util.Vec3; |