Skip to content

Commit

Permalink
Merge pull request #28 from KoutaChan/zodd-room
Browse files Browse the repository at this point in the history
feat: Add Zodd-1 room
  • Loading branch information
Quantizr authored Mar 25, 2024
2 parents 1f4c4e0 + 066ac4d commit 861bc69
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;

Expand All @@ -55,7 +59,6 @@ public class RoomDetection {
public static String roomDirection = "undefined";
public static Point roomCorner;


public static HashSet<BlockPos> currentScannedBlocks = new HashSet<>();
public static HashMap<BlockPos, Integer> blocksToCheck = new HashMap<>();
public static int totalBlocksAvailableToCheck = 0;
Expand All @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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":
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -228,7 +233,6 @@ public void onTick(TickEvent.ClientTickEvent event) {
}
}


void updateCurrentRoom() {
EntityPlayerSP player = mc.thePlayer;
map = MapUtils.updatedMap();
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -450,4 +463,4 @@ Future<HashMap<String, List<String>>> getPossibleRooms() {
return updatedPossibleRooms;
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
46 changes: 35 additions & 11 deletions src/main/java/io/github/quantizr/dungeonrooms/utils/MapUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {

Expand All @@ -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];

Expand Down Expand Up @@ -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<String, Vec4b> entry : mapData.mapDecorations.entrySet()) {
Expand Down Expand Up @@ -448,4 +472,4 @@ public static BlockPos relativeToActual(BlockPos relative, String cornerDirectio
}
return new BlockPos(x, relative.getY(), z);
}
}
}
Binary file not shown.
Binary file not shown.
34 changes: 25 additions & 9 deletions src/main/resources/assets/dungeonrooms/dungeonrooms.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
15 changes: 12 additions & 3 deletions src/main/resources/assets/dungeonrooms/secretlocations.json
Original file line number Diff line number Diff line change
Expand Up @@ -5504,7 +5504,7 @@
"z":24
},
{
"secretName":"3 - Stonk (may locked)",
"secretName":"3 - Stonk",
"category":"stonk",
"x":63,
"y":55,
Expand All @@ -5521,7 +5521,7 @@
"secretName":"3 - Entrance",
"category":"entrance",
"x":63,
"y":55,
"y":54,
"z":7
},
{
Expand Down Expand Up @@ -5981,5 +5981,14 @@
"y":94,
"z":26
}
],
"Zodd-1": [
{
"secretName":"1 - Chest",
"category":"chest",
"x":7,
"y":70,
"z":3
}
]
}
}

0 comments on commit 861bc69

Please sign in to comment.