From b09f774d422263ce15b97d6d0804beddf856176d Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Sun, 27 Feb 2022 11:53:57 -0500 Subject: feat: improve formating :) --- .../notenoughupdates/dungeons/DungeonMap.java | 3051 ++++++++++---------- 1 file changed, 1585 insertions(+), 1466 deletions(-) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java') 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 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 decorations = new ArrayList<>(); - //private final List lastDecorations = new ArrayList<>(); - private long lastDecorationsMillis = -1; - private long lastLastDecorationsMillis = -1; - - private final Map playerEntityMapPositions = new HashMap<>(); - private final Map playerMarkerMapPositions = new HashMap<>(); - private final Set rawPlayerMarkerMapPositions = new HashSet<>(); - private final Map playerMarkerMapPositionsLast = new HashMap<>(); - private final HashMap playerIdMap = new HashMap<>(); - - private final Map 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 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 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 decorations = new ArrayList<>(); + //private final List lastDecorations = new ArrayList<>(); + private long lastDecorationsMillis = -1; + private long lastLastDecorationsMillis = -1; + + private final Map playerEntityMapPositions = new HashMap<>(); + private final Map playerMarkerMapPositions = new HashMap<>(); + private final Set rawPlayerMarkerMapPositions = new HashSet<>(); + private final Map playerMarkerMapPositionsLast = new HashMap<>(); + private final HashMap playerIdMap = new HashMap<>(); + + private final Map 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 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); - GlStateManager.loadIdentity(); - GlStateManager.ortho(0.0D, mapSizeX * scaleFactor, mapSizeY * scaleFactor, 0.0D, 1000.0D, 3000.0D); - GlStateManager.matrixMode(5888); - GlStateManager.loadIdentity(); - GlStateManager.translate(0.0F, 0.0F, -2000.0F); - - GlStateManager.scale(scaleFactor, scaleFactor, 1); - mapFramebuffer1.bindFramebuffer(true); - - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - GlStateManager.disableBlend(); - } else { - GL11.glEnable(GL11.GL_SCISSOR_TEST); - GL11.glScissor((centerX - mapSizeX / 2) * 2, Minecraft.getMinecraft().displayHeight - (centerY + mapSizeY / 2) * 2, mapSizeX * 2, mapSizeY * 2); - - GlStateManager.translate(centerX - mapSizeX / 2, centerY - mapSizeY / 2, 100); - } - - if (NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBackgroundBlur > 0.1 && NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBackgroundBlur < 100 && NotEnoughUpdates.INSTANCE.config.dungeonMap.dmEnable) { - GlStateManager.translate(-centerX + mapSizeX / 2, -centerY + mapSizeY / 2, 0); - BackgroundBlur.renderBlurredBackground(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBackgroundBlur, - scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), - centerX - mapSizeX / 2, centerY - mapSizeY / 2, mapSizeX, mapSizeY); - BackgroundBlur.markDirty(); - GlStateManager.translate(centerX - mapSizeX / 2, centerY - mapSizeY / 2, 0); - } - - GlStateManager.translate(mapCenterX, mapCenterY, 10); - - if (!useFb || NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBackgroundBlur > 0.1 && NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBackgroundBlur < 100) { - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - } - Utils.drawRectNoBlend(-mapCenterX, -mapCenterY, mapCenterX, mapCenterY, backgroundColour); - - GlStateManager.rotate(-rotation + 180, 0, 0, 1); - - if (NotEnoughUpdates.INSTANCE.config.dungeonMap.dmCenterPlayer && playerPos != null) { - float x = playerPos.getRenderX(); - float y = playerPos.getRenderY(); - x -= minRoomX * (renderRoomSize + renderConnSize); - y -= minRoomY * (renderRoomSize + renderConnSize); - - GlStateManager.translate(-x, -y, 0); - } else { - GlStateManager.translate(-roomsSizeX / 2, -roomsSizeY / 2, 0); - } - - for (Map.Entry entry : roomMap.entrySet()) { - RoomOffset roomOffset = entry.getKey(); - Room room = entry.getValue(); - - int x = (roomOffset.x - minRoomX) * (renderRoomSize + renderConnSize); - int y = (roomOffset.y - minRoomY) * (renderRoomSize + renderConnSize); - - GlStateManager.pushMatrix(); - GlStateManager.translate(x, y, 0); - - room.render(renderRoomSize, renderConnSize); - - GlStateManager.translate(-x, -y, 0); - GlStateManager.popMatrix(); - } - - GlStateManager.translate(-mapCenterX + roomsSizeX / 2f, -mapCenterY + roomsSizeY / 2f, 0); - - GlStateManager.translate(mapCenterX, mapCenterY, 0); - GlStateManager.rotate(rotation - 180, 0, 0, 1); - GlStateManager.translate(-mapCenterX, -mapCenterY, 0); - - GlStateManager.translate(mapCenterX, mapCenterY, 0); - - for (Map.Entry entry : roomMap.entrySet()) { - RoomOffset roomOffset = entry.getKey(); - Room room = entry.getValue(); - - float x = (roomOffset.x - minRoomX) * (renderRoomSize + renderConnSize) - roomsSizeX / 2f + renderRoomSize / 2f; - float y = (roomOffset.y - minRoomY) * (renderRoomSize + renderConnSize) - roomsSizeY / 2f + renderRoomSize / 2f; - float x2 = (float) (-x * Math.cos(Math.toRadians(-rotation)) + y * Math.sin(Math.toRadians(-rotation))); - float y2 = (float) (-x * Math.sin(Math.toRadians(-rotation)) - y * Math.cos(Math.toRadians(-rotation))); - - GlStateManager.pushMatrix(); - GlStateManager.translate(x2, y2, 0); - - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - room.renderNoRotate(renderRoomSize, renderConnSize, rotation); - - GlStateManager.translate(-x2, -y2, 0); - GlStateManager.popMatrix(); - } - - GlStateManager.translate(-mapCenterX, -mapCenterY, 0); - - GlStateManager.translate(mapCenterX, mapCenterY, 0); - GlStateManager.rotate(-rotation + 180, 0, 0, 1); - GlStateManager.translate(-mapCenterX, -mapCenterY, 0); - - GlStateManager.translate(mapCenterX - roomsSizeX / 2f, mapCenterY - roomsSizeY / 2f, 0); - - Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer worldrenderer = tessellator.getWorldRenderer(); - int k = 0; + 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); + GlStateManager.loadIdentity(); + GlStateManager.ortho(0.0D, mapSizeX * scaleFactor, mapSizeY * scaleFactor, 0.0D, 1000.0D, 3000.0D); + GlStateManager.matrixMode(5888); + GlStateManager.loadIdentity(); + GlStateManager.translate(0.0F, 0.0F, -2000.0F); + + GlStateManager.scale(scaleFactor, scaleFactor, 1); + mapFramebuffer1.bindFramebuffer(true); + + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + GlStateManager.disableBlend(); + } else { + GL11.glEnable(GL11.GL_SCISSOR_TEST); + GL11.glScissor( + (centerX - mapSizeX / 2) * 2, + Minecraft.getMinecraft().displayHeight - (centerY + mapSizeY / 2) * 2, + mapSizeX * 2, + mapSizeY * 2 + ); + + GlStateManager.translate(centerX - mapSizeX / 2, centerY - mapSizeY / 2, 100); + } + + if (NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBackgroundBlur > 0.1 && + NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBackgroundBlur < 100 && + NotEnoughUpdates.INSTANCE.config.dungeonMap.dmEnable) { + GlStateManager.translate(-centerX + mapSizeX / 2, -centerY + mapSizeY / 2, 0); + BackgroundBlur.renderBlurredBackground(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBackgroundBlur, + scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), + centerX - mapSizeX / 2, centerY - mapSizeY / 2, mapSizeX, mapSizeY + ); + BackgroundBlur.markDirty(); + GlStateManager.translate(centerX - mapSizeX / 2, centerY - mapSizeY / 2, 0); + } + + GlStateManager.translate(mapCenterX, mapCenterY, 10); + + if (!useFb || NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBackgroundBlur > 0.1 && + NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBackgroundBlur < 100) { + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate( + GL11.GL_SRC_ALPHA, + GL11.GL_ONE_MINUS_SRC_ALPHA, + GL11.GL_ONE, + GL11.GL_ONE_MINUS_SRC_ALPHA + ); + } + Utils.drawRectNoBlend(-mapCenterX, -mapCenterY, mapCenterX, mapCenterY, backgroundColour); + + GlStateManager.rotate(-rotation + 180, 0, 0, 1); + + if (NotEnoughUpdates.INSTANCE.config.dungeonMap.dmCenterPlayer && playerPos != null) { + float x = playerPos.getRenderX(); + float y = playerPos.getRenderY(); + x -= minRoomX * (renderRoomSize + renderConnSize); + y -= minRoomY * (renderRoomSize + renderConnSize); + + GlStateManager.translate(-x, -y, 0); + } else { + GlStateManager.translate(-roomsSizeX / 2, -roomsSizeY / 2, 0); + } + + for (Map.Entry entry : roomMap.entrySet()) { + RoomOffset roomOffset = entry.getKey(); + Room room = entry.getValue(); + + int x = (roomOffset.x - minRoomX) * (renderRoomSize + renderConnSize); + int y = (roomOffset.y - minRoomY) * (renderRoomSize + renderConnSize); + + GlStateManager.pushMatrix(); + GlStateManager.translate(x, y, 0); + + room.render(renderRoomSize, renderConnSize); + + GlStateManager.translate(-x, -y, 0); + GlStateManager.popMatrix(); + } + + GlStateManager.translate(-mapCenterX + roomsSizeX / 2f, -mapCenterY + roomsSizeY / 2f, 0); + + GlStateManager.translate(mapCenterX, mapCenterY, 0); + GlStateManager.rotate(rotation - 180, 0, 0, 1); + GlStateManager.translate(-mapCenterX, -mapCenterY, 0); + + GlStateManager.translate(mapCenterX, mapCenterY, 0); + + for (Map.Entry entry : roomMap.entrySet()) { + RoomOffset roomOffset = entry.getKey(); + Room room = entry.getValue(); + + float x = + (roomOffset.x - minRoomX) * (renderRoomSize + renderConnSize) - roomsSizeX / 2f + renderRoomSize / 2f; + float y = + (roomOffset.y - minRoomY) * (renderRoomSize + renderConnSize) - roomsSizeY / 2f + renderRoomSize / 2f; + float x2 = (float) (-x * Math.cos(Math.toRadians(-rotation)) + y * Math.sin(Math.toRadians(-rotation))); + float y2 = (float) (-x * Math.sin(Math.toRadians(-rotation)) - y * Math.cos(Math.toRadians(-rotation))); + + GlStateManager.pushMatrix(); + GlStateManager.translate(x2, y2, 0); + + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + room.renderNoRotate(renderRoomSize, renderConnSize, rotation); + + GlStateManager.translate(-x2, -y2, 0); + GlStateManager.popMatrix(); + } + + GlStateManager.translate(-mapCenterX, -mapCenterY, 0); + + GlStateManager.translate(mapCenterX, mapCenterY, 0); + GlStateManager.rotate(-rotation + 180, 0, 0, 1); + GlStateManager.translate(-mapCenterX, -mapCenterY, 0); + + GlStateManager.translate(mapCenterX - roomsSizeX / 2f, mapCenterY - roomsSizeY / 2f, 0); + + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + int k = 0; + + for (Map.Entry entry : playerMarkerMapPositions.entrySet()) { + String name = entry.getKey(); + MapPosition pos = entry.getValue(); + float x = pos.getRenderX(); + float y = pos.getRenderY(); + float angle = pos.rotation; + + boolean doInterp = NotEnoughUpdates.INSTANCE.config.dungeonMap.dmPlayerInterp; + if (!isFloorOne && playerEntityMapPositions.containsKey(name)) { + MapPosition entityPos = playerEntityMapPositions.get(name); + angle = entityPos.rotation; - for (Map.Entry entry : playerMarkerMapPositions.entrySet()) { - String name = entry.getKey(); - MapPosition pos = entry.getValue(); - float x = pos.getRenderX(); - float y = pos.getRenderY(); - float angle = pos.rotation; - - boolean doInterp = NotEnoughUpdates.INSTANCE.config.dungeonMap.dmPlayerInterp; - if (!isFloorOne && playerEntityMapPositions.containsKey(name)) { - MapPosition entityPos = playerEntityMapPositions.get(name); - angle = entityPos.rotation; - - float deltaX = entityPos.getRenderX() - pos.getRenderX(); - float deltaY = entityPos.getRenderY() - pos.getRenderY(); + float deltaX = entityPos.getRenderX() - pos.getRenderX(); + float deltaY = entityPos.getRenderY() - pos.getRenderY(); /*if(deltaX > (renderRoomSize + renderConnSize)/2) { deltaX -= (renderRoomSize + renderConnSize); @@ -617,845 +671,901 @@ public class DungeonMap { deltaY += (renderRoomSize + renderConnSize); }*/ - x += deltaX; - y += deltaY; - - doInterp = false; - } - - float minU = 3 / 4f; - float minV = 0; - - if (name.equals(Minecraft.getMinecraft().thePlayer.getName())) { - minU = 1 / 4f; - } - - float maxU = minU + 1 / 4f; - float maxV = minV + 1 / 4f; - - if (doInterp && playerMarkerMapPositionsLast.containsKey(name)) { - MapPosition last = playerMarkerMapPositionsLast.get(name); - float xLast = last.getRenderX(); - float yLast = last.getRenderY(); - - float distSq = (x - xLast) * (x - xLast) + (y - yLast) * (y - yLast); - if (distSq < renderRoomSize * renderRoomSize / 4f) { - float angleLast = last.rotation; - if (angle > 180 && angleLast < 180) angleLast += 360; - if (angleLast > 180 && angle < 180) angle += 360; - - float interpFactor = Math.round((System.currentTimeMillis() - lastDecorationsMillis) * 100f) / 100f / (lastDecorationsMillis - lastLastDecorationsMillis); - interpFactor = Math.max(0, Math.min(1, interpFactor)); - - x = xLast + (x - xLast) * interpFactor; - y = yLast + (y - yLast) * interpFactor; - angle = angleLast + (angle - angleLast) * interpFactor; - angle %= 360; - } - } - - boolean blackBorder = false; - boolean headLayer = false; - int pixelWidth = 8; - int pixelHeight = 8; - if (renderRoomSize >= 24) { - pixelWidth = pixelHeight = 12; - } - GlStateManager.color(1, 1, 1, 1); - if ((!NotEnoughUpdates.INSTANCE.config.dungeons.showOwnHeadAsMarker || - playerMarkerMapPositions.size() <= 1 || minU != 1 / 4f) && - NotEnoughUpdates.INSTANCE.config.dungeonMap.dmPlayerHeads >= 1 && - playerSkinMap.containsKey(entry.getKey())) { - Minecraft.getMinecraft().getTextureManager().bindTexture(playerSkinMap.get(entry.getKey())); - - minU = 8 / 64f; - minV = 8 / 64f; - maxU = 16 / 64f; - maxV = 16 / 64f; - - headLayer = true; - if (NotEnoughUpdates.INSTANCE.config.dungeonMap.dmPlayerHeads >= 2) { - blackBorder = true; - } - } else { - Minecraft.getMinecraft().getTextureManager().bindTexture(mapIcons); - } - - x -= minRoomX * (renderRoomSize + renderConnSize); - y -= minRoomY * (renderRoomSize + renderConnSize); - - GlStateManager.pushMatrix(); - - GlStateManager.disableDepth(); - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - - GlStateManager.translate(x, y, -0.02F); - GlStateManager.scale(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmIconScale, - NotEnoughUpdates.INSTANCE.config.dungeonMap.dmIconScale, 1); - GlStateManager.rotate(angle, 0.0F, 0.0F, 1.0F); - GlStateManager.translate(-0.5F, 0.5F, 0.0F); - - if (blackBorder) { - Gui.drawRect(-pixelWidth / 2 - 1, -pixelHeight / 2 - 1, pixelWidth / 2 + 1, pixelHeight / 2 + 1, 0xff111111); - GlStateManager.color(1, 1, 1, 1); - } - - worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX); - worldrenderer.pos(-pixelWidth / 2f, pixelHeight / 2f, 30 + ((float) k * -0.005F)).tex(minU, minV).endVertex(); - worldrenderer.pos(pixelWidth / 2f, pixelHeight / 2f, 30 + ((float) k * -0.005F)).tex(maxU, minV).endVertex(); - worldrenderer.pos(pixelWidth / 2f, -pixelHeight / 2f, 30 + ((float) k * -0.005F)).tex(maxU, maxV).endVertex(); - worldrenderer.pos(-pixelWidth / 2f, -pixelHeight / 2f, 30 + ((float) k * -0.005F)).tex(minU, maxV).endVertex(); - tessellator.draw(); - - if (headLayer) { - worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX); - worldrenderer.pos(-pixelWidth / 2f, pixelHeight / 2f, 30 + ((float) k * -0.005F) + 0.001f).tex(minU + 0.5f, minV).endVertex(); - worldrenderer.pos(pixelWidth / 2f, pixelHeight / 2f, 30 + ((float) k * -0.005F) + 0.001f).tex(maxU + 0.5f, minV).endVertex(); - worldrenderer.pos(pixelWidth / 2f, -pixelHeight / 2f, 30 + ((float) k * -0.005F) + 0.001f).tex(maxU + 0.5f, maxV).endVertex(); - worldrenderer.pos(-pixelWidth / 2f, -pixelHeight / 2f, 30 + ((float) k * -0.005F) + 0.001f).tex(minU + 0.5f, maxV).endVertex(); - tessellator.draw(); - } - GlStateManager.popMatrix(); - k--; - } - - if (useFb) { - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - } else { - GL11.glDisable(GL11.GL_SCISSOR_TEST); - } - } - GlStateManager.popMatrix(); - - if (useFb) { - Framebuffer renderFromBuffer = mapFramebuffer1; - if (useShd) { - GlStateManager.pushMatrix(); - { - try { - upload(mapShader, mapSizeX, mapSizeY, scaleFactor, getBorderRadius()); - mapShader.setProjectionMatrix(projectionMatrix); - mapShader.loadShader(0); - renderFromBuffer = mapFramebuffer2; - } catch (Exception ignored) {} - } - GlStateManager.popMatrix(); - } - - Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true); - - Utils.pushGuiScale(2); - - GlStateManager.translate(centerX, centerY, 100); - - renderFromBuffer.bindFramebufferTexture(); - Utils.drawTexturedRect(-mapSizeX / 2, -mapSizeY / 2, mapSizeX, mapSizeY, - 0, 1, 1, 0, GL11.GL_NEAREST); - GlStateManager.bindTexture(0); - - GlStateManager.translate(-centerX, -centerY, -100); - - Utils.pushGuiScale(-1); - } - - GlStateManager.translate(centerX, centerY, 100); - - if (NotEnoughUpdates.INSTANCE.config.dungeonMap.dmChromaBorder) { - int colour = SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBorderColour); - - Gui.drawRect(-mapCenterX - 2, -mapCenterY - 2, -mapCenterX, -mapCenterY, - colour); //topleft - Gui.drawRect(-mapCenterX - 2, mapCenterY + 2, -mapCenterX, mapCenterY, - SpecialColour.rotateHue(colour, -180)); //bottomleft - Gui.drawRect(mapCenterX, -mapCenterY - 2, mapCenterX + 2, mapCenterY, - SpecialColour.rotateHue(colour, -180)); //topright - Gui.drawRect(mapCenterX, mapCenterY, mapCenterX + 2, mapCenterY + 2, - colour); //bottomright - - for (int i = 0; i < 20; i++) { - int start1 = SpecialColour.rotateHue(colour, -9 * i); - int start2 = SpecialColour.rotateHue(colour, -9 * i - 9); - int end1 = SpecialColour.rotateHue(colour, -180 - 9 * i); - int end2 = SpecialColour.rotateHue(colour, -180 - 9 * i - 9); - - Utils.drawGradientRect(-mapCenterX - 2, -mapCenterY + (int) (mapSizeY * (i / 20f)), -mapCenterX, - -mapCenterY + (int) (mapSizeY * ((i + 1) / 20f)), start1, start2); //left - Utils.drawGradientRect(mapCenterX, -mapCenterY + (int) (mapSizeX * (i / 20f)), mapCenterX + 2, - -mapCenterY + (int) (mapSizeX * ((i + 1) / 20f)), - end1, end2); //right - Utils.drawGradientRectHorz(-mapCenterX + (int) (mapSizeX * (i / 20f)), -mapCenterY - 2, - -mapCenterX + (int) (mapSizeX * ((i + 1) / 20f)), -mapCenterY, start1, start2); //top - Utils.drawGradientRectHorz(-mapCenterX + (int) (mapSizeX * (i / 20f)), - mapCenterY, -mapCenterX + (int) (mapSizeX * ((i + 1) / 20f)), mapCenterY + 2, - end1, end2); //bottom - } - - } else {