diff --git a/src/main/java/io/github/quantizr/dungeonrooms/dungeons/catacombs/DungeonManager.java b/src/main/java/io/github/quantizr/dungeonrooms/dungeons/catacombs/DungeonManager.java index 6771ebd..31dc1dc 100644 --- a/src/main/java/io/github/quantizr/dungeonrooms/dungeons/catacombs/DungeonManager.java +++ b/src/main/java/io/github/quantizr/dungeonrooms/dungeons/catacombs/DungeonManager.java @@ -48,7 +48,7 @@ public class DungeonManager { public static Point[] entranceMapCorners; public static Point entrancePhysicalNWCorner; - public static int tickAmount = 0; + public static Integer mapId; long bloodTime = Long.MAX_VALUE; @@ -90,9 +90,8 @@ public void onTick(TickEvent.ClientTickEvent event) { EntityPlayerSP player = mc.thePlayer; if (!Utils.inCatacombs) return; //From this point forward, everything assumes that Utils.inCatacombs == true - tickAmount++; - if ((gameStage == 0 || gameStage == 1) && tickAmount % 20 == 0) { + if (gameStage == 0 || gameStage == 1) { if (DungeonRooms.firstLogin) { DungeonRooms.firstLogin = false; @@ -113,8 +112,7 @@ public void onTick(TickEvent.ClientTickEvent event) { DungeonRooms.logger.info("DungeonRooms: gameStage set to " + gameStage); } - Integer[][] map = MapUtils.updatedMap(); - if (map != null) { + if (MapUtils.mapExists()) { DungeonRooms.logger.warn("DungeonRooms: Run started but gameStage is not on 2"); gameStage = 2; DungeonRooms.logger.info("DungeonRooms: gameStage set to " + gameStage); @@ -148,17 +146,15 @@ public void onTick(TickEvent.ClientTickEvent event) { } oddRun = !oddRun; } - - tickAmount = 0; } } @SubscribeEvent public void onWorldUnload(WorldEvent.Unload event) { Utils.inCatacombs = false; - tickAmount = 0; gameStage = 0; + mapId = null; map = null; entranceMapCorners = null; entrancePhysicalNWCorner = null; diff --git a/src/main/java/io/github/quantizr/dungeonrooms/dungeons/catacombs/RoomDetection.java b/src/main/java/io/github/quantizr/dungeonrooms/dungeons/catacombs/RoomDetection.java index 20ddb82..2e86b72 100644 --- a/src/main/java/io/github/quantizr/dungeonrooms/dungeons/catacombs/RoomDetection.java +++ b/src/main/java/io/github/quantizr/dungeonrooms/dungeons/catacombs/RoomDetection.java @@ -28,14 +28,18 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.settings.GameSettings; +import net.minecraft.item.ItemStack; import net.minecraft.util.*; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; import java.awt.*; -import java.util.*; import java.util.List; -import java.util.concurrent.*; +import java.util.*; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; import static io.github.quantizr.dungeonrooms.dungeons.catacombs.DungeonManager.*; @@ -55,7 +59,6 @@ public class RoomDetection { public static String roomDirection = "undefined"; public static Point roomCorner; - public static HashSet currentScannedBlocks = new HashSet<>(); public static HashMap blocksToCheck = new HashMap<>(); public static int totalBlocksAvailableToCheck = 0; @@ -72,12 +75,14 @@ public class RoomDetection { @SubscribeEvent public void onTick(TickEvent.ClientTickEvent event) { if (event.phase != TickEvent.Phase.START) return; - EntityPlayerSP player = mc.thePlayer; - if (!Utils.inCatacombs) return; + EntityPlayerSP player = mc.thePlayer; //From this point forward, everything assumes that Utils.inCatacombs == true if (gameStage == 2) { //Room clearing phase + if (mapId == null && extractMapId() == null) // Extract the map id + return; // If we failed to extract the map id, we cannot detect the dungeon room + stage2Ticks++; if (stage2Ticks == 10) { stage2Ticks = 0; @@ -90,16 +95,16 @@ public void onTick(TickEvent.ClientTickEvent event) { if (entranceMapCorners == null) { map = MapUtils.updatedMap(); entranceMapCorners = MapUtils.entranceMapCorners(map); - DungeonRooms.logger.info("DungeonRooms: Getting entrance map corners from hotbar map..."); - } else if (entranceMapCorners[0] == null || entranceMapCorners[1] == null) { //prevent crashes if hotbar map bugged - DungeonRooms.logger.warn("DungeonRooms: Entrance room not found, hotbar map possibly bugged"); + DungeonRooms.logger.info("DungeonRooms: Getting entrance map corners from map data..."); + } else if (entranceMapCorners[0] == null || entranceMapCorners[1] == null) { //prevent crashes if map data bugged + DungeonRooms.logger.warn("DungeonRooms: Entrance room not found, map data possibly bugged"); entranceMapNullCount++; entranceMapCorners = null; //retry getting corners again next loop if (entranceMapNullCount == 8) { player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED - + "Dungeon Rooms: Error with hotbar map, perhaps your texture pack is interfering with room detection?")); + + "Dungeon Rooms: Error with map data, perhaps your texture pack is interfering with room detection?")); DungeonRooms.textToDisplay = new ArrayList<>(Collections.singletonList( - "Dungeon Rooms: " + EnumChatFormatting.RED + "Hotbar map may be bugged" + "Dungeon Rooms: " + EnumChatFormatting.RED + "Entrance Room corner not found" )); //gameStage = 4; //DungeonRooms.logger.info("DungeonRooms: gameStage set to " + gameStage); @@ -142,7 +147,7 @@ public void onTick(TickEvent.ClientTickEvent event) { updateCurrentRoom(); if (roomColor.equals("undefined")) { DungeonRooms.textToDisplay = new ArrayList<>(Collections.singletonList("Dungeon Rooms: " - + EnumChatFormatting.RED + "Waiting for hotbar map to update...")); + + EnumChatFormatting.RED + "Waiting for map data to update...")); } else { switch (roomColor) { case "brown": @@ -194,12 +199,12 @@ public void onTick(TickEvent.ClientTickEvent event) { if (possibleRoomsSet.size() == 0) { //no match - DungeonRooms.textToDisplay = new ArrayList<>(Arrays.asList( + DungeonRooms.textToDisplay = new ArrayList<>(Arrays.asList( "Dungeon Rooms: " + EnumChatFormatting.RED + "No Matching Rooms Detected", EnumChatFormatting.RED + "This mod might not have data for this room.", EnumChatFormatting.WHITE + "Retrying every 5 seconds..." - )); - redoScan = System.currentTimeMillis() + 5000; + )); + redoScan = System.currentTimeMillis() + 5000; } else if (possibleRoomsSet.size() == 1) { //room found roomName = possibleRoomsSet.first(); @@ -228,7 +233,6 @@ public void onTick(TickEvent.ClientTickEvent event) { } } - void updateCurrentRoom() { EntityPlayerSP player = mc.thePlayer; map = MapUtils.updatedMap(); @@ -273,6 +277,15 @@ public static void resetCurrentRoom() { Waypoints.secretNum = 0; } + public static Integer extractMapId() { + if (!MapUtils.mapExists()) + return null; + ItemStack mapSlot = Minecraft.getMinecraft().thePlayer.inventory.getStackInSlot(8); //get map ItemStack + // MapUtils.updatedMap(mapSlot); // - Skip check + DungeonRooms.logger.info("DungeonRooms: Extracting the map id"); + return mapId = mapSlot.getMetadata(); + } + public static void newRoom() { if (!roomName.equals("undefined") && !roomCategory.equals("undefined")) { //update Waypoints info @@ -450,4 +463,4 @@ Future>> getPossibleRooms() { return updatedPossibleRooms; }); } -} +} \ No newline at end of file diff --git a/src/main/java/io/github/quantizr/dungeonrooms/handlers/OpenLink.java b/src/main/java/io/github/quantizr/dungeonrooms/handlers/OpenLink.java index d14a8e8..f94d159 100644 --- a/src/main/java/io/github/quantizr/dungeonrooms/handlers/OpenLink.java +++ b/src/main/java/io/github/quantizr/dungeonrooms/handlers/OpenLink.java @@ -69,7 +69,7 @@ public static void checkForLink(String type){ ChatComponentText sbp = new ChatComponentText(EnumChatFormatting.YELLOW + "" + EnumChatFormatting.UNDERLINE + sbpURL); sbp.setChatStyle(sbp.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, sbpURL))); player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED - + "Dungeon Rooms: You need the SkyblockPersonalized (SBP) Mod for this feature, get it from ").appendSibling(sbp)); + + "Dungeon Rooms: You need the Skyblock Personalized (SBP) Mod for this feature, get it from ").appendSibling(sbp)); } break; } diff --git a/src/main/java/io/github/quantizr/dungeonrooms/utils/MapUtils.java b/src/main/java/io/github/quantizr/dungeonrooms/utils/MapUtils.java index 2855b08..eddad78 100644 --- a/src/main/java/io/github/quantizr/dungeonrooms/utils/MapUtils.java +++ b/src/main/java/io/github/quantizr/dungeonrooms/utils/MapUtils.java @@ -18,6 +18,7 @@ package io.github.quantizr.dungeonrooms.utils; +import io.github.quantizr.dungeonrooms.dungeons.catacombs.DungeonManager; import net.minecraft.block.material.MapColor; import net.minecraft.client.Minecraft; import net.minecraft.init.Items; @@ -28,8 +29,8 @@ import net.minecraft.world.storage.MapData; import java.awt.*; -import java.util.*; import java.util.List; +import java.util.*; public class MapUtils { @@ -45,16 +46,42 @@ public static boolean mapExists() { } /** - * Reads the hotbar map and converts it into a 2D Integer array of RGB colors which can be used by the rest of the + * Reads the map data and converts it into a 2D Integer array of RGB colors which can be used by the rest of the * code * * @return null if map not found, otherwise 128x128 Array of the RGB Integer colors of each point on the map */ public static Integer[][] updatedMap() { - if (!mapExists()) return null; //make sure map exists - Minecraft mc = Minecraft.getMinecraft(); - ItemStack mapSlot = mc.thePlayer.inventory.getStackInSlot(8); //get map ItemStack - MapData mapData = Items.filled_map.getMapData(mapSlot, mc.theWorld); + return updatedMap(DungeonManager.mapId); + } + + /** + * Reads the map data and converts it into a 2D Integer array of RGB colors which can be used by the rest of the + * code + * + * @return null if map not found, otherwise 128x128 Array of the RGB Integer colors of each point on the map + */ + public static Integer[][] updatedMap(int mapId) { + return updatedMap((MapData) Minecraft.getMinecraft().theWorld.getMapStorage().loadData(MapData.class, "map_" + mapId)); + } + + /** + * Reads the map item and converts it into a 2D Integer array of RGB colors which can be used by the rest of the + * code + * + * @return null if map not found, otherwise 128x128 Array of the RGB Integer colors of each point on the map + */ + public static Integer[][] updatedMap(ItemStack mapSlot) { + return updatedMap(Items.filled_map.getMapData(mapSlot, Minecraft.getMinecraft().theWorld)); + } + + /** + * Reads the map data and converts it into a 2D Integer array of RGB colors which can be used by the rest of the + * code + * + * @return null if map not found, otherwise 128x128 Array of the RGB Integer colors of each point on the map + */ + public static Integer[][] updatedMap(MapData mapData) { if(mapData == null) return null; Integer[][] map = new Integer[128][128]; @@ -308,10 +335,7 @@ public static String roomCategory(String roomSize, String roomColor) { * @return the coordinate of the player marker on the map */ public static Point playerMarkerPos() { - if (!mapExists()) return null; //make sure map exists - Minecraft mc = Minecraft.getMinecraft(); - ItemStack mapSlot = mc.thePlayer.inventory.getStackInSlot(8); //get map ItemStack - MapData mapData = Items.filled_map.getMapData(mapSlot, mc.theWorld); + MapData mapData = (MapData) Minecraft.getMinecraft().theWorld.getMapStorage().loadData(MapData.class, "map_" + DungeonManager.mapId); if(mapData == null) return null; if (mapData.mapDecorations != null) { for (Map.Entry entry : mapData.mapDecorations.entrySet()) { @@ -448,4 +472,4 @@ public static BlockPos relativeToActual(BlockPos relative, String cornerDirectio } return new BlockPos(x, relative.getY(), z); } -} +} \ No newline at end of file diff --git a/src/main/resources/assets/dungeonrooms/catacombs/1x1/Temple-3.skeleton b/src/main/resources/assets/dungeonrooms/catacombs/1x1/Temple-3.skeleton index a0be54e..b2193e7 100644 Binary files a/src/main/resources/assets/dungeonrooms/catacombs/1x1/Temple-3.skeleton and b/src/main/resources/assets/dungeonrooms/catacombs/1x1/Temple-3.skeleton differ diff --git a/src/main/resources/assets/dungeonrooms/catacombs/1x1/Zodd-1.skeleton b/src/main/resources/assets/dungeonrooms/catacombs/1x1/Zodd-1.skeleton new file mode 100644 index 0000000..099d554 Binary files /dev/null and b/src/main/resources/assets/dungeonrooms/catacombs/1x1/Zodd-1.skeleton differ diff --git a/src/main/resources/assets/dungeonrooms/dungeonrooms.json b/src/main/resources/assets/dungeonrooms/dungeonrooms.json index 5303f6b..a6c7f4c 100644 --- a/src/main/resources/assets/dungeonrooms/dungeonrooms.json +++ b/src/main/resources/assets/dungeonrooms/dungeonrooms.json @@ -891,54 +891,70 @@ "category": "1x1", "secrets": 3, "fairysoul": false, - "sbp": "redstone-skull" + "dsg": "null", + "sbp": null }, "Sewer-7": { "category": "1x4", "secrets": 7, "fairysoul": false, - "sbp": "sewer" + "dsg": "null", + "sbp": null }, "Altar-6": { "category": "L-shape", "secrets": 6, "fairysoul": false, - "sbp": "altar" + "dsg": "null", + "sbp": null }, "Slime-5": { "category": "1x3", "secrets": 5, "fairysoul": false, - "sbp": "slime" + "dsg": "null", + "sbp": null }, "Crypts-1": { "category": "1x1", "secrets": 1, "fairysoul": false, - "sbp": "crypts" + "dsg": "null", + "sbp": null }, "Draw-Bridge-6": { "category": "1x1", "secrets": 6, "fairysoul": false, - "sbp": "draw-bridge" + "dsg": "null", + "sbp": null }, "Double-Stair-3": { "category": "1x1", "secrets": 3, "fairysoul": false, - "sbp": "double-stair" + "dsg": "null", + "sbp": null }, "Lava-Skulls-3": { "category": "1x1", "secrets": 3, "fairysoul": false, - "sbp": "lava-skulls" + "dsg": "null", + "sbp": null }, "Four-Banner-1": { "category": "1x1", "secrets": 1, "fairysoul": false, - "sbp": "four-banner" + "dsg": "null", + "sbp": null + }, + "Zodd-1": { + "category": "1x1", + "secrets": 1, + "fairysoul": false, + "dsg": "null", + "sbp": null } } \ No newline at end of file diff --git a/src/main/resources/assets/dungeonrooms/secretlocations.json b/src/main/resources/assets/dungeonrooms/secretlocations.json index d5e3834..d315277 100644 --- a/src/main/resources/assets/dungeonrooms/secretlocations.json +++ b/src/main/resources/assets/dungeonrooms/secretlocations.json @@ -5504,7 +5504,7 @@ "z":24 }, { - "secretName":"3 - Stonk (may locked)", + "secretName":"3 - Stonk", "category":"stonk", "x":63, "y":55, @@ -5521,7 +5521,7 @@ "secretName":"3 - Entrance", "category":"entrance", "x":63, - "y":55, + "y":54, "z":7 }, { @@ -5981,5 +5981,14 @@ "y":94, "z":26 } + ], + "Zodd-1": [ + { + "secretName":"1 - Chest", + "category":"chest", + "x":7, + "y":70, + "z":3 + } ] -} +} \ No newline at end of file