aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authornea <romangraef@gmail.com>2022-01-16 00:26:23 +0100
committernea <romangraef@gmail.com>2022-07-27 19:14:12 +0200
commitf43b4669f47e93b5914a4eff55ae77c5d0560efb (patch)
treec0ca5a8c328ca8ace5015a7354d337682f30a3a2 /src
parent01ce1186f271be0fc9cd65d759bc3905392c4ca8 (diff)
downloadNotEnoughUpdates-f43b4669f47e93b5914a4eff55ae77c5d0560efb.tar.gz
NotEnoughUpdates-f43b4669f47e93b5914a4eff55ae77c5d0560efb.tar.bz2
NotEnoughUpdates-f43b4669f47e93b5914a4eff55ae77c5d0560efb.zip
Squishy
Diffstat (limited to 'src')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java2
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DiagCommand.java15
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java1717
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/dungeons/GuiDungeonMapEditor.java1545
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/dungeons/SpiritLeap.java40
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/dungeons/map/DungeonMap.java161
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/dungeons/map/DungeonMapDebugOverlay.java117
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/dungeons/map/DungeonMapPlayers.java267
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/dungeons/map/DungeonMapRenderer.java526
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/dungeons/map/DungeonMapStaticParser.java228
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/dungeons/map/DungeonResources.java86
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/dungeons/map/Room.java122
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/dungeons/map/RoomConnection.java28
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/dungeons/map/RoomConnectionType.java5
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/dungeons/map/RoomOffset.java46
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/customtypes/NEUDebugFlag.java51
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/NEUDebugLogger.java4
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/RecencyList.java130
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java16
-rw-r--r--src/main/resources/assets/notenoughupdates/dungeon_map/corridors_default/black_corridor.pngbin0 -> 4829 bytes
20 files changed, 2567 insertions, 2539 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
index 8c23aa60..9701005f 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
@@ -27,7 +27,6 @@ import io.github.moulberry.notenoughupdates.commands.Commands;
import io.github.moulberry.notenoughupdates.core.BackgroundBlur;
import io.github.moulberry.notenoughupdates.cosmetics.CapeManager;
import io.github.moulberry.notenoughupdates.cosmetics.ShaderManager;
-import io.github.moulberry.notenoughupdates.dungeons.DungeonMap;
import io.github.moulberry.notenoughupdates.listener.ChatListener;
import io.github.moulberry.notenoughupdates.listener.ItemTooltipListener;
import io.github.moulberry.notenoughupdates.listener.NEUEventListener;
@@ -262,7 +261,6 @@ public class NotEnoughUpdates {
MinecraftForge.EVENT_BUS.register(SBInfo.getInstance());
MinecraftForge.EVENT_BUS.register(CustomItemEffects.INSTANCE);
MinecraftForge.EVENT_BUS.register(new Constants());
- MinecraftForge.EVENT_BUS.register(new DungeonMap());
MinecraftForge.EVENT_BUS.register(new SunTzu());
MinecraftForge.EVENT_BUS.register(new MiningStuff());
MinecraftForge.EVENT_BUS.register(FairySouls.getInstance());
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DiagCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DiagCommand.java
index 326c00b4..fb546efb 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DiagCommand.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DiagCommand.java
@@ -41,7 +41,8 @@ public class DiagCommand extends ClientCommandBase {
" center=<off | on> Disable / enable using center\n" +
"/neudiag wishing Wishing Compass Solver diagnostics\n" +
"/neudiag debug\n" +
- " <no sub-command> Show current flags\n" +
+ " <no sub-command> Show all enabled flags\n" +
+ " <list> Show all flags\n"+
" <enable | disable> <flag> Enable/disable flag\n";
private void showUsage(ICommandSender sender) {
@@ -86,6 +87,10 @@ public class DiagCommand extends ClientCommandBase {
boolean enablingFlag = true;
String action = args[1];
switch (action) {
+ case "list":
+ sender.addChatMessage(new ChatComponentText(
+ EnumChatFormatting.YELLOW + "Here are all flags:\n" + NEUDebugFlag.getFlagList()));
+ return;
case "disable":
enablingFlag = false;
// falls through
@@ -93,7 +98,7 @@ public class DiagCommand extends ClientCommandBase {
if (args.length != 3) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED +
"You must specify a flag:\n" +
- NEUDebugFlag.FLAG_LIST));
+ NEUDebugFlag.getFlagList()));
return;
}
@@ -108,7 +113,7 @@ public class DiagCommand extends ClientCommandBase {
} catch (IllegalArgumentException e) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED +
flagName + " is invalid. Valid flags are:\n" +
- NEUDebugFlag.FLAG_LIST));
+ NEUDebugFlag.getFlagList()));
return;
}
break;
@@ -118,8 +123,8 @@ public class DiagCommand extends ClientCommandBase {
}
}
- sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "Effective debug flags: " +
- NotEnoughUpdates.INSTANCE.config.hidden.debugFlags.toString()));
+ sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "Effective debug flags: \n" +
+ NEUDebugFlag.getEnabledFlags()));
break;
default:
showUsage(sender);
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java
deleted file mode 100644
index 2693341a..00000000
--- a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java
+++ /dev/null
@@ -1,1717 +0,0 @@
-/*
- * Copyright (C) 2022 NotEnoughUpdates contributors
- *
- * This file is part of NotEnoughUpdates.
- *
- * NotEnoughUpdates is free software: you can redistribute it
- * and/or modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation, either
- * version 3 of the License, or (at your option) any later version.
- *
- * NotEnoughUpdates is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>.
- */
-
-package io.github.moulberry.notenoughupdates.dungeons;
-
-import com.google.common.collect.Iterables;
-import com.google.gson.JsonObject;
-import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
-import io.github.moulberry.notenoughupdates.core.BackgroundBlur;
-import io.github.moulberry.notenoughupdates.core.config.Position;
-import io.github.moulberry.notenoughupdates.util.NEUResourceManager;
-import io.github.moulberry.notenoughupdates.util.SpecialColour;
-import io.github.moulberry.notenoughupdates.util.Utils;
-import net.minecraft.block.material.MapColor;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.entity.AbstractClientPlayer;
-import net.minecraft.client.gui.Gui;
-import net.minecraft.client.gui.ScaledResolution;
-import net.minecraft.client.renderer.GlStateManager;
-import net.minecraft.client.renderer.OpenGlHelper;
-import net.minecraft.client.renderer.Tessellator;
-import net.minecraft.client.renderer.WorldRenderer;
-import net.minecraft.client.renderer.texture.TextureUtil;
-import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
-import net.minecraft.client.resources.DefaultPlayerSkin;
-import net.minecraft.client.shader.Framebuffer;
-import net.minecraft.client.shader.Shader;
-import net.minecraft.entity.Entity;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.init.Items;
-import net.minecraft.item.Item;
-import net.minecraft.item.ItemMap;
-import net.minecraft.item.ItemStack;
-import net.minecraft.scoreboard.Score;
-import net.minecraft.scoreboard.ScoreObjective;
-import net.minecraft.scoreboard.ScorePlayerTeam;
-import net.minecraft.scoreboard.Scoreboard;
-import net.minecraft.util.Matrix4f;
-import net.minecraft.util.ResourceLocation;
-import net.minecraft.util.Vec4b;
-import net.minecraft.world.storage.MapData;
-import net.minecraftforge.client.event.RenderGameOverlayEvent;
-import net.minecraftforge.event.world.WorldEvent;
-import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
-import org.lwjgl.opengl.GL11;
-import org.lwjgl.opengl.GL14;
-
-import java.awt.*;
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-
-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();
-
- /*if((useFb && !OpenGlHelper.isFramebufferEnabled()) || (useShd && !OpenGlHelper.areShadersSupported())) {
- Utils.drawStringCentered(EnumChatFormatting.RED+"NEU Dungeon Map requires framebuffers & shaders",
- Minecraft.getMinecraft().fontRendererObj, centerX, centerY-10, true, 0);
- Utils.drawStringCentered(EnumChatFormatting.RED+"Turn off Optifine Fast Render",
- Minecraft.getMinecraft().fontRendererObj, centerX, centerY, true, 0);
- Utils.drawStringCentered(EnumChatFormatting.RED+"If that doesn't work, join NEU discord for support",
- Minecraft.getMinecraft().fontRendererObj, centerX, centerY+10, true, 0);
- 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();