aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java3051
1 files changed, 1585 insertions, 1466 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java
index bdf6647b..592f5b19 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java
@@ -50,353 +50,389 @@ import java.util.List;
import java.util.*;
public class DungeonMap {
- private static final ResourceLocation GREEN_CHECK = new ResourceLocation("notenoughupdates:dungeon_map/green_check.png");
- private static final ResourceLocation WHITE_CHECK = new ResourceLocation("notenoughupdates:dungeon_map/white_check.png");
- private static final ResourceLocation QUESTION = new ResourceLocation("notenoughupdates:dungeon_map/question.png");
- private static final ResourceLocation CROSS = new ResourceLocation("notenoughupdates:dungeon_map/cross.png");
-
- private static final ResourceLocation ROOM_RED = new ResourceLocation("notenoughupdates:dungeon_map/rooms_default/red_room.png");
- private static final ResourceLocation ROOM_BROWN = new ResourceLocation("notenoughupdates:dungeon_map/rooms_default/brown_room.png");
- private static final ResourceLocation ROOM_GRAY = new ResourceLocation("notenoughupdates:dungeon_map/rooms_default/gray_room.png");
- private static final ResourceLocation ROOM_GREEN = new ResourceLocation("notenoughupdates:dungeon_map/rooms_default/green_room.png");
- private static final ResourceLocation ROOM_PINK = new ResourceLocation("notenoughupdates:dungeon_map/rooms_default/pink_room.png");
- private static final ResourceLocation ROOM_PURPLE = new ResourceLocation("notenoughupdates:dungeon_map/rooms_default/purple_room.png");
- private static final ResourceLocation ROOM_YELLOW = new ResourceLocation("notenoughupdates:dungeon_map/rooms_default/yellow_room.png");
- private static final ResourceLocation ROOM_ORANGE = new ResourceLocation("notenoughupdates:dungeon_map/rooms_default/orange_room.png");
-
- private static final ResourceLocation CORRIDOR_RED = new ResourceLocation("notenoughupdates:dungeon_map/corridors_default/red_corridor.png");
- private static final ResourceLocation CORRIDOR_BROWN = new ResourceLocation("notenoughupdates:dungeon_map/corridors_default/brown_corridor.png");
- private static final ResourceLocation CORRIDOR_GRAY = new ResourceLocation("notenoughupdates:dungeon_map/corridors_default/gray_corridor.png");
- private static final ResourceLocation CORRIDOR_GREEN = new ResourceLocation("notenoughupdates:dungeon_map/corridors_default/green_corridor.png");
- private static final ResourceLocation CORRIDOR_PINK = new ResourceLocation("notenoughupdates:dungeon_map/corridors_default/pink_corridor.png");
- private static final ResourceLocation CORRIDOR_PURPLE = new ResourceLocation("notenoughupdates:dungeon_map/corridors_default/purple_corridor.png");
- private static final ResourceLocation CORRIDOR_YELLOW = new ResourceLocation("notenoughupdates:dungeon_map/corridors_default/yellow_corridor.png");
- private static final ResourceLocation CORRIDOR_ORANGE = new ResourceLocation("notenoughupdates:dungeon_map/corridors_default/orange_corridor.png");
-
- private static final ResourceLocation DIVIDER_BROWN = new ResourceLocation("notenoughupdates:dungeon_map/dividers_default/brown_divider.png");
-
- private static final ResourceLocation CORNER_BROWN = new ResourceLocation("notenoughupdates:dungeon_map/corners_default/brown_corner.png");
-
- private final HashMap<RoomOffset, Room> roomMap = new HashMap<>();
- private Color[][] colourMap = new Color[128][128];
- private int startRoomX = -1;
- private int startRoomY = -1;
- private int connectorSize = 5;
- private int roomSize = 0;
-
- //private final List<MapDecoration> decorations = new ArrayList<>();
- //private final List<MapDecoration> lastDecorations = new ArrayList<>();
- private long lastDecorationsMillis = -1;
- private long lastLastDecorationsMillis = -1;
-
- private final Map<String, MapPosition> playerEntityMapPositions = new HashMap<>();
- private final Map<String, MapPosition> playerMarkerMapPositions = new HashMap<>();
- private final Set<MapPosition> rawPlayerMarkerMapPositions = new HashSet<>();
- private final Map<String, MapPosition> playerMarkerMapPositionsLast = new HashMap<>();
- private final HashMap<String, Integer> playerIdMap = new HashMap<>();
-
- private final Map<String, ResourceLocation> playerSkinMap = new HashMap<>();
-
- private static class RoomOffset {
- int x;
- int y;
-
- public RoomOffset(int x, int y) {
- this.x = x;
- this.y = y;
- }
-
- public RoomOffset left() {
- return new RoomOffset(x - 1, y);
- }
-
- public RoomOffset right() {
- return new RoomOffset(x + 1, y);
- }
-
- public RoomOffset up() {
- return new RoomOffset(x, y - 1);
- }
-
- public RoomOffset down() {
- return new RoomOffset(x, y + 1);
- }
-
- public RoomOffset[] getNeighbors() {
- return new RoomOffset[]{left(), right(), up(), down()};
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- RoomOffset that = (RoomOffset) o;
- return x == that.x && y == that.y;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(x, y);
- }
- }
-
- private enum RoomConnectionType {
- NONE, WALL, CORRIDOR, ROOM_DIVIDER
- }
-
- private static class RoomConnection {
- RoomConnectionType type;
- Color colour;
-
- public RoomConnection(RoomConnectionType type, Color colour) {
- this.type = type;
- this.colour = colour;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- RoomConnection that = (RoomConnection) o;
- return type == that.type &&
- Objects.equals(colour, that.colour);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(type, colour);
- }
- }
-
- private class Room {
- Color colour = new Color(0, 0, 0, 0);
- int tickColour = 0;
- boolean fillCorner = false;
-
- RoomConnection left = new RoomConnection(RoomConnectionType.NONE, new Color(0, true));
- RoomConnection up = new RoomConnection(RoomConnectionType.NONE, new Color(0, true));
- RoomConnection right = new RoomConnection(RoomConnectionType.NONE, new Color(0, true));
- RoomConnection down = new RoomConnection(RoomConnectionType.NONE, new Color(0, true));
-
- public void renderNoRotate(int roomSize, int connectorSize, int rotation) {
- if (tickColour != 0) {
- Color tick = new Color(tickColour, true);
- ResourceLocation indicatorTex = null;
- if (tick.getRed() == 255 && tick.getGreen() == 255 && tick.getBlue() == 255) {
- indicatorTex = WHITE_CHECK;
- } else if (tick.getRed() == 0 && tick.getGreen() == 124 && tick.getBlue() == 0) {
- indicatorTex = GREEN_CHECK;
- } else if (tick.getRed() == 13 && tick.getGreen() == 13 && tick.getBlue() == 13) {
- indicatorTex = QUESTION;
- } else if (tick.getRed() == 255 && tick.getGreen() == 0 && tick.getBlue() == 0) {
- indicatorTex = CROSS;
- }
- if (indicatorTex != null) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(indicatorTex);
- float x = 0;
- float y = 0;
-
- if (NotEnoughUpdates.INSTANCE.config.dungeonMap.dmCenterCheck) {
- if (fillCorner) {
- x += -(roomSize + connectorSize) / 2f * Math.cos(Math.toRadians(rotation - 45)) * 1.414f;
- y += (roomSize + connectorSize) / 2f * Math.sin(Math.toRadians(rotation - 45)) * 1.414;
- }
- if (down.type == RoomConnectionType.ROOM_DIVIDER && right.type != RoomConnectionType.ROOM_DIVIDER) {
- x += -(roomSize + connectorSize) / 2f * Math.sin(Math.toRadians(rotation));
- y += -(roomSize + connectorSize) / 2f * Math.cos(Math.toRadians(rotation));
- } else if (down.type != RoomConnectionType.ROOM_DIVIDER && right.type == RoomConnectionType.ROOM_DIVIDER) {
- x += -(roomSize + connectorSize) / 2f * Math.cos(Math.toRadians(rotation));
- y += (roomSize + connectorSize) / 2f * Math.sin(Math.toRadians(rotation));
- }
- }
- GlStateManager.translate(x, y, 0);
- if (!NotEnoughUpdates.INSTANCE.config.dungeonMap.dmOrientCheck) {
- GlStateManager.rotate(-rotation + 180, 0, 0, 1);
- }
-
- GlStateManager.pushMatrix();
- GlStateManager.scale(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmIconScale,
- NotEnoughUpdates.INSTANCE.config.dungeonMap.dmIconScale, 1);
- Utils.drawTexturedRect(-5, -5, 10, 10, GL11.GL_NEAREST);
- GlStateManager.popMatrix();
-
- if (!NotEnoughUpdates.INSTANCE.config.dungeonMap.dmOrientCheck) {
- GlStateManager.rotate(rotation - 180, 0, 0, 1);
- }
- GlStateManager.translate(-x, -y, 0);
- }
- }
- }
-
- public void render(int roomSize, int connectorSize) {
- ResourceLocation roomTex = null;
- if (colour.getRed() == 114 && colour.getGreen() == 67 && colour.getBlue() == 27) {
- roomTex = ROOM_BROWN;
- } else if (colour.getRed() == 65 && colour.getGreen() == 65 && colour.getBlue() == 65) {
- roomTex = ROOM_GRAY;
- } else if (colour.getRed() == 0 && colour.getGreen() == 124 && colour.getBlue() == 0) {
- roomTex = ROOM_GREEN;
- } else if (colour.getRed() == 242 && colour.getGreen() == 127 && colour.getBlue() == 165) {
- roomTex = ROOM_PINK;
- } else if (colour.getRed() == 178 && colour.getGreen() == 76 && colour.getBlue() == 216) {
- roomTex = ROOM_PURPLE;
- } else if (colour.getRed() == 255 && colour.getGreen() == 0 && colour.getBlue() == 0) {
- roomTex = ROOM_RED;
- } else if (colour.getRed() == 229 && colour.getGreen() == 229 && colour.getBlue() == 51) {
- roomTex = ROOM_YELLOW;
- } else if (colour.getRed() == 216 && colour.getGreen() == 127 && colour.getBlue() == 51) {
- roomTex = ROOM_ORANGE;
- }
-
- if (roomTex != null) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(roomTex);
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(0, 0, roomSize, roomSize, GL11.GL_LINEAR);
- } else {
- Gui.drawRect(0, 0, roomSize, roomSize, colour.getRGB());
- }
-
- if (fillCorner) {
- GlStateManager.color(1, 1, 1, 1);
- Minecraft.getMinecraft().getTextureManager().bindTexture(CORNER_BROWN);
- Utils.drawTexturedRect(roomSize, roomSize, connectorSize, connectorSize, GL11.GL_NEAREST);
- }
-
- for (int k = 0; k < 2; k++) {
- RoomConnection connection = down;
- if (k == 1) connection = right;
-
- if (connection.type == RoomConnectionType.NONE || connection.type == RoomConnectionType.WALL) continue;
-
- ResourceLocation corridorTex = null;
- if (connection.colour.getRed() == 114 && connection.colour.getGreen() == 67 && connection.colour.getBlue() == 27) {
- corridorTex = connection.type == RoomConnectionType.CORRIDOR ? CORRIDOR_BROWN : DIVIDER_BROWN;
- } else if (connection.colour.getRed() == 65 && connection.colour.getGreen() == 65 && connection.colour.getBlue() == 65) {
- corridorTex = CORRIDOR_GRAY;
- } else if (connection.colour.getRed() == 0 && connection.colour.getGreen() == 124 && connection.colour.getBlue() == 0) {
- corridorTex = CORRIDOR_GREEN;
- } else if (connection.colour.getRed() == 242 && connection.colour.getGreen() == 127 && connection.colour.getBlue() == 165) {
- corridorTex = CORRIDOR_PINK;
- } else if (connection.colour.getRed() == 178 && connection.colour.getGreen() == 76 && connection.colour.getBlue() == 216) {
- corridorTex = CORRIDOR_PURPLE;
- } else if (connection.colour.getRed() == 255 && connection.colour.getGreen() == 0 && connection.colour.getBlue() == 0) {
- corridorTex = CORRIDOR_RED;
- } else if (connection.colour.getRed() == 229 && connection.colour.getGreen() == 229 && connection.colour.getBlue() == 51) {
- corridorTex = CORRIDOR_YELLOW;
- } else if (connection.colour.getRed() == 216 && connection.colour.getGreen() == 127 && connection.colour.getBlue() == 51) {
- corridorTex = CORRIDOR_ORANGE;
- }
-
- if (corridorTex == null) {
- int xOffset = 0;
- int yOffset = 0;
- int width = 0;
- int height = 0;
-
- if (connection == right) {
- xOffset = roomSize;
- width = connectorSize;
- height = roomSize;
-
- if (connection.type == RoomConnectionType.CORRIDOR) {
- height = 8;
- yOffset += 4;
- }
- } else if (connection == down) {
- yOffset = roomSize;
- width = roomSize;
- height = connectorSize;
-
- if (connection.type == RoomConnectionType.CORRIDOR) {
- width = 8;
- xOffset += 4;
- }
- }
-
- Gui.drawRect(xOffset, yOffset, xOffset + width, yOffset + height, connection.colour.getRGB());
- } else {
- GlStateManager.color(1, 1, 1, 1);
- Minecraft.getMinecraft().getTextureManager().bindTexture(corridorTex);
- GlStateManager.pushMatrix();
- if (connection == right) {
- GlStateManager.translate(roomSize / 2f, roomSize / 2f, 0);
- GlStateManager.rotate(-90, 0, 0, 1);
- GlStateManager.translate(-roomSize / 2f, -roomSize / 2f, 0);
- }
- Utils.drawTexturedRect(0, roomSize, roomSize, connectorSize, GL11.GL_NEAREST);
- GlStateManager.popMatrix();
- }
- }
- }
- }
-
- private static final ResourceLocation mapIcons = new ResourceLocation("textures/map/map_icons.png");
-
- public static Framebuffer mapFramebuffer1 = null;
- public static Framebuffer mapFramebuffer2 = null;
- public static Matrix4f projectionMatrix = null;
- public static Shader mapShader = null;
-
- private static Framebuffer checkFramebufferSizes(Framebuffer framebuffer, int width, int height) {
- if (framebuffer == null || framebuffer.framebufferWidth != width || framebuffer.framebufferHeight != height) {
- if (framebuffer == null) {
- framebuffer = new Framebuffer(width, height, true);
- } else {
- framebuffer.createBindFramebuffer(width, height);
- }
- framebuffer.setFramebufferFilter(GL11.GL_NEAREST);
- }
- return framebuffer;
- }
-
- private static void upload(Shader shader, int width, int height, int scale, float radiusSq) {
- if (shader == null) return;
- shader.getShaderManager().getShaderUniformOrDefault("ProjMat").set(projectionMatrix);
- shader.getShaderManager().getShaderUniformOrDefault("InSize").set(width * scale, height * scale);
- shader.getShaderManager().getShaderUniformOrDefault("OutSize").set(width, height);
- shader.getShaderManager().getShaderUniformOrDefault("ScreenSize").set((float) width, (float) height);
- shader.getShaderManager().getShaderUniformOrDefault("radiusSq").set(radiusSq);
- }
-
- public int getRenderRoomSize() {
- double roomSizeOption = NotEnoughUpdates.INSTANCE.config.dungeonMap.dmRoomSize;
- if (roomSizeOption <= 0) return 12;
- return 12 + (int) Math.round(roomSizeOption * 4);
- }
-
- public int getRenderConnSize() {
- int roomSizeOption = Math.round(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmRoomSize);
- if (roomSizeOption <= 0) return 3;
- return 3 + roomSizeOption;
- }
-
- private final HashMap<Integer, Float> borderRadiusCache = new HashMap<>();
-
- public float getBorderRadius() {
- int borderSizeOption = Math.round(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBorderSize);
- String sizeId = borderSizeOption == 0 ? "small" : borderSizeOption == 2 ? "large" : "medium";
-
- int style = NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBorderStyle;
- if (borderRadiusCache.containsKey(style)) {
- return borderRadiusCache.get(style);
- }
-
- try (BufferedReader reader = new BufferedReader(new InputStreamReader(Minecraft.getMinecraft().getResourceManager().getResource(
- new ResourceLocation("notenoughupdates:dungeon_map/borders/" + sizeId + "/" + style + ".json")).getInputStream(), StandardCharsets.UTF_8))) {
- JsonObject json = NotEnoughUpdates.INSTANCE.manager.gson.fromJson(reader, JsonObject.class);
- float radiusSq = json.get("radiusSq").getAsFloat();
-
- borderRadiusCache.put(style, radiusSq);
- return radiusSq;
- } catch (Exception ignored) {}
-
- borderRadiusCache.put(style, 1f);
- return 1f;
- }
-
- public void render(int centerX, int centerY) {
- boolean useFb = NotEnoughUpdates.INSTANCE.config.dungeonMap.dmCompat <= 1 && OpenGlHelper.isFramebufferEnabled();
- boolean useShd = NotEnoughUpdates.INSTANCE.config.dungeonMap.dmCompat <= 0 && OpenGlHelper.areShadersSupported();
+ private static final ResourceLocation GREEN_CHECK = new ResourceLocation(
+ "notenoughupdates:dungeon_map/green_check.png");
+ private static final ResourceLocation WHITE_CHECK = new ResourceLocation(
+ "notenoughupdates:dungeon_map/white_check.png");
+ private static final ResourceLocation QUESTION = new ResourceLocation("notenoughupdates:dungeon_map/question.png");
+ private static final ResourceLocation CROSS = new ResourceLocation("notenoughupdates:dungeon_map/cross.png");
+
+ private static final ResourceLocation ROOM_RED = new ResourceLocation(
+ "notenoughupdates:dungeon_map/rooms_default/red_room.png");
+ private static final ResourceLocation ROOM_BROWN = new ResourceLocation(
+ "notenoughupdates:dungeon_map/rooms_default/brown_room.png");
+ private static final ResourceLocation ROOM_GRAY = new ResourceLocation(
+ "notenoughupdates:dungeon_map/rooms_default/gray_room.png");
+ private static final ResourceLocation ROOM_GREEN = new ResourceLocation(
+ "notenoughupdates:dungeon_map/rooms_default/green_room.png");
+ private static final ResourceLocation ROOM_PINK = new ResourceLocation(
+ "notenoughupdates:dungeon_map/rooms_default/pink_room.png");
+ private static final ResourceLocation ROOM_PURPLE = new ResourceLocation(
+ "notenoughupdates:dungeon_map/rooms_default/purple_room.png");
+ private static final ResourceLocation ROOM_YELLOW = new ResourceLocation(
+ "notenoughupdates:dungeon_map/rooms_default/yellow_room.png");
+ private static final ResourceLocation ROOM_ORANGE = new ResourceLocation(
+ "notenoughupdates:dungeon_map/rooms_default/orange_room.png");
+
+ private static final ResourceLocation CORRIDOR_RED = new ResourceLocation(
+ "notenoughupdates:dungeon_map/corridors_default/red_corridor.png");
+ private static final ResourceLocation CORRIDOR_BROWN = new ResourceLocation(
+ "notenoughupdates:dungeon_map/corridors_default/brown_corridor.png");
+ private static final ResourceLocation CORRIDOR_GRAY = new ResourceLocation(
+ "notenoughupdates:dungeon_map/corridors_default/gray_corridor.png");
+ private static final ResourceLocation CORRIDOR_GREEN = new ResourceLocation(
+ "notenoughupdates:dungeon_map/corridors_default/green_corridor.png");
+ private static final ResourceLocation CORRIDOR_PINK = new ResourceLocation(
+ "notenoughupdates:dungeon_map/corridors_default/pink_corridor.png");
+ private static final ResourceLocation CORRIDOR_PURPLE = new ResourceLocation(
+ "notenoughupdates:dungeon_map/corridors_default/purple_corridor.png");
+ private static final ResourceLocation CORRIDOR_YELLOW = new ResourceLocation(
+ "notenoughupdates:dungeon_map/corridors_default/yellow_corridor.png");
+ private static final ResourceLocation CORRIDOR_ORANGE = new ResourceLocation(
+ "notenoughupdates:dungeon_map/corridors_default/orange_corridor.png");
+
+ private static final ResourceLocation DIVIDER_BROWN = new ResourceLocation(
+ "notenoughupdates:dungeon_map/dividers_default/brown_divider.png");
+
+ private static final ResourceLocation CORNER_BROWN = new ResourceLocation(
+ "notenoughupdates:dungeon_map/corners_default/brown_corner.png");
+
+ private final HashMap<RoomOffset, Room> roomMap = new HashMap<>();
+ private Color[][] colourMap = new Color[128][128];
+ private int startRoomX = -1;
+ private int startRoomY = -1;
+ private int connectorSize = 5;
+ private int roomSize = 0;
+
+ //private final List<MapDecoration> decorations = new ArrayList<>();
+ //private final List<MapDecoration> lastDecorations = new ArrayList<>();
+ private long lastDecorationsMillis = -1;
+ private long lastLastDecorationsMillis = -1;
+
+ private final Map<String, MapPosition> playerEntityMapPositions = new HashMap<>();
+ private final Map<String, MapPosition> playerMarkerMapPositions = new HashMap<>();
+ private final Set<MapPosition> rawPlayerMarkerMapPositions = new HashSet<>();
+ private final Map<String, MapPosition> playerMarkerMapPositionsLast = new HashMap<>();
+ private final HashMap<String, Integer> playerIdMap = new HashMap<>();
+
+ private final Map<String, ResourceLocation> playerSkinMap = new HashMap<>();
+
+ private static class RoomOffset {
+ int x;
+ int y;
+
+ public RoomOffset(int x, int y) {
+ this.x = x;
+ this.y = y;
+ }
+
+ public RoomOffset left() {
+ return new RoomOffset(x - 1, y);
+ }
+
+ public RoomOffset right() {
+ return new RoomOffset(x + 1, y);
+ }
+
+ public RoomOffset up() {
+ return new RoomOffset(x, y - 1);
+ }
+
+ public RoomOffset down() {
+ return new RoomOffset(x, y + 1);
+ }
+
+ public RoomOffset[] getNeighbors() {
+ return new RoomOffset[]{left(), right(), up(), down()};
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ RoomOffset that = (RoomOffset) o;
+ return x == that.x && y == that.y;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(x, y);
+ }
+ }
+
+ private enum RoomConnectionType {
+ NONE, WALL, CORRIDOR, ROOM_DIVIDER
+ }
+
+ private static class RoomConnection {
+ RoomConnectionType type;
+ Color colour;
+
+ public RoomConnection(RoomConnectionType type, Color colour) {
+ this.type = type;
+ this.colour = colour;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ RoomConnection that = (RoomConnection) o;
+ return type == that.type &&
+ Objects.equals(colour, that.colour);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(type, colour);
+ }
+ }
+
+ private class Room {
+ Color colour = new Color(0, 0, 0, 0);
+ int tickColour = 0;
+ boolean fillCorner = false;
+
+ RoomConnection left = new RoomConnection(RoomConnectionType.NONE, new Color(0, true));
+ RoomConnection up = new RoomConnection(RoomConnectionType.NONE, new Color(0, true));
+ RoomConnection right = new RoomConnection(RoomConnectionType.NONE, new Color(0, true));
+ RoomConnection down = new RoomConnection(RoomConnectionType.NONE, new Color(0, true));
+
+ public void renderNoRotate(int roomSize, int connectorSize, int rotation) {
+ if (tickColour != 0) {
+ Color tick = new Color(tickColour, true);
+ ResourceLocation indicatorTex = null;
+ if (tick.getRed() == 255 && tick.getGreen() == 255 && tick.getBlue() == 255) {
+ indicatorTex = WHITE_CHECK;
+ } else if (tick.getRed() == 0 && tick.getGreen() == 124 && tick.getBlue() == 0) {
+ indicatorTex = GREEN_CHECK;
+ } else if (tick.getRed() == 13 && tick.getGreen() == 13 && tick.getBlue() == 13) {
+ indicatorTex = QUESTION;
+ } else if (tick.getRed() == 255 && tick.getGreen() == 0 && tick.getBlue() == 0) {
+ indicatorTex = CROSS;
+ }
+ if (indicatorTex != null) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(indicatorTex);
+ float x = 0;
+ float y = 0;
+
+ if (NotEnoughUpdates.INSTANCE.config.dungeonMap.dmCenterCheck) {
+ if (fillCorner) {
+ x += -(roomSize + connectorSize) / 2f * Math.cos(Math.toRadians(rotation - 45)) * 1.414f;
+ y += (roomSize + connectorSize) / 2f * Math.sin(Math.toRadians(rotation - 45)) * 1.414;
+ }
+ if (down.type == RoomConnectionType.ROOM_DIVIDER && right.type != RoomConnectionType.ROOM_DIVIDER) {
+ x += -(roomSize + connectorSize) / 2f * Math.sin(Math.toRadians(rotation));
+ y += -(roomSize + connectorSize) / 2f * Math.cos(Math.toRadians(rotation));
+ } else if (down.type != RoomConnectionType.ROOM_DIVIDER && right.type == RoomConnectionType.ROOM_DIVIDER) {
+ x += -(roomSize + connectorSize) / 2f * Math.cos(Math.toRadians(rotation));
+ y += (roomSize + connectorSize) / 2f * Math.sin(Math.toRadians(rotation));
+ }
+ }
+ GlStateManager.translate(x, y, 0);
+ if (!NotEnoughUpdates.INSTANCE.config.dungeonMap.dmOrientCheck) {
+ GlStateManager.rotate(-rotation + 180, 0, 0, 1);
+ }
+
+ GlStateManager.pushMatrix();
+ GlStateManager.scale(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmIconScale,
+ NotEnoughUpdates.INSTANCE.config.dungeonMap.dmIconScale, 1
+ );
+ Utils.drawTexturedRect(-5, -5, 10, 10, GL11.GL_NEAREST);
+ GlStateManager.popMatrix();
+
+ if (!NotEnoughUpdates.INSTANCE.config.dungeonMap.dmOrientCheck) {
+ GlStateManager.rotate(rotation - 180, 0, 0, 1);
+ }
+ GlStateManager.translate(-x, -y, 0);
+ }
+ }
+ }
+
+ public void render(int roomSize, int connectorSize) {
+ ResourceLocation roomTex = null;
+ if (colour.getRed() == 114 && colour.getGreen() == 67 && colour.getBlue() == 27) {
+ roomTex = ROOM_BROWN;
+ } else if (colour.getRed() == 65 && colour.getGreen() == 65 && colour.getBlue() == 65) {
+ roomTex = ROOM_GRAY;
+ } else if (colour.getRed() == 0 && colour.getGreen() == 124 && colour.getBlue() == 0) {
+ roomTex = ROOM_GREEN;
+ } else if (colour.getRed() == 242 && colour.getGreen() == 127 && colour.getBlue() == 165) {
+ roomTex = ROOM_PINK;
+ } else if (colour.getRed() == 178 && colour.getGreen() == 76 && colour.getBlue() == 216) {
+ roomTex = ROOM_PURPLE;
+ } else if (colour.getRed() == 255 && colour.getGreen() == 0 && colour.getBlue() == 0) {
+ roomTex = ROOM_RED;
+ } else if (colour.getRed() == 229 && colour.getGreen() == 229 && colour.getBlue() == 51) {
+ roomTex = ROOM_YELLOW;
+ } else if (colour.getRed() == 216 && colour.getGreen() == 127 && colour.getBlue() == 51) {
+ roomTex = ROOM_ORANGE;
+ }
+
+ if (roomTex != null) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(roomTex);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(0, 0, roomSize, roomSize, GL11.GL_LINEAR);
+ } else {
+ Gui.drawRect(0, 0, roomSize, roomSize, colour.getRGB());
+ }
+
+ if (fillCorner) {
+ GlStateManager.color(1, 1, 1, 1);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(CORNER_BROWN);
+ Utils.drawTexturedRect(roomSize, roomSize, connectorSize, connectorSize, GL11.GL_NEAREST);
+ }
+
+ for (int k = 0; k < 2; k++) {
+ RoomConnection connection = down;
+ if (k == 1) connection = right;
+
+ if (connection.type == RoomConnectionType.NONE || connection.type == RoomConnectionType.WALL) continue;
+
+ ResourceLocation corridorTex = null;
+ if (connection.colour.getRed() == 114 && connection.colour.getGreen() == 67 &&
+ connection.colour.getBlue() == 27) {
+ corridorTex = connection.type == RoomConnectionType.CORRIDOR ? CORRIDOR_BROWN : DIVIDER_BROWN;
+ } else if (connection.colour.getRed() == 65 && connection.colour.getGreen() == 65 &&
+ connection.colour.getBlue() == 65) {
+ corridorTex = CORRIDOR_GRAY;
+ } else if (connection.colour.getRed() == 0 && connection.colour.getGreen() == 124 &&
+ connection.colour.getBlue() == 0) {
+ corridorTex = CORRIDOR_GREEN;
+ } else if (connection.colour.getRed() == 242 && connection.colour.getGreen() == 127 &&
+ connection.colour.getBlue() == 165) {
+ corridorTex = CORRIDOR_PINK;
+ } else if (connection.colour.getRed() == 178 && connection.colour.getGreen() == 76 &&
+ connection.colour.getBlue() == 216) {
+ corridorTex = CORRIDOR_PURPLE;
+ } else if (connection.colour.getRed() == 255 && connection.colour.getGreen() == 0 &&
+ connection.colour.getBlue() == 0) {
+ corridorTex = CORRIDOR_RED;
+ } else if (connection.colour.getRed() == 229 && connection.colour.getGreen() == 229 &&
+ connection.colour.getBlue() == 51) {
+ corridorTex = CORRIDOR_YELLOW;
+ } else if (connection.colour.getRed() == 216 && connection.colour.getGreen() == 127 &&
+ connection.colour.getBlue() == 51) {
+ corridorTex = CORRIDOR_ORANGE;
+ }
+
+ if (corridorTex == null) {
+ int xOffset = 0;
+ int yOffset = 0;
+ int width = 0;
+ int height = 0;
+
+ if (connection == right) {
+ xOffset = roomSize;
+ width = connectorSize;
+ height = roomSize;
+
+ if (connection.type == RoomConnectionType.CORRIDOR) {
+ height = 8;
+ yOffset += 4;
+ }
+ } else if (connection == down) {
+ yOffset = roomSize;
+ width = roomSize;
+ height = connectorSize;
+
+ if (connection.type == RoomConnectionType.CORRIDOR) {
+ width = 8;
+ xOffset += 4;
+ }
+ }
+
+ Gui.drawRect(xOffset, yOffset, xOffset + width, yOffset + height, connection.colour.getRGB());
+ } else {
+ GlStateManager.color(1, 1, 1, 1);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(corridorTex);
+ GlStateManager.pushMatrix();
+ if (connection == right) {
+ GlStateManager.translate(roomSize / 2f, roomSize / 2f, 0);
+ GlStateManager.rotate(-90, 0, 0, 1);
+ GlStateManager.translate(-roomSize / 2f, -roomSize / 2f, 0);
+ }
+ Utils.drawTexturedRect(0, roomSize, roomSize, connectorSize, GL11.GL_NEAREST);
+ GlStateManager.popMatrix();
+ }
+ }
+ }
+ }
+
+ private static final ResourceLocation mapIcons = new ResourceLocation("textures/map/map_icons.png");
+
+ public static Framebuffer mapFramebuffer1 = null;
+ public static Framebuffer mapFramebuffer2 = null;
+ public static Matrix4f projectionMatrix = null;
+ public static Shader mapShader = null;
+
+ private static Framebuffer checkFramebufferSizes(Framebuffer framebuffer, int width, int height) {
+ if (framebuffer == null || framebuffer.framebufferWidth != width || framebuffer.framebufferHeight != height) {
+ if (framebuffer == null) {
+ framebuffer = new Framebuffer(width, height, true);
+ } else {
+ framebuffer.createBindFramebuffer(width, height);
+ }
+ framebuffer.setFramebufferFilter(GL11.GL_NEAREST);
+ }
+ return framebuffer;
+ }
+
+ private static void upload(Shader shader, int width, int height, int scale, float radiusSq) {
+ if (shader == null) return;
+ shader.getShaderManager().getShaderUniformOrDefault("ProjMat").set(projectionMatrix);
+ shader.getShaderManager().getShaderUniformOrDefault("InSize").set(width * scale, height * scale);
+ shader.getShaderManager().getShaderUniformOrDefault("OutSize").set(width, height);
+ shader.getShaderManager().getShaderUniformOrDefault("ScreenSize").set((float) width, (float) height);
+ shader.getShaderManager().getShaderUniformOrDefault("radiusSq").set(radiusSq);
+ }
+
+ public int getRenderRoomSize() {
+ double roomSizeOption = NotEnoughUpdates.INSTANCE.config.dungeonMap.dmRoomSize;
+ if (roomSizeOption <= 0) return 12;
+ return 12 + (int) Math.round(roomSizeOption * 4);
+ }
+
+ public int getRenderConnSize() {
+ int roomSizeOption = Math.round(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmRoomSize);
+ if (roomSizeOption <= 0) return 3;
+ return 3 + roomSizeOption;
+ }
+
+ private final HashMap<Integer, Float> borderRadiusCache = new HashMap<>();
+
+ public float getBorderRadius() {
+ int borderSizeOption = Math.round(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBorderSize);
+ String sizeId = borderSizeOption == 0 ? "small" : borderSizeOption == 2 ? "large" : "medium";
+
+ int style = NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBorderStyle;
+ if (borderRadiusCache.containsKey(style)) {
+ return borderRadiusCache.get(style);
+ }
+
+ try (
+ BufferedReader reader = new BufferedReader(new InputStreamReader(Minecraft
+ .getMinecraft()
+ .getResourceManager()
+ .getResource(
+ new ResourceLocation("notenoughupdates:dungeon_map/borders/" + sizeId + "/" + style + ".json"))
+ .getInputStream(), StandardCharsets.UTF_8))
+ ) {
+ JsonObject json = NotEnoughUpdates.INSTANCE.manager.gson.fromJson(reader, JsonObject.class);
+ float radiusSq = json.get("radiusSq").getAsFloat();
+
+ borderRadiusCache.put(style, radiusSq);
+ return radiusSq;
+ } catch (Exception ignored) {
+ }
+
+ borderRadiusCache.put(style, 1f);
+ return 1f;
+ }
+
+ public void render(int centerX, int centerY) {
+ boolean useFb = NotEnoughUpdates.INSTANCE.config.dungeonMap.dmCompat <= 1 && OpenGlHelper.isFramebufferEnabled();
+ boolean useShd = NotEnoughUpdates.INSTANCE.config.dungeonMap.dmCompat <= 0 && OpenGlHelper.areShadersSupported();
/*if((useFb && !OpenGlHelper.isFramebufferEnabled()) || (useShd && !OpenGlHelper.areShadersSupported())) {
Utils.drawStringCentered(EnumChatFormatting.RED+"NEU Dungeon Map requires framebuffers & shaders",
@@ -408,203 +444,221 @@ public class DungeonMap {
return;
}*/
- ScaledResolution scaledResolution = Utils.pushGuiScale(2);
-
- int minRoomX = 999;
- int minRoomY = 999;
- int maxRoomX = -999;
- int maxRoomY = -999;
- for (RoomOffset offset : roomMap.keySet()) {
- minRoomX = Math.min(offset.x, minRoomX);
- minRoomY = Math.min(offset.y, minRoomY);
- maxRoomX = Math.max(offset.x, maxRoomX);
- maxRoomY = Math.max(offset.y, maxRoomY);
- }
-
- int borderSizeOption = Math.round(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBorderSize);
-
- int renderRoomSize = getRenderRoomSize();
- int renderConnSize = getRenderConnSize();
-
- MapPosition playerPos = null;
- if (playerEntityMapPositions.containsKey(Minecraft.getMinecraft().thePlayer.getName())) {
- playerPos = playerEntityMapPositions.get(Minecraft.getMinecraft().thePlayer.getName());
- } else if (playerMarkerMapPositions.containsKey(Minecraft.getMinecraft().thePlayer.getName())) {
- playerPos = playerMarkerMapPositions.get(Minecraft.getMinecraft().thePlayer.getName());
- }
-
- int rotation = 180;
- if (playerPos != null && NotEnoughUpdates.INSTANCE.config.dungeonMap.dmRotatePlayer) {
- rotation = (int) playerPos.rotation;
- }
-
- int mapSizeX;
- int mapSizeY;
- if (NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBorderStyle <= 1) {
- mapSizeX = 80 + Math.round(40 * NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBorderSize);
- } else {
- mapSizeX = borderSizeOption == 0 ? 90 : borderSizeOption == 1 ? 120 : borderSizeOption == 2 ? 160 : 240;
- }
- mapSizeY = mapSizeX;
- int roomsSizeX = (maxRoomX - minRoomX) * (renderRoomSize + renderConnSize) + renderRoomSize;
- int roomsSizeY = (maxRoomY - minRoomY) * (renderRoomSize + renderConnSize) + renderRoomSize;
- int mapCenterX = mapSizeX / 2;
- int mapCenterY = mapSizeY / 2;
- int scaleFactor = 8;
-
- projectionMatrix = Utils.createProjectionMatrix(mapSizeX * scaleFactor, mapSizeY * scaleFactor);
- mapFramebuffer1 = checkFramebufferSizes(mapFramebuffer1, mapSizeX * scaleFactor, mapSizeY * scaleFactor);
- mapFramebuffer2 = checkFramebufferSizes(mapFramebuffer2, mapSizeX * scaleFactor, mapSizeY * scaleFactor);
- mapFramebuffer1.framebufferColor[1] = 0;
- mapFramebuffer1.framebufferColor[2] = 0;
-
- try {
- if (mapShader == null) {
- mapShader = new Shader(new NEUResourceManager(Minecraft.getMinecraft().getResourceManager()),
- "dungeonmap", mapFramebuffer1, mapFramebuffer2);
- }
- } catch (Exception e) {
- e.printStackTrace();
- Utils.pushGuiScale(-1);
- return;
- }
-
- int backgroundColour = SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBackgroundColour);
-
- mapFramebuffer1.framebufferColor[0] = ((backgroundColour >> 16) & 0xFF) / 255f;
- mapFramebuffer1.framebufferColor[1] = ((backgroundColour >> 8) & 0xFF) / 255f;
- mapFramebuffer1.framebufferColor[2] = (backgroundColour & 0xFF) / 255f;
- mapFramebuffer2.framebufferColor[0] = ((backgroundColour >> 16) & 0xFF) / 255f;
- mapFramebuffer2.framebufferColor[1] = ((backgroundColour >> 8) & 0xFF) / 255f;
- mapFramebuffer2.framebufferColor[2] = (backgroundColour & 0xFF) / 255f;
-
- try {
- if (useFb) {
- mapFramebuffer1.framebufferClear();
- mapFramebuffer2.framebufferClear();
- }
-
- GlStateManager.pushMatrix();
- {
- if (useFb) {
- GlStateManager.matrixMode(5889);
- GlStateM