From 431d4a5eca207aa6f86a90e3c4e1912885f115eb Mon Sep 17 00:00:00 2001 From: Moulberry Date: Sat, 31 Oct 2020 21:49:14 +1100 Subject: 1.4.9 --- .../moulberry/notenoughupdates/DumymMod.java | 53 + .../moulberry/notenoughupdates/DungeonBlocks.java | 2 +- .../moulberry/notenoughupdates/DungeonMap.java | 1522 +- .../moulberry/notenoughupdates/GuiButtonItem.java | 93 + .../notenoughupdates/GuiDungeonMapEditor.java | 754 + .../notenoughupdates/NotEnoughUpdates.java | 39 +- .../notenoughupdates/auction/APIManager.java | 6 +- .../notenoughupdates/gamemodes/SBGamemodes.java | 4 +- .../notenoughupdates/options/Options.java | 100 +- .../profileviewer/PlayerStats.java | 9 +- .../profileviewer/ProfileViewer.java | 6 +- .../moulberry/notenoughupdates/util/Constants.java | 2 +- .../notenoughupdates/util/SpecialColour.java | 14 + .../moulberry/notenoughupdates/util/Utils.java | 85 + .../dungeon_map/borders/large/1.json | 3 + .../dungeon_map/borders/large/10.json | 3 + .../dungeon_map/borders/large/10.png | Bin 0 -> 7050 bytes .../dungeon_map/borders/large/11.json | 3 + .../dungeon_map/borders/large/11.png | Bin 0 -> 16913 bytes .../dungeon_map/borders/large/2.json | 3 + .../dungeon_map/borders/large/2.png | Bin 0 -> 1006 bytes .../dungeon_map/borders/large/3.json | 3 + .../dungeon_map/borders/large/3.png | Bin 0 -> 6971 bytes .../dungeon_map/borders/large/4.json | 3 + .../dungeon_map/borders/large/4.png | Bin 0 -> 10886 bytes .../dungeon_map/borders/large/5.json | 3 + .../dungeon_map/borders/large/5.png | Bin 0 -> 13433 bytes .../dungeon_map/borders/large/6.json | 3 + .../dungeon_map/borders/large/6.png | Bin 0 -> 10655 bytes .../dungeon_map/borders/large/7.json | 3 + .../dungeon_map/borders/large/7.png | Bin 0 -> 4217 bytes .../dungeon_map/borders/large/8.json | 3 + .../dungeon_map/borders/large/8.png | Bin 0 -> 6904 bytes .../borders/map_border_dragon_stone.png | Bin 0 -> 4952 bytes .../dungeon_map/borders/medium/1.json | 3 + .../dungeon_map/borders/medium/10.json | 3 + .../dungeon_map/borders/medium/10.png | Bin 0 -> 6703 bytes .../dungeon_map/borders/medium/11.json | 3 + .../dungeon_map/borders/medium/11.png | Bin 0 -> 15370 bytes .../dungeon_map/borders/medium/2.json | 3 + .../dungeon_map/borders/medium/2.png | Bin 0 -> 717 bytes .../dungeon_map/borders/medium/3.json | 3 + .../dungeon_map/borders/medium/3.png | Bin 0 -> 6522 bytes .../dungeon_map/borders/medium/4.json | 3 + .../dungeon_map/borders/medium/4.png | Bin 0 -> 7093 bytes .../dungeon_map/borders/medium/5.json | 3 + .../dungeon_map/borders/medium/5.png | Bin 0 -> 7618 bytes .../dungeon_map/borders/medium/6.json | 3 + .../dungeon_map/borders/medium/6.png | Bin 0 -> 7874 bytes .../dungeon_map/borders/medium/7.json | 3 + .../dungeon_map/borders/medium/7.png | Bin 0 -> 4400 bytes .../dungeon_map/borders/medium/8.json | 3 + .../dungeon_map/borders/medium/8.png | Bin 0 -> 6277 bytes .../dungeon_map/borders/small/1.json | 3 + .../dungeon_map/borders/small/10.json | 3 + .../dungeon_map/borders/small/10.png | Bin 0 -> 7045 bytes .../dungeon_map/borders/small/11.json | 3 + .../dungeon_map/borders/small/11.png | Bin 0 -> 12576 bytes .../dungeon_map/borders/small/2.json | 3 + .../dungeon_map/borders/small/2.png | Bin 0 -> 1949 bytes .../dungeon_map/borders/small/3.json | 3 + .../dungeon_map/borders/small/3.png | Bin 0 -> 6697 bytes .../dungeon_map/borders/small/4.json | 3 + .../dungeon_map/borders/small/4.png | Bin 0 -> 5947 bytes .../dungeon_map/borders/small/5.json | 3 + .../dungeon_map/borders/small/5.png | Bin 0 -> 8456 bytes .../dungeon_map/borders/small/6.json | 3 + .../dungeon_map/borders/small/6.png | Bin 0 -> 6474 bytes .../dungeon_map/borders/small/7.json | 3 + .../dungeon_map/borders/small/7.png | Bin 0 -> 4502 bytes .../dungeon_map/borders/small/8.json | 3 + .../dungeon_map/borders/small/8.png | Bin 0 -> 6789 bytes .../dungeon_map/borders/small/9.json | 3 + .../dungeon_map/borders/small/9.png | Bin 0 -> 5897 bytes .../dungeon_map/borders/steampunk.png | Bin 0 -> 10039 bytes .../dungeon_map/corners_default/brown_corner.png | Bin 0 -> 971 bytes .../corridors_default/brown_corridor.png | Bin 0 -> 1023 bytes .../corridors_default/gray_corridor.png | Bin 0 -> 1055 bytes .../corridors_default/green_corridor.png | Bin 0 -> 1107 bytes .../corridors_default/orange_corridor.png | Bin 0 -> 1083 bytes .../corridors_default/pink_corridor.png | Bin 0 -> 1032 bytes .../corridors_default/purple_corridor.png | Bin 0 -> 1044 bytes .../dungeon_map/corridors_default/red_corridor.png | Bin 0 -> 1055 bytes .../corridors_default/yellow_corridor.png | Bin 0 -> 1033 bytes .../dungeon_map/dividers_default/brown_divider.png | Bin 0 -> 964 bytes .../dungeon_map/editor/background.png | Bin 0 -> 2414 bytes .../dungeon_map/rooms_default/orange_room.png | Bin 0 -> 979 bytes .../assets/notenoughupdates/maps/F1Full.json | 16386 +++++++++++++++++++ .../shaders/program/dungeonmap.fsh | 32 + .../shaders/program/dungeonmap.json | 19 + .../shaders/program/dungeonmap.vsh | 16 + 91 files changed, 18795 insertions(+), 440 deletions(-) create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/DumymMod.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/GuiButtonItem.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/GuiDungeonMapEditor.java create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/large/1.json create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/large/10.json create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/large/10.png create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/large/11.json create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/large/11.png create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/large/2.json create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/large/2.png create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/large/3.json create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/large/3.png create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/large/4.json create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/large/4.png create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/large/5.json create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/large/5.png create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/large/6.json create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/large/6.png create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/large/7.json create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/large/7.png create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/large/8.json create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/large/8.png create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/map_border_dragon_stone.png create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/medium/1.json create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/medium/10.json create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/medium/10.png create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/medium/11.json create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/medium/11.png create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/medium/2.json create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/medium/2.png create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/medium/3.json create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/medium/3.png create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/medium/4.json create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/medium/4.png create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/medium/5.json create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/medium/5.png create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/medium/6.json create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/medium/6.png create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/medium/7.json create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/medium/7.png create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/medium/8.json create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/medium/8.png create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/small/1.json create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/small/10.json create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/small/10.png create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/small/11.json create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/small/11.png create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/small/2.json create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/small/2.png create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/small/3.json create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/small/3.png create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/small/4.json create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/small/4.png create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/small/5.json create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/small/5.png create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/small/6.json create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/small/6.png create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/small/7.json create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/small/7.png create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/small/8.json create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/small/8.png create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/small/9.json create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/small/9.png create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/steampunk.png create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/corners_default/brown_corner.png create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/corridors_default/brown_corridor.png create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/corridors_default/gray_corridor.png create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/corridors_default/green_corridor.png create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/corridors_default/orange_corridor.png create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/corridors_default/pink_corridor.png create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/corridors_default/purple_corridor.png create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/corridors_default/red_corridor.png create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/corridors_default/yellow_corridor.png create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/dividers_default/brown_divider.png create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/editor/background.png create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/rooms_default/orange_room.png create mode 100644 src/main/resources/assets/notenoughupdates/maps/F1Full.json create mode 100644 src/main/resources/assets/notenoughupdates/shaders/program/dungeonmap.fsh create mode 100644 src/main/resources/assets/notenoughupdates/shaders/program/dungeonmap.json create mode 100644 src/main/resources/assets/notenoughupdates/shaders/program/dungeonmap.vsh (limited to 'src') 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 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 decorations = new ArrayList<>(); - private final List lastDecorations = new ArrayList<>(); + //private final List decorations = new ArrayList<>(); + //private final List lastDecorations = new ArrayList<>(); private long lastDecorationsMillis = -1; private long lastLastDecorationsMillis = -1; - private Map playerMapPositions = new HashMap<>(); + private Map playerEntityMapPositions = new HashMap<>(); + private Map playerMarkerMapPositions = new HashMap<>(); + private Map playerMarkerMapPositionsLast = new HashMap<>(); + + private Map 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 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 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 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 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 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 entry : roomMap.entrySet()) { + RoomOffset roomOffset = entry.getKey(); + Room room = entry.getValue(); + + int x = (roomOffset.x-minRoomX)*(renderRoomSize+renderConnSize); + int y = (roomOffset.y-minRoomY)*(renderRoomSize+renderConnSize); + + GlStateManager.pushMatrix(); + GlStateManager.translate(x, y, 0); + + room.render(renderRoomSize, renderConnSize); + + GlStateManager.translate(-x, -y, 0); + GlStateManager.popMatrix(); + } + + GlStateManager.translate(-mapCenterX+roomsSizeX/2f, -mapCenterY+roomsSizeY/2f, 0); + + GlStateManager.translate(mapCenterX, mapCenterY, 0); + GlStateManager.rotate(rotation-180, 0, 0, 1); + GlStateManager.translate(-mapCenterX, -mapCenterY, 0); + + GlStateManager.translate(mapCenterX, mapCenterY, 0); + + for(Map.Entry entry : roomMap.entrySet()) { + RoomOffset roomOffset = entry.getKey(); + Room room = entry.getValue(); + + float x = (roomOffset.x-minRoomX)*(renderRoomSize+renderConnSize)-roomsSizeX/2f+renderRoomSize/2f; + float y = (roomOffset.y-minRoomY)*(renderRoomSize+renderConnSize)-roomsSizeY/2f+renderRoomSize/2f; + float x2 = (float)(-x*Math.cos(Math.toRadians(-rotation)) + y*Math.sin(Math.toRadians(-rotation))); + float y2 = (float)(-x*Math.sin(Math.toRadians(-rotation)) - y*Math.cos(Math.toRadians(-rotation))); + + GlStateManager.pushMatrix(); + GlStateManager.translate(x2, y2, 0); + + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + room.renderNoRotate(renderRoomSize, renderConnSize, rotation); + + GlStateManager.translate(-x2, -y2, 0); + GlStateManager.popMatrix(); + } + + + GlStateManager.translate(-mapCenterX, -mapCenterY, 0); + + GlStateManager.translate(mapCenterX, mapCenterY, 0); + GlStateManager.rotate(-rotation+180, 0, 0, 1); + GlStateManager.translate(-mapCenterX, -mapCenterY, 0); + + GlStateManager.translate(mapCenterX-roomsSizeX/2f, mapCenterY-roomsSizeY/2f, 0); + + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + int k = 0; + + for(Map.Entry entry : playerMarkerMapPositions.entrySet()) { + String name = entry.getKey(); + MapPosition pos = entry.getValue(); + float x = pos.getRenderX(); + float y = pos.getRenderY(); + float angle = pos.rotation; + + boolean doInterp = NotEnoughUpdates.INSTANCE.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 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; + } + } + } }