summaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorMoulberry <james.jenour@student.scotch.wa.edu.au>2020-10-31 21:49:14 +1100
committerMoulberry <james.jenour@student.scotch.wa.edu.au>2020-10-31 21:49:14 +1100
commit431d4a5eca207aa6f86a90e3c4e1912885f115eb (patch)
tree8d3bd19ad3d40da034aaca8e2766dadb627bfaf1 /src/main/java
parent2397734d98c30a05db58bc6ef67607078889a386 (diff)
downloadNotEnoughUpdates-431d4a5eca207aa6f86a90e3c4e1912885f115eb.tar.gz
NotEnoughUpdates-431d4a5eca207aa6f86a90e3c4e1912885f115eb.tar.bz2
NotEnoughUpdates-431d4a5eca207aa6f86a90e3c4e1912885f115eb.zip
1.4.9
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/DumymMod.java53
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/DungeonBlocks.java2
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/DungeonMap.java1522
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/GuiButtonItem.java93
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/GuiDungeonMapEditor.java754
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java39
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java6
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/gamemodes/SBGamemodes.java4
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/Options.java100
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PlayerStats.java9
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java6
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/Constants.java2
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/SpecialColour.java14
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java85
14 files changed, 2249 insertions, 440 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/DumymMod.java b/src/main/java/io/github/moulberry/notenoughupdates/DumymMod.java
new file mode 100644
index 00000000..07205519
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/DumymMod.java
@@ -0,0 +1,53 @@
+package io.github.moulberry.notenoughupdates;
+
+import java.util.Arrays;
+
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.inventory.GuiChest;
+import net.minecraft.init.Blocks;
+import net.minecraft.item.ItemStack;
+import net.minecraftforge.client.event.GuiScreenEvent;
+import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.fml.common.Mod;
+import net.minecraftforge.fml.common.Mod.EventHandler;
+import net.minecraftforge.fml.common.ModMetadata;
+import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
+
+public class DumymMod {
+
+ @SubscribeEvent
+ public void onInitGui(GuiScreenEvent.InitGuiEvent.Post event) {
+ int width = event.gui.width / 2;
+ int height = event.gui.height / 2 - 106;
+
+ if (event.gui instanceof GuiChest)
+ {
+ event.buttonList.add(new GuiButtonItem(1001, width + 88, height + 47, new ItemStack(Blocks.crafting_table)));
+ event.buttonList.add(new GuiButtonItem(1000, width + 88, height + 66, new ItemStack(Blocks.ender_chest)));
+ }
+ }
+
+ private long lastButtonClick = -1;
+
+ @SubscribeEvent
+ public void onPostActionPerformedGui(GuiScreenEvent.ActionPerformedEvent.Post event) {
+ long now = System.currentTimeMillis();
+
+ if (event.gui instanceof GuiChest)
+ {
+ if (now - this.lastButtonClick > 100L)
+ {
+ if (event.button.id == 1000)
+ {
+ Minecraft.getMinecraft().thePlayer.sendChatMessage("/enderchest");
+ }
+ else if (event.button.id == 1001)
+ {
+ Minecraft.getMinecraft().thePlayer.sendChatMessage("/craft");
+ }
+ this.lastButtonClick = now;
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/DungeonBlocks.java b/src/main/java/io/github/moulberry/notenoughupdates/DungeonBlocks.java
index f0b92c6a..cdf7b59b 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/DungeonBlocks.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/DungeonBlocks.java
@@ -39,7 +39,7 @@ public class DungeonBlocks implements IResourceManagerReloadListener {
}
public static boolean isInDungeons() {
- return !NotEnoughUpdates.INSTANCE.manager.config.disableDungeonBlocks.value &&
+ return false && !NotEnoughUpdates.INSTANCE.manager.config.disableDungeonBlocks.value &&
(NotEnoughUpdates.INSTANCE.manager.config.dungeonBlocksEverywhere.value ||
(SBInfo.getInstance().getLocation() != null && SBInfo.getInstance().getLocation().equals("dungeon")));
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/DungeonMap.java b/src/main/java/io/github/moulberry/notenoughupdates/DungeonMap.java
index c9be3dab..daff1a24 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/DungeonMap.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/DungeonMap.java
@@ -1,32 +1,50 @@
package io.github.moulberry.notenoughupdates;
+import com.google.common.math.BigIntegerMath;
+import com.google.gson.JsonObject;
+import io.github.moulberry.notenoughupdates.questing.SBInfo;
+import io.github.moulberry.notenoughupdates.util.SpecialColour;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
+import net.minecraft.client.entity.AbstractClientPlayer;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.MapItemRenderer;
-import net.minecraft.client.renderer.GlStateManager;
-import net.minecraft.client.renderer.Tessellator;
-import net.minecraft.client.renderer.WorldRenderer;
+import net.minecraft.client.gui.ScaledResolution;
+import net.minecraft.client.renderer.*;
+import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.renderer.texture.DynamicTexture;
+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.player.EntityPlayer;
import net.minecraft.init.Blocks;
+import net.minecraft.init.Items;
import net.minecraft.item.ItemMap;
import net.minecraft.item.ItemStack;
import net.minecraft.scoreboard.ScorePlayerTeam;
-import net.minecraft.util.BlockPos;
-import net.minecraft.util.ResourceLocation;
-import net.minecraft.util.Vec4b;
+import net.minecraft.util.*;
import net.minecraft.world.storage.MapData;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
+import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
+import org.lwjgl.BufferUtils;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
+import org.lwjgl.opengl.GL14;
+import org.lwjgl.opengl.GL30;
+import org.lwjgl.opengl.GL45;
import java.awt.*;
import java.awt.image.BufferedImage;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.nio.ByteBuffer;
+import java.nio.IntBuffer;
+import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.List;
@@ -43,9 +61,22 @@ public class DungeonMap {
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 int RENDER_ROOM_SIZE = 16;
- private static final int RENDER_CONN_SIZE = 4;
+ 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 static final ResourceLocation BORDER_STEAMPUNK = new ResourceLocation("notenoughupdates:dungeon_map/borders/steampunk.png");
private final HashMap<RoomOffset, Room> roomMap = new HashMap<>();
private Color[][] colourMap = new Color[128][128];
@@ -53,15 +84,17 @@ public class DungeonMap {
private int startRoomY = -1;
private int connectorSize = 5;
private int roomSize = 0;
-
- private int roomSizeBlocks = 7;
- private final List<MapDecoration> decorations = new ArrayList<>();
- private final List<MapDecoration> lastDecorations = new ArrayList<>();
+ //private final List<MapDecoration> decorations = new ArrayList<>();
+ //private final List<MapDecoration> lastDecorations = new ArrayList<>();
private long lastDecorationsMillis = -1;
private long lastLastDecorationsMillis = -1;
- private Map<EntityPlayer, MapPosition> playerMapPositions = new HashMap<>();
+ private Map<String, MapPosition> playerEntityMapPositions = new HashMap<>();
+ private Map<String, MapPosition> playerMarkerMapPositions = new HashMap<>();
+ private Map<String, MapPosition> playerMarkerMapPositionsLast = new HashMap<>();
+
+ private Map<String, ResourceLocation> playerSkinMap = new HashMap<>();
private class RoomOffset {
int x;
@@ -144,6 +177,50 @@ public class DungeonMap {
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;
+ }
+ if(indicatorTex != null) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(indicatorTex);
+ float x = 0;
+ float y = 0;
+
+ if(NotEnoughUpdates.INSTANCE.manager.config.dmCenterCheck.value) {
+ 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.manager.config.dmOrientCheck.value) {
+ GlStateManager.rotate(-rotation+180, 0, 0, 1);
+ }
+
+ Utils.drawTexturedRect(-5, -5, 10, 10, GL11.GL_NEAREST);
+
+ if(!NotEnoughUpdates.INSTANCE.manager.config.dmOrientCheck.value) {
+ 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) {
@@ -160,82 +237,170 @@ public class DungeonMap {
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);
- }
-
- //Gui.drawRect(0, 0, roomSize, roomSize, colour.getRGB());
- if(tickColour != 0) {
- Gui.drawRect(roomSize/2-4, roomSize/2-4, roomSize/2+4, roomSize/2+4, tickColour);
+ } else {
+ Gui.drawRect(0, 0, roomSize, roomSize, colour.getRGB());
}
if(fillCorner) {
- Gui.drawRect(-connectorSize, -connectorSize, 0, 0, colour.getRGB());
+ 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<4; k++) {
- RoomConnection connection = up;
+ for(int k=0; k<2; k++) {
+ RoomConnection connection = down;
if(k == 1) connection = right;
- if(k == 2) connection = down;
- if(k == 3) connection = left;
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;
+ }
- int xOffset = 0;
- int yOffset = 0;
- int width = 0;
- int height = 0;
+ if(corridorTex == null) {
+ int xOffset = 0;
+ int yOffset = 0;
+ int width = 0;
+ int height = 0;
- if(connection == up) {
- yOffset = -connectorSize;
- width = roomSize;
- height = connectorSize;
+ if(connection == right) {
+ xOffset = roomSize;
+ width = connectorSize;
+ height = roomSize;
- if(connection.type == RoomConnectionType.CORRIDOR) {
- width = 8;
- xOffset += 4;
- }
- } else 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;
+ 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;
+ }
}
- } else if(connection == left) {
- xOffset = -connectorSize;
- width = connectorSize;
- height = roomSize;
-
- if(connection.type == RoomConnectionType.CORRIDOR) {
- height = 8;
- yOffset += 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();
}
-
- Gui.drawRect(xOffset, yOffset, xOffset+width, yOffset+height, connection.colour.getRGB());
}
}
}
private static final ResourceLocation mapIcons = new ResourceLocation("textures/map/map_icons.png");
- public void render() {
+ 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() {
+ int roomSizeOption = NotEnoughUpdates.INSTANCE.manager.config.dmRoomSize.value.intValue();
+ return roomSizeOption == 0 ? 12 : roomSizeOption == 2 ? 20 : 16;
+ }
+
+ public int getRenderConnSize() {
+ int roomSizeOption = NotEnoughUpdates.INSTANCE.manager.config.dmRoomSize.value.intValue();
+ return roomSizeOption == 0 ? 3 : roomSizeOption == 2 ? 5 : 4;
+ }
+
+ private HashMap<Integer, Float> borderRadiusCache = new HashMap<>();
+ public float getBorderRadius() {
+ int borderSizeOption = NotEnoughUpdates.INSTANCE.manager.config.dmBorderSize.value.intValue();
+ String sizeId = borderSizeOption == 0 ? "small" : borderSizeOption == 2 ? "large" : "medium";
+
+ int style = NotEnoughUpdates.INSTANCE.manager.config.dmBorderStyle.value.intValue();
+ 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) {
+ ScaledResolution scaledResolution = Utils.pushGuiScale(2);
+
+ boolean useFb = NotEnoughUpdates.INSTANCE.manager.config.dmCompat.value <= 1;
+ boolean useShd = NotEnoughUpdates.INSTANCE.manager.config.dmCompat.value <= 0;
+
+ 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;
+ }
+
int minRoomX = 999;
int minRoomY = 999;
int maxRoomX = -999;
@@ -247,131 +412,385 @@ public class DungeonMap {
maxRoomY = Math.max(offset.y, maxRoomY);
}
- /*Set<Color> uniques = new HashSet<>();
- for(Color[] cs : colourMap) {
- for(Color c : cs) {
- uniques.add(c);
+ int borderSizeOption = NotEnoughUpdates.INSTANCE.manager.config.dmBorderSize.value.intValue();
+
+ 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.manager.config.dmRotatePlayer.value) {
+ rotation = (int)playerPos.rotation;
+ }
+
+ int mapSizeX = borderSizeOption == 0 ? 90 : borderSizeOption == 2 ? 160 : 120;
+ int mapSizeY = borderSizeOption == 0 ? 90 : borderSizeOption == 2 ? 160 : 120;
+ 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();
+ return;
}
- System.out.println("Unique colours:");
- for(Color c : uniques) {
- System.out.println(c + "" + c.getAlpha());
- }*/
- int centerX = 80;
- int centerY = 80;
- int rotation = (int)Minecraft.getMinecraft().thePlayer.rotationYawHead;
+ int backgroundColour = SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.manager.config.dmBackgroundColour.value);
- GlStateManager.pushMatrix();
- GlStateManager.translate(centerX, centerY, 0);
- GlStateManager.rotate(-rotation+180, 0, 0, 1);
- GlStateManager.translate(-(maxRoomX-minRoomX+1)*(RENDER_ROOM_SIZE+RENDER_CONN_SIZE)/2f,
- -(maxRoomY-minRoomY+1)*(RENDER_ROOM_SIZE+RENDER_CONN_SIZE)/2f, 0);
+ 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;
- Gui.drawRect(-10, -10, (maxRoomX-minRoomX)*(RENDER_ROOM_SIZE+RENDER_CONN_SIZE)+RENDER_ROOM_SIZE+10,
- (maxRoomY-minRoomY)*(RENDER_ROOM_SIZE+RENDER_CONN_SIZE)+RENDER_ROOM_SIZE+10,
- new Color(200, 200, 200).getRGB());
+ try {
+ if(useFb) {
+ mapFramebuffer1.framebufferClear();
+ mapFramebuffer2.framebufferClear();
+ }
- for(Map.Entry<RoomOffset, Room> entry : roomMap.entrySet()) {
- RoomOffset roomOffset = entry.getKey();
- Room room = entry.getValue();
-
- int x = (roomOffset.x-minRoomX)*(RENDER_ROOM_SIZE+RENDER_CONN_SIZE);
- int y = (roomOffset.y-minRoomY)*(RENDER_ROOM_SIZE+RENDER_CONN_SIZE);
-
- GlStateManager.pushMatrix();
- GlStateManager.translate(x, y, 0);
- room.render(RENDER_ROOM_SIZE, RENDER_CONN_SIZE);
- GlStateManager.translate(-x, -y, 0);
- GlStateManager.popMatrix();
- }
-
- Tessellator tessellator = Tessellator.getInstance();
- WorldRenderer worldrenderer = tessellator.getWorldRenderer();
- GlStateManager.color(1, 1, 1, 1);
- Minecraft.getMinecraft().getTextureManager().bindTexture(mapIcons);
- int k = 0;
- for(int i=0; i<decorations.size(); i++) {
- MapDecoration decoration = decorations.get(i);
- float minU = (float)(decoration.id % 4) / 4.0F;
- float minV = (float)(decoration.id / 4) / 4.0F;
-
- float x = decoration.position.getRenderX();
- float y = decoration.position.getRenderY();
- float angle = decoration.angle;
-
- if(decoration.id == 1) {
- angle = Minecraft.getMinecraft().thePlayer.rotationYawHead;
- } else {
- if(false && i < lastDecorations.size()) {
- MapDecoration last = lastDecorations.get(i);
- float xLast = last.position.getRenderX();
- float yLast = last.position.getRenderY();
-
- float distSq = (x-xLast)*(x-xLast)+(y-yLast)*(y-yLast);
- if(distSq < RENDER_ROOM_SIZE*RENDER_ROOM_SIZE) {
- float angleLast = last.angle;
- 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;
- }
+ 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(decoration.id == 3 || decoration.id == 1) {
- float closestDistSq = RENDER_ROOM_SIZE*RENDER_ROOM_SIZE;
- EntityPlayer closestPlayer = null;
- for(Map.Entry<EntityPlayer, MapPosition> entry : playerMapPositions.entrySet()) {
- if(Minecraft.getMinecraft().thePlayer.getName().equalsIgnoreCase(entry.getKey().getName()) != (decoration.id == 1)) {
- continue;
+ if(NotEnoughUpdates.INSTANCE.manager.config.dmBackgroundBlur.value > 0.1) {
+ GlStateManager.translate(-centerX+mapSizeX/2, -centerY+mapSizeY/2, 0);
+ renderBlurredBackground(scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(),
+ centerX-mapSizeX/2, centerY-mapSizeY/2, mapSizeX, mapSizeY);
+ GlStateManager.translate(centerX-mapSizeX/2, centerY-mapSizeY/2, 0);
+ }
+
+ GlStateManager.translate(mapCenterX, mapCenterY, 10);
+
+ if(!useFb || NotEnoughUpdates.INSTANCE.manager.config.dmBackgroundBlur.value > 0.1) {
+ 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.manager.config.dmCenterPlayer.value && 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<RoomOffset, Room> 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<RoomOffset, Room> 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<String, MapPosition> 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.manager.config.dmPlayerInterp.value;
+ if(playerEntityMapPositions.containsKey(name)) {
+ MapPosition entityPos = playerEntityMapPositions.get(name);
+ angle = entityPos.rotation;
+
+ float deltaX = entityPos.getRenderX() - pos.getRenderX();
+ float deltaY = entityPos.getRenderY() - pos.getRenderY();
+
+ /*if(deltaX > (renderRoomSize + renderConnSize)/2) {
+ deltaX -= (renderRoomSize + renderConnSize);
+ } else if(deltaX < -(renderRoomSize + renderConnSize)/2) {
+ deltaX += (renderRoomSize + renderConnSize);
+ }
+ if(deltaY > (renderRoomSize + renderConnSize)/2) {
+ deltaY -= (renderRoomSize + renderConnSize);
+ } else if(deltaY < -(renderRoomSize + renderConnSize)/2) {
+ deltaY += (renderRoomSize + renderConnSize);
+ }*/
+
+ x += deltaX;
+ y += deltaY;
+
+ doInterp = false;
}
- float playerX = entry.getValue().getRenderX();
- float playerY = entry.getValue().getRenderY();
+ float minU = 3/4f;
+ float minV = 0;
+
+ if(name.equals(Minecraft.getMinecraft().thePlayer.getName())) {
+ minU = 1/4f;
+ }
- float distSq = (playerX-x)*(playerX-x) + (playerY-y)*(playerY-y);
+ float maxU = minU + 1/4f;
+ float maxV = minV + 1/4f;
- if(distSq < closestDistSq) {
- closestDistSq = distSq;
- closestPlayer = entry.getKey();
+ 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;
+ }
}
+
+ int pixelWidth = 8;
+ int pixelHeight = 8;
+ GlStateManager.color(1, 1, 1, 1);
+ if(NotEnoughUpdates.INSTANCE.manager.config.dmPlayerHeads.value >= 1 &&
+ playerSkinMap.containsKey(entry.getKey())) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(playerSkinMap.get(entry.getKey()));
+
+ if(NotEnoughUpdates.INSTANCE.manager.config.dmPlayerHeads.value >= 3) {
+ minU = 9/64f;
+ minV = 9/64f;
+ maxU = 15/64f;
+ maxV = 15/64f;
+ } else {
+ minU = 8/64f;
+ minV = 8/64f;
+ maxU = 16/64f;
+ maxV = 16/64f;
+ }
+
+ if(NotEnoughUpdates.INSTANCE.manager.config.dmPlayerHeads.value >= 2) {
+ pixelWidth = 6;
+ pixelHeight = 6;
+ }
+ } 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.rotate(angle, 0.0F, 0.0F, 1.0F);
+ GlStateManager.translate(-0.5F, 0.5F, 0.0F);
+ 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();
+
+ GlStateManager.popMatrix();
+ k--;
}
- if(closestPlayer != null) {
- x = playerMapPositions.get(closestPlayer).getRenderX();
- y = playerMapPositions.get(closestPlayer).getRenderY();
- angle = closestPlayer.rotationYawHead;
+ 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 e) {
+ }
+ } 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.manager.config.dmChromaBorder.value) {
+ int colour = SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.manager.config.dmBorderColour.value);
+
+ 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 {
+ Gui.drawRect(-mapCenterX-2, -mapCenterY, -mapCenterX, mapCenterY,
+ SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.manager.config.dmBorderColour.value)); //left
+ Gui.drawRect(mapCenterX, -mapCenterY, mapCenterX+2, mapCenterY,
+ SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.manager.config.dmBorderColour.value)); //right
+ Gui.drawRect(-mapCenterX-2, -mapCenterY-2, mapCenterX+2, -mapCenterY,
+ SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.manager.config.dmBorderColour.value)); //top
+ Gui.drawRect(-mapCenterX-2, mapCenterY, mapCenterX+2, mapCenterY+2,
+ SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.manager.config.dmBorderColour.value)); //bottom
+ }
+
+ String sizeId = borderSizeOption == 0 ? "small" : borderSizeOption == 2 ? "large" : "medium";
+
+ ResourceLocation rl = new ResourceLocation("notenoughupdates:dungeon_map/borders/"+sizeId+"/"+
+ NotEnoughUpdates.INSTANCE.manager.config.dmBorderStyle.value.intValue()+".png");
+ if(Minecraft.getMinecraft().getTextureManager().getTexture(rl) != TextureUtil.missingTexture) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(rl);
+ GlStateManager.color(1, 1, 1, 1);
+
+ int size = borderSizeOption == 0 ? 165 : borderSizeOption == 2 ? 300 : 220;
+ Utils.drawTexturedRect(-size/2, -size/2, size, size, GL11.GL_NEAREST);
}
- x -= minRoomX*(RENDER_ROOM_SIZE+RENDER_CONN_SIZE);
- y -= minRoomY*(RENDER_ROOM_SIZE+RENDER_CONN_SIZE);
-
- GlStateManager.pushMatrix();
- GlStateManager.translate(x, y, -0.02F);
- GlStateManager.rotate(angle, 0.0F, 0.0F, 1.0F);
- GlStateManager.scale(4.0F, 4.0F, 3.0F);
- GlStateManager.translate(-0.125F, 0.125F, 0.0F);
- worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX);
- worldrenderer.pos(-1.0D, 1.0D, 10+((float)k * -0.001F)).tex(minU, minV).endVertex();
- worldrenderer.pos(1.0D, 1.0D, 10+((float)k * -0.001F)).tex(minU+1/4f, minV).endVertex();
- worldrenderer.pos(1.0D, -1.0D, 10+((float)k * -0.001F)).tex(minU+1/4f, minV+1/4f).endVertex();
- worldrenderer.pos(-1.0D, -1.0D, 10+((float)k * -0.001F)).tex(minU, minV+1/4f).endVertex();
- tessellator.draw();
- GlStateManager.popMatrix();
- k--;
- }
-
- GlStateManager.rotate(rotation-180, 0, 0, 1);
- GlStateManager.translate(-centerX, -centerY, 0);
- GlStateManager.popMatrix();
+ GlStateManager.translate(-centerX, -centerY, -100);
+ } catch(Exception e) {
+ e.printStackTrace();
+ Minecraft.getMinecraft().entityRenderer.setupOverlayRendering();
+ Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true);
+ }
+
+ Utils.pushGuiScale(-1);
+
+ GlStateManager.enableBlend();
+ GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
+ GlStateManager.enableDepth();
}
@@ -409,6 +828,7 @@ public class DungeonMap {
}
for(int k=0; k<4; k++) {
+ Color colour = null;
int totalFilled = 0;
for(int i=0; i<roomSize; i++) {
@@ -431,8 +851,22 @@ public class DungeonMap {
}
if(x > 0 && y > 0 && x < colourMap.length && y < colourMap[x].length) {
- if(colourMap[x][y].equals(room.colour)) {
- totalFilled++;
+ Color pixel = colourMap[x][y];
+ if(pixel.getAlpha() > 40) {
+ if(colour == null) {
+ colour = pixel;
+ totalFilled = 1;
+ } else {
+ if(colour.equals(pixel)) {
+ totalFilled++;
+ } else {
+ totalFilled--;
+ if(totalFilled <= 0) {
+ colour = pixel;
+ totalFilled = 1;
+ }
+ }
+ }
}
}
}
@@ -446,24 +880,24 @@ public class DungeonMap {
type = RoomConnectionType.CORRIDOR;
}
if(k == 0) {
- room.up = new RoomConnection(type, room.colour);
+ room.up = new RoomConnection(type, colour);
} else if(k == 1) {
- room.right = new RoomConnection(type, room.colour);
+ room.right = new RoomConnection(type, colour);
} else if(k == 2) {
- room.down = new RoomConnection(type, room.colour);
+ room.down = new RoomConnection(type, colour);
} else {
- room.left = new RoomConnection(type, room.colour);
+ room.left = new RoomConnection(type, colour);
}
}
+ int x = startRoomX + roomOffset.x*(roomSize+connectorSize) + roomSize + connectorSize/2;
+ int y = startRoomY + roomOffset.y*(roomSize+connectorSize) + roomSize + connectorSize/2;
+
room.fillCorner = false;
- if(room.left.type == RoomConnectionType.ROOM_DIVIDER && room.up.type == RoomConnectionType.ROOM_DIVIDER) {
- RoomOffset upleft = new RoomOffset(roomOffset.x-1, roomOffset.y-1);
- if(roomMap.containsKey(upleft)) {
- Room upleftRoom = roomMap.get(upleft);
- if(upleftRoom.right.type == RoomConnectionType.ROOM_DIVIDER && upleftRoom.down.type == RoomConnectionType.ROOM_DIVIDER) {
- room.fillCorner = true;
- }
+ if(x > 0 && y > 0 && x < colourMap.length && y < colourMap[x].length) {
+ Color pixel = colourMap[x][y];
+ if(pixel.equals(room.colour)) {
+ room.fillCorner = true;
}
}
}
@@ -478,7 +912,7 @@ public class DungeonMap {
int x = startRoomX + neighbor.x*(roomSize+connectorSize);
int y = startRoomY + neighbor.y*(roomSize+connectorSize);
- if(x > 0 && y > 0 && x+roomSize < colourMap.length && y+roomSize < colourMap[x].length) {
+ if(x >= 0 && y >= 0 && x+roomSize < colourMap.length && y+roomSize < colourMap[x].length) {
if(colourMap[x][y].getAlpha() > 100) {
roomMap.put(neighbor, new Room());
loadNeighbors(neighbor);
@@ -499,33 +933,6 @@ public class DungeonMap {
}
}
- class MapDecoration {
- MapPosition position;
- int id;
- float angle;
-
- public MapDecoration(MapPosition position, int id, float angle) {
- this.position = position;
- this.id = id;
- this.angle = angle;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- MapDecoration that = (MapDecoration) o;
- return id == that.id &&
- Float.compare(that.angle, angle) == 0 &&
- Objects.equals(position, that.position);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(position, id, angle);
- }
- }
-
private class MapPosition {
public float roomOffsetX;
public float connOffsetX;
@@ -533,6 +940,8 @@ public class DungeonMap {
public float roomOffsetY;
public float connOffsetY;
+ public float rotation;
+
public MapPosition(float roomOffsetX, float connOffsetX, float roomOffsetY, float connOffsetY) {
this.roomOffsetX = roomOffsetX;
this.connOffsetX = connOffsetX;
@@ -541,11 +950,11 @@ public class DungeonMap {
}
public float getRenderX() {
- return roomOffsetX*RENDER_ROOM_SIZE + connOffsetX*RENDER_CONN_SIZE;
+ return roomOffsetX*getRenderRoomSize() + connOffsetX*getRenderConnSize();
}
public float getRenderY() {
- return roomOffsetY*RENDER_ROOM_SIZE + connOffsetY*RENDER_CONN_SIZE;
+ return roomOffsetY*getRenderRoomSize() + connOffsetY*getRenderConnSize();
}
@Override
@@ -556,28 +965,374 @@ public class DungeonMap {
return Float.compare(that.roomOffsetX, roomOffsetX) == 0 &&
Float.compare(that.connOffsetX, connOffsetX) == 0 &&
Float.compare(that.roomOffsetY, roomOffsetY) == 0 &&
- Float.compare(that.connOffsetY, connOffsetY) == 0;
+ Float.compare(that.connOffsetY, connOffsetY) == 0 &&
+ Float.compare(that.rotation, rotation) == 0;
}
@Override
public int hashCode() {
- return Objects.hash(roomOffsetX, connOffsetX, roomOffsetY, connOffsetY);
+ return Objects.hash(roomOffsetX, connOffsetX, roomOffsetY, connOffsetY, rotation);
+ }
+ }
+
+ private long lastClearCache = 0;
+ public void renderMap(int centerX, int centerY, Color[][] colourMap, Map<String, Vec4b> mapDecorations,
+ int roomSizeBlocks, Set<String> actualPlayers, boolean usePlayerPositions) {
+ if(!NotEnoughUpdates.INSTANCE.manager.config.dmEnable.value) return;
+ if(colourMap == null) return;
+ if(colourMap.length != 128) return;
+ if(colourMap[0].length != 128) return;
+ this.colourMap = colourMap;
+
+ if(System.currentTimeMillis() - lastClearCache > 1000) {
+ roomMap.clear();
+ startRoomX = -1;
+ startRoomY = -1;
+ connectorSize = -1;
+ roomSize = -1;
+ borderRadiusCache.clear();
+
+ lastClearCache = System.currentTimeMillis();
+ }
+
+ if(startRoomX < 0 || startRoomY < 0 || roomSize <= 0) {
+ for(int x=0; x<colourMap.length; x++) {
+ for(int y=0; y<colourMap[x].length; y++) {
+ Color c = colourMap[x][y];
+ if(c.getAlpha() > 80) {
+ if(startRoomX < 0 && startRoomY < 0 && c.getRed() == 0 && c.getGreen() == 124 && c.getBlue() == 0) {
+ roomSize = 0;
+ out:
+ for(int xd=0; xd<=20; xd++) {
+ for(int yd=0; yd<=20; yd++) {
+ if(x+xd >= colourMap.length || y+yd >= colourMap[x+xd].length) continue;
+ Color c2 = colourMap[x+xd][y+yd];
+
+ if(c2.getGreen() != 124 || c2.getAlpha() <= 80) {
+ if(xd < 10 && yd < 10) {
+ break out;
+ }
+ } else {
+ roomSize = Math.max(roomSize, Math.min(xd+1, yd+1));
+ }
+ if(xd == 20 && yd == 20) {
+ if(roomSize == 0) roomSize = 20;
+ startRoomX = x;
+ startRoomY = y;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if(connectorSize <= 0) {
+ for(int i=0; i<roomSize; i++) {
+ for(int k=0; k<4; k++) {
+ for(int j=1; j<8; j++) {
+ int x;
+ int y;
+
+ if(k == 0) {
+ x = startRoomX+i;
+ y = startRoomY-j;
+ } else if(k == 1) {
+ x = startRoomX+roomSize+j-1;
+ y = startRoomY+i;
+ } else if(k == 2) {
+ x = startRoomX+i;
+ y = startRoomY+roomSize+j-1;
+ } else {
+ x = startRoomX-j;
+ y = startRoomY+i;
+ }
+
+ if(x > 0 && y > 0 && x < colourMap.length && y < colourMap[x].length) {
+ if(colourMap[x][y].getAlpha() > 80) {
+ if(j == 1) {
+ break;
+ }
+ connectorSize = Math.min(connectorSize, j-1);
+ }
+ }
+ }
+ }
+ }
+
+ if(connectorSize <= 0) {
+ connectorSize = 4;
+ }
+ }
+
+ for(EntityPlayer player : Minecraft.getMinecraft().theWorld.playerEntities) {
+ if(player instanceof AbstractClientPlayer && actualPlayers.contains(player.getName())) {
+ AbstractClientPlayer aplayer = (AbstractClientPlayer) player;
+ ResourceLocation skin = aplayer.getLocationSkin();
+ if(skin != DefaultPlayerSkin.getDefaultSkin(aplayer.getUniqueID())) {
+ playerSkinMap.put(player.getName(), skin);
+ }
+ }
+ }
+
+ playerEntityMapPositions.clear();
+ if(usePlayerPositions) {
+ for(EntityPlayer player : Minecraft.getMinecraft().theWorld.playerEntities) {
+ if(actualPlayers.contains(player.getName())) {
+ float roomX = (float)player.posX / (roomSizeBlocks+1);
+ float roomY = (float)player.posZ / (roomSizeBlocks+1);
+
+ float playerRoomOffsetX = (float) Math.floor(roomX);
+ float playerConnOffsetX = (float) Math.floor(roomX);
+ float playerRoomOffsetY = (float) Math.floor(roomY);
+ float playerConnOffsetY = (float) Math.floor(roomY);
+
+ float roomXInBlocks = (float)player.posX % (roomSizeBlocks+1);
+ if(roomXInBlocks < 2) { //0,1
+ playerConnOffsetX -= 2/5f-roomXInBlocks/5f;
+ } else if(roomXInBlocks > roomSizeBlocks-2) { //31,30,29
+ playerRoomOffsetX++;
+ playerConnOffsetX += (roomXInBlocks - (roomSizeBlocks-2))/5f;
+ } else {
+ playerRoomOffsetX += (roomXInBlocks-2) / (roomSizeBlocks-4);
+ }
+
+ float roomYInBlocks = (float)player.posZ % (roomSizeBlocks+1);
+ if(roomYInBlocks < 2) { //0,1
+ playerConnOffsetY -= 2/5f-roomYInBlocks/5f;
+ } else if(roomYInBlocks > roomSizeBlocks-2) { //31,30,29
+ playerRoomOffsetY++;
+ playerConnOffsetY += (roomYInBlocks - (roomSizeBlocks-2))/5f;
+ } else {
+ playerRoomOffsetY += (roomYInBlocks-2) / (roomSizeBlocks-4);
+ }
+
+ playerRoomOffsetX -= startRoomX/(roomSize+connectorSize);
+ playerRoomOffsetY -= startRoomY/(roomSize+connectorSize);
+ playerConnOffsetX -= startRoomX/(roomSize+connectorSize);
+ playerConnOffsetY -= startRoomY/(roomSize+connectorSize);
+
+ MapPosition pos = new MapPosition(playerRoomOffsetX, playerConnOffsetX, playerRoomOffsetY, playerConnOffsetY);
+ pos.rotation = player.rotationYawHead % 360;
+ if(pos.rotation < 0) pos.rotation += 360;
+ playerEntityMapPositions.put(player.getName(), pos);
+ }
+ }
+ }
+
+ loadNeighbors(new RoomOffset(0, 0));
+ updateRoomColours();
+ for(RoomOffset offset : roomMap.keySet()) {
+ updateRoomConnections(offset);
+ }
+
+ if(mapDecorations != null && mapDecorations.size() > 0) {
+ List<MapPosition> positions = new ArrayList<>();
+ for (Vec4b vec4b : mapDecorations.values()) {
+ float x = (float) vec4b.func_176112_b() / 2.0F + 64.0F;
+ float y = (float) vec4b.func_176113_c() / 2.0F + 64.0F;
+
+ x = Math.max(0, Math.min(160, x));
+ y = Math.max(0, Math.min(160, y));
+
+ float deltaX = x - startRoomX;
+ float deltaY = y - startRoomY;
+
+ float roomsOffsetX = (int) Math.floor(deltaX / (roomSize + connectorSize));
+ float connOffsetX = (int) Math.floor(deltaX / (roomSize + connectorSize));
+ float xRemainder = deltaX % (roomSize + connectorSize);
+ if (Math.abs(xRemainder) > roomSize) {
+ roomsOffsetX += Math.copySign(1, xRemainder);
+ connOffsetX += Math.copySign(1, xRemainder) * (Math.abs(xRemainder) - roomSize) / connectorSize;
+ } else {
+ roomsOffsetX += xRemainder / roomSize;
+ }
+ if (deltaX < 0 && xRemainder != 0) {
+ roomsOffsetX++;
+ connOffsetX++;
+ }
+ float roomsOffsetY = (int) Math.floor(deltaY / (roomSize + connectorSize));
+ float connOffsetY = (int) Math.floor(deltaY / (roomSize + connectorSize));
+ float yRemainder = deltaY % (roomSize + connectorSize);
+ if (Math.abs(yRemainder) > roomSize) {
+ roomsOffsetY += Math.copySign(1, yRemainder);
+ connOffsetY += Math.copySign(1, yRemainder) * (Math.abs(yRemainder) - roomSize) / connectorSize;
+ } else {
+ roomsOffsetY += yRemainder / roomSize;
+ }
+ if (deltaY < 0 && yRemainder != 0) {
+ roomsOffsetY++;
+ connOffsetY++;
+ }
+
+ float angle = (float) (vec4b.func_176111_d() * 360) / 16.0F;
+
+ MapPosition pos = new MapPosition(roomsOffsetX, connOffsetX, roomsOffsetY, connOffsetY);
+ pos.rotation = angle % 360;
+ if(pos.rotation < 0) pos.rotation += 360;
+ positions.add(pos);
+ }
+
+ //System.out.println(playerMarkerMapPositions.size() + ":" + positions.size());
+ boolean different = playerMarkerMapPositions.size() != positions.size();
+
+ if (!different) {
+ for (MapPosition pos : playerMarkerMapPositions.values()) {
+ if (!positions.contains(pos)) {
+ different = true;
+ break;
+ }
+ }
+ }
+
+ if(different && positions.size() > 0) {
+ lastLastDecorationsMillis = lastDecorationsMillis;
+ lastDecorationsMillis = System.currentTimeMillis();
+
+ playerMarkerMapPositionsLast.clear();
+ for (Map.Entry<String, MapPosition> entry : playerMarkerMapPositions.entrySet()) {
+ playerMarkerMapPositionsLast.put(entry.getKey(), entry.getValue());
+ }
+ playerMarkerMapPositions.clear();
+
+ Set<String> foundPlayers = new HashSet<>();
+ for (Map.Entry<String, MapPosition> entry : playerEntityMapPositions.entrySet()) {
+ playerMarkerMapPositions.put(entry.getKey(), entry.getValue());
+ playerMarkerMapPositionsLast.put(entry.getKey(), entry.getValue());
+ foundPlayers.add(entry.getKey());
+ }
+
+ HashMap<String, HashMap<Integer, Float>> distanceMap = new HashMap<>();
+ for (Map.Entry<String, MapPosition> entry : playerMarkerMapPositionsLast.entrySet()) {
+ HashMap<Integer, Float> deltaDists = new HashMap<>();
+ for (int i = 0; i < positions.size(); i++) {
+ float dx = entry.getValue().getRenderX() - positions.get(i).getRenderX();
+ float dy = entry.getValue().getRenderY() - positions.get(i).getRenderY();
+ deltaDists.put(i, dx * dx + dy * dy);
+ }
+ distanceMap.put(entry.getKey(), deltaDists);
+ }
+
+ List<String> playerList = new ArrayList<>(playerMarkerMapPositionsLast.keySet());
+ List<List<String>> playerPermutations = permutations(playerList);
+
+ //if(playerPermutations.size() > 0 || playerMarkerMapPositionsLast.size() > 0)
+ // System.out.println("Perm Size: " + playerPermutations.size() + " from " + playerMarkerMapPositionsLast.size());
+
+ List<Integer> finalUsedIndexes = new ArrayList<>();
+ if (playerPermutations.size() > 0) {
+ HashMap<String, Integer> smallestPermutation = null;
+ float smallestTotalDistance = 0;
+
+ for (List<String> permutation : playerPermutations) {
+ HashMap<String, Integer> usedIndexes = new HashMap<>();
+
+ float totalDistance = 0;
+ for (String player : permutation) {
+ int smallestIndex = -1;
+ float smallestDist = 0;
+ for (Map.Entry<Integer, Float> entry : distanceMap.get(player).entrySet()) {
+ if (!usedIndexes.containsValue(entry.getKey())) {
+ if (smallestIndex == -1 || entry.getValue() < smallestDist) {
+ smallestIndex = entry.getKey();
+ smallestDist = entry.getValue();
+ }
+ }
+ }
+ if (smallestIndex != -1) {
+ usedIndexes.put(player, smallestIndex);
+ totalDistance += smallestDist;
+ }
+ }
+
+ if (smallestPermutation == null || totalDistance < smallestTotalDistance) {
+ smallestPermutation = usedIndexes;
+ smallestTotalDistance = totalDistance;
+ }
+ }
+
+ //System.out.println("--- PERM START ---");
+ for (Map.Entry<String, Integer> entry : smallestPermutation.entrySet()) {
+ //System.out.println(entry.getKey() + ":" + entry.getValue() + " : Total dist: " + smallestTotalDistance);
+ finalUsedIndexes.add(entry.getValue());
+ playerMarkerMapPositions.put(entry.getKey(), positions.get(entry.getValue()));
+ }
+ }
+
+ List<Integer> nonUsedIndexes = new ArrayList<>();
+ for(int i=0; i<positions.size(); i++) {
+ if(!finalUsedIndexes.contains(i)) {
+ nonUsedIndexes.add(i);
+ }
+ }
+
+ for(String missingPlayer : actualPlayers) {
+ if(!playerList.contains(missingPlayer)) {
+ if(nonUsedIndexes.isEmpty()) break;
+ playerMarkerMapPositions.put(missingPlayer, positions.get(nonUsedIndexes.get(0)));
+ nonUsedIndexes.remove(0);
+ }
+ }
+ }
+ } else if(mapDecorations == null) {
+ playerMarkerMapPositions.clear();
+ playerMarkerMapPositionsLast.clear();
+
+ for (Map.Entry<String, MapPosition> entry : playerEntityMapPositions.entrySet()) {
+ playerMarkerMapPositions.put(entry.getKey(), entry.getValue());
+ }
+ }
+
+ if(!roomMap.isEmpty() && startRoomX >= 0 && startRoomY >= 0) {
+ render(centerX, centerY);
+ }
+
+ this.colourMap = colourMap;
+ }
+
+ @SubscribeEvent(priority=EventPriority.HIGH)
+ public void onRenderOverlayPre(RenderGameOverlayEvent.Pre event) {
+ if(event.type == RenderGameOverlayEvent.ElementType.ALL) {
+ if(NotEnoughUpdates.INSTANCE.manager.config.dmBackgroundBlur.value > 0.1) {
+ blurBackground();
+ }
+ GlStateManager.enableBlend();
+ GlStateManager.enableTexture2D();
}
}
@SubscribeEvent
public void onRenderOverlay(RenderGameOverlayEvent event) {
if(event.type == RenderGameOverlayEvent.ElementType.ALL) {
+ if(SBInfo.getInstance().getLocation() == null || !SBInfo.getInstance().getLocation().equals("dungeon")) {
+ return;
+ }
+
ItemStack stack = Minecraft.getMinecraft().thePlayer.inventory.mainInventory[8];
- if(NotEnoughUpdates.INSTANCE.colourMap != null || (stack != null && stack.getItem() instanceof ItemMap)) {
- if(NotEnoughUpdates.INSTANCE.colourMap != null) {
- colourMap = NotEnoughUpdates.INSTANCE.colourMap;
+ boolean holdingBow = stack != null && stack.getItem() == Items.arrow;
+ if(holdingBow || (stack != null && stack.getItem() instanceof ItemMap)) {
+ Map<String, Vec4b> decorations = null;
+
+ Color[][] colourMap = new Color[128][128];
+ if(holdingBow) {
+ for(int x=0; x<128; x++) {
+ for(int y=0; y<128; y++) {
+ if(this.colourMap != null && this.colourMap[x][y] != null) {
+ colourMap[x][y] = this.colourMap[x][y];
+ } else {
+ colourMap[x][y] = new Color(0, true);
+ }
+ }
+ }
} else {
ItemMap map = (ItemMap) stack.getItem();
MapData mapData = map.getMapData(stack, Minecraft.getMinecraft().theWorld);
if(mapData == null) return;
+ decorations = mapData.mapDecorations;
+
for (int i = 0; i < 16384; ++i) {
int x = i % 128;
int y = i / 128;
@@ -593,80 +1348,10 @@ public class DungeonMap {
colourMap[x][y] = c;
}
-
- //mapData.
}
- roomMap.clear();
- startRoomX = -1;
- startRoomY = -1;
- connectorSize = 5;
- roomSize = 0;
-
- for(int x=0; x<colourMap.length; x++) {
- for(int y=0; y<colourMap[x].length; y++) {
- Color c = colourMap[x][y];
- if(c.getAlpha() > 80) {
- if(startRoomX < 0 && startRoomY < 0 && c.getRed() == 0 && c.getGreen() == 124 && c.getBlue() == 0) {
- roomSize = 0;
- out:
- for(int xd=0; xd<=20; xd++) {
- for(int yd=0; yd<=20; yd++) {
- if(x+xd >= colourMap.length || y+yd >= colourMap[x+xd].length) continue;
- Color c2 = colourMap[x+xd][y+yd];
-
- if(c2.getGreen() != 124 || c2.getAlpha() <= 80) {
- if(xd < 10 && yd < 10) {
- break out;
- }
- } else {
- roomSize = Math.max(roomSize, Math.min(xd+1, yd+1));
- }
- if(xd == 20 && yd == 20) {
- if(roomSize == 0) roomSize = 20;
- startRoomX = x;
- startRoomY = y;
- }
- }
- }
- }
- }
- }
- }
-
- for(int i=0; i<roomSize; i++) {
- for(int k=0; k<4; k++) {
- for(int j=1; j<8; j++) {
- int x;
- int y;
-
- if(k == 0) {
- x = startRoomX+i;
- y = startRoomY-j;
- } else if(k == 1) {
- x = startRoomX+roomSize+j-1;
- y = startRoomY+i;
- } else if(k == 2) {
- x = startRoomX+i;
- y = startRoomY+roomSize+j-1;
- } else {
- x = startRoomX-j;
- y = startRoomY+i;
- }
-
- if(x > 0 && y > 0 && x < colourMap.length && y < colourMap[x].length) {
- if(colourMap[x][y].getAlpha() > 80) {
- if(j == 1) {
- break;
- }
- connectorSize = Math.min(connectorSize, j-1);
- }
- }
- }
- }
- }
-
- List<Integer> dists = new ArrayList<>();
+ int roomSizeBlocks = 31;
+ /*List<Integer> dists = new ArrayList<>();
int currentBlockCount = 0;
for(int i=0; i<300; i++) {
IBlockState state = Minecraft.getMinecraft().theWorld.getBlockState(new BlockPos(0, 99, i));
@@ -677,7 +1362,6 @@ public class DungeonMap {
currentBlockCount++;
}
}
- //roomSizeBlocks = 7;
currentBlockCount = 0;
for(int i=0; i<300; i++) {
IBlockState state = Minecraft.getMinecraft().theWorld.getBlockState(new BlockPos(i, 99, 0));
@@ -700,163 +1384,151 @@ public class DungeonMap {
}
}
}
- if(mostCommonDist != -1) roomSizeBlocks = Math.max(31, mostCommonDist);
- if(Keyboard.isKeyDown(Keyboard.KEY_N)) System.out.println(roomSizeBlocks + ":" + dists.size());
+ if(mostCommonDist > 31) roomSizeBlocks = mostCommonDist;*/
Set<String> actualPlayers = new HashSet<>();
for(ScorePlayerTeam team : Minecraft.getMinecraft().thePlayer.getWorldScoreboard().getTeams()) {
if(team.getTeamName().startsWith("a")) {
- for(String player : team.getMembershipCollection()) {
- actualPlayers.add(player.toLowerCase());
- }
+ actualPlayers.addAll(team.getMembershipCollection());
}
}
- playerMapPositions.clear();
- for(EntityPlayer player : Minecraft.getMinecraft().theWorld.playerEntities) {
- if(actualPlayers.isEmpty() || actualPlayers.contains(player.getName().toLowerCase())) {
- float roomX = (float)player.posX / (roomSizeBlocks+1);
- float roomY = (float)player.posZ / (roomSizeBlocks+1);
-
- float playerRoomOffsetX = (float) Math.floor(roomX);
- float playerConnOffsetX = (float) Math.floor(roomX);
- float playerRoomOffsetY = (float) Math.floor(roomY);
- float playerConnOffsetY = (float) Math.floor(roomY);
-
- float roomXInBlocks = (float)player.posX % (roomSizeBlocks+1);
- if(roomXInBlocks < 2) { //0,1
- playerConnOffsetX -= roomXInBlocks/5f;
- } else if(roomXInBlocks > roomSizeBlocks-3) { //31,30,29
- playerRoomOffsetX++;
- playerConnOffsetX += (roomXInBlocks - (roomSizeBlocks-3))/5f;
- } else {
- playerRoomOffsetX += (roomXInBlocks-2) / (roomSizeBlocks-5);
- }
-
- float roomYInBlocks = (float)player.posZ % (roomSizeBlocks+1);
- if(roomYInBlocks < 2) { //0,1
- playerConnOffsetY -= roomYInBlocks/5f;
- } else if(roomYInBlocks > roomSizeBlocks-3) { //31,30,29
- playerRoomOffsetY++;
- playerConnOffsetY += (roomYInBlocks - (roomSizeBlocks-3))/5f;
- } else {
- playerRoomOffsetY += (roomYInBlocks-2) / (roomSizeBlocks-5);
- }
+ renderMap((int)(NotEnoughUpdates.INSTANCE.manager.config.dmCenterX.value/100*Minecraft.getMinecraft().displayWidth/2),
+ (int)(NotEnoughUpdates.INSTANCE.manager.config.dmCenterY.value/100*Minecraft.getMinecraft().displayHeight/2),
+ colourMap, decorations, roomSizeBlocks, actualPlayers, true);
+ }
+ }
+ }
- playerRoomOffsetX -= startRoomX/(roomSize+connectorSize);
- playerRoomOffsetY -= startRoomY/(roomSize+connectorSize);
- playerConnOffsetX -= startRoomX/(roomSize+connectorSize);
- playerConnOffsetY -= startRoomY/(roomSize+connectorSize);
+ public List<List<String>> permutations(List<String> values) {
+ List<List<String>> permutations = new ArrayList<>();
- playerMapPositions.put(player, new MapPosition(playerRoomOffsetX, playerConnOffsetX, playerRoomOffsetY, playerConnOffsetY));
- }
- }
+ if(values.size() == 1) {
+ permutations.add(values);
+ return permutations;
+ }
- loadNeighbors(new RoomOffset(0, 0));
- updateRoomColours();
- for(RoomOffset offset : roomMap.keySet()) {
- updateRoomConnections(offset);
+ for(String first : values) {
+ List<String> newList = new ArrayList<>();
+ for(String val : values) {
+ if(!val.equals(first)) {
+ newList.add(val);
}
+ }
- if(NotEnoughUpdates.INSTANCE.colourMap == null) {
- ItemMap map = (ItemMap) stack.getItem();
- MapData mapData = map.getMapData(stack, Minecraft.getMinecraft().theWorld);
-
- if(mapData.mapDecorations.size() > 0) {
- boolean different = mapData.mapDecorations.size() != decorations.size();
-
- List<MapDecoration> decorationsNew = new ArrayList<>();
-
- for (Vec4b vec4b : mapData.mapDecorations.values()) {
- byte b0 = vec4b.func_176110_a();
-
- float x = (float)vec4b.func_176112_b() / 2.0F + 64.0F;
- float y = (float)vec4b.func_176113_c() / 2.0F + 64.0F;
-
- float deltaX = x - startRoomX;
- float deltaY = y - startRoomY;
-
- float roomsOffsetX = (int)Math.floor(deltaX / (roomSize+connectorSize));
- float connOffsetX = (int)Math.floor(deltaX / (roomSize+connectorSize));
- float xRemainder = deltaX % (roomSize+connectorSize);
- if(Math.abs(xRemainder) > roomSize) {
- roomsOffsetX++;
- connOffsetX += (xRemainder-roomSize)/connectorSize;
- } else {
- roomsOffsetX += xRemainder/roomSize;
- }
- if(deltaX < 0) {
- roomsOffsetX++;
- connOffsetX++;
- }
- float roomsOffsetY = (int)Math.floor(deltaY / (roomSize+connectorSize));
- float connOffsetY = (int)Math.floor(deltaY / (roomSize+connectorSize));
- float yRemainder = deltaY % (roomSize+connectorSize);
- if(Math.abs(yRemainder) > roomSize) {
- roomsOffsetY++;
- connOffsetY += Math.abs(yRemainder-roomSize)/connectorSize;
- } else {
- roomsOffsetY += yRemainder/roomSize;
- }
- if(deltaY < 0) {
- roomsOffsetY++;
- connOffsetY++;
- }
-
- float angle = (float)(vec4b.func_176111_d() * 360) / 16.0F;
-
- MapDecoration decoration = new MapDecoration(new MapPosition(roomsOffsetX, connOffsetX, roomsOffsetY, connOffsetY), (int)b0, angle);
- if(!different && !decorations.contains(decoration)) {
- different = true;
- }
- decorationsNew.add(decoration);
- }
+ for(List<String> list2 : permutations(newList)) {
+ List<String> perm = new ArrayList<>();
+ perm.add(first);
+ perm.addAll(list2);
+ permutations.add(perm);
+ }
+ }
- if(different) {
- lastDecorations.clear();
+ return permutations;
+ }
- for(int i=0; i<decorations.size() && i<decorationsNew.size(); i++) {
- MapDecoration match = decorationsNew.get(i);
+ Shader blurShaderHorz = null;
+ Framebuffer blurOutputHorz = null;
+ Shader blurShaderVert = null;
+ Framebuffer blurOutputVert = null;
+
+ /**
+ * Creates a projection matrix that projects from our coordinate space [0->width; 0->height] to OpenGL coordinate
+ * space [-1 -> 1; 1 -> -1] (Note: flipped y-axis).
+ *
+ * This is so that we can render to and from the framebuffer in a way that is familiar to us, instead of needing to
+ * apply scales and translations manually.
+ */
+ private Matrix4f createProjectionMatrix(int width, int height) {
+ Matrix4f projMatrix = new Matrix4f();
+ projMatrix.setIdentity();
+ projMatrix.m00 = 2.0F / (float)width;
+ projMatrix.m11 = 2.0F / (float)(-height);
+ projMatrix.m22 = -0.0020001999F;
+ projMatrix.m33 = 1.0F;
+ projMatrix.m03 = -1.0F;
+ projMatrix.m13 = 1.0F;
+ projMatrix.m23 = -1.0001999F;
+ return projMatrix;
+ }
- float lowestDistSq = 999;
- MapDecoration closest = null;
+ private double lastBgBlurFactor = -1;
+ private void blurBackground() {
+ if(!OpenGlHelper.isFramebufferEnabled()) return;
- for(int j=0; j<decorations.size(); j++) {
- MapDecoration old = decorations.get(j);
+ int width = Minecraft.getMinecraft().displayWidth;
+ int height = Minecraft.getMinecraft().displayHeight;
- if(old.id != match.id) continue;
+ if(blurOutputHorz == null) {
+ blurOutputHorz = new Framebuffer(width, height, false);
+ blurOutputHorz.setFramebufferFilter(GL11.GL_NEAREST);
+ }
+ if(blurOutputVert == null) {
+ blurOutputVert = new Framebuffer(width, height, false);
+ blurOutputVert.setFramebufferFilter(GL11.GL_NEAREST);
+ }
+ if(blurOutputHorz.framebufferWidth != width || blurOutputHorz.framebufferHeight != height) {
+ blurOutputHorz.createBindFramebuffer(width, height);
+ blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height));
+ Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
+ }
+ if(blurOutputVert.framebufferWidth != width || blurOutputVert.framebufferHeight != height) {
+ blurOutputVert.createBindFramebuffer(width, height);
+ blurShaderVert.setProjectionMatrix(createProjectionMatrix(width, height));
+ Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
+ }
- float xOff = (old.position.roomOffsetX*RENDER_ROOM_SIZE+old.position.connOffsetX*RENDER_CONN_SIZE) -
- (match.position.roomOffsetX*RENDER_ROOM_SIZE+match.position.connOffsetX*RENDER_CONN_SIZE);
- float yOff = (old.position.roomOffsetY*RENDER_ROOM_SIZE+old.position.connOffsetY*RENDER_CONN_SIZE) -
- (match.position.roomOffsetY*RENDER_ROOM_SIZE+match.position.connOffsetY*RENDER_CONN_SIZE);
- float distSq = xOff*xOff + yOff*yOff;
- if(distSq < lowestDistSq) {
- lowestDistSq = distSq;
- closest = old;
- }
- }
+ if(blurShaderHorz == null) {
+ try {
+ blurShaderHorz = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur",
+ Minecraft.getMinecraft().getFramebuffer(), blurOutputHorz);
+ blurShaderHorz.getShaderManager().getShaderUniform("BlurDir").set(1, 0);
+ blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height));
+ } catch(Exception e) { }
+ }
+ if(blurShaderVert == null) {
+ try {
+ blurShaderVert = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur",
+ blurOutputHorz, blurOutputVert);
+ blurShaderVert.getShaderManager().getShaderUniform("BlurDir").set(0, 1);
+ blurShaderVert.setProjectionMatrix(createProjectionMatrix(width, height));
+ } catch(Exception e) { }
+ }
+ if(blurShaderHorz != null && blurShaderVert != null) {
+ float blur = NotEnoughUpdates.INSTANCE.manager.config.dmBackgroundBlur.value.floatValue();
+ if(blur != lastBgBlurFactor) {
+ blurShaderHorz.getShaderManager().getShaderUniform("Radius").set((float)blur);
+ blurShaderVert.getShaderManager().getShaderUniform("Radius").set((float)blur);
+ lastBgBlurFactor = blur;
+ }
+ GL11.glPushMatrix();
+ blurShaderHorz.loadShader(0);
+ blurShaderVert.loadShader(0);
+ GlStateManager.enableDepth();
+ GL11.glPopMatrix();
- if(closest != null) {
- lastDecorations.add(closest);
- }
- }
+ Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
+ }
+ }
- decorations.clear();
- decorations.addAll(decorationsNew);
+ /**
+ * Renders a subsection of the blurred framebuffer on to the corresponding section of the screen.
+ * Essentially, this method will "blur" the background inside the bounds specified by [x->x+blurWidth, y->y+blurHeight]
+ */
+ public void renderBlurredBackground(int width, int height, int x, int y, int blurWidth, int blurHeight) {
+ if(!OpenGlHelper.isFramebufferEnabled()) return;
- lastLastDecorationsMillis = lastDecorationsMillis;
- lastDecorationsMillis = System.currentTimeMillis();
- }
- }
+ if(blurOutputVert == null) return;
- }
+ float uMin = x/(float)width;
+ float uMax = (x+blurWidth)/(float)width;
+ float vMin = (height-y)/(float)height;
+ float vMax = (height-y-blurHeight)/(float)height;
- if(!roomMap.isEmpty()) {
- render();
- }
- }
- }
+ blurOutputVert.bindFramebufferTexture();
+ GlStateManager.color(1f, 1f, 1f, 1f);
+ Utils.drawTexturedRectNoBlend(x, y, blurWidth, blurHeight, uMin, uMax, vMin, vMax, GL11.GL_LINEAR);
+ blurOutputVert.unbindFramebufferTexture();
}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/GuiButtonItem.java b/src/main/java/io/github/moulberry/notenoughupdates/GuiButtonItem.java
new file mode 100644
index 00000000..a08b27bc
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/GuiButtonItem.java
@@ -0,0 +1,93 @@
+package io.github.moulberry.notenoughupdates;
+
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.Gui;
+import net.minecraft.client.gui.GuiButton;
+import net.minecraft.client.renderer.GlStateManager;
+import net.minecraft.client.renderer.RenderHelper;
+import net.minecraft.init.Items;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagList;
+import net.minecraft.nbt.NBTTagString;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.util.ResourceLocation;
+
+public class GuiButtonItem extends GuiButton
+{
+ private static final ResourceLocation TEXTURE = new ResourceLocation("dummy:textures/gui/blank.png");
+ private ItemStack itemStack;
+ private String customName;
+
+ public GuiButtonItem(int buttonID, int xPos, int yPos, ItemStack itemStack)
+ {
+ this(buttonID, xPos, yPos, xPos, itemStack, itemStack.getDisplayName());
+ }
+
+ public GuiButtonItem(int buttonID, int xPos, int yPos, int potionX, ItemStack itemStack)
+ {
+ this(buttonID, xPos, yPos, potionX, itemStack, itemStack.getDisplayName());
+ }
+
+ public GuiButtonItem(int buttonID, int xPos, int yPos, ItemStack itemStack, String customName)
+ {
+ this(buttonID, xPos, yPos, xPos, itemStack, customName);
+ }
+
+ public GuiButtonItem(int buttonID, int xPos, int yPos, int potionX, ItemStack itemStack, String customName)
+ {
+ super(buttonID, xPos, yPos, 18, 18, "");
+ this.itemStack = itemStack;
+ this.customName = customName;
+ }
+
+ @Override
+ public void drawButton(Minecraft mc, int mouseX, int mouseY)
+ {
+ boolean flag = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
+
+ if (this.visible)
+ {
+ if (this.itemStack.getItem() == Items.nether_star)
+ {
+ ItemStack skyBlockMenu = this.itemStack.copy();
+ NBTTagList list = new NBTTagList();
+ skyBlockMenu.setStackDisplayName("SkyBlock Menu");
+ list.appendTag(new NBTTagString(EnumChatFormatting.GRAY + "View all of your SkyBlock"));
+ skyBlockMenu.getTagCompound().getCompoundTag("display").setTag("Lore", list);
+ this.itemStack = skyBlockMenu;
+ }
+
+ mc.getTextureManager().bindTexture(TEXTURE);
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+ Gui.drawModalRectWithCustomSizedTexture(this.xPosition, this.yPosition, flag ? 18 : 0, 0, this.width, this.height, 36, 18);
+
+ GlStateManager.enableDepth();
+ GlStateManager.enableRescaleNormal();
+ GlStateManager.enableBlend();
+ GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
+ RenderHelper.enableGUIStandardItemLighting();
+ GlStateManager.enableLighting();
+ mc.getRenderItem().renderItemAndEffectIntoGUI(this.itemStack, this.xPosition + 1, this.yPosition + 1);
+ }
+ }
+
+ public String getName()
+ {
+ return this.customName;
+ }
+
+ public ItemStack getItemStack()
+ {
+ return this.itemStack;
+ }
+
+ public void setName(String name)
+ {
+ this.customName = name;
+ }
+
+ public void setItemStack(ItemStack itemStack)
+ {
+ this.itemStack = itemStack;
+ }
+} \ No newline at end of file
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/GuiDungeonMapEditor.java b/src/main/java/io/github/moulberry/notenoughupdates/GuiDungeonMapEditor.java
new file mode 100644
index 00000000..5bc4b6ee
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/GuiDungeonMapEditor.java
@@ -0,0 +1,754 @@
+package io.github.moulberry.notenoughupdates;
+
+import io.github.moulberry.notenoughupdates.infopanes.SettingsInfoPane;
+import io.github.moulberry.notenoughupdates.itemeditor.GuiElementTextField;
+import io.github.moulberry.notenoughupdates.options.Options;
+import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer;
+import io.github.moulberry.notenoughupdates.util.SpecialColour;
+import io.github.moulberry.notenoughupdates.util.Utils;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.Gui;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.client.gui.ScaledResolution;
+import net.minecraft.client.renderer.GlStateManager;
+import net.minecraft.client.renderer.OpenGlHelper;
+import net.minecraft.client.renderer.texture.DynamicTexture;
+import net.minecraft.client.shader.Framebuffer;
+import net.minecraft.client.shader.Shader;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.util.Matrix4f;
+import net.minecraft.util.ResourceLocation;
+import net.minecraft.util.Vec4b;
+import org.lwjgl.input.Keyboard;
+import org.lwjgl.input.Mouse;
+import org.lwjgl.opengl.GL11;
+
+import java.awt.*;
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.util.*;
+import java.util.List;
+
+import static io.github.moulberry.notenoughupdates.GuiTextures.*;
+import static io.github.moulberry.notenoughupdates.GuiTextures.colour_selector_dot;
+
+public class GuiDungeonMapEditor extends GuiScreen {
+
+ public static final ResourceLocation BACKGROUND = new ResourceLocation("notenoughupdates:dungeon_map/editor/background.png");
+ public static final ResourceLocation BUTTON = new ResourceLocation("notenoughupdates:button.png");
+ private static final DungeonMap demoMap = new DungeonMap();
+
+ private int sizeX;
+ private int sizeY;
+ private int guiLeft;
+ private int guiTop;
+
+ private List<Button> buttons = new ArrayList<>();
+
+ private static final int colourEditorBG = new Color(80, 80, 80, 220).getRGB();
+ private static ResourceLocation colourPickerLocation = new ResourceLocation("notenoughupdates:dynamic/colourpicker");
+ private static ResourceLocation colourPickerBarValueLocation = new ResourceLocation("notenoughupdates:dynamic/colourpickervalue");
+ private static ResourceLocation colourPickerBarOpacityLocation = new ResourceLocation("notenoughupdates:dynamic/colourpickeropacity");
+
+ private GuiElementTextField hexField = new GuiElementTextField("",
+ GuiElementTextField.SCALE_TEXT | GuiElementTextField.FORCE_CAPS | GuiElementTextField.NO_SPACE);
+
+ private GuiElementTextField xField = new GuiElementTextField("", GuiElementTextField.NUM_ONLY | GuiElementTextField.NO_SPACE);
+ private GuiElementTextField yField = new GuiElementTextField("", GuiElementTextField.NUM_ONLY | GuiElementTextField.NO_SPACE);
+ private GuiElementTextField blurField = new GuiElementTextField("", GuiElementTextField.NUM_ONLY | GuiElementTextField.NO_SPACE);
+ private ColourEditor activeColourEditor = null;
+
+ private class ColourEditor {
+ public int x;
+ public int y;
+ public Options.Option<String> option;
+ public String special;
+
+ public ColourEditor(int x, int y, Options.Option<String> option, String special) {
+ this.x = x;
+ this.y = y;
+ this.option = option;
+ this.special = special;
+ }
+ }
+
+ class Button {
+ private int id;
+ private int x;
+ private int y;
+ private String text;
+ private Color colour = new Color(-1, true);
+
+ public Button(int id, int x, int y, String text) {
+ this.id = id;
+ this.x = x;
+ this.y = y;
+ this.text = text;
+ }
+
+ public void render() {
+ if(text == null) return;
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(BUTTON);
+ if(isButtonPressed(id)) {
+ GlStateManager.color(colour.getRed()*0.85f/255f, colour.getGreen()*0.85f/255f,
+ colour.getBlue()*0.85f/255f, 1);
+ Utils.drawTexturedRect(guiLeft+x, guiTop+y, 48, 16, 1, 0, 1, 0, GL11.GL_NEAREST);
+ } else {
+ GlStateManager.color(colour.getRed()/255f, colour.getGreen()/255f, colour.getBlue()/255f, 1);
+ Utils.drawTexturedRect(guiLeft+x, guiTop+y, 48, 16, GL11.GL_NEAREST);
+ }
+
+ if(text.length() > 0) {
+ Utils.drawStringCenteredScaledMaxWidth(text, Minecraft.getMinecraft().fontRendererObj , guiLeft+x+24, guiTop+y+8, false, 39, 0xFF000000);
+ }
+ }
+
+ }
+
+ public GuiDungeonMapEditor() {
+ //Map Border Size
+ buttons.add(new Button(0, 6, 37, "Small"));
+ buttons.add(new Button(1, 52, 37, "Medium"));
+ buttons.add(new Button(2, 98, 37, "Large"));
+
+ //Map Rooms Size
+ buttons.add(new Button(3, 6, 67, "Small"));
+ buttons.add(new Button(4, 52, 67, "Medium"));
+ buttons.add(new Button(5, 98, 67, "Large"));
+
+ //Map Border Styles
+ buttons.add(new Button(6, 6, 97, "Default"));
+ buttons.add(new Button(7, 52, 97, "Custom"));
+ buttons.add(new Button(8, 98, 97, "Stone"));
+ buttons.add(new Button(9, 6, 116, "Wood"));
+ buttons.add(new Button(10, 52, 116, "Rustic(S)"));
+ buttons.add(new Button(11, 98, 116, "Rustic(C)"));
+ buttons.add(new Button(12, 6, 135, "Fade"));
+ buttons.add(new Button(13, 52, 135, "Ribbons"));
+ buttons.add(new Button(14, 98, 135, "Paper"));
+ buttons.add(new Button(15, 6, 154, "Crimson"));
+ buttons.add(new Button(16, 52, 154, "Ornate"));
+ buttons.add(new Button(17, 98, 154, "Dragon"));
+
+ //Dungeon Map
+ buttons.add(new Button(18, 20+139, 36, "Yes/No"));
+ //Center
+ buttons.add(new Button(19, 84+139, 36, "Player/Map"));
+ //Rotate
+ buttons.add(new Button(20, 20+139, 65, "Player/No Rotate"));
+ //Icon Style
+ buttons.add(new Button(21, 84+139, 65, "Default/Heads"));
+ //Check Orient
+ buttons.add(new Button(22, 20+139, 94, "Normal/Reorient"));
+ //Check Center
+ buttons.add(new Button(23, 84+139, 94, "Yes/No"));
+ //Interpolation
+ buttons.add(new Button(24, 20+139, 123, "Yes/No"));
+ //Compatibility
+ buttons.add(new Button(25, 84+139, 123, "Normal/No SHD/No FB/SHD"));
+
+ //Background
+ buttons.add(new Button(26, 20+139, 152, ""));
+ //Border
+ buttons.add(new Button(27, 84+139, 152, ""));
+
+ //Compatibility
+ buttons.add(new Button(28, 84+139, 181, "Normal/Scroll"));
+
+ xField.setText(String.valueOf(NotEnoughUpdates.INSTANCE.manager.config.dmCenterX.value));
+ yField.setText(String.valueOf(NotEnoughUpdates.INSTANCE.manager.config.dmCenterY.value));
+ blurField.setText(String.valueOf(NotEnoughUpdates.INSTANCE.manager.config.dmBackgroundBlur.value));
+ }
+
+ private void showColourEditor(int mouseX, int mouseY, Options.Option<String> option, String special) {
+ activeColourEditor = new ColourEditor(mouseX, mouseY, option, special);
+ hexField.otherComponentClick();
+ }
+
+ @Override
+ public void drawScreen(int mouseX, int mouseY, float partialTicks) {
+ ScaledResolution scaledResolution = Utils.pushGuiScale(2);
+ this.width = scaledResolution.getScaledWidth();
+ this.height = scaledResolution.getScaledHeight();
+
+ this.sizeX = 431;
+ this.sizeY = 237;
+ this.guiLeft = (this.width - this.sizeX) / 2;
+ this.guiTop = (this.height-this.sizeY)/2;
+
+ super.drawScreen(mouseX, mouseY, partialTicks);
+ drawDefaultBackground();
+
+ blurBackground();
+ renderBlurredBackground(width, height, guiLeft+2, guiTop+2, sizeX-4, sizeY-4);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(BACKGROUND);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(guiLeft, guiTop, sizeX, sizeY, GL11.GL_NEAREST);
+
+ Minecraft.getMinecraft().fontRendererObj.drawString("NEU Dungeon Map Editor", guiLeft+8, guiTop+6, 0xFFB4B4B4);
+
+ Utils.drawStringCenteredScaledMaxWidth("Map Border Size", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft+76, guiTop+30, false, 137, 0xFFB4B4B4);
+ Utils.drawStringCenteredScaledMaxWidth("Map Rooms Size", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft+76, guiTop+60, false, 137, 0xFFB4B4B4);
+ Utils.drawStringCenteredScaledMaxWidth("Map Border Style", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft+76, guiTop+90, false, 137, 0xFFB4B4B4);
+
+ Utils.drawStringCenteredScaledMaxWidth("Dungeon Map", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft+44+139, guiTop+30, false, 60, 0xFFB4B4B4);
+ Utils.drawStringCenteredScaledMaxWidth("Center", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft+108+139, guiTop+30, false, 60, 0xFFB4B4B4);
+
+ Utils.drawStringCenteredScaledMaxWidth("Rotate", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft+44+139, guiTop+59, false, 60, 0xFFB4B4B4);
+ Utils.drawStringCenteredScaledMaxWidth("Icon Style", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft+108+139, guiTop+59, false, 60, 0xFFB4B4B4);
+
+ Utils.drawStringCenteredScaledMaxWidth("Check Orient", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft+44+139, guiTop+88, false, 60, 0xFFB4B4B4);
+ Utils.drawStringCenteredScaledMaxWidth("Check Center", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft+108+139, guiTop+88, false, 60, 0xFFB4B4B4);
+
+ Utils.drawStringCenteredScaledMaxWidth("Interpolation", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft+44+139, guiTop+117, false, 60, 0xFFB4B4B4);
+ Utils.drawStringCenteredScaledMaxWidth("Compatibility", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft+108+139, guiTop+117, false, 60, 0xFFB4B4B4);
+
+ Utils.drawStringCenteredScaledMaxWidth("Background", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft+44+139, guiTop+146, false, 60, 0xFFB4B4B4);
+ Utils.drawStringCenteredScaledMaxWidth("Border", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft+108+139, guiTop+146, false, 60, 0xFFB4B4B4);
+
+ Utils.drawStringCenteredScaledMaxWidth("BG Blur", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft+44+139, guiTop+175, false, 60, 0xFFB4B4B4);
+ Utils.drawStringCenteredScaledMaxWidth("Chroma Type", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft+108+139, guiTop+175, false, 60, 0xFFB4B4B4);
+
+ Utils.drawStringCenteredScaledMaxWidth("X (%)", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft+44+139, guiTop+204, false, 60, 0xFFB4B4B4);
+ Utils.drawStringCenteredScaledMaxWidth("Y (%)", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft+108+139, guiTop+204, false, 60, 0xFFB4B4B4);
+
+ Options options = NotEnoughUpdates.INSTANCE.manager.config;
+ buttons.get(18).text = options.dmEnable.value ? "Enabled" : "Disabled";
+ buttons.get(19).text = options.dmCenterPlayer.value ? "Player" : "Map";
+ buttons.get(20).text = options.dmRotatePlayer.value ? "Player" : "No Rotate";
+ buttons.get(21).text = options.dmPlayerHeads.value <= 0 ? "Default" : options.dmPlayerHeads.value >= 3 ? "SmallHeads" :
+ options.dmPlayerHeads.value == 1 ? "Heads" : "ScaledHeads";
+ buttons.get(22).text = options.dmOrientCheck.value ? "Orient" : "Default";
+ buttons.get(23).text = options.dmCenterCheck.value ? "Center" : "Default";
+ buttons.get(24).text = options.dmPlayerInterp.value ? "Interp" : "No Interp";
+ buttons.get(25).text = options.dmCompat.value <= 0 ? "Normal" : options.dmCompat.value >= 2 ? "No FB/SHD" : "No SHD";
+
+ buttons.get(26).colour = new Color(SpecialColour.specialToChromaRGB(options.dmBackgroundColour.value));
+ buttons.get(27).colour = new Color(SpecialColour.specialToChromaRGB(options.dmBorderColour.value));
+
+ buttons.get(28).text = options.dmChromaBorder.value ? "Scroll" : "Normal";
+
+ blurField.setSize(48, 16);
+ xField.setSize(48, 16);
+ yField.setSize(48, 16);
+ blurField.render(guiLeft+20+139, guiTop+181);
+ xField.render(guiLeft+20+139, guiTop+210);
+ yField.render(guiLeft+84+139, guiTop+210);
+
+ Map<String, Vec4b> decorations = new HashMap<>();
+ Vec4b vec4b = new Vec4b((byte)3, (byte)(((50)-64)*2), (byte)(((40)-64)*2), (byte)((60)*16/360));
+ decorations.put(Minecraft.getMinecraft().thePlayer.getName(), vec4b);
+
+ HashSet<String> players = new HashSet<>();
+ players.add(Minecraft.getMinecraft().thePlayer.getName());
+ GlStateManager.color(1, 1, 1, 1);
+
+ demoMap.renderMap(guiLeft+357, guiTop+125, NotEnoughUpdates.INSTANCE.colourMap, decorations, 0,
+ players, false);
+
+ for(Button button : buttons) {
+ button.render();
+ }
+
+ if(activeColourEditor != null) {
+ Gui.drawRect(activeColourEditor.x, activeColourEditor.y, activeColourEditor.x+119, activeColourEditor.y+89, colourEditorBG);
+
+ int currentColour = SpecialColour.specialToSimpleRGB(activeColourEditor.special);
+ Color c = new Color(currentColour, true);
+ float[] hsv = Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), null);
+
+ BufferedImage bufferedImage = new BufferedImage(256, 256, BufferedImage.TYPE_INT_ARGB);
+ for(int x=0; x<256; x++) {
+ for(int y=0; y<256; y++) {
+ float radius = (float) Math.sqrt(((x-128)*(x-128)+(y-128)*(y-128))/16384f);
+ float angle = (float) Math.toDegrees(Math.atan((128-x)/(y-128+1E-5))+Math.PI/2);
+ if(y < 128) angle += 180;
+ if(radius <= 1) {
+ int rgb = Color.getHSBColor(angle/360f, (float)Math.pow(radius, 1.5f), hsv[2]).getRGB();
+ bufferedImage.setRGB(x, y, rgb);
+ }
+ }
+ }
+
+ BufferedImage bufferedImageValue = new BufferedImage(10, 64, BufferedImage.TYPE_INT_ARGB);
+ for(int x=0; x<10; x++) {
+ for(int y=0; y<64; y++) {
+ if((x == 0 || x == 9) && (y == 0 || y == 63)) continue;
+
+ int rgb = Color.getHSBColor(hsv[0], hsv[1], (64-y)/64f).getRGB();
+ bufferedImageValue.setRGB(x, y, rgb);
+ }
+ }
+
+ BufferedImage bufferedImageOpacity = new BufferedImage(10, 64, BufferedImage.TYPE_INT_ARGB);
+ for(int x=0; x<10; x++) {
+ for(int y=0; y<64; y++) {
+ if((x == 0 || x == 9) && (y == 0 || y == 63)) continue;
+
+ int rgb = (currentColour & 0x00FFFFFF) | (Math.min(255, (64-y)*4) << 24);
+ bufferedImageOpacity.setRGB(x, y, rgb);
+ }
+ }
+
+ float selradius = (float) Math.pow(hsv[1], 1/1.5f)*32;
+ int selx = (int)(Math.cos(Math.toRadians(hsv[0]*360))*selradius);
+ int sely = (int)(Math.sin(Math.toRadians(hsv[0]*360))*selradius);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(colour_selector_bar_alpha);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(activeColourEditor.x+5+64+5+10+5, activeColourEditor.y+5, 10, 64, GL11.GL_NEAREST);
+
+ Minecraft.getMinecraft().getTextureManager().loadTexture(colourPickerBarValueLocation, new DynamicTexture(bufferedImageValue));
+ Minecraft.getMinecraft().getTextureManager().bindTexture(colourPickerBarValueLocation);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(activeColourEditor.x+5+64+5, activeColourEditor.y+5, 10, 64, GL11.GL_NEAREST);
+
+ Minecraft.getMinecraft().getTextureManager().loadTexture(colourPickerBarOpacityLocation, new DynamicTexture(bufferedImageOpacity));
+ Minecraft.getMinecraft().getTextureManager().bindTexture(colourPickerBarOpacityLocation);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(activeColourEditor.x+5+64+5+10+5, activeColourEditor.y+5, 10, 64, GL11.GL_NEAREST);
+
+ int chromaSpeed = SpecialColour.getSpeed(activeColourEditor.special);
+ int currentColourChroma = SpecialColour.specialToChromaRGB(activeColourEditor.special);
+ Color cChroma = new Color(currentColourChroma, true);
+ float hsvChroma[] = Color.RGBtoHSB(cChroma.getRed(), cChroma.getGreen(), cChroma.getBlue(), null);
+
+ if(chromaSpeed > 0) {
+ Gui.drawRect(activeColourEditor.x+5+64+5+10+5+10+5+1, activeColourEditor.y+5+1,
+ activeColourEditor.x+5+64+5+10+5+10+5+10-1, activeColourEditor.y+5+64-1,
+ Color.HSBtoRGB(hsvChroma[0], 0.8f, 0.8f));
+ } else {
+ Gui.drawRect(activeColourEditor.x+5+64+5+10+5+10+5+1, activeColourEditor.y+5+27+1,
+ activeColourEditor.x+5+64+5+10+5+10+5+10-1, activeColourEditor.y+5+37-1,
+ Color.HSBtoRGB((hsvChroma[0]+(System.currentTimeMillis()-SpecialColour.startTime)/1000f)%1, 0.8f, 0.8f));
+ }
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(colour_selector_bar);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(activeColourEditor.x+5+64+5, activeColourEditor.y+5, 10, 64, GL11.GL_NEAREST);
+ Utils.drawTexturedRect(activeColourEditor.x+5+64+5+10+5, activeColourEditor.y+5, 10, 64, GL11.GL_NEAREST);
+
+ if(chromaSpeed > 0) {
+ Utils.drawTexturedRect(activeColourEditor.x+5+64+5+10+5+10+5, activeColourEditor.y+5, 10, 64, GL11.GL_NEAREST);
+ } else {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(colour_selector_chroma);
+ Utils.drawTexturedRect(activeColourEditor.x+5+64+5+10+5+10+5, activeColourEditor.y+5+27, 10, 10, GL11.GL_NEAREST);
+ }
+
+ Gui.drawRect(activeColourEditor.x+5+64+5, activeColourEditor.y+5+64-(int)(64*hsv[2]),
+ activeColourEditor.x+5+64+5+10, activeColourEditor.y+5+64-(int)(64*hsv[2])+1, 0xFF000000);
+ Gui.drawRect(activeColourEditor.x+5+64+5+10+5, activeColourEditor.y+5+64-c.getAlpha()/4,
+ activeColourEditor.x+5+64+5+10+5+10, activeColourEditor.y+5+64-c.getAlpha()/4-1, 0xFF000000);
+ if(chromaSpeed > 0) {
+ Gui.drawRect(activeColourEditor.x+5+64+5+10+5+10+5,
+ activeColourEditor.y+5+64-(int)(chromaSpeed/255f*64),
+ activeColourEditor.x+5+64+5+10+5+10+5+10,
+ activeColourEditor.y+5+64-(int)(chromaSpeed/255f*64)+1, 0xFF000000);
+ }
+
+ Minecraft.getMinecraft().getTextureManager().loadTexture(colourPickerLocation, new DynamicTexture(bufferedImage));
+ Minecraft.getMinecraft().getTextureManager().bindTexture(colourPickerLocation);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(activeColourEditor.x+5, activeColourEditor.y+5, 64, 64, GL11.GL_NEAREST);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(colour_selector_dot);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(activeColourEditor.x+5+32+selx-4, activeColourEditor.y+5+32+sely-4, 8, 8, GL11.GL_NEAREST);
+
+ Utils.drawStringCenteredScaledMaxWidth(EnumChatFormatting.GRAY.toString()+Math.round(hsv[2]*100)+"",
+ Minecraft.getMinecraft().fontRendererObj,
+ activeColourEditor.x+5+64+5+5-(Math.round(hsv[2]*100)==100?1:0), activeColourEditor.y+5+64+5+5, true, 13, -1);
+ Utils.drawStringCenteredScaledMaxWidth(EnumChatFormatting.GRAY.toString()+Math.round(c.getAlpha()/255f*100)+"",
+ Minecraft.getMinecraft().fontRendererObj,
+ activeColourEditor.x+5+64+5+15+5, activeColourEditor.y+5+64+5+5, true, 13, -1);
+ if(chromaSpeed > 0) {
+ Utils.drawStringCenteredScaledMaxWidth(EnumChatFormatting.GRAY.toString()+(int)SpecialColour.getSecondsForSpeed(chromaSpeed)+"s",
+ Minecraft.getMinecraft().fontRendererObj,
+ activeColourEditor.x+5+64+5+30+6, activeColourEditor.y+5+64+5+5, true, 13, -1);
+ }
+
+ hexField.setSize(48, 10);
+ if(!hexField.getFocus()) hexField.setText(Integer.toHexString(c.getRGB() & 0xFFFFFF).toUpperCase());
+
+ StringBuilder sb = new StringBuilder(EnumChatFormatting.GRAY+"#");
+ for(int i=0; i<6-hexField.getText().length(); i++) {
+ sb.append("0");
+ }
+ sb.append(EnumChatFormatting.WHITE);
+
+ hexField.setPrependText(sb.toString());
+ hexField.render(activeColourEditor.x+5+8, activeColourEditor.y+5+64+5);
+ }
+
+ Utils.pushGuiScale(-1);
+ }
+
+ @Override
+ protected void mouseClicked(int mouseX, int mouseY, int mouseButton) {
+ for(Button button : buttons) {
+ if(mouseX >= guiLeft+button.x && mouseX <= guiLeft+button.x+48 &&
+ mouseY >= guiTop+button.y && mouseY <= guiTop+button.y+16) {
+ buttonClicked(mouseX, mouseY, button.id);
+
+ xField.otherComponentClick();
+ yField.otherComponentClick();
+ blurField.otherComponentClick();
+ return;
+ }
+ }
+
+
+ if(mouseY > guiTop+181 && mouseY < guiTop+181+16) {
+ if(mouseX > guiLeft+20+139 && mouseX < guiLeft+20+139+48) {
+ blurField.mouseClicked(mouseX, mouseY, mouseButton);
+ xField.otherComponentClick();
+ yField.otherComponentClick();
+ return;
+ }
+ } else if(mouseY > guiTop+210 && mouseY < guiTop+210+16) {
+ if(mouseX > guiLeft+20+139 && mouseX < guiLeft+20+139+48) {
+ xField.mouseClicked(mouseX, mouseY, mouseButton);
+ yField.otherComponentClick();
+ blurField.otherComponentClick();
+ return;
+ } else if(mouseX > guiLeft+84+139 && mouseX < guiLeft+84+139+48) {
+ yField.mouseClicked(mouseX, mouseY, mouseButton);
+ xField.otherComponentClick();
+ blurField.otherComponentClick();
+ return;
+ }
+ }
+
+ blurField.otherComponentClick();
+ xField.otherComponentClick();
+ yField.otherComponentClick();
+ }
+
+ @Override
+ public void handleMouseInput() throws IOException {
+ super.handleMouseInput();
+
+ int mouseX = Mouse.getEventX() * this.width / this.mc.displayWidth;
+ int mouseY = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1;
+ if(activeColourEditor != null && (Mouse.isButtonDown(0) || Mouse.isButtonDown(1))) {
+ if(mouseX >= activeColourEditor.x && mouseX <= activeColourEditor.x+119) {
+ if(mouseY >= activeColourEditor.y && mouseY <= activeColourEditor.y+89) {
+ if(Mouse.getEventButtonState()) {
+ if(mouseX > activeColourEditor.x+5+8 && mouseX < activeColourEditor.x+5+8+48) {
+ if(mouseY > activeColourEditor.y+5+64+5 && mouseY < activeColourEditor.y+5+64+5+10) {
+ hexField.mouseClicked(mouseX, mouseY, Mouse.getEventButton());
+ Utils.pushGuiScale(-1);
+ return;
+ }
+ }
+ }
+ hexField.otherComponentClick();
+
+ int currentColour = SpecialColour.specialToSimpleRGB(activeColourEditor.special);
+ Color c = new Color(currentColour, true);
+ float[] hsv = Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), null);
+
+ int xWheel = mouseX - activeColourEditor.x - 5;
+ int yWheel = mouseY - activeColourEditor.y - 5;
+
+ if(xWheel > 0 && xWheel < 64) {
+ if(yWheel > 0 && yWheel < 64) {
+ float radius = (float) Math.sqrt(((xWheel-32)*(xWheel-32)+(yWheel-32)*(yWheel-32))/1024f);
+ float angle = (float) Math.toDegrees(Math.atan((32-xWheel)/(yWheel-32+1E-5))+Math.PI/2);
+ if(yWheel < 32) angle += 180;
+
+ int rgb = Color.getHSBColor(angle/360f, (float)Math.pow(Math.min(1, radius), 1.5f), hsv[2]).getRGB();
+ activeColourEditor.special = SpecialColour.special(SpecialColour.getSpeed(activeColourEditor.special), c.getAlpha(), rgb);
+ activeColourEditor.option.value = (String) activeColourEditor.special;
+ }
+ }
+
+ int xValue = mouseX - (activeColourEditor.x+5+64+5);
+ int y = mouseY - activeColourEditor.y - 5;
+
+ if(y > -5 && y <= 69) {
+ y = Math.max(0, Math.min(64, y));
+ if(xValue > 0 && xValue < 10) {
+ int rgb = Color.getHSBColor(hsv[0], hsv[1], 1-y/64f).getRGB();
+ activeColourEditor.special = SpecialColour.special(SpecialColour.getSpeed(activeColourEditor.special), c.getAlpha(), rgb);
+ activeColourEditor.option.value = activeColourEditor.special;
+ }
+
+ int xOpacity = mouseX - (activeColourEditor.x+5+64+5+10+5);
+
+ if(xOpacity > 0 && xOpacity < 10) {
+ activeColourEditor.special = SpecialColour.special(SpecialColour.getSpeed(activeColourEditor.special),
+ 255-(int)(y/64f*255), currentColour);
+ activeColourEditor.option.value = activeColourEditor.special;
+ }
+ }
+
+ int chromaSpeed = SpecialColour.getSpeed(activeColourEditor.special);
+
+ int xChroma = mouseX - (activeColourEditor.x+5+64+5+10+5+10+5);
+ if(xChroma > 0 && xChroma < 10) {
+ if(chromaSpeed > 0) {
+ if(y > -5 && y <= 69) {
+ y = Math.max(0, Math.min(64, y));
+ activeColourEditor.special = SpecialColour.special(255-Math.round(y/64f*255), c.getAlpha(), currentColour);
+ activeColourEditor.option.value = activeColourEditor.special;
+ }
+ } else if(mouseY > activeColourEditor.y+5+27 && mouseY < activeColourEditor.y+5+37) {
+ activeColourEditor.special = SpecialColour.special(200, c.getAlpha(), currentColour);
+ activeColourEditor.option.value = activeColourEditor.special;
+ }
+ }
+
+ Utils.pushGuiScale(-1);
+ return;
+ }
+ }
+ if(Mouse.getEventButtonState()) {
+ activeColourEditor = null;
+ hexField.otherComponentClick();
+ }
+ }
+ }
+
+ @Override
+ public void handleKeyboardInput() throws IOException {
+ super.handleKeyboardInput();
+
+ if(activeColourEditor != null && hexField.getFocus()) {
+ String old = hexField.getText();
+
+ hexField.keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey());
+
+ if(hexField.getText().length() > 6) {
+ hexField.setText(old);
+ } else {
+ try {
+ String text = hexField.getText().toLowerCase();
+
+ int rgb = Integer.parseInt(text, 16);
+ int alpha = (SpecialColour.specialToSimpleRGB(activeColourEditor.special) >> 24) & 0xFF;
+ activeColourEditor.special = SpecialColour.special(SpecialColour.getSpeed(activeColourEditor.special), alpha, rgb);
+ activeColourEditor.option.value = activeColourEditor.special;
+ } catch(Exception e) {};
+ }
+ }
+ }
+
+ @Override
+ protected void keyTyped(char typedChar, int keyCode) throws IOException {
+ super.keyTyped(typedChar, keyCode);
+
+ if(xField.getFocus()) {
+ xField.keyTyped(typedChar, keyCode);
+
+ try {
+ xField.setCustomBorderColour(-1);
+ NotEnoughUpdates.INSTANCE.manager.config.dmCenterX.setValue(xField.getText());
+ } catch(Exception e) {
+ xField.setCustomBorderColour(Color.RED.getRGB());
+ }
+ } else if(yField.getFocus()) {
+ yField.keyTyped(typedChar, keyCode);
+
+ try {
+ yField.setCustomBorderColour(-1);
+ NotEnoughUpdates.INSTANCE.manager.config.dmCenterY.setValue(yField.getText());
+ } catch(Exception e) {
+ yField.setCustomBorderColour(Color.RED.getRGB());
+ }
+ } else if(blurField.getFocus()) {
+ blurField.keyTyped(typedChar, keyCode);
+
+ try {
+ blurField.setCustomBorderColour(-1);
+ NotEnoughUpdates.INSTANCE.manager.config.dmBackgroundBlur.setValue(blurField.getText());
+ } catch(Exception e) {
+ blurField.setCustomBorderColour(Color.RED.getRGB());
+ }
+ }
+ }
+
+ private void buttonClicked(int mouseX, int mouseY, int id) {
+ Options options = NotEnoughUpdates.INSTANCE.manager.config;
+ switch (id) {
+ case 0:
+ options.dmBorderSize.value = 0.0; break;
+ case 1:
+ options.dmBorderSize.value = 1.0; break;
+ case 2:
+ options.dmBorderSize.value = 2.0; break;
+ case 3:
+ options.dmRoomSize.value = 0.0; break;
+ case 4:
+ options.dmRoomSize.value = 1.0; break;
+ case 5:
+ options.dmRoomSize.value = 2.0; break;
+ case 18:
+ options.dmEnable.value = !options.dmEnable.value; break;
+ case 19:
+ options.dmCenterPlayer.value = !options.dmCenterPlayer.value; break;
+ case 20:
+ options.dmRotatePlayer.value = !options.dmRotatePlayer.value; break;
+ case 21:
+ options.dmPlayerHeads.value++;
+ if(options.dmPlayerHeads.value > 3) options.dmPlayerHeads.value = 0.0;break;
+ case 22:
+ options.dmOrientCheck.value = !options.dmOrientCheck.value; break;
+ case 23:
+ options.dmCenterCheck.value = !options.dmCenterCheck.value; break;
+ case 24:
+ options.dmPlayerInterp.value = !options.dmPlayerInterp.value; break;
+ case 25:
+ options.dmCompat.value++;
+ if(options.dmCompat.value > 2) options.dmCompat.value = 0.0;
+ break;
+ case 26:
+ showColourEditor(mouseX, mouseY, options.dmBackgroundColour, options.dmBackgroundColour.value); break;
+ case 27:
+ showColourEditor(mouseX, mouseY, options.dmBorderColour, options.dmBorderColour.value); break;
+ case 28:
+ options.dmChromaBorder.value = !options.dmChromaBorder.value; break;
+ default:
+ if(id >= 6 && id <= 17) {
+ options.dmBorderStyle.value = (double)id-6; break;
+ }
+ }
+ try { NotEnoughUpdates.INSTANCE.manager.saveConfig(); } catch(IOException ignored) {};
+
+ }
+
+ private boolean isButtonPressed(int id) {
+ Options options = NotEnoughUpdates.INSTANCE.manager.config;
+ if(id >= 0 && id <= 2) {
+ return options.dmBorderSize.value == id;
+ } else if(id >= 3 && id <= 5) {
+ return options.dmRoomSize.value == id-3;
+ } else if(id >= 6 && id <= 17) {
+ return options.dmBorderStyle.value == id-6;
+ }
+ return false;
+ }
+
+ Shader blurShaderHorz = null;
+ Framebuffer blurOutputHorz = null;
+ Shader blurShaderVert = null;
+ Framebuffer blurOutputVert = null;
+
+ /**
+ * Creates a projection matrix that projects from our coordinate space [0->width; 0->height] to OpenGL coordinate
+ * space [-1 -> 1; 1 -> -1] (Note: flipped y-axis).
+ *
+ * This is so that we can render to and from the framebuffer in a way that is familiar to us, instead of needing to
+ * apply scales and translations manually.
+ */
+ private Matrix4f createProjectionMatrix(int width, int height) {
+ Matrix4f projMatrix = new Matrix4f();
+ projMatrix.setIdentity();
+ projMatrix.m00 = 2.0F / (float)width;
+ projMatrix.m11 = 2.0F / (float)(-height);
+ projMatrix.m22 = -0.0020001999F;
+ projMatrix.m33 = 1.0F;
+ projMatrix.m03 = -1.0F;
+ projMatrix.m13 = 1.0F;
+ projMatrix.m23 = -1.0001999F;
+ return projMatrix;
+ }
+
+ private double lastBgBlurFactor = -1;
+ private void blurBackground() {
+ if(!OpenGlHelper.isFramebufferEnabled()) return;
+
+ int width = Minecraft.getMinecraft().displayWidth;
+ int height = Minecraft.getMinecraft().displayHeight;
+
+ if(blurOutputHorz == null) {
+ blurOutputHorz = new Framebuffer(width, height, false);
+ blurOutputHorz.setFramebufferFilter(GL11.GL_NEAREST);
+ }
+ if(blurOutputVert == null) {
+ blurOutputVert = new Framebuffer(width, height, false);
+ blurOutputVert.setFramebufferFilter(GL11.GL_NEAREST);
+ }
+ if(blurOutputHorz.framebufferWidth != width || blurOutputHorz.framebufferHeight != height) {
+ blurOutputHorz.createBindFramebuffer(width, height);
+ blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height));
+ Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
+ }
+ if(blurOutputVert.framebufferWidth != width || blurOutputVert.framebufferHeight != height) {
+ blurOutputVert.createBindFramebuffer(width, height);
+ blurShaderVert.setProjectionMatrix(createProjectionMatrix(width, height));
+ Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
+ }
+
+ if(blurShaderHorz == null) {
+ try {
+ blurShaderHorz = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur",
+ Minecraft.getMinecraft().getFramebuffer(), blurOutputHorz);
+ blurShaderHorz.getShaderManager().getShaderUniform("BlurDir").set(1, 0);
+ blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height));
+ } catch(Exception e) { }
+ }
+ if(blurShaderVert == null) {
+ try {
+ blurShaderVert = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur",
+ blurOutputHorz, blurOutputVert);
+ blurShaderVert.getShaderManager().getShaderUniform("BlurDir").set(0, 1);
+ blurShaderVert.setProjectionMatrix(createProjectionMatrix(width, height));
+ } catch(Exception e) { }
+ }
+ if(blurShaderHorz != null && blurShaderVert != null) {
+ if(15 != lastBgBlurFactor) {
+ blurShaderHorz.getShaderManager().getShaderUniform("Radius").set((float)15);
+ blurShaderVert.getShaderManager().getShaderUniform("Radius").set((float)15);
+ lastBgBlurFactor = 15;
+ }
+ GL11.glPushMatrix();
+ blurShaderHorz.loadShader(0);
+ blurShaderVert.loadShader(0);
+ GlStateManager.enableDepth();
+ GL11.glPopMatrix();
+
+ Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
+ }
+ }
+
+ /**
+ * Renders a subsection of the blurred framebuffer on to the corresponding section of the screen.
+ * Essentially, this method will "blur" the background inside the bounds specified by [x->x+blurWidth, y->y+blurHeight]
+ */
+ public void renderBlurredBackground(int width, int height, int x, int y, int blurWidth, int blurHeight) {
+ if(!OpenGlHelper.isFramebufferEnabled()) return;
+
+ float uMin = x/(float)width;
+ float uMax = (x+blurWidth)/(float)width;
+ float vMin = (height-y)/(float)height;
+ float vMax = (height-y-blurHeight)/(float)height;
+
+ blurOutputVert.bindFramebufferTexture();
+ GlStateManager.color(1f, 1f, 1f, 1f);
+ //Utils.setScreen(width*f, height*f, f);
+ Utils.drawTexturedRect(x, y, blurWidth, blurHeight, uMin, uMax, vMin, vMax);
+ //Utils.setScreen(width, height, f);
+ blurOutputVert.unbindFramebufferTexture();
+ }
+
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
index fe31ce01..fee96152 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
@@ -688,14 +688,39 @@ public class NotEnoughUpdates {
public Color[][] colourMap = null;
SimpleCommand neumapCommand = new SimpleCommand("neumap", new SimpleCommand.ProcessCommandRunnable() {
public void processCommand(ICommandSender sender, String[] args) {
+ if(colourMap == null) {
+ try {
+ BufferedReader reader = new BufferedReader(new InputStreamReader(Minecraft.getMinecraft().getResourceManager().getResource(
+ new ResourceLocation("notenoughupdates:maps/F1Full.json")).getInputStream(), StandardCharsets.UTF_8));
+ JsonObject json = NotEnoughUpdates.INSTANCE.manager.gson.fromJson(reader, JsonObject.class);
+
+ colourMap = new Color[128][128];
+ for(int x=0; x<128; x++) {
+ for(int y=0; y<128; y++) {
+ colourMap[x][y] = new Color(0, 0, 0, 0);
+ }
+ }
+ for(Map.Entry<String, JsonElement> entry : json.entrySet()) {
+ int x = Integer.parseInt(entry.getKey().split(":")[0]);
+ int y = Integer.parseInt(entry.getKey().split(":")[1]);
+
+ colourMap[x][y] = new Color(entry.getValue().getAsInt(), true);
+ }
+ } catch(Exception ignored) { }
+ }
+
+ if(!manager.config.dev.value) {
+ openGui = new GuiDungeonMapEditor();
+ return;
+ }
+
if(args.length == 1 && args[0].equals("reset")) {
colourMap = null;
return;
}
if(args.length != 2) {
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED+
- "Dev feature if you don't know how to use then don't use it 4Head."));
+ openGui = new GuiDungeonMapEditor();
return;
}
@@ -734,10 +759,13 @@ public class NotEnoughUpdates {
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN+
"Saved to file."));
}
+
+ return;
}
if(args[0].equals("load")) {
JsonObject json = manager.getJsonFromFile(new File(manager.configLocation, "maps/"+args[1]+".json"));
+
colourMap = new Color[128][128];
for(int x=0; x<128; x++) {
for(int y=0; y<128; y++) {
@@ -750,7 +778,11 @@ public class NotEnoughUpdates {
colourMap[x][y] = new Color(entry.getValue().getAsInt(), true);
}
+
+ return;
}
+
+ openGui = new GuiDungeonMapEditor();
}
});
@@ -811,7 +843,8 @@ public class NotEnoughUpdates {
MinecraftForge.EVENT_BUS.register(new SBGamemodes());
MinecraftForge.EVENT_BUS.register(SBInfo.getInstance());
MinecraftForge.EVENT_BUS.register(CustomItemEffects.INSTANCE);
- //MinecraftForge.EVENT_BUS.register(new DungeonMap());
+ MinecraftForge.EVENT_BUS.register(new DungeonMap());
+ MinecraftForge.EVENT_BUS.register(new DumymMod());
//MinecraftForge.EVENT_BUS.register(new BetterPortals());
IResourceManager resourceManager = Minecraft.getMinecraft().getResourceManager();
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java b/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java
index 92d95e74..4530fc6e 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java
@@ -317,8 +317,10 @@ public class APIManager {
if(disable != null && disable.get("auctions").getAsBoolean()) return;
while(!pagesToDownload.isEmpty()) {
- int page = pagesToDownload.pop();
- getPageFromAPI(page);
+ try {
+ int page = pagesToDownload.pop();
+ getPageFromAPI(page);
+ } catch(NoSuchElementException ignored) {} //Weird race condition?
}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/gamemodes/SBGamemodes.java b/src/main/java/io/github/moulberry/notenoughupdates/gamemodes/SBGamemodes.java
index 81be2204..d570843a 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/gamemodes/SBGamemodes.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/gamemodes/SBGamemodes.java
@@ -246,6 +246,8 @@ public class SBGamemodes {
public void onTick(TickEvent.ClientTickEvent event) {
if(getGamemode() == null || !NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return;
+ boolean inDungeons = SBInfo.getInstance().getLocation() != null && SBInfo.getInstance().getLocation().equals("dungeon");
+
if("Your Island".equals(SBInfo.getInstance().location) &&
(EnumChatFormatting.YELLOW+"Break a log").equals(SBInfo.getInstance().objective)) {
getGamemode().locked = false;
@@ -291,7 +293,7 @@ public class SBGamemodes {
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
EnumChatFormatting.AQUA+"(Use "+EnumChatFormatting.YELLOW+"/neugamemodes"+
EnumChatFormatting.AQUA+" if you would like to use fairy souls)"));
- } else if(ironmanMode.isBanned(containerName)) {
+ } else if(!inDungeons && ironmanMode.isBanned(containerName)) {
Minecraft.getMinecraft().thePlayer.closeScreen();
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(""));
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/Options.java b/src/main/java/io/github/moulberry/notenoughupdates/options/Options.java
index 62d12062..f6ce41dd 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/Options.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/Options.java
@@ -1,6 +1,7 @@
package io.github.moulberry.notenoughupdates.options;
import com.google.gson.*;
+import io.github.moulberry.notenoughupdates.GuiDungeonMapEditor;
import io.github.moulberry.notenoughupdates.GuiEnchantColour;
import io.github.moulberry.notenoughupdates.NEUOverlayPlacements;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
@@ -392,6 +393,93 @@ public class Options {
false,
"enchantColours", CAT_ALL);
+ //Dungeon Map Options
+ public Option<Double> dmBorderSize = new Option(
+ 1.0,
+ "dmBorderSize",
+ false,
+ "", CAT_ALL);
+ public Option<Double> dmRoomSize = new Option(
+ 1.0,
+ "dmRoomSize",
+ false,
+ "", CAT_ALL);
+ public Option<Double> dmBorderStyle = new Option(
+ 0.0,
+ "dmBorderStyle",
+ false,
+ "", CAT_ALL);
+ public Option<Boolean> dmEnable = new Option(
+ true,
+ "dmEnable",
+ false,
+ "", CAT_ALL);
+ public Option<Boolean> dmCenterPlayer = new Option(
+ false,
+ "dmCenterPlayer",
+ false,
+ "", CAT_ALL);
+ public Option<Boolean> dmRotatePlayer = new Option(
+ true,
+ "dmCenterPlayer",
+ false,
+ "", CAT_ALL);
+ public Option<Boolean> dmOrientCheck = new Option(
+ true,
+ "dmOrientCheck",
+ false,
+ "", CAT_ALL);
+ public Option<Boolean> dmCenterCheck = new Option(
+ false,
+ "dmOrientCheck",
+ false,
+ "", CAT_ALL);
+ public Option<Double> dmPlayerHeads = new Option(
+ 0.0,
+ "dmPlayerHeads",
+ false,
+ "", CAT_ALL);
+ public Option<Boolean> dmPlayerInterp = new Option(
+ true,
+ "dmPlayerInterp",
+ false,
+ "", CAT_ALL);
+ public Option<Double> dmCompat = new Option(
+ 0.0,
+ "dmCompat",
+ false,
+ "", CAT_ALL);
+ public Option<String> dmBackgroundColour = new Option(
+ "00:170:75:75:75",
+ "dmBackgroundColour",
+ false,
+ "", FLAG_COLOUR, CAT_ALL);
+ public Option<String> dmBorderColour = new Option(
+ "00:0:0:0:0",
+ "dmBorderColour",
+ false,
+ "", FLAG_COLOUR, CAT_ALL);
+ public Option<Boolean> dmChromaBorder = new Option(
+ false,
+ "dmChromaBorder",
+ false,
+ "", CAT_ALL);
+ public Option<Double> dmBackgroundBlur = new Option(
+ 3.0,
+ "dmBackgroundBlur",
+ false,
+ "", CAT_ALL);
+ public Option<Double> dmCenterX = new Option(
+ 8.5,
+ "dmCenterX",
+ false,
+ "", CAT_ALL);
+ public Option<Double> dmCenterY = new Option(
+ 15.0,
+ "dmCenterY",
+ false,
+ "", CAT_ALL);
+
private ArrayList<String> createDefaultQuickCommands() {
ArrayList<String> arr = new ArrayList<>();
arr.add("/warp home:Warp Home:eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzljODg4MWU0MjkxNWE5ZDI5YmI2MWExNmZiMjZkMDU5OTEzMjA0ZDI2NWRmNWI0MzliM2Q3OTJhY2Q1NiJ9fX0=");
@@ -436,10 +524,14 @@ public class Options {
Minecraft.getMinecraft().displayGuiScreen(new NEUOverlayPlacements());
}));
-
buttons.add(new Button("Edit Enchant Colours", "Allows you to change the colour of any enchant at any level.", () -> {
Minecraft.getMinecraft().displayGuiScreen(new GuiEnchantColour());
}));
+
+
+ buttons.add(new Button("Edit Dungeon Map", "Allows you to configure the NEU dungeon map.", () -> {
+ Minecraft.getMinecraft().displayGuiScreen(new GuiDungeonMapEditor());
+ }));
}
public List<Button> getButtons() {
@@ -608,13 +700,15 @@ public class Options {
for (Field f : Options.class.getDeclaredFields()) {
try {
- if (((Option) f.get(oDefault)).value instanceof List) {
+ if (((Option<?>) f.get(oDefault)).value instanceof List) {
//If the default size of the list is greater than the loaded size, use the default value.
//if(((List<?>)((Option)f.get(oDefault)).value).size() > ((List<?>)((Option)f.get(oLoad)).value).size()) {
// continue;
//}
}
- ((Option) f.get(oDefault)).value = ((Option) f.get(oLoad)).value;
+ if(((Option<?>) f.get(oDefault)).value.getClass().isAssignableFrom(((Option<?>) f.get(oLoad)).value.getClass())) {
+ ((Option) f.get(oDefault)).value = ((Option) f.get(oLoad)).value;
+ }
} catch (Exception e) {
}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PlayerStats.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PlayerStats.java
index e1ee32f6..5223e127 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PlayerStats.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PlayerStats.java
@@ -213,7 +213,10 @@ public class PlayerStats {
Stats skillBonus = getSkillBonus(skillInfo);
Stats petBonus = getPetBonus(profile);
- if(fairyBonus == null || skillBonus == null || petBonus == null) return null;
+ if(fairyBonus == null || skillBonus == null || petBonus == null) {
+ System.out.println(petBonus);
+ return null;
+ }
passiveBonuses.add(fairyBonus);
passiveBonuses.add(skillBonus);
@@ -493,7 +496,9 @@ public class PlayerStats {
Stats armorBonuses = getItemBonuses(false, armor);
Stats talismanBonuses = getItemBonuses(true, inventory, talisman_bag);
- if(passiveBonuses == null || armorBonuses == null || talismanBonuses == null) return null;
+ if(passiveBonuses == null || armorBonuses == null || talismanBonuses == null) {
+ return null;
+ }
Stats stats = getBaseStats().add(passiveBonuses).add(armorBonuses).add(talismanBonuses);
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java
index 007ab7a9..e4ab29d2 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java
@@ -914,9 +914,11 @@ public class ProfileViewer {
}
public PlayerStats.Stats getStats(String profileId) {
- if(stats.get(profileId) != null) return stats.get(profileId);
+ //if(stats.get(profileId) != null) return stats.get(profileId);
JsonObject profileInfo = getProfileInformation(profileId);
- if(profileInfo == null) return null;
+ if(profileInfo == null) {
+ return null;
+ }
PlayerStats.Stats stats = PlayerStats.getStats(getSkillInfo(profileId), getInventoryInfo(profileId), getCollectionInfo(profileId), profileInfo);
this.stats.put(profileId, stats);
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Constants.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Constants.java
index 4f8ab5ce..f70d3a3c 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/Constants.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Constants.java
@@ -4,7 +4,7 @@ import com.google.gson.JsonObject;
public class Constants {
- public static final JsonObject BONUSES = Utils.getConstant("enchants");
+ public static final JsonObject BONUSES = Utils.getConstant("bonuses");
public static final JsonObject DISABLE = Utils.getConstant("disable");
public static final JsonObject ENCHANTS = Utils.getConstant("enchants");
public static final JsonObject LEVELING = Utils.getConstant("leveling");
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/SpecialColour.java b/src/main/java/io/github/moulberry/notenoughupdates/util/SpecialColour.java
index 9ec6da3e..5bcd23c3 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/SpecialColour.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/SpecialColour.java
@@ -77,5 +77,19 @@ public class SpecialColour {
return (a & 0xFF) << 24 | (Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]) & 0x00FFFFFF);
}
+ public static int rotateHue(int argb, int degrees) {
+ int a = (argb >> 24) & 0xFF;
+ int r = (argb >> 16) & 0xFF;
+ int g = (argb >> 8) & 0xFF;
+ int b = (argb) & 0xFF;
+
+ float[] hsv = Color.RGBtoHSB(r, g, b, null);
+
+ hsv[0] += degrees/360f;
+ hsv[0] %= 1;
+
+ return (a & 0xFF) << 24 | (Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]) & 0x00FFFFFF);
+ }
+
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java
index 04bad54f..f732779c 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java
@@ -420,6 +420,33 @@ public class Utils {
GlStateManager.disableBlend();
}
+ public static void drawTexturedRectNoBlend(float x, float y, float width, float height, float uMin, float uMax, float vMin, float vMax, int filter) {
+ GlStateManager.enableTexture2D();
+
+ GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, filter);
+ GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, filter);
+
+ Tessellator tessellator = Tessellator.getInstance();
+ WorldRenderer worldrenderer = tessellator.getWorldRenderer();
+ worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX);
+ worldrenderer
+ .pos(x, y+height, 0.0D)
+ .tex(uMin, vMax).endVertex();
+ worldrenderer
+ .pos(x+width, y+height, 0.0D)
+ .tex(uMax, vMax).endVertex();
+ worldrenderer
+ .pos(x+width, y, 0.0D)
+ .tex(uMax, vMin).endVertex();
+ worldrenderer
+ .pos(x, y, 0.0D)
+ .tex(uMin, vMin).endVertex();
+ tessellator.draw();
+
+ GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
+ GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
+ }
+
public static ItemStack createItemStack(Item item, String displayname, String... lore) {
return createItemStack(item, displayname, 0, lore);
}
@@ -620,6 +647,34 @@ public class Utils {
GlStateManager.enableTexture2D();
}
+ public static void drawGradientRectHorz(int left, int top, int right, int bottom, int startColor, int endColor) {
+ float f = (float)(startColor >> 24 & 255) / 255.0F;
+ float f1 = (float)(startColor >> 16 & 255) / 255.0F;
+ float f2 = (float)(startColor >> 8 & 255) / 255.0F;
+ float f3 = (float)(startColor & 255) / 255.0F;
+ float f4 = (float)(endColor >> 24 & 255) / 255.0F;
+ float f5 = (float)(endColor >> 16 & 255) / 255.0F;
+ float f6 = (float)(endColor >> 8 & 255) / 255.0F;
+ float f7 = (float)(endColor & 255) / 255.0F;
+ GlStateManager.disableTexture2D();
+ GlStateManager.enableBlend();
+ GlStateManager.disableAlpha();
+ GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
+ GlStateManager.shadeModel(7425);
+ Tessellator tessellator = Tessellator.getInstance();
+ WorldRenderer worldrenderer = tessellator.getWorldRenderer();
+ worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR);
+ worldrenderer.pos((double)right, (double)top, 0).color(f5, f6, f7, f4).endVertex();
+ worldrenderer.pos((double)left, (double)top, 0).color(f1, f2, f3, f).endVertex();
+ worldrenderer.pos((double)left, (double)bottom, 0).color(f1, f2, f3, f).endVertex();
+ worldrenderer.pos((double)right, (double)bottom, 0).color(f5, f6, f7, f4).endVertex();
+ tessellator.draw();
+ GlStateManager.shadeModel(7424);
+ GlStateManager.disableBlend();
+ GlStateManager.enableAlpha();
+ GlStateManager.enableTexture2D();
+ }
+
public static void drawHoveringText(List<String> textLines, final int mouseX, final int mouseY, final int screenWidth, final int screenHeight, final int maxTextWidth, FontRenderer font) {
drawHoveringText(textLines, mouseX, mouseY, screenWidth, screenHeight, maxTextWidth, font, true);
}
@@ -910,4 +965,34 @@ public class Utils {
GlStateManager.enableTexture2D();
}
+ public static void drawRectNoBlend(int left, int top, int right, int bottom, int color) {
+ if (left < right) {
+ int i = left;
+ left = right;
+ right = i;
+ }
+
+ if (top < bottom) {
+ int j = top;
+ top = bottom;
+ bottom = j;
+ }
+
+ float f3 = (float)(color >> 24 & 255) / 255.0F;
+ float f = (float)(color >> 16 & 255) / 255.0F;
+ float f1 = (float)(color >> 8 & 255) / 255.0F;
+ float f2 = (float)(color & 255) / 255.0F;
+ Tessellator tessellator = Tessellator.getInstance();
+ WorldRenderer worldrenderer = tessellator.getWorldRenderer();
+ GlStateManager.disableTexture2D();
+ GlStateManager.color(f, f1, f2, f3);
+ worldrenderer.begin(7, DefaultVertexFormats.POSITION);
+ worldrenderer.pos((double)left, (double)bottom, 0.0D).endVertex();
+ worldrenderer.pos((double)right, (double)bottom, 0.0D).endVertex();
+ worldrenderer.pos((double)right, (double)top, 0.0D).endVertex();
+ worldrenderer.pos((double)left, (double)top, 0.0D).endVertex();
+ tessellator.draw();
+ GlStateManager.enableTexture2D();
+ }
+
}