From f89c363dda53046d832089d94f04695ce60d3ae6 Mon Sep 17 00:00:00 2001 From: Moulberry Date: Wed, 4 Nov 2020 05:36:16 +1100 Subject: fine 1.5.3 --- .../moulberry/notenoughupdates/DungeonBlocks.java | 315 ---- .../moulberry/notenoughupdates/DungeonMap.java | 1558 ------------------- .../notenoughupdates/GuiDungeonMapEditor.java | 843 ----------- .../notenoughupdates/NEUEventListener.java | 113 +- .../moulberry/notenoughupdates/NEUOverlay.java | 37 +- .../notenoughupdates/NotEnoughUpdates.java | 31 +- .../notenoughupdates/auction/APIManager.java | 13 +- .../notenoughupdates/dungeons/DungeonBlocks.java | 261 ++++ .../notenoughupdates/dungeons/DungeonMap.java | 1560 ++++++++++++++++++++ .../notenoughupdates/dungeons/DungeonWin.java | 409 +++++ .../dungeons/GuiDungeonMapEditor.java | 845 +++++++++++ .../notenoughupdates/gamemodes/SBGamemodes.java | 2 +- .../notenoughupdates/mixins/MixinEntityPlayer.java | 9 - .../notenoughupdates/mixins/MixinRender.java | 19 +- .../notenoughupdates/mixins/MixinRenderFish.java | 125 +- .../notenoughupdates/mixins/MixinRenderList.java | 16 +- .../mixins/MixinTileEntitySpecialRenderer.java | 29 +- .../mixins/MixinVboRenderList.java | 20 +- .../notenoughupdates/options/Options.java | 31 +- .../moulberry/notenoughupdates/util/Utils.java | 6 + .../dungeon_map/borders/large/9.json | 3 + .../dungeon_map/borders/large/9.png | Bin 0 -> 6779 bytes .../dungeon_map/borders/medium/9.json | 3 + .../dungeon_map/borders/medium/9.png | Bin 0 -> 6362 bytes .../assets/notenoughupdates/dungeon_win/a.png | Bin 0 -> 569 bytes .../assets/notenoughupdates/dungeon_win/b.png | Bin 0 -> 261 bytes .../assets/notenoughupdates/dungeon_win/c.png | Bin 0 -> 330 bytes .../notenoughupdates/dungeon_win/confetti.png | Bin 0 -> 532 bytes .../assets/notenoughupdates/dungeon_win/d.png | Bin 0 -> 277 bytes .../assets/notenoughupdates/dungeon_win/s.png | Bin 0 -> 579 bytes .../assets/notenoughupdates/dungeon_win/splus.png | Bin 0 -> 2296 bytes 31 files changed, 3319 insertions(+), 2929 deletions(-) delete mode 100644 src/main/java/io/github/moulberry/notenoughupdates/DungeonBlocks.java delete mode 100644 src/main/java/io/github/moulberry/notenoughupdates/DungeonMap.java delete mode 100644 src/main/java/io/github/moulberry/notenoughupdates/GuiDungeonMapEditor.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonBlocks.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonWin.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/dungeons/GuiDungeonMapEditor.java create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/large/9.json create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/large/9.png create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/medium/9.json create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/borders/medium/9.png create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_win/a.png create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_win/b.png create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_win/c.png create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_win/confetti.png create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_win/d.png create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_win/s.png create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_win/splus.png (limited to 'src') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/DungeonBlocks.java b/src/main/java/io/github/moulberry/notenoughupdates/DungeonBlocks.java deleted file mode 100644 index f0b92c6a..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/DungeonBlocks.java +++ /dev/null @@ -1,315 +0,0 @@ -package io.github.moulberry.notenoughupdates; - -import io.github.moulberry.notenoughupdates.questing.SBInfo; -import io.github.moulberry.notenoughupdates.util.SpecialColour; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.*; -import net.minecraft.client.renderer.texture.*; -import net.minecraft.client.resources.IResourceManager; -import net.minecraft.client.resources.IResourceManagerReloadListener; -import net.minecraft.client.shader.Framebuffer; -import net.minecraft.util.ResourceLocation; -import org.lwjgl.BufferUtils; -import org.lwjgl.opengl.*; - -import java.nio.IntBuffer; -import java.util.HashMap; -import java.util.Map; - -public class DungeonBlocks implements IResourceManagerReloadListener { - - //public static Framebuffer framebuffer = null; - private static int textureId = -1; - private static IntBuffer intbuffer = null; - private static HashMap modified = new HashMap<>(); - - @Override - public void onResourceManagerReload(IResourceManager resourceManager) { - reset(); - } - - public static boolean textureExists() { - return textureId != -1 && isInDungeons(); - } - - public static void bindTextureIfExists() { - if(textureExists()) { - GlStateManager.bindTexture(textureId); - } - } - - public static boolean isInDungeons() { - return !NotEnoughUpdates.INSTANCE.manager.config.disableDungeonBlocks.value && - (NotEnoughUpdates.INSTANCE.manager.config.dungeonBlocksEverywhere.value || - (SBInfo.getInstance().getLocation() != null && SBInfo.getInstance().getLocation().equals("dungeon"))); - } - - public static void reset() { - textureId = -1; - for(int tex : modified.values()) { - GlStateManager.deleteTexture(tex); - } - modified.clear(); - } - - public static int getModifiedTexture(ResourceLocation location, int colour) { - if(!isInDungeons()) { - return -1; - } - - if(((colour >> 24) & 0xFF) < 50) { - return -1; - } - - String id = location.getResourceDomain()+":"+location.getResourcePath(); - if(modified.containsKey(id)) { - return modified.get(id); - } - - Minecraft.getMinecraft().getTextureManager().bindTexture(location); - int mipmapLevels = GL11.glGetTexParameteri(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LEVEL); - int w = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, 0, GL11.GL_TEXTURE_WIDTH); - int h = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, 0, GL11.GL_TEXTURE_HEIGHT); - - if(intbuffer == null || intbuffer.capacity() < w*h) intbuffer = BufferUtils.createIntBuffer(w*h); - - int textureId = TextureUtil.glGenTextures(); - GlStateManager.bindTexture(textureId); - - if (mipmapLevels >= 0) { - GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LEVEL, mipmapLevels); - GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MIN_LOD, 0.0F); - GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LOD, (float)mipmapLevels); - GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL14.GL_TEXTURE_LOD_BIAS, 0.0F); - } - - for (int i = 0; i <= mipmapLevels; ++i) { - GL11.glTexImage2D(GL11.GL_TEXTURE_2D, i, GL11.GL_RGBA, w >> i, h >> i, 0, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, ((IntBuffer)null)); - } - - GlStateManager.bindTexture(textureId); - - GL11.glPixelStorei(GL11.GL_PACK_ALIGNMENT, 1); - GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1); - - for (int level = 0; level <= mipmapLevels; level++) { - int w2 = w >> level; - int h2 = h >> level; - - Minecraft.getMinecraft().getTextureManager().bindTexture(location); - GL11.glGetTexImage(GL11.GL_TEXTURE_2D, level, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, intbuffer); - - for(int x=0; x> 24) & 0xFF)/255f; - float newRed = ((newCol >> 16) & 0xFF)/255f; - float newGreen = ((newCol >> 8) & 0xFF)/255f; - float newBlue = (newCol & 0xFF)/255f; - - int oldCol = intbuffer.get(index); - int oldAlpha = (oldCol >> 24) & 0xFF; - float oldRed = ((oldCol >> 16) & 0xFF)/255f; - float oldGreen = ((oldCol >> 8) & 0xFF)/255f; - float oldBlue = (oldCol & 0xFF)/255f; - - int r = (int)((newRed*newAlpha + oldRed*(1-newAlpha))*255); - int g = (int)((newGreen*newAlpha + oldGreen*(1-newAlpha))*255); - int b = (int)((newBlue*newAlpha + oldBlue*(1-newAlpha))*255); - - intbuffer.put(index, oldAlpha << 24 | r << 16 | g << 8 | b); - } - } - - GlStateManager.bindTexture(textureId); - GL11.glTexImage2D(GL11.GL_TEXTURE_2D, level, GL11.GL_RGBA, w2, h2, - 0, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, intbuffer); - } - - modified.put(id, textureId); - return textureId; - } - - public static void tick() { - if(!isInDungeons()) { - return; - } - - if(textureId == -1) { - int locationBlocksId = Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationBlocksTexture).getGlTextureId(); - - GlStateManager.bindTexture(locationBlocksId); - int mipmapLevels = GL11.glGetTexParameteri(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LEVEL); - int w = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, 0, GL11.GL_TEXTURE_WIDTH); - int h = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, 0, GL11.GL_TEXTURE_HEIGHT); - - if(intbuffer == null || intbuffer.capacity() < w*h) intbuffer = BufferUtils.createIntBuffer(w*h); - - if(textureId == -1) { - textureId = TextureUtil.glGenTextures(); - GlStateManager.bindTexture(textureId); - - if (mipmapLevels >= 0) { - GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LEVEL, mipmapLevels); - GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MIN_LOD, 0.0F); - GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LOD, (float)mipmapLevels); - GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL14.GL_TEXTURE_LOD_BIAS, 0.0F); - } - - for (int i = 0; i <= mipmapLevels; ++i) { - GL11.glTexImage2D(GL11.GL_TEXTURE_2D, i, GL11.GL_RGBA, w >> i, h >> i, 0, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, ((IntBuffer)null)); - } - } - GlStateManager.bindTexture(textureId); - - GL11.glPixelStorei(GL11.GL_PACK_ALIGNMENT, 1); - GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1); - - HashMap spriteMap = new HashMap<>(); - spriteMap.put(Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("minecraft:blocks/stonebrick_cracked"), - SpecialColour.specialToSimpleRGB(NotEnoughUpdates.INSTANCE.manager.config.dungCrackedColour.value)); - spriteMap.put(Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("minecraft:blocks/dispenser_front_horizontal"), - SpecialColour.specialToSimpleRGB(NotEnoughUpdates.INSTANCE.manager.config.dungDispenserColour.value)); - spriteMap.put(Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("minecraft:blocks/lever"), - SpecialColour.specialToSimpleRGB(NotEnoughUpdates.INSTANCE.manager.config.dungLeverColour.value)); - spriteMap.put(Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("minecraft:blocks/trip_wire"), - SpecialColour.specialToSimpleRGB(NotEnoughUpdates.INSTANCE.manager.config.dungTripWireColour.value)); - - for (int level = 0; level <= mipmapLevels; level++) { - int w2 = w >> level; - int h2 = h >> level; - - GlStateManager.bindTexture(locationBlocksId); - GL11.glGetTexImage(GL11.GL_TEXTURE_2D, level, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, intbuffer); - - for(Map.Entry entry : spriteMap.entrySet()) { - if(((entry.getValue() >> 24) & 0xFF) < 50) continue; - - TextureAtlasSprite tas = entry.getKey(); - for(int x=(int)(w2*tas.getMinU()); x= 0) { - GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LEVEL, Minecraft.getMinecraft().gameSettings.mipmapLevels); - GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MIN_LOD, 0.0F); - GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LOD, (float)Minecraft.getMinecraft().gameSettings.mipmapLevels); - GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL14.GL_TEXTURE_LOD_BIAS, 0.0F); - } - - for (int i = 0; i <= Minecraft.getMinecraft().gameSettings.mipmapLevels; ++i) { - GL11.glTexImage2D(GL11.GL_TEXTURE_2D, i, GL11.GL_RGBA, w >> i, h >> i, - 0, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, ((IntBuffer)null)); - } - - //framebuffer.framebufferClear(); - framebuffer.bindFramebuffer(true); - GlStateManager.clearColor(1, 1, 1, 0); - GlStateManager.clear(GL11.GL_COLOR_BUFFER_BIT); - GL11.glClearColor(1, 1, 1, 0); - - Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.locationBlocksTexture); - GlStateManager.color(1, 1, 1, 1); - Utils.drawTexturedRect(0, 0, w, h, 0, 1, 1, 0, GL11.GL_LINEAR); - - framebuffer.bindFramebufferTexture(); - GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LEVEL, Minecraft.getMinecraft().gameSettings.mipmapLevels); - GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MIN_LOD, 0.0F); - GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LOD, (float)Minecraft.getMinecraft().gameSettings.mipmapLevels); - GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL14.GL_TEXTURE_LOD_BIAS, 0.0F); - GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D); - - ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - GlStateManager.matrixMode(5889); - GlStateManager.loadIdentity(); - GlStateManager.ortho(0.0D, scaledResolution.getScaledWidth_double(), scaledResolution.getScaledHeight_double(), - 0.0D, 1000.0D, 3000.0D); - GlStateManager.matrixMode(5888); - GlStateManager.loadIdentity(); - GlStateManager.translate(0.0F, 0.0F, -2000.0F); - - GL11.glPopMatrix(); - - Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true); - - - /*framebuffer.bindFramebufferTexture(); - if(Keyboard.isKeyDown(Keyboard.KEY_B)) Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.locationBlocksTexture); - Utils.drawTexturedRect(0, 0, w, h, GL11.GL_NEAREST);*/ - - /*GlStateManager.bindTexture(textureId); - 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); - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - - //GlStateManager.enableTexture2D(); - //GlStateManager.enableBlend(); - //GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - - - //GlStateManager.disableBlend(); - - Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true); - } catch(Exception e) { - e.printStackTrace(); - } - }*/ - } - - 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, false); - framebuffer.framebufferColor[0] = 1f; - framebuffer.framebufferColor[1] = 0f; - framebuffer.framebufferColor[2] = 0f; - framebuffer.framebufferColor[3] = 0; - } else { - framebuffer.createBindFramebuffer(width, height); - } - framebuffer.setFramebufferFilter(GL11.GL_NEAREST); - } - return framebuffer; - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/DungeonMap.java b/src/main/java/io/github/moulberry/notenoughupdates/DungeonMap.java deleted file mode 100644 index 79b9e106..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/DungeonMap.java +++ /dev/null @@ -1,1558 +0,0 @@ -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.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.*; -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; - -public class DungeonMap { - - private static final ResourceLocation GREEN_CHECK = new ResourceLocation("notenoughupdates:dungeon_map/green_check.png"); - private static final ResourceLocation WHITE_CHECK = new ResourceLocation("notenoughupdates:dungeon_map/white_check.png"); - private static final ResourceLocation QUESTION = new ResourceLocation("notenoughupdates:dungeon_map/question.png"); - private static final ResourceLocation CROSS = new ResourceLocation("notenoughupdates:dungeon_map/cross.png"); - - private static final ResourceLocation ROOM_RED = new ResourceLocation("notenoughupdates:dungeon_map/rooms_default/red_room.png"); - private static final ResourceLocation ROOM_BROWN = new ResourceLocation("notenoughupdates:dungeon_map/rooms_default/brown_room.png"); - private static final ResourceLocation ROOM_GRAY = new ResourceLocation("notenoughupdates:dungeon_map/rooms_default/gray_room.png"); - private static final ResourceLocation ROOM_GREEN = new ResourceLocation("notenoughupdates:dungeon_map/rooms_default/green_room.png"); - private static final ResourceLocation ROOM_PINK = new ResourceLocation("notenoughupdates:dungeon_map/rooms_default/pink_room.png"); - private static final ResourceLocation ROOM_PURPLE = new ResourceLocation("notenoughupdates:dungeon_map/rooms_default/purple_room.png"); - private static final ResourceLocation ROOM_YELLOW = new ResourceLocation("notenoughupdates:dungeon_map/rooms_default/yellow_room.png"); - private static final ResourceLocation ROOM_ORANGE = new ResourceLocation("notenoughupdates:dungeon_map/rooms_default/orange_room.png"); - - private static final ResourceLocation CORRIDOR_RED = new ResourceLocation("notenoughupdates:dungeon_map/corridors_default/red_corridor.png"); - private static final ResourceLocation CORRIDOR_BROWN = new ResourceLocation("notenoughupdates:dungeon_map/corridors_default/brown_corridor.png"); - private static final ResourceLocation CORRIDOR_GRAY = new ResourceLocation("notenoughupdates:dungeon_map/corridors_default/gray_corridor.png"); - private static final ResourceLocation CORRIDOR_GREEN = new ResourceLocation("notenoughupdates:dungeon_map/corridors_default/green_corridor.png"); - private static final ResourceLocation CORRIDOR_PINK = new ResourceLocation("notenoughupdates:dungeon_map/corridors_default/pink_corridor.png"); - private static final ResourceLocation CORRIDOR_PURPLE = new ResourceLocation("notenoughupdates:dungeon_map/corridors_default/purple_corridor.png"); - private static final ResourceLocation CORRIDOR_YELLOW = new ResourceLocation("notenoughupdates:dungeon_map/corridors_default/yellow_corridor.png"); - private static final ResourceLocation CORRIDOR_ORANGE = new ResourceLocation("notenoughupdates:dungeon_map/corridors_default/orange_corridor.png"); - - private static final ResourceLocation DIVIDER_BROWN = new ResourceLocation("notenoughupdates:dungeon_map/dividers_default/brown_divider.png"); - - private static final ResourceLocation CORNER_BROWN = new ResourceLocation("notenoughupdates:dungeon_map/corners_default/brown_corner.png"); - - private 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]; - private int startRoomX = -1; - private int startRoomY = -1; - private int connectorSize = 5; - private int roomSize = 0; - - //private final List decorations = new ArrayList<>(); - //private final List lastDecorations = new ArrayList<>(); - private long lastDecorationsMillis = -1; - private long lastLastDecorationsMillis = -1; - - private Map playerEntityMapPositions = new HashMap<>(); - private Map playerMarkerMapPositions = new HashMap<>(); - private Map playerMarkerMapPositionsLast = new HashMap<>(); - - private Map playerSkinMap = new HashMap<>(); - - private class RoomOffset { - int x; - int y; - - public RoomOffset(int x, int y) { - this.x = x; - this.y = y; - } - - public RoomOffset left() { - return new RoomOffset(x-1, y); - } - - public RoomOffset right() { - return new RoomOffset(x+1, y); - } - - public RoomOffset up() { - return new RoomOffset(x, y-1); - } - - public RoomOffset down() { - return new RoomOffset(x, y+1); - } - - public RoomOffset[] getNeighbors() { - return new RoomOffset[]{left(), right(), up(), down()}; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - RoomOffset that = (RoomOffset) o; - return x == that.x && y == that.y; - } - - @Override - public int hashCode() { - return Objects.hash(x, y); - } - } - - private enum RoomConnectionType { - NONE, WALL, CORRIDOR, ROOM_DIVIDER - } - - private class RoomConnection { - RoomConnectionType type; - Color colour; - - public RoomConnection(RoomConnectionType type, Color colour) { - this.type = type; - this.colour = colour; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - RoomConnection that = (RoomConnection) o; - return type == that.type && - Objects.equals(colour, that.colour); - } - - @Override - public int hashCode() { - return Objects.hash(type, colour); - } - } - - private class Room { - Color colour = new Color(0, 0, 0, 0); - int tickColour = 0; - boolean fillCorner = false; - - RoomConnection left = new RoomConnection(RoomConnectionType.NONE, new Color(0, true)); - RoomConnection up = new RoomConnection(RoomConnectionType.NONE, new Color(0, true)); - RoomConnection right = new RoomConnection(RoomConnectionType.NONE, new Color(0, true)); - RoomConnection down = new RoomConnection(RoomConnectionType.NONE, new Color(0, true)); - - public void renderNoRotate(int roomSize, int connectorSize, int rotation) { - if(tickColour != 0) { - Color tick = new Color(tickColour, true); - ResourceLocation indicatorTex = null; - if(tick.getRed() == 255 && tick.getGreen() == 255 && tick.getBlue() == 255) { - indicatorTex = WHITE_CHECK; - } else if(tick.getRed() == 0 && tick.getGreen() == 124 && tick.getBlue() == 0) { - indicatorTex = GREEN_CHECK; - } else if(tick.getRed() == 13 && tick.getGreen() == 13 && tick.getBlue() == 13) { - indicatorTex = QUESTION; - } else if(tick.getRed() == 255 && tick.getGreen() == 0 && tick.getBlue() == 0) { - indicatorTex = CROSS; - } - if(indicatorTex != null) { - Minecraft.getMinecraft().getTextureManager().bindTexture(indicatorTex); - float x = 0; - float y = 0; - - if(NotEnoughUpdates.INSTANCE.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) { - roomTex = ROOM_BROWN; - } else if(colour.getRed() == 65 && colour.getGreen() == 65 && colour.getBlue() == 65) { - roomTex = ROOM_GRAY; - } else if(colour.getRed() == 0 && colour.getGreen() == 124 && colour.getBlue() == 0) { - roomTex = ROOM_GREEN; - } else if(colour.getRed() == 242 && colour.getGreen() == 127 && colour.getBlue() == 165) { - roomTex = ROOM_PINK; - } else if(colour.getRed() == 178 && colour.getGreen() == 76 && colour.getBlue() == 216) { - roomTex = ROOM_PURPLE; - } else if(colour.getRed() == 255 && colour.getGreen() == 0 && colour.getBlue() == 0) { - roomTex = ROOM_RED; - } else if(colour.getRed() == 229 && colour.getGreen() == 229 && colour.getBlue() == 51) { - roomTex = ROOM_YELLOW; - } else if(colour.getRed() == 216 && colour.getGreen() == 127 && colour.getBlue() == 51) { - roomTex = ROOM_ORANGE; - } - - if(roomTex != null) { - Minecraft.getMinecraft().getTextureManager().bindTexture(roomTex); - GlStateManager.color(1, 1, 1, 1); - Utils.drawTexturedRect(0, 0, roomSize, roomSize, GL11.GL_LINEAR); - } else { - Gui.drawRect(0, 0, roomSize, roomSize, colour.getRGB()); - } - - if(fillCorner) { - GlStateManager.color(1, 1, 1, 1); - Minecraft.getMinecraft().getTextureManager().bindTexture(CORNER_BROWN); - Utils.drawTexturedRect(roomSize, roomSize, connectorSize, connectorSize, GL11.GL_NEAREST); - } - - for(int k=0; k<2; k++) { - RoomConnection connection = down; - if(k == 1) connection = right; - - if(connection.type == RoomConnectionType.NONE || connection.type == RoomConnectionType.WALL) continue; - - ResourceLocation corridorTex = null; - if(connection.colour.getRed() == 114 && connection.colour.getGreen() == 67 && connection.colour.getBlue() == 27) { - corridorTex = connection.type == RoomConnectionType.CORRIDOR ? CORRIDOR_BROWN : DIVIDER_BROWN; - } else if(connection.colour.getRed() == 65 && connection.colour.getGreen() == 65 && connection.colour.getBlue() == 65) { - corridorTex = CORRIDOR_GRAY; - } else if(connection.colour.getRed() == 0 && connection.colour.getGreen() == 124 && connection.colour.getBlue() == 0) { - corridorTex = CORRIDOR_GREEN; - } else if(connection.colour.getRed() == 242 && connection.colour.getGreen() == 127 && connection.colour.getBlue() == 165) { - corridorTex = CORRIDOR_PINK; - } else if(connection.colour.getRed() == 178 && connection.colour.getGreen() == 76 && connection.colour.getBlue() == 216) { - corridorTex = CORRIDOR_PURPLE; - } else if(connection.colour.getRed() == 255 && connection.colour.getGreen() == 0 && connection.colour.getBlue() == 0) { - corridorTex = CORRIDOR_RED; - } else if(connection.colour.getRed() == 229 && connection.colour.getGreen() == 229 && connection.colour.getBlue() == 51) { - corridorTex = CORRIDOR_YELLOW; - } else if(connection.colour.getRed() == 216 && connection.colour.getGreen() == 127 && connection.colour.getBlue() == 51) { - corridorTex = CORRIDOR_ORANGE; - } - - if(corridorTex == null) { - int xOffset = 0; - int yOffset = 0; - int width = 0; - int height = 0; - - if(connection == right) { - xOffset = roomSize; - width = connectorSize; - height = roomSize; - - if(connection.type == RoomConnectionType.CORRIDOR) { - height = 8; - yOffset += 4; - } - } else if(connection == down) { - yOffset = roomSize; - width = roomSize; - height = connectorSize; - - if(connection.type == RoomConnectionType.CORRIDOR) { - width = 8; - xOffset += 4; - } - } - - Gui.drawRect(xOffset, yOffset, xOffset+width, yOffset+height, connection.colour.getRGB()); - } else { - GlStateManager.color(1, 1, 1, 1); - Minecraft.getMinecraft().getTextureManager().bindTexture(corridorTex); - GlStateManager.pushMatrix(); - if(connection==right) { - GlStateManager.translate(roomSize/2f, roomSize/2f, 0); - GlStateManager.rotate(-90, 0, 0, 1); - GlStateManager.translate(-roomSize/2f, -roomSize/2f, 0); - } - Utils.drawTexturedRect(0, roomSize, roomSize, connectorSize, GL11.GL_NEAREST); - GlStateManager.popMatrix(); - } - } - } - } - - private static final ResourceLocation mapIcons = new ResourceLocation("textures/map/map_icons.png"); - - public static Framebuffer mapFramebuffer1 = null; - public static Framebuffer mapFramebuffer2 = null; - public static Matrix4f projectionMatrix = null; - public static Shader mapShader = null; - - private static Framebuffer checkFramebufferSizes(Framebuffer framebuffer, int width, int height) { - if(framebuffer == null || framebuffer.framebufferWidth != width || framebuffer.framebufferHeight != height) { - if(framebuffer == null) { - framebuffer = new Framebuffer(width, height, true); - } else { - framebuffer.createBindFramebuffer(width, height); - } - framebuffer.setFramebufferFilter(GL11.GL_NEAREST); - } - return framebuffer; - } - - private static void upload(Shader shader, int width, int height, int scale, float radiusSq) { - if(shader == null) return; - shader.getShaderManager().getShaderUniformOrDefault("ProjMat").set(projectionMatrix); - shader.getShaderManager().getShaderUniformOrDefault("InSize").set(width*scale, height*scale); - shader.getShaderManager().getShaderUniformOrDefault("OutSize").set(width, height); - shader.getShaderManager().getShaderUniformOrDefault("ScreenSize").set((float)width, (float)height); - shader.getShaderManager().getShaderUniformOrDefault("radiusSq").set(radiusSq); - } - - public int getRenderRoomSize() { - int roomSizeOption = NotEnoughUpdates.INSTANCE.manager.config.dmRoomSize.value.intValue(); - if(roomSizeOption <= 0) return 12; - return 12 + roomSizeOption*4; - } - - public int getRenderConnSize() { - int roomSizeOption = NotEnoughUpdates.INSTANCE.manager.config.dmRoomSize.value.intValue(); - if(roomSizeOption <= 0) return 3; - return 3 + roomSizeOption; - } - - 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; - int maxRoomY = -999; - for(RoomOffset offset : roomMap.keySet()) { - minRoomX = Math.min(offset.x, minRoomX); - minRoomY = Math.min(offset.y, minRoomY); - maxRoomX = Math.max(offset.x, maxRoomX); - maxRoomY = Math.max(offset.y, maxRoomY); - } - - int borderSizeOption = 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 : borderSizeOption == 3 ? 240 : 120; - int mapSizeY = borderSizeOption == 0 ? 90 : borderSizeOption == 2 ? 160 : borderSizeOption == 3 ? 240 : 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; - } - - int backgroundColour = SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.manager.config.dmBackgroundColour.value); - - mapFramebuffer1.framebufferColor[0] = ((backgroundColour >> 16) & 0xFF)/255f; - mapFramebuffer1.framebufferColor[1] = ((backgroundColour >> 8) & 0xFF)/255f; - mapFramebuffer1.framebufferColor[2] = (backgroundColour & 0xFF)/255f; - mapFramebuffer2.framebufferColor[0] = ((backgroundColour >> 16) & 0xFF)/255f; - mapFramebuffer2.framebufferColor[1] = ((backgroundColour >> 8) & 0xFF)/255f; - mapFramebuffer2.framebufferColor[2] = (backgroundColour & 0xFF)/255f; - - try { - if(useFb) { - mapFramebuffer1.framebufferClear(); - mapFramebuffer2.framebufferClear(); - } - - GlStateManager.pushMatrix(); { - if(useFb) { - GlStateManager.matrixMode(5889); - GlStateManager.loadIdentity(); - GlStateManager.ortho(0.0D, mapSizeX*scaleFactor, mapSizeY*scaleFactor, 0.0D, 1000.0D, 3000.0D); - GlStateManager.matrixMode(5888); - GlStateManager.loadIdentity(); - GlStateManager.translate(0.0F, 0.0F, -2000.0F); - - GlStateManager.scale(scaleFactor, scaleFactor, 1); - mapFramebuffer1.bindFramebuffer(true); - - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - GlStateManager.disableBlend(); - } else { - GL11.glEnable(GL11.GL_SCISSOR_TEST); - GL11.glScissor((centerX-mapSizeX/2)*2, Minecraft.getMinecraft().displayHeight-(centerY+mapSizeY/2)*2, mapSizeX*2, mapSizeY*2); - - GlStateManager.translate(centerX-mapSizeX/2, centerY-mapSizeY/2, 100); - } - - if(NotEnoughUpdates.INSTANCE.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 minU = 3/4f; - float minV = 0; - - if(name.equals(Minecraft.getMinecraft().thePlayer.getName())) { - minU = 1/4f; - } - - float maxU = minU + 1/4f; - float maxV = minV + 1/4f; - - if(doInterp && playerMarkerMapPositionsLast.containsKey(name)) { - MapPosition last = playerMarkerMapPositionsLast.get(name); - float xLast = last.getRenderX(); - float yLast = last.getRenderY(); - - float distSq = (x-xLast) * (x-xLast) + (y-yLast) * (y-yLast); - if (distSq < renderRoomSize*renderRoomSize/4f) { - float angleLast = last.rotation; - if (angle > 180 && angleLast < 180) angleLast += 360; - if (angleLast > 180 && angle < 180) angle += 360; - - float interpFactor = Math.round((System.currentTimeMillis() - lastDecorationsMillis) * 100f) / 100f / (lastDecorationsMillis - lastLastDecorationsMillis); - interpFactor = Math.max(0, Math.min(1, interpFactor)); - - x = xLast + (x - xLast) * interpFactor; - y = yLast + (y - yLast) * interpFactor; - angle = angleLast + (angle - angleLast) * interpFactor; - angle %= 360; - } - } - - boolean headLayer = false; - int pixelWidth = 8; - int pixelHeight = 8; - if(renderRoomSize >= 24) { - pixelWidth = pixelHeight = 12; - } - 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())); - - headLayer = true; - 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 = pixelWidth*6/8; - pixelHeight = pixelHeight*6/8; - } - } 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(); - - if(headLayer) { - worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX); - worldrenderer.pos(-pixelWidth/2f, pixelHeight/2f, 30+((float)k * -0.005F)+0.001f).tex(minU+0.5f, minV).endVertex(); - worldrenderer.pos(pixelWidth/2f, pixelHeight/2f, 30+((float)k * -0.005F)+0.001f).tex(maxU+0.5f, minV).endVertex(); - worldrenderer.pos(pixelWidth/2f, -pixelHeight/2f, 30+((float)k * -0.005F)+0.001f).tex(maxU+0.5f, maxV).endVertex(); - worldrenderer.pos(-pixelWidth/2f, -pixelHeight/2f, 30+((float)k * -0.005F)+0.001f).tex(minU+0.5f, maxV).endVertex(); - tessellator.draw(); - } - GlStateManager.popMatrix(); - k--; - } - - if(useFb) { - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - } else { - GL11.glDisable(GL11.GL_SCISSOR_TEST); - } - } GlStateManager.popMatrix(); - - if(useFb) { - Framebuffer renderFromBuffer = mapFramebuffer1; - if(useShd) { - GlStateManager.pushMatrix(); { - try { - upload(mapShader, mapSizeX, mapSizeY, scaleFactor, getBorderRadius()); - mapShader.setProjectionMatrix(projectionMatrix); - mapShader.loadShader(0); - renderFromBuffer = mapFramebuffer2; - } catch(Exception 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 : borderSizeOption == 3 ? 440 : 220; - Utils.drawTexturedRect(-size/2, -size/2, size, size, GL11.GL_NEAREST); - } - - 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(); - } - - - public void updateRoomConnections(RoomOffset roomOffset) { - if(roomMap.containsKey(roomOffset)) { - Room room = roomMap.get(roomOffset); - - int otherPixelFilled = 0; - int otherPixelColour = 0; - for(int xOff=0; xOff 0 && y > 0 && x < colourMap.length && y < colourMap[x].length) { - Color c = colourMap[x][y]; - if(!c.equals(room.colour)) { - if(otherPixelColour == c.getRGB()) { - otherPixelFilled++; - } else { - otherPixelFilled--; - if(otherPixelFilled <= 0) { - otherPixelFilled = 1; - otherPixelColour = c.getRGB(); - } - } - } - } - } - } - - room.tickColour = 0; - if((float)otherPixelFilled/roomSize/connectorSize > 0.05) { - room.tickColour = otherPixelColour; - } - - for(int k=0; k<4; k++) { - Color colour = null; - int totalFilled = 0; - - for(int i=0; i 0 &