diff options
29 files changed, 935 insertions, 545 deletions
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<String, Integer> 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<w2; x++) { - for(int y=0; y<h2; y++) { - int index = x+y*w2; - - int newCol = colour; - float newAlpha = ((newCol >> 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<TextureAtlasSprite, Integer> 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<TextureAtlasSprite, Integer> entry : spriteMap.entrySet()) { - if(((entry.getValue() >> 24) & 0xFF) < 50) continue; - - TextureAtlasSprite tas = entry.getKey(); - for(int x=(int)(w2*tas.getMinU()); x<w2*tas.getMaxU(); x++) { - for(int y=(int)(h2*tas.getMinV()); y<h2*tas.getMaxV(); y++) { - int index = x+y*w2; - - int newCol = entry.getValue(); - - intbuffer.put(index, newCol); - } - } - } - - 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); - } - } - /*if(framebuffer == null || true) { - Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.locationBlocksTexture); - 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); - - framebuffer = checkFramebufferSizes(framebuffer, w, h); - - try { - int locationBlocksId = Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationBlocksTexture).getGlTextureId(); - - //framebuffer2.bindFramebufferTexture(); - //GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, w, h, 0, GL11.GL_RGBA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, ((ByteBuffer)null)); - - //textureId = GlStateManager.generateTexture(); - //GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA8, w, h, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, ((ByteBuffer)null)); - - GL11.glPushMatrix(); - - GlStateManager.matrixMode(5889); - GlStateManager.loadIdentity(); - GlStateManager.ortho(0.0D, w, h, 0.0D, 1000.0D, 3000.0D); - GlStateManager.matrixMode(5888); - GlStateManager.loadIdentity(); - GlStateManager.translate(0.0F, 0.0F, -2000.0F); - - framebuffer.bindFramebufferTexture(); - if (Minecraft.getMinecraft().gameSettings.mipmapLevels >= 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/NEUEventListener.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java index 3c9f0190..f67b09ed 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java @@ -6,6 +6,8 @@ import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.auction.APIManager; import io.github.moulberry.notenoughupdates.auction.CustomAHGui; import io.github.moulberry.notenoughupdates.cosmetics.CapeManager; +import io.github.moulberry.notenoughupdates.dungeons.DungeonBlocks; +import io.github.moulberry.notenoughupdates.dungeons.DungeonWin; import io.github.moulberry.notenoughupdates.gamemodes.SBGamemodes; import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer; import io.github.moulberry.notenoughupdates.profileviewer.ProfileViewer; @@ -38,7 +40,6 @@ import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; -import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.text.WordUtils; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; @@ -120,6 +121,9 @@ public class NEUEventListener { } } + private long notificationDisplayMillis = 0; + private List<String> notificationLines = null; + /** * 1)Will send the cached message from #sendChatMessage when at least 200ms has passed since the last message. * This is used in order to prevent the mod spamming messages. @@ -134,21 +138,20 @@ public class NEUEventListener { if(event.phase != TickEvent.Phase.START) return; boolean longUpdate = false; - boolean veryLongUpdate = false; long currentTime = System.currentTimeMillis(); if(currentTime - lastLongUpdate > 1000) { longUpdate = true; lastLongUpdate = currentTime; } - if(longUpdate && currentTime - lastVeryLongUpdate > 10000) { - veryLongUpdate = true; - lastVeryLongUpdate = currentTime; - } - if(veryLongUpdate) { - DungeonBlocks.reset(); + if(!NotEnoughUpdates.INSTANCE.manager.config.slowDungeonBlocks.value) { + DungeonBlocks.tick(); } + DungeonWin.tick(); if(longUpdate) { - DungeonBlocks.tick(); + if(NotEnoughUpdates.INSTANCE.manager.config.slowDungeonBlocks.value) { + DungeonBlocks.tick(); + } + neu.updateSkyblockScoreboard(); CapeManager.getInstance().tick(); @@ -177,6 +180,18 @@ public class NEUEventListener { displayUpdateMessageIfOutOfDate(); } + long maxMemoryMB = Runtime.getRuntime().maxMemory()/1024L/1024L; + if(maxMemoryMB > 4100) { + notificationDisplayMillis = System.currentTimeMillis(); + notificationLines = new ArrayList<>(); + notificationLines.add(EnumChatFormatting.DARK_RED+"Too much memory allocated!"); + notificationLines.add(String.format(EnumChatFormatting.DARK_GRAY+"NEU has detected %03dMB of memory allocated to Minecraft!", maxMemoryMB)); + notificationLines.add(EnumChatFormatting.DARK_GRAY+"It is recommended to allocated between 2-4GB of memory"); + notificationLines.add(EnumChatFormatting.DARK_GRAY+"More than 4GB WILL cause FPS issues, EVEN if you have 16GB+ available"); + notificationLines.add(""); + notificationLines.add(EnumChatFormatting.DARK_GRAY+"For more information, visit #ram-info in discord.gg/spr6ESn"); + } + if(!neu.manager.config.loadedModBefore.value) { neu.manager.config.loadedModBefore.value = true; try { neu.manager.saveConfig(); } catch(IOException e) {} @@ -203,7 +218,7 @@ public class NEUEventListener { } if(longUpdate && neu.hasSkyblockScoreboard()) { if(neu.manager.getCurrentProfile() == null || neu.manager.getCurrentProfile().length() == 0) { - ProfileViewer.Profile profile = neu.profileViewer.getProfile(Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", ""), + ProfileViewer.Profile profile = NotEnoughUpdates.profileViewer.getProfile(Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", ""), callback->{}); if(profile != null) { String latest = profile.getLatestProfile(); @@ -295,6 +310,44 @@ public class NEUEventListener { Minecraft.getMinecraft().currentScreen instanceof GuiContainer && neu.overlay.isUsingMobsFilter()) { event.setCanceled(true); } + long timeRemaining = 15000 - (System.currentTimeMillis() - notificationDisplayMillis); + if(event.type == RenderGameOverlayEvent.ElementType.ALL) { + DungeonWin.render(event.partialTicks); + } + if(event.type == RenderGameOverlayEvent.ElementType.ALL && + timeRemaining > 0 && notificationLines != null && notificationLines.size() > 0) { + int width = 0; + int height = notificationLines.size()*10+10; + + for(String line : notificationLines) { + int len = Minecraft.getMinecraft().fontRendererObj.getStringWidth(line) + 8; + if(len > width) { + width = len; + } + } + + ScaledResolution sr = Utils.pushGuiScale(2); + + int midX = sr.getScaledWidth()/2; + int topY = sr.getScaledHeight()*3/4-height/2; + Gui.drawRect(midX-width/2, sr.getScaledHeight()*3/4-height/2, + midX+width/2, sr.getScaledHeight()*3/4+height/2, 0xFF3C3C3C); + Gui.drawRect(midX-width/2+2, sr.getScaledHeight()*3/4-height/2+2, + midX+width/2-2, sr.getScaledHeight()*3/4+height/2-2, 0xFFC8C8C8); + + Minecraft.getMinecraft().fontRendererObj.drawString((timeRemaining/1000)+"s", midX-width/2+3, + topY+3, 0xFF000000, false); + + Utils.drawStringCentered(notificationLines.get(0), Minecraft.getMinecraft().fontRendererObj, + midX, topY+4+5, false, -1); + for(int i=1; i<notificationLines.size(); i++) { + String line = notificationLines.get(i); + Utils.drawStringCentered(line, Minecraft.getMinecraft().fontRendererObj, + midX, topY+4+5+2+i*10, false, -1); + } + + Utils.pushGuiScale(-1); + } } /** @@ -447,6 +500,8 @@ public class NEUEventListener { */ @SubscribeEvent(priority = EventPriority.LOW) public void onGuiChat(ClientChatReceivedEvent e) { + DungeonWin.onChatMessage(e); + String r = null; String unformatted = Utils.cleanColour(e.message.getUnformattedText()); if(unformatted.startsWith("You are playing on profile: ")) { @@ -1368,36 +1423,32 @@ public class NEUEventListener { EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(auctionInfo.get("clean_sales").getAsFloat())+" sales/day"); } } - } else if(hasBazaarPrice) { + int stackMultiplier = 1; + int shiftStackMultiplier = event.itemStack.stackSize > 1 ? event.itemStack.stackSize : 64; if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { - int bazaarBuyPrice = (int)bazaarInfo.get("avg_buy").getAsFloat()*64; - event.toolTip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Bazaar Buy (Stack): "+ - EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(bazaarBuyPrice)+" coins"); - int bazaarSellPrice = (int)bazaarInfo.get("avg_sell").getAsFloat()*64; - event.toolTip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Bazaar Sell (Stack): "+ - EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(bazaarSellPrice)+" coins"); - if(neu.manager.config.advancedPriceInfo.value) { - int bazaarInstantBuyPrice = (int)bazaarInfo.get("curr_buy").getAsFloat()*64; - event.toolTip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Bazaar Insta-Buy (Stack): "+ - EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(bazaarInstantBuyPrice)+" coins"); - int bazaarInstantSellPrice = (int)bazaarInfo.get("curr_sell").getAsFloat()*64; - event.toolTip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Bazaar Insta-Sell (Stack): "+ - EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(bazaarInstantSellPrice)+" coins"); - } + stackMultiplier = shiftStackMultiplier; } else { - event.toolTip.add(EnumChatFormatting.DARK_GRAY.toString()+"[SHIFT show stack]"); - int bazaarBuyPrice = (int)bazaarInfo.get("avg_buy").getAsFloat(); + event.toolTip.add(EnumChatFormatting.DARK_GRAY.toString()+"[SHIFT show x"+shiftStackMultiplier+"]"); + } + if(bazaarInfo.has("avg_buy")) { + int bazaarBuyPrice = (int)bazaarInfo.get("avg_buy").getAsFloat()*stackMultiplier; event.toolTip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Bazaar Buy: "+ EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(bazaarBuyPrice)+" coins"); - int bazaarSellPrice = (int)bazaarInfo.get("avg_sell").getAsFloat(); + } + if(bazaarInfo.has("avg_sell")) { + int bazaarSellPrice = (int)bazaarInfo.get("avg_sell").getAsFloat()*stackMultiplier; event.toolTip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Bazaar Sell: "+ EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(bazaarSellPrice)+" coins"); - if(neu.manager.config.advancedPriceInfo.value) { - int bazaarInstantBuyPrice = (int)bazaarInfo.get("curr_buy").getAsFloat(); + } + if(neu.manager.config.advancedPriceInfo.value) { + if(bazaarInfo.has("curr_buy")) { + int bazaarInstantBuyPrice = (int)bazaarInfo.get("curr_buy").getAsFloat()*stackMultiplier; event.toolTip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Bazaar Insta-Buy: "+ EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(bazaarInstantBuyPrice)+" coins"); - int bazaarInstantSellPrice = (int)bazaarInfo.get("curr_sell").getAsFloat(); + } + if(bazaarInfo.has("curr_sell")) { + int bazaarInstantSellPrice = (int)bazaarInfo.get("curr_sell").getAsFloat()*stackMultiplier; event.toolTip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Bazaar Insta-Sell: "+ EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(bazaarInstantSellPrice)+" coins"); } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java index b2742bf9..73381955 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java @@ -2033,34 +2033,31 @@ public class NEUOverlay extends Gui { } } else if(hasBazaarPrice) { + int stackMultiplier = 1; + int shiftStackMultiplier = 64; if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { - int bazaarBuyPrice = (int)bazaarInfo.get("avg_buy").getAsFloat()*64; - text.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Bazaar Buy (Stack): "+ - EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(bazaarBuyPrice)+" coins"); - int bazaarSellPrice = (int)bazaarInfo.get("avg_sell").getAsFloat()*64; - text.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Bazaar Sell (Stack): "+ - EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(bazaarSellPrice)+" coins"); - if(manager.config.advancedPriceInfo.value) { - int bazaarInstantBuyPrice = (int)bazaarInfo.get("curr_buy").getAsFloat()*64; - text.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Bazaar Insta-Buy (Stack): "+ - EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(bazaarInstantBuyPrice)+" coins"); - int bazaarInstantSellPrice = (int)bazaarInfo.get("curr_sell").getAsFloat()*64; - text.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Bazaar Insta-Sell (Stack): "+ - EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(bazaarInstantSellPrice)+" coins"); - } + stackMultiplier = shiftStackMultiplier; } else { - text.add(EnumChatFormatting.DARK_GRAY.toString()+"[SHIFT show stack]"); - int bazaarBuyPrice = (int)bazaarInfo.get("avg_buy").getAsFloat(); + text.add(EnumChatFormatting.DARK_GRAY.toString()+"[SHIFT show x"+shiftStackMultiplier+"]"); + } + if(bazaarInfo.has("avg_buy")) { + int bazaarBuyPrice = (int)bazaarInfo.get("avg_buy").getAsFloat()*stackMultiplier; text.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Bazaar Buy: "+ EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(bazaarBuyPrice)+" coins"); - int bazaarSellPrice = (int)bazaarInfo.get("avg_sell").getAsFloat(); + } + if(bazaarInfo.has("avg_sell")) { + int bazaarSellPrice = (int)bazaarInfo.get("avg_sell").getAsFloat()*stackMultiplier; text.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Bazaar Sell: "+ EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(bazaarSellPrice)+" coins"); - if(manager.config.advancedPriceInfo.value) { - int bazaarInstantBuyPrice = (int)bazaarInfo.get("curr_buy").getAsFloat(); + } + if(manager.config.advancedPriceInfo.value) { + if(bazaarInfo.has("curr_buy")) { + int bazaarInstantBuyPrice = (int)bazaarInfo.get("curr_buy").getAsFloat()*stackMultiplier; text.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Bazaar Insta-Buy: "+ EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(bazaarInstantBuyPrice)+" coins"); - int bazaarInstantSellPrice = (int)bazaarInfo.get("curr_sell").getAsFloat(); + } + if(bazaarInfo.has("curr_sell")) { + int bazaarInstantSellPrice = (int)bazaarInfo.get("curr_sell").getAsFloat()*stackMultiplier; text.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Bazaar Insta-Sell: "+ EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(bazaarInstantSellPrice)+" coins"); } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java index 891b9711..f90f4367 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java @@ -11,6 +11,9 @@ import io.github.moulberry.notenoughupdates.auction.CustomAHGui; import io.github.moulberry.notenoughupdates.commands.SimpleCommand; import io.github.moulberry.notenoughupdates.cosmetics.CapeManager; import io.github.moulberry.notenoughupdates.cosmetics.GuiCosmetics; +import io.github.moulberry.notenoughupdates.dungeons.DungeonMap; +import io.github.moulberry.notenoughupdates.dungeons.DungeonWin; +import io.github.moulberry.notenoughupdates.dungeons.GuiDungeonMapEditor; import io.github.moulberry.notenoughupdates.gamemodes.GuiGamemodes; import io.github.moulberry.notenoughupdates.gamemodes.SBGamemodes; import io.github.moulberry.notenoughupdates.infopanes.CollectionLogInfoPane; @@ -27,12 +30,6 @@ import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.gui.inventory.GuiInventory; import net.minecraft.client.renderer.OpenGlHelper; -import net.minecraft.client.renderer.texture.DynamicTexture; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.renderer.texture.TextureMap; -import net.minecraft.client.resources.IReloadableResourceManager; -import net.minecraft.client.resources.IResourceManager; -import net.minecraft.client.resources.IResourceManagerReloadListener; import net.minecraft.client.settings.KeyBinding; import net.minecraft.command.ICommandSender; import net.minecraft.entity.player.EntityPlayer; @@ -58,24 +55,18 @@ import net.minecraftforge.fml.common.gameevent.TickEvent; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.text.WordUtils; import org.apache.commons.lang3.text.translate.UnicodeUnescaper; -import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.Display; import org.lwjgl.opengl.GL11; -import javax.imageio.ImageIO; -import javax.net.ssl.*; import javax.swing.*; import java.awt.*; import java.awt.datatransfer.StringSelection; -import java.awt.image.BufferedImage; import java.io.*; import java.lang.management.ManagementFactory; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.net.*; import java.nio.charset.StandardCharsets; -import java.security.cert.CertificateException; -import java.security.cert.X509Certificate; import java.util.*; import java.util.List; import java.util.concurrent.Executors; @@ -229,6 +220,16 @@ public class NotEnoughUpdates { } }); + SimpleCommand dungeonWinTest = new SimpleCommand("neudungeonwintest", new SimpleCommand.ProcessCommandRunnable() { + public void processCommand(ICommandSender sender, String[] args) { + if(args.length > 0) { + DungeonWin.TEAM_SCORE = new ResourceLocation("notenoughupdates:dungeon_win/"+args[0].toLowerCase()+".png"); + } + + DungeonWin.displayWin(); + } + }); + SimpleCommand reloadRepoCommand = new SimpleCommand("neureloadrepo", new SimpleCommand.ProcessCommandRunnable() { public void processCommand(ICommandSender sender, String[] args) { File items = new File(manager.repoLocation, "items"); @@ -846,11 +847,6 @@ public class NotEnoughUpdates { MinecraftForge.EVENT_BUS.register(new DungeonMap()); //MinecraftForge.EVENT_BUS.register(new BetterPortals()); - IResourceManager resourceManager = Minecraft.getMinecraft().getResourceManager(); - if(resourceManager instanceof IReloadableResourceManager) { - ((IReloadableResourceManager)resourceManager).registerReloadListener(new DungeonBlocks()); - } - File f = new File(event.getModConfigurationDirectory(), "notenoughupdates"); f.mkdirs(); ClientCommandHandler.instance.registerCommand(collectionLogCommand); @@ -872,6 +868,7 @@ public class NotEnoughUpdates { ClientCommandHandler.instance.registerCommand(neumapCommand); ClientCommandHandler.instance.registerCommand(settingsCommand); ClientCommandHandler.instance.registerCommand(settingsCommand2); + ClientCommandHandler.instance.registerCommand(dungeonWinTest); manager = new NEUManager(this, f); manager.loadItemInformation(); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java b/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java index 886ffd73..d6f390c6 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java @@ -228,15 +228,9 @@ public class APIManager { } public int getLowestBin(String internalname) { - if(internalname.contains("AUGER")) { - System.out.println("Tried to get auger!"); - } if(lowestBins != null && lowestBins.has(internalname)) { JsonElement e = lowestBins.get(internalname); if(e.isJsonPrimitive() && e.getAsJsonPrimitive().isNumber()) { - if(internalname.contains("AUGER")) { - System.out.println("s:"+e.getAsInt()); - } return e.getAsInt(); } } @@ -245,7 +239,12 @@ public class APIManager { public void updateLowestBin() { manager.hypixelApi.getMyApiGZIPAsync("lowestbin.json.gz", (jsonObject) -> { - lowestBins = jsonObject; + if(lowestBins == null) { + lowestBins = new JsonObject(); + } + for(Map.Entry<String, JsonElement> entry : jsonObject.entrySet()) { + lowestBins.add(entry.getKey(), entry.getValue()); + } }, () -> {}); } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonBlocks.java b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonBlocks.java new file mode 100644 index 00000000..fb9de198 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonBlocks.java @@ -0,0 +1,261 @@ +package io.github.moulberry.notenoughupdates.dungeons; + +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.questing.SBInfo; +import io.github.moulberry.notenoughupdates.util.SpecialColour; +import io.github.moulberry.notenoughupdates.util.Utils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.ScaledResolution; +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.input.Keyboard; +import org.lwjgl.opengl.*; + +import java.awt.*; +import java.nio.FloatBuffer; +import java.nio.IntBuffer; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; + +public class DungeonBlocks { + + private static Framebuffer framebufferBlocksTo = null; + private static Framebuffer framebufferBlocksFrom = null; + + private static HashMap<String, Framebuffer> framebuffersDynamicTo = new HashMap<>(); + public static HashMap<String, Framebuffer> framebuffersDynamicFrom = new HashMap<>(); + private static HashSet<String> dynamicUpdated = new HashSet<>(); + + private static FloatBuffer projectionMatrixOld = BufferUtils.createFloatBuffer(16); + private static FloatBuffer modelviewMatrixOld = BufferUtils.createFloatBuffer(16); + + public static boolean textureExists() { + return framebufferBlocksFrom != null && isOverriding(); + } + + public static void bindTextureIfExists() { + if(textureExists()) { + framebufferBlocksFrom.bindFramebufferTexture(); + } + } + + public static boolean isOverriding() { + return OpenGlHelper.isFramebufferEnabled() && !NotEnoughUpdates.INSTANCE.manager.config.disableDungeonBlocks.value && + (NotEnoughUpdates.INSTANCE.manager.config.dungeonBlocksEverywhere.value || + (SBInfo.getInstance().getLocation() != null && SBInfo.getInstance().getLocation().equals("dungeon"))); + } + + public static boolean bindModifiedTexture(ResourceLocation location, int colour) { + if(!isOverriding()) { + return false; + } + + if(Utils.disableCustomDungColours) { + return false; + } + + if(((colour >> 24) & 0xFF) < 10) { + return false; + } + + String id = location.getResourceDomain()+":"+location.getResourcePath(); + if(dynamicUpdated.contains(id) && framebuffersDynamicFrom.containsKey(id)) { + framebuffersDynamicFrom.get(id).bindFramebufferTexture(); + return true; + } + + Minecraft.getMinecraft().getTextureManager().bindTexture(location); + 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); + + Framebuffer to = checkFramebufferSizes(framebuffersDynamicTo.get(id), w, h); + dynamicUpdated.add(id); + + try { + GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, projectionMatrixOld); + GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, modelviewMatrixOld); + + GL11.glPushMatrix(); + + GlStateManager.matrixMode(GL11.GL_PROJECTION); + GlStateManager.loadIdentity(); + GlStateManager.ortho(0.0D, w, h, 0.0D, 1000.0D, 3000.0D); + GlStateManager.matrixMode(GL11.GL_MODELVIEW); + GlStateManager.loadIdentity(); + GlStateManager.translate(0.0F, 0.0F, -2000.0F); + + to.bindFramebuffer(true); + GlStateManager.clearColor(0, 1, 0, 1); + GlStateManager.clear(GL11.GL_COLOR_BUFFER_BIT); + + GlStateManager.disableBlend(); + GlStateManager.disableLighting(); + GlStateManager.disableFog(); + + Minecraft.getMinecraft().getTextureManager().bindTexture(location); + GlStateManager.color(1, 1, 1, 1); + Utils.drawTexturedRectNoBlend(0, 0, w, h, 0, 1, 1, 0, GL11.GL_LINEAR); + + 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(0, 0, w, h, colour); + + GL11.glPopMatrix(); + + to.bindFramebufferTexture(); + if (Minecraft.getMinecraft().gameSettings.mipmapLevels >= 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); + GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D); + } + + GlStateManager.matrixMode(GL11.GL_PROJECTION); + GL11.glLoadMatrix(projectionMatrixOld); + GlStateManager.matrixMode(GL11.GL_MODELVIEW); + GL11.glLoadMatrix(modelviewMatrixOld); + + Framebuffer from = checkFramebufferSizes(framebuffersDynamicFrom.get(id), w, h); + framebuffersDynamicFrom.put(id, to); + framebuffersDynamicTo.put(id, from); + + to.bindFramebufferTexture(); + + Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true); + GlStateManager.disableBlend(); + GlStateManager.enableLighting(); + return true; + } catch(Exception e) { + e.printStackTrace(); + } + Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true); + GlStateManager.disableBlend(); + GlStateManager.enableLighting(); + return false; + } + + private static HashMap<ResourceLocation, String> dynamicPreloadMap = new HashMap<>(); + + static { + dynamicPreloadMap.put(new ResourceLocation("textures/entity/bat.png"), + NotEnoughUpdates.INSTANCE.manager.config.dungBatColour.value); + dynamicPreloadMap.put(new ResourceLocation("textures/entity/chest/normal.png"), + NotEnoughUpdates.INSTANCE.manager.config.dungChestColour.value); + dynamicPreloadMap.put(new ResourceLocation("textures/entity/chest/normal_double.png"), + NotEnoughUpdates.INSTANCE.manager.config.dungChestColour.value); + dynamicPreloadMap.put(new ResourceLocation("textures/entity/chest/trapped.png"), + NotEnoughUpdates.INSTANCE.manager.config.dungTrappedChestColour.value); + dynamicPreloadMap.put(new ResourceLocation("textures/entity/chest/trapped_double.png"), + NotEnoughUpdates.INSTANCE.manager.config.dungTrappedChestColour.value); + } + + public static void tick() { + if(!isOverriding() || Minecraft.getMinecraft().theWorld == null) { + return; + } + + dynamicUpdated.clear(); + + for(Map.Entry<ResourceLocation, String> entry : dynamicPreloadMap.entrySet()) { + bindModifiedTexture(entry.getKey(), SpecialColour.specialToChromaRGB(entry.getValue())); + } + + Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.locationBlocksTexture); + 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); + + Framebuffer to = checkFramebufferSizes(framebufferBlocksTo, w, h); + + try { + GL11.glPushMatrix(); + + GlStateManager.matrixMode(5889); + GlStateManager.loadIdentity(); + GlStateManager.ortho(0.0D, w, h, 0.0D, 1000.0D, 3000.0D); + GlStateManager.matrixMode(5888); + GlStateManager.loadIdentity(); + GlStateManager.translate(0.0F, 0.0F, -2000.0F); + + to.bindFramebuffer(true); + GlStateManager.clear(GL11.GL_COLOR_BUFFER_BIT); + + GlStateManager.disableBlend(); + GlStateManager.disableLighting(); + GlStateManager.disableFog(); + + Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.locationBlocksTexture); + GlStateManager.color(1, 1, 1, 1); + Utils.drawTexturedRectNoBlend(0, 0, w, h, 0, 1, 1, 0, GL11.GL_LINEAR); + + HashMap<TextureAtlasSprite, Integer> spriteMap = new HashMap<>(); + spriteMap.put(Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("minecraft:blocks/stonebrick_cracked"), + SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.manager.config.dungCrackedColour.value)); + spriteMap.put(Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("minecraft:blocks/dispenser_front_horizontal"), + SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.manager.config.dungDispenserColour.value)); + spriteMap.put(Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("minecraft:blocks/lever"), + SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.manager.config.dungLeverColour.value)); + spriteMap.put(Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("minecraft:blocks/trip_wire"), + SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.manager.config.dungTripWireColour.value)); + + for(Map.Entry<TextureAtlasSprite, Integer> entry : spriteMap.entrySet()) { + if(((entry.getValue() >> 24) & 0xFF) < 10) continue; + + TextureAtlasSprite tas = entry.getKey(); + Gui.drawRect((int)(w*tas.getMinU()), h-(int)(h*tas.getMaxV())-1, + (int)(w*tas.getMaxU())+1, h-(int)(h*tas.getMinV()), entry.getValue()); + } + + 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(); + + to.bindFramebufferTexture(); + if (Minecraft.getMinecraft().gameSettings.mipmapLevels >= 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); + GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D); + } + + Framebuffer from = checkFramebufferSizes(framebufferBlocksFrom, w, h); + framebufferBlocksFrom = to; + framebufferBlocksTo = from; + } catch(Exception e) { + e.printStackTrace(); + } + Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true); + GlStateManager.enableBlend(); + } + + 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/dungeons/DungeonMap.java index 79b9e106..e68cde61 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/DungeonMap.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java @@ -1,7 +1,9 @@ -package io.github.moulberry.notenoughupdates; +package io.github.moulberry.notenoughupdates.dungeons; import com.google.common.math.BigIntegerMath; import com.google.gson.JsonObject; +import io.github.moulberry.notenoughupdates.NEUResourceManager; +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.questing.SBInfo; import io.github.moulberry.notenoughupdates.util.SpecialColour; import io.github.moulberry.notenoughupdates.util.Utils; @@ -77,8 +79,6 @@ public class DungeonMap { private static final ResourceLocation CORNER_BROWN = new ResourceLocation("notenoughupdates:dungeon_map/corners_default/brown_corner.png"); - private static final ResourceLocation BORDER_STEAMPUNK = new ResourceLocation("notenoughupdates:dungeon_map/borders/steampunk.png"); - private final HashMap<RoomOffset, Room> roomMap = new HashMap<>(); private Color[][] colourMap = new Color[128][128]; private int startRoomX = -1; @@ -391,8 +391,6 @@ public class DungeonMap { } 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; @@ -406,6 +404,8 @@ public class DungeonMap { return; } + ScaledResolution scaledResolution = Utils.pushGuiScale(2); + int minRoomX = 999; int minRoomY = 999; int maxRoomX = -999; @@ -1311,10 +1311,10 @@ public class DungeonMap { @SubscribeEvent(priority=EventPriority.HIGH) public void onRenderOverlayPre(RenderGameOverlayEvent.Pre event) { - if(event.type == RenderGameOverlayEvent.ElementType.ALL) { - if(NotEnoughUpdates.INSTANCE.manager.config.dmBackgroundBlur.value > 0.1) { - blurBackground(); - } + if(event.type == RenderGameOverlayEvent.ElementType.ALL && + NotEnoughUpdates.INSTANCE.manager.config.dmEnable.value && + NotEnoughUpdates.INSTANCE.manager.config.dmBackgroundBlur.value > 0.1) { + blurBackground(); GlStateManager.enableBlend(); GlStateManager.enableTexture2D(); } @@ -1323,6 +1323,8 @@ public class DungeonMap { @SubscribeEvent public void onRenderOverlay(RenderGameOverlayEvent event) { if(event.type == RenderGameOverlayEvent.ElementType.ALL) { + if(!NotEnoughUpdates.INSTANCE.manager.config.dmEnable.value) return; + if(SBInfo.getInstance().getLocation() == null || !SBInfo.getInstance().getLocation().equals("dungeon")) { return; } @@ -1520,9 +1522,10 @@ public class DungeonMap { } if(blurShaderHorz != null && blurShaderVert != null) { float blur = NotEnoughUpdates.INSTANCE.manager.config.dmBackgroundBlur.value.floatValue(); + blur = Math.max(0, Math.min(50, blur)); if(blur != lastBgBlurFactor) { - blurShaderHorz.getShaderManager().getShaderUniform("Radius").set((float)blur); - blurShaderVert.getShaderManager().getShaderUniform("Radius").set((float)blur); + blurShaderHorz.getShaderManager().getShaderUniform("Radius").set(blur); + blurShaderVert.getShaderManager().getShaderUniform("Radius").set(blur); lastBgBlurFactor = blur; } GL11.glPushMatrix(); @@ -1530,7 +1533,6 @@ public class DungeonMap { blurShaderVert.loadShader(0); GlStateManager.enableDepth(); GL11.glPopMatrix(); - Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false); } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonWin.java b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonWin.java new file mode 100644 index 00000000..2c99c8c0 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonWin.java @@ -0,0 +1,409 @@ +package io.github.moulberry.notenoughupdates.dungeons; + +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.util.Utils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.event.ClientChatReceivedEvent; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL14; + +import java.awt.*; +import java.util.*; +import java.util.List; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class DungeonWin { + + private static class Confetti { + private float x; + private float y; + private float xLast; + private float yLast; + private int life = 0; + private float xVel; + private float yVel; + private int id; + + public Confetti(float x, float y, float xVel, float yVel) { + this.x = x; + this.xLast = x; + this.y = y; + this.yLast = y; + this.xVel = xVel; + this.yVel = yVel; + this.id = rand.nextInt(16); + this.life = 20+rand.nextInt(10); + } + } + public static ResourceLocation CONFETTI = new ResourceLocation("notenoughupdates:dungeon_win/confetti.png"); + public static ResourceLocation SPLUS = new ResourceLocation("notenoughupdates:dungeon_win/splus.png"); + public static ResourceLocation S = new ResourceLocation("notenoughupdates:dungeon_win/s.png"); + public static ResourceLocation A = new ResourceLocation("notenoughupdates:dungeon_win/a.png"); + public static ResourceLocation B = new ResourceLocation("notenoughupdates:dungeon_win/b.png"); + public static ResourceLocation C = new ResourceLocation("notenoughupdates:dungeon_win/c.png"); + public static ResourceLocation D = new ResourceLocation("notenoughupdates:dungeon_win/d.png"); + public static ResourceLocation TEAM_SCORE = SPLUS; + + private static final int SCALE_FACTOR = 3; + private static final int WIDTH = 32*SCALE_FACTOR; + private static final int HEIGHT = 16*SCALE_FACTOR; + + private static boolean hideChat = false; + private static long lastDungeonFinish = 0; + private static final Pattern TEAM_SCORE_REGEX = Pattern.compile("Team Score: [0-9]+ \\((S\\+|S|A|B|C|D)\\)"); + + private static final ScheduledExecutorService SES = Executors.newScheduledThreadPool(1); + + public static Random rand = new Random(); + public static List<Confetti> confetti = new ArrayList<>(); + public static List<String> text = new ArrayList<>(); + public static long startTime = 0; + + static { + for(int i=0; i<10; i++) { + text.add("{PLACEHOLDER DUNGEON STAT #"+i+"}"); + } + } + + public static void displayWin() { + if(NotEnoughUpdates.INSTANCE.manager.config.dungeonWinMillis.value < 100) return; + startTime = System.currentTimeMillis(); + confetti.clear(); + } + + public static void tick() { + if(NotEnoughUpdates.INSTANCE.manager.config.dungeonWinMillis.value < 100) return; + if(System.currentTimeMillis() - startTime > 5000) return; + int deltaTime = (int)(System.currentTimeMillis() - startTime); + + if(deltaTime < 1000) { + ScaledResolution sr = Utils.pushGuiScale(2); + int cap = 0; + switch(TEAM_SCORE.getResourcePath()) { + case "dungeon_win/splus.png": + cap = 200; break; + case "dungeon_win/s.png": + cap = 100; break; + case "dungeon_win/a.png": + cap = 50; break; + } + int maxConfetti = Math.min(cap, deltaTime/5); + while(confetti.size() < maxConfetti) { + int y; + if(deltaTime < 500) { + y = sr.getScaledHeight()/2-(int)(Math.sin(deltaTime/1000f*Math.PI)*sr.getScaledHeight()/9); + } else { + y = sr.getScaledHeight()/6+(int)(Math.sin(deltaTime/1000f*Math.PI)*sr.getScaledHeight()*4/18); + } + int xOffset = -WIDTH/2+rand.nextInt(WIDTH); + int x = sr.getScaledWidth()/2+xOffset; + + int xVel = xOffset/2; + int yVel = -25-rand.nextInt(10)+Math.abs(xVel)/2; + + confetti.add(new Confetti(x, y, xVel, yVel)); + } + } else { + Set<Confetti> toRemove = new HashSet<>(); + for(Confetti c : confetti) { + if(c.life <= 0) { + toRemove.add(c); + } + } + try { + confetti.removeAll(toRemove); + } catch(ConcurrentModificationException ignored) {} + } + + Utils.pushGuiScale(-1); + for(Confetti c : confetti) { + c.yVel += 1; + c.xVel /= 1.1f; + c.yVel /= 1.1f; + c.xLast = c.x; + c.yLast = c.y; + c.x += c.xVel; + c.y += c.yVel; + c.life--; + } + } + + public static void onChatMessage(ClientChatReceivedEvent e) { + if(NotEnoughUpdates.INSTANCE.manager.config.dungeonWinMillis.value < 100) return; + long currentTime = System.currentTimeMillis(); + String unformatted = Utils.cleanColour(e.message.getUnformattedText()); + if(e.message.getFormattedText().startsWith(EnumChatFormatting.RESET+" ")) { + if(unformatted.contains("\u25AC")) { + System.out.println("CONTAINS BREAK!"); + } + if(currentTime - lastDungeonFinish > 10000) { + Matcher matcher = TEAM_SCORE_REGEX.matcher(unformatted); + if(matcher.find()) { + lastDungeonFinish = currentTime; + + String score = matcher.group(1); + System.out.println(score); + switch (score.toUpperCase()) { + case "S+": + TEAM_SCORE = SPLUS; break; + case "S": + TEAM_SCORE = S; break; + case "A": + TEAM_SCORE = A; break; + case "B": + TEAM_SCORE = B; break; + case "C": + TEAM_SCORE = C; break; + default: + TEAM_SCORE = D; break; + } + + SES.schedule(()->{ + NotEnoughUpdates.INSTANCE.sendChatMessage("/showextrastats"); + }, 100L, TimeUnit.MILLISECONDS); + } + } + } + if(currentTime - lastDungeonFinish > 100 && currentTime - lastDungeonFinish < 10000) { + if(hideChat) { + e.setCanceled(true); + if(unformatted.contains("\u25AC")) { + hideChat = false; + lastDungeonFinish = 0; + displayWin(); + } else { + if(unformatted.trim().length() > 0) { + text.add(e.message.getFormattedText().substring(2).trim()); + } + } + } else { + if(unformatted.contains("\u25AC")) { + hideChat = true; + text.clear(); + e.setCanceled(true); + } + } + + } + } + + public static void render(float partialTicks) { + if(NotEnoughUpdates.INSTANCE.manager.config.dungeonWinMillis.value < 100) return; + int maxTime = Math.min(30000, NotEnoughUpdates.INSTANCE.manager.config.dungeonWinMillis.value.intValue()); + if(System.currentTimeMillis() - startTime > maxTime) return; + int deltaTime = (int)(System.currentTimeMillis() - startTime); + + float alpha = Math.max(0, Math.min(1, 1-(deltaTime-maxTime+150)/150f)); + + ScaledResolution sr = Utils.pushGuiScale(2); + + if(deltaTime > 600) { + float bottom; + if(deltaTime < 1000) { + bottom = sr.getScaledHeight()/6f+(float)Math.sin(deltaTime/1000f*Math.PI)*sr.getScaledHeight()*4/18+HEIGHT/2; + } else { + bottom = sr.getScaledHeight()/6f+HEIGHT/2; + } + for(int i=0; i<text.size(); i++) { + String line = text.get(i); + float textCenterY = sr.getScaledHeight()/6f+HEIGHT/2+7+i*10; + if(textCenterY > bottom) { + int textAlpha = (int)(alpha * (deltaTime > 1000 ? 255 : Math.min(255, (textCenterY-bottom)/30f*255))); + GlStateManager.enableBlend(); + + if(textAlpha > 150) { + for(int xOff=-2; xOff<=2; xOff++) { + for(int yOff=-2; yOff<=2; yOff++) { + if(Math.abs(xOff) != Math.abs(yOff)) { + Utils.drawStringCentered(Utils.cleanColourNotModifiers(line), Minecraft.getMinecraft().fontRendererObj, + sr.getScaledWidth()/2+xOff/2f, textCenterY+yOff/2f, false, + ((textAlpha/Math.max(Math.abs(xOff), Math.abs(yOff))) << 24)); + } + } + } + } + + Utils.drawStringCentered(line, Minecraft.getMinecraft().fontRendererObj, + sr.getScaledWidth()/2, textCenterY, false, (textAlpha << 24) | 0x00FFFFFF); + } + } + } + + for(Confetti c : confetti) { + Minecraft.getMinecraft().getTextureManager().bindTexture(CONFETTI); + GlStateManager.color(1, 1, 1, 1); + if(c.life >= 15) { + GlStateManager.color(1, 1, 1, Math.min(1, c.life/4f)); + Utils.drawTexturedRect(c.xLast+(c.x-c.xLast)*partialTicks-4, c.yLast+(c.y-c.yLast)*partialTicks-4, + 8, 8, (c.id%4)/4f, (c.id%4+1)/4f, (c.id/4)/4f, (c.id/4+1)/4f, GL11.GL_NEAREST); + } + } + + Minecraft.getMinecraft().getTextureManager().bindTexture(TEAM_SCORE); + GlStateManager.color(1, 1, 1, alpha); + + GlStateManager.pushMatrix(); + if(deltaTime < 1600) { + GlStateManager.translate(sr.getScaledWidth()/2, 0, 0); + if(deltaTime < 500) { + GlStateManager.translate(0, sr.getScaledHeight()/2f-Math.sin(deltaTime/1000f*Math.PI)*sr.getScaledHeight()/9, 0); + } else if(deltaTime < 1000) { + GlStateManager.translate(0, sr.getScaledHeight()/6f+Math.sin(deltaTime/1000f*Math.PI)*sr.getScaledHeight()*4/18, 0); + } else { + GlStateManager.translate(0, sr.getScaledHeight()/6f, 0); + } + if(deltaTime < 200) { + float scale = deltaTime/200f; + GlStateManager.scale(scale, scale, 1); + } else if(deltaTime < 1000) { + float scale = 1+(float)Math.sin((deltaTime-200)/800f*Math.PI)*0.8f; + GlStateManager.scale(scale, scale, 1); + } else if(deltaTime < 1100) { + float scale = 1+(float)Math.sin((deltaTime-1000)/100f*Math.PI)*0.15f; + GlStateManager.scale(scale, scale, 1); + } + + if(deltaTime < 600) { + GlStateManager.rotate(180+deltaTime/600f*180, 0, 1, 0); + GlStateManager.rotate(180-deltaTime/600f*180, 1, 0, 0); + GlStateManager.rotate(-180-deltaTime/600f*165, 0, 0, 1); + } else if(deltaTime < 1000) { + GlStateManager.rotate(15-(deltaTime-600)/400f*11, 0, 0, 1); + } else { + float logFac = 1-(float)Math.log((deltaTime-1000)/600f*1.7f+1); + logFac = logFac*logFac; + + GlStateManager.rotate(4f*logFac, 0, 0, 1); + float x = (deltaTime-1000)/300f; + GlStateManager.rotate((float)(40*(1-Math.log(x*0.85f+1))*Math.sin(10*x*x)), 0, 1, 0); + } + } else { + GlStateManager.translate(sr.getScaledWidth()/2, sr.getScaledHeight()/6f, 0); + } + + GlStateManager.disableCull(); + + Utils.drawTexturedRect(-WIDTH/2, -HEIGHT/2, WIDTH, HEIGHT, GL11.GL_NEAREST); + GlStateManager.translate(0, 0, -SCALE_FACTOR*2); + Utils.drawTexturedRect(-WIDTH/2, -HEIGHT/2, WIDTH, HEIGHT, GL11.GL_NEAREST); + GlStateManager.translate(0, 0, SCALE_FACTOR*2); + + if(deltaTime < 1600) { + float epsilon = 0.01f; + for(int xIndex=0; xIndex<32; xIndex++) { + for(int yIndex=0; yIndex<16; yIndex++) { + float uMin = xIndex/32f; + float uMax = (xIndex+1)/32f; + float vMin = yIndex/16f; + float vMax = (yIndex+1)/16f; + + int x = -WIDTH/2+xIndex*SCALE_FACTOR; + int y = -HEIGHT/2+yIndex*SCALE_FACTOR; + + 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); + + 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); + + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + //Left + worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX); + worldrenderer + .pos(x+epsilon, y+SCALE_FACTOR, 0.0D+epsilon) + .tex(uMin, vMax).endVertex(); + worldrenderer + .pos(x+epsilon, y, 0.0D+epsilon) + .tex(uMax, vMax).endVertex(); + worldrenderer + .pos(x+epsilon, y, -SCALE_FACTOR*2-epsilon) + .tex(uMax, vMin).endVertex(); + worldrenderer + .pos(x+epsilon, y+SCALE_FACTOR, -SCALE_FACTOR*2-epsilon) + .tex(uMin, vMin).endVertex(); + tessellator.draw(); + //Right + worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX); + worldrenderer + .pos(x+SCALE_FACTOR-epsilon, y+SCALE_FACTOR, 0.0D+epsilon) + .tex(uMin, vMax).endVertex(); + worldrenderer + .pos(x+SCALE_FACTOR-epsilon, y, 0.0D+epsilon) + .tex(uMax, vMax).endVertex(); + worldrenderer + .pos(x+SCALE_FACTOR-epsilon, y, -SCALE_FACTOR*2-epsilon) + .tex(uMax, vMin).endVertex(); + worldrenderer + .pos(x+SCALE_FACTOR-epsilon, y+SCALE_FACTOR, -SCALE_FACTOR*2-epsilon) + .tex(uMin, vMin).endVertex(); + tessellator.draw(); + //Top + worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX); + worldrenderer + .pos(x+SCALE_FACTOR, y+epsilon, 0.0D+epsilon) + .tex(uMin, vMax).endVertex(); + worldrenderer + .pos(x, y+epsilon, 0.0D+epsilon) + .tex(uMax, vMax).endVertex(); + worldrenderer + .pos(x, y+epsilon, -SCALE_FACTOR*2-epsilon) + .tex(uMax, vMin).endVertex(); + worldrenderer + .pos(x+SCALE_FACTOR, y+epsilon, -SCALE_FACTOR*2-epsilon) + .tex(uMin, vMin).endVertex(); + tessellator.draw(); + //Top + worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX); + worldrenderer + .pos(x+SCALE_FACTOR, y+SCALE_FACTOR-epsilon, 0.0D+epsilon) + .tex(uMin, vMax).endVertex(); + worldrenderer + .pos(x, y+SCALE_FACTOR-epsilon, 0.0D+epsilon) + .tex(uMax, vMax).endVertex(); + worldrenderer + .pos(x, y+SCALE_FACTOR-epsilon, -SCALE_FACTOR*2-epsilon) + .tex(uMax, vMin).endVertex(); + worldrenderer + .pos(x+SCALE_FACTOR, y+SCALE_FACTOR-epsilon, -SCALE_FACTOR*2-epsilon) + .tex(uMin, vMin).endVertex(); + tessellator.draw(); + + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); + + GlStateManager.disableBlend(); + } + } + } + + GlStateManager.popMatrix(); + + for(Confetti c : confetti) { + Minecraft.getMinecraft().getTextureManager().bindTexture(CONFETTI); + GlStateManager.color(1, 1, 1, 1); + if(c.life > 0 && c.life < 15) { + GlStateManager.color(1, 1, 1, Math.min(1, c.life/4f)); + Utils.drawTexturedRect(c.xLast+(c.x-c.xLast)*partialTicks-4, c.yLast+(c.y-c.yLast)*partialTicks-4, + 8, 8, (c.id%4)/4f, (c.id%4+1)/4f, (c.id/4)/4f, (c.id/4+1)/4f, GL11.GL_NEAREST); + } + } + + Utils.pushGuiScale(-1); + + GlStateManager.enableBlend(); + } + +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/GuiDungeonMapEditor.java b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/GuiDungeonMapEditor.java index 6058dc51..5890b5c0 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/GuiDungeonMapEditor.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/GuiDungeonMapEditor.java @@ -1,9 +1,8 @@ -package io.github.moulberry.notenoughupdates; +package io.github.moulberry.notenoughupdates.dungeons; -import io.github.moulberry.notenoughupdates.infopanes.SettingsInfoPane; +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.itemeditor.GuiElementTextField; import io.github.moulberry.notenoughupdates.options.Options; -import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer; import io.github.moulberry.notenoughupdates.util.SpecialColour; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; @@ -226,7 +225,7 @@ public class GuiDungeonMapEditor extends GuiScreen { case 14: mapDesc = "Paper border"; mapCredit = "KingJames02st"; break; case 15: - mapDesc = "Nether-inspired border"; break; + mapDesc = "Nether-inspired border"; mapCredit = "DTRW191"; break; case 16: mapDesc = "Golden ornate border"; mapCredit = "iDevil4Hell"; break; case 17: @@ -598,7 +597,7 @@ public class GuiDungeonMapEditor extends GuiScreen { } } - Utils.pushGuiScale(-1); + try { NotEnoughUpdates.INSTANCE.manager.saveConfig(); } catch(IOException ignored) {} return; } } @@ -643,6 +642,7 @@ public class GuiDungeonMapEditor extends GuiScreen { try { xField.setCustomBorderColour(-1); NotEnoughUpdates.INSTANCE.manager.config.dmCenterX.setValue(xField.getText()); + try { NotEnoughUpdates.INSTANCE.manager.saveConfig(); } catch(IOException ignored) {} } catch(Exception e) { xField.setCustomBorderColour(Color.RED.getRGB()); } @@ -652,6 +652,7 @@ public class GuiDungeonMapEditor extends GuiScreen { try { yField.setCustomBorderColour(-1); NotEnoughUpdates.INSTANCE.manager.config.dmCenterY.setValue(yField.getText()); + try { NotEnoughUpdates.INSTANCE.manager.saveConfig(); } catch(IOException ignored) {} } catch(Exception e) { yField.setCustomBorderColour(Color.RED.getRGB()); } @@ -661,6 +662,7 @@ public class GuiDungeonMapEditor extends GuiScreen { try { blurField.setCustomBorderColour(-1); NotEnoughUpdates.INSTANCE.manager.config.dmBackgroundBlur.setValue(blurField.getText()); + try { NotEnoughUpdates.INSTANCE.manager.saveConfig(); } catch(IOException ignored) {} } catch(Exception e) { blurField.setCustomBorderColour(Color.RED.getRGB()); } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/gamemodes/SBGamemodes.java b/src/main/java/io/github/moulberry/notenoughupdates/gamemodes/SBGamemodes.java index d570843a..377977ac 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/gamemodes/SBGamemodes.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/gamemodes/SBGamemodes.java @@ -111,7 +111,7 @@ public class SBGamemodes { public boolean isBanned(String inventoryName) { for(String banned : bannedInventories) { - if(inventoryName.contains(banned)) return true; + if(inventoryName.contains(banned + " ") || inventoryName.endsWith(banned)) return true; } return false; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityPlayer.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityPlayer.java index 78201a8f..8757e369 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityPlayer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityPlayer.java @@ -1,20 +1,11 @@ package io.github.moulberry.notenoughupdates.mixins; -import io.github.moulberry.notenoughupdates.DungeonBlocks; import io.github.moulberry.notenoughupdates.cosmetics.CapeManager; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.RenderList; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EnumPlayerModelParts; -import net.minecraft.util.EnumWorldBlockLayer; -import org.lwjgl.input.Keyboard; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL12; -import org.lwjgl.opengl.GL14; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin({EntityPlayer.class}) diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRender.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRender.java index dcdb4bf4..2c92a0b1 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRender.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRender.java @@ -1,32 +1,29 @@ package io.github.moulberry.notenoughupdates.mixins; -import io.github.moulberry.notenoughupdates.DungeonBlocks; +import io.github.moulberry.notenoughupdates.dungeons.DungeonBlocks; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.util.SpecialColour; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.Render; import net.minecraft.entity.Entity; import net.minecraft.entity.passive.EntityBat; import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(Render.class) public class MixinRender { @Inject(method="bindEntityTexture", at=@At("HEAD"), cancellable = true) - public void bindEntityTexture(Entity entity, CallbackInfoReturnable cir) { - if(entity instanceof EntityBat && DungeonBlocks.isInDungeons()) { - int tex = DungeonBlocks.getModifiedTexture(new ResourceLocation("textures/entity/bat.png"), - SpecialColour.specialToSimpleRGB(NotEnoughUpdates.INSTANCE.manager.config.dungBatColour.value)); - - if(tex >= 0) { - GlStateManager.bindTexture(tex); + public void bindEntityTexture(Entity entity, CallbackInfoReturnable<Boolean> cir) { + if(entity instanceof EntityBat && DungeonBlocks.isOverriding()) { + if(DungeonBlocks.bindModifiedTexture(new ResourceLocation("textures/entity/bat.png"), + SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.manager.config.dungChestColour.value))) { cir.setReturnValue(true); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST_MIPMAP_LINEAR); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); } } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderFish.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderFish.java index 59ce4852..fc536267 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderFish.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderFish.java @@ -60,75 +60,80 @@ public abstract class MixinRenderFish extends Render<EntityFishHook> { GlStateManager.disableRescaleNormal(); GlStateManager.popMatrix(); - if (entity.angler != null) { + double playerVecX; + double playerVecY; + double playerVecZ; + double startY; + if(this.renderManager.options.thirdPersonView == 0 && entity.angler == Minecraft.getMinecraft().thePlayer) { float f7 = entity.angler.getSwingProgress(partialTicks); - float f8 = MathHelper.sin(MathHelper.sqrt_float(f7) * (float)Math.PI); - - double d0; - double d1; - double d2; - double d3; - if(this.renderManager.options.thirdPersonView == 0 && entity.angler == Minecraft.getMinecraft().thePlayer) { - double fov = this.renderManager.options.fovSetting; - fov = fov / 90.0; - double xFactor = 0.5 + 0.55*((fov-0.333)/0.889); - Vec3 vec3 = new Vec3(-xFactor * fov, -0.045D * fov, 0.4D); - vec3 = vec3.rotatePitch(-(entity.angler.prevRotationPitch + (entity.angler.rotationPitch - entity.angler.prevRotationPitch) * partialTicks) * (float)Math.PI / 180.0F); - vec3 = vec3.rotateYaw(-(entity.angler.prevRotationYaw + (entity.angler.rotationYaw - entity.angler.prevRotationYaw) * partialTicks) * (float)Math.PI / 180.0F); - vec3 = vec3.rotateYaw(f8 * 0.5F); - vec3 = vec3.rotatePitch(-f8 * 0.7F); - d0 = entity.angler.prevPosX + (entity.angler.posX - entity.angler.prevPosX) * (double)partialTicks + vec3.xCoord; - d1 = entity.angler.prevPosY + (entity.angler.posY - entity.angler.prevPosY) * (double)partialTicks + vec3.yCoord; - d2 = entity.angler.prevPosZ + (entity.angler.posZ - entity.angler.prevPosZ) * (double)partialTicks + vec3.zCoord; - d3 = entity.angler.getEyeHeight(); - } else { - float f9 = (entity.angler.prevRenderYawOffset + (entity.angler.renderYawOffset - entity.angler.prevRenderYawOffset) * partialTicks) * (float)Math.PI / 180.0F; - double d4 = MathHelper.sin(f9); - double d6 = MathHelper.cos(f9); - d0 = entity.angler.prevPosX + (entity.angler.posX - entity.angler.prevPosX) * (double)partialTicks - d6 * 0.35D - d4 * 0.8D; - d1 = entity.angler.prevPosY + entity.angler.getEyeHeight() + (entity.angler.posY - entity.angler.prevPosY) * (double)partialTicks - 0.45D; - d2 = entity.angler.prevPosZ + (entity.angler.posZ - entity.angler.prevPosZ) * (double)partialTicks - d4 * 0.35D + d6 * 0.8D; - d3 = entity.angler.isSneaking() ? -0.1875D : 0.0D; - } + float sqrtSinSwing = MathHelper.sin(MathHelper.sqrt_float(f7) * (float)Math.PI); - double d13 = entity.prevPosX + (entity.posX - entity.prevPosX) * (double)partialTicks; - double d5 = entity.prevPosY + (entity.posY - entity.prevPosY) * (double)partialTicks + 0.25D; - double d7 = entity.prevPosZ + (entity.posZ - entity.prevPosZ) * (double)partialTicks; - double d9 = (double)((float)(d0 - d13)); - double d11 = (double)((float)(d1 - d5)) + d3; - double d12 = (double)((float)(d2 - d7)); - GlStateManager.disableTexture2D(); - GlStateManager.disableLighting(); - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - worldrenderer.begin(3, DefaultVertexFormats.POSITION_COLOR); - - String specialColour; - if (entity.angler.getUniqueID().equals(Minecraft.getMinecraft().thePlayer.getUniqueID())) { - specialColour = NotEnoughUpdates.INSTANCE.manager.config.selfRodLineColour.value; - } else { - specialColour = NotEnoughUpdates.INSTANCE.manager.config.otherRodLineColour.value; - } - int colourI = SpecialColour.specialToChromaRGB(specialColour); + double decimalFov = (this.renderManager.options.fovSetting / 110.0D); + Vec3 fppOffset = new Vec3((-decimalFov + (decimalFov / 2.5) - (decimalFov / 8)) + 0.025, -0.045D * (this.renderManager.options.fovSetting / 100.0D), 0.4D); + fppOffset = fppOffset.rotatePitch(-mathLerp(partialTicks, entity.angler.prevRotationPitch, entity.angler.rotationPitch) * ((float)Math.PI / 180.0F)); + fppOffset = fppOffset.rotateYaw(-mathLerp(partialTicks, entity.angler.prevRotationYaw, entity.angler.rotationYaw) * ((float)Math.PI / 180.0F)); + fppOffset = fppOffset.rotateYaw(sqrtSinSwing * 0.5F); + fppOffset = fppOffset.rotatePitch(-sqrtSinSwing * 0.7F); + + playerVecX = entity.angler.prevPosX + (entity.angler.posX - entity.angler.prevPosX) * (double)partialTicks + fppOffset.xCoord; + playerVecY = entity.angler.prevPosY + (entity.angler.posY - entity.angler.prevPosY) * (double)partialTicks + fppOffset.yCoord; + playerVecZ = entity.angler.prevPosZ + (entity.angler.posZ - entity.angler.prevPosZ) * (double)partialTicks + fppOffset.zCoord; + startY = entity.angler.getEyeHeight(); + } else { + float angle = (entity.angler.prevRenderYawOffset + (entity.angler.renderYawOffset - entity.angler.prevRenderYawOffset) * partialTicks) * (float)Math.PI / 180.0F; + double d4 = MathHelper.sin(angle); + double d6 = MathHelper.cos(angle); + playerVecX = entity.angler.prevPosX + (entity.angler.posX - entity.angler.prevPosX) * (double)partialTicks - d6 * 0.35D - d4 * 0.8D; + playerVecY = entity.angler.prevPosY + entity.angler.getEyeHeight() + (entity.angler.posY - entity.angler.prevPosY) * (double)partialTicks - 0.45D; + playerVecZ = entity.angler.prevPosZ + (entity.angler.posZ - entity.angler.prevPosZ) * (double)partialTicks - d4 * 0.35D + d6 * 0.8D; + startY = entity.angler.isSneaking() ? -0.1875D : 0.0D; + } + + double d13 = entity.prevPosX + (entity.posX - entity.prevPosX) * (double)partialTicks; + double d5 = entity.prevPosY + (entity.posY - entity.prevPosY) * (double)partialTicks + 0.25D; + double d7 = entity.prevPosZ + (entity.posZ - entity.prevPosZ) * (double)partialTicks; + double d9 = (double)((float)(playerVecX - d13)); + double d11 = (double)((float)(playerVecY - d5)) + startY; + double d12 = (double)((float)(playerVecZ - d7)); + GlStateManager.disableTexture2D(); + GlStateManager.disableLighting(); + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + worldrenderer.begin(3, DefaultVertexFormats.POSITION_COLOR); - for (int l = 0; l <= 16; ++l) { - if(SpecialColour.getSpeed(specialColour) > 0) { //has chroma - colourI = SpecialColour.rotateHue(colourI, 10); - } - Color colour = new Color(colourI, true); + String specialColour; + if (entity.angler.getUniqueID().equals(Minecraft.getMinecraft().thePlayer.getUniqueID())) { + specialColour = NotEnoughUpdates.INSTANCE.manager.config.selfRodLineColour.value; + } else { + specialColour = NotEnoughUpdates.INSTANCE.manager.config.otherRodLineColour.value; + } + int colourI = SpecialColour.specialToChromaRGB(specialColour); - float f10 = (float)l / 16.0F; - worldrenderer.pos(x + d9 * (double)f10, y + d11 * (double)(f10 * f10 + f10) * 0.5D + 0.25D, z + d12 * (double)f10) - .color(colour.getRed(), colour.getGreen(), colour.getBlue(), colour.getAlpha()).endVertex(); + for (int l = 0; l <= 16; ++l) { + if(SpecialColour.getSpeed(specialColour) > 0) { //has chroma + colourI = SpecialColour.rotateHue(colourI, 10); } + Color colour = new Color(colourI, true); - tessellator.draw(); - GlStateManager.disableBlend(); - GlStateManager.enableLighting(); - GlStateManager.enableTexture2D(); + float f10 = (float)l / 16.0F; + worldrenderer.pos(x + d9 * (double)f10, y + d11 * (double)(f10 * f10 + f10) * 0.5D + 0.25D, z + d12 * (double)f10) + .color(colour.getRed(), colour.getGreen(), colour.getBlue(), colour.getAlpha()).endVertex(); } + + tessellator.draw(); + GlStateManager.disableBlend(); + GlStateManager.enableLighting(); + GlStateManager.enableTexture2D(); } } } + private static float mathLerp(float var1, float var2, float var3) { + return var2 + var1 * (var3 - var2); + } + + private static double mathLerp(double var1, double var2, double var3) { + return var2 + var1 * (var3 - var2); + } + }
\ No newline at end of file diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderList.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderList.java index 03300d45..ffaf9ebb 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderList.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderList.java @@ -1,28 +1,14 @@ package io.github.moulberry.notenoughupdates.mixins; -import io.github.moulberry.notenoughupdates.DungeonBlocks; -import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import io.github.moulberry.notenoughupdates.util.Utils; -import net.minecraft.client.Minecraft; +import io.github.moulberry.notenoughupdates.dungeons.DungeonBlocks; import net.minecraft.client.renderer.*; -import net.minecraft.client.renderer.texture.DynamicTexture; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.renderer.texture.TextureMap; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.util.EnumWorldBlockLayer; -import net.minecraft.util.ResourceLocation; -import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL12; -import org.lwjgl.opengl.GL14; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import javax.imageio.ImageIO; -import java.awt.image.BufferedImage; - @Mixin({RenderList.class}) public abstract class MixinRenderList { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinTileEntitySpecialRenderer.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinTileEntitySpecialRenderer.java index b8a77051..d53f62c9 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinTileEntitySpecialRenderer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinTileEntitySpecialRenderer.java @@ -1,15 +1,10 @@ package io.github.moulberry.notenoughupdates.mixins; -import io.github.moulberry.notenoughupdates.DungeonBlocks; +import io.github.moulberry.notenoughupdates.dungeons.DungeonBlocks; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.util.SpecialColour; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.RenderList; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; -import net.minecraft.util.EnumWorldBlockLayer; import net.minecraft.util.ResourceLocation; -import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -21,15 +16,19 @@ public abstract class MixinTileEntitySpecialRenderer { @Inject(method="bindTexture", at=@At("HEAD"), cancellable = true) public void bindTexture(ResourceLocation location, CallbackInfo info) { - if(DungeonBlocks.isInDungeons() && location.getResourcePath().equals("textures/entity/chest/normal.png")) { - int tex = DungeonBlocks.getModifiedTexture(location, - SpecialColour.specialToSimpleRGB(NotEnoughUpdates.INSTANCE.manager.config.dungChestColour.value)); - - if(tex >= 0) { - info.cancel(); - GlStateManager.bindTexture(tex); - GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST_MIPMAP_LINEAR); - GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); + if(DungeonBlocks.isOverriding()) { + if(location.getResourcePath().equals("textures/entity/chest/normal.png") || + location.getResourcePath().equals("textures/entity/chest/normal_double.png") || + location.getResourcePath().equals("textures/entity/chest/trapped.png") || + location.getResourcePath().equals("textures/entity/chest/trapped_double.png")) { + String colour = location.getResourcePath().contains("trapped") ? NotEnoughUpdates.INSTANCE.manager.config.dungTrappedChestColour.value : + NotEnoughUpdates.INSTANCE.manager.config.dungChestColour.value; + if(DungeonBlocks.bindModifiedTexture(location, + SpecialColour.specialToChromaRGB(colour))) { + info.cancel(); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST_MIPMAP_LINEAR); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); + } } } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinVboRenderList.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinVboRenderList.java index 03dded06..42d81781 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinVboRenderList.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinVboRenderList.java @@ -1,32 +1,14 @@ package io.github.moulberry.notenoughupdates.mixins; -import io.github.moulberry.notenoughupdates.DungeonBlocks; -import io.github.moulberry.notenoughupdates.ItemRarityHalo; -import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import io.github.moulberry.notenoughupdates.util.Utils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.ChunkRenderContainer; -import net.minecraft.client.renderer.GlStateManager; +import io.github.moulberry.notenoughupdates.dungeons.DungeonBlocks; import net.minecraft.client.renderer.VboRenderList; -import net.minecraft.client.renderer.entity.RenderItem; -import net.minecraft.client.renderer.texture.DynamicTexture; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.renderer.texture.TextureMap; -import net.minecraft.item.ItemStack; import net.minecraft.util.EnumWorldBlockLayer; -import net.minecraft.util.ResourceLocation; -import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL12; -import org.lwjgl.opengl.GL14; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import javax.imageio.ImageIO; -import java.awt.image.BufferedImage; - @Mixin({VboRenderList.class}) public abstract class MixinVboRenderList { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/Options.java b/src/main/java/io/github/moulberry/notenoughupdates/options/Options.java index adaf1ad0..1b6cebe3 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/Options.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/Options.java @@ -1,18 +1,12 @@ package io.github.moulberry.notenoughupdates.options; import com.google.gson.*; -import io.github.moulberry.notenoughupdates.GuiDungeonMapEditor; +import io.github.moulberry.notenoughupdates.dungeons.GuiDungeonMapEditor; import io.github.moulberry.notenoughupdates.GuiEnchantColour; import io.github.moulberry.notenoughupdates.NEUOverlayPlacements; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import io.github.moulberry.notenoughupdates.mbgui.MBAnchorPoint; -import io.github.moulberry.notenoughupdates.util.SpecialColour; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; -import net.minecraft.util.Util; -import net.minecraftforge.client.ClientCommandHandler; -import net.minecraftforge.client.ForgeHooksClient; -import org.lwjgl.util.vector.Vector2f; import java.awt.*; import java.io.*; @@ -186,9 +180,16 @@ public class Options { "If true, will show the overlay for cracked bricks, etc. even when not in dungeons.", CAT_MISC); public Option<Boolean> disableDungeonBlocks = new Option( true, - "Disables the dungeon blocks feature", + "Disable the dungeon blocks feature", false, "If true, the dungeon block overlay will be disabled. WARNING: May cause memory/fps issues on some machines", CAT_FEATURES); + public Option<Boolean> slowDungeonBlocks = new Option( + false, + "Slowly Update Dungeon Block Textures", + false, + "If true, dungeon blocks will only update once every second.\n" + + "Use this option if you are having performance\n" + + "issues relating to the dungeon blocks.", CAT_MISC); public Option<Boolean> missingEnchantList = new Option( true, "Missing Enchant List", @@ -256,6 +257,11 @@ public class Options { "SBMenu Button Style", false, "Style of the buttons used for the skyblock menu.", 0, 10, CAT_FEATURES); + public Option<Double> dungeonWinMillis = new Option( + 5000.0, + "Dungeon Victory Screen Millis", + false, + "Changes how long the victory screen at the end of dungeons appears for. 0 = off", FLAG_INT, 0, 15000, CAT_SLIDERS); public Option<String> itemBackgroundColour = new Option( "00:255:100:100:100", @@ -318,6 +324,12 @@ public class Options { false, "Dungeon Chest Colour", FLAG_COLOUR, CAT_COLOURS); + public Option<String> dungTrappedChestColour = new Option( + "0:255:0:163:36", + "Dungeon Trapped Chest Colour", + false, + "Dungeon Trapped Chest Colour", + FLAG_COLOUR, CAT_COLOURS); public Option<String> dungBatColour = new Option( "0:255:12:255:0", "Dungeon Bat Colour", @@ -597,6 +609,7 @@ public class Options { tryAddOption(invAuctionPrice, options); tryAddOption(dungeonBlocksEverywhere, options); tryAddOption(disableDungeonBlocks, options); + tryAddOption(slowDungeonBlocks, options); tryAddOption(missingEnchantList, options); tryAddOption(accessoryBagOverlay, options); tryAddOption(rodColours, options); @@ -610,6 +623,7 @@ public class Options { tryAddOption(tooltipBorderOpacity, options); tryAddOption(dynamicMenuBackgroundStyle, options); tryAddOption(dynamicMenuButtonStyle, options); + tryAddOption(dungeonWinMillis, options); //Text tryAddOption(apiKey, options); //Colour @@ -626,6 +640,7 @@ public class Options { tryAddOption(dungLeverColour, options); tryAddOption(dungTripWireColour, options); tryAddOption(dungChestColour, options); + tryAddOption(dungTrappedChestColour, options); tryAddOption(dungBatColour, options); return options; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java index f732779c..e2faa5aa 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -31,6 +31,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagString; +import net.minecraft.potion.Potion; import net.minecraft.server.MinecraftServer; import net.minecraft.util.*; import net.minecraftforge.fml.common.Loader; @@ -57,6 +58,7 @@ import java.util.regex.Pattern; public class Utils { private static boolean hasEffectOverride = false; + public static boolean disableCustomDungColours = false; private static LinkedList<Integer> guiScales = new LinkedList<>(); private static ScaledResolution lastScale = new ScaledResolution(Minecraft.getMinecraft()); //Labymod compatibility @@ -144,6 +146,7 @@ public class Utils { public static void drawItemStackWithoutGlint(ItemStack stack, int x, int y) { RenderItem itemRender = Minecraft.getMinecraft().getRenderItem(); + disableCustomDungColours = true; RenderHelper.enableGUIStandardItemLighting(); itemRender.zLevel = -145; //Negates the z-offset of the below method. hasEffectOverride = true; @@ -153,6 +156,7 @@ public class Utils { hasEffectOverride = false; itemRender.zLevel = 0; RenderHelper.disableStandardItemLighting(); + disableCustomDungColours = false; } public static void drawItemStackWithText(ItemStack stack, int x, int y, String text) { @@ -160,12 +164,14 @@ public class Utils { RenderItem itemRender = Minecraft.getMinecraft().getRenderItem(); + disableCustomDungColours = true; RenderHelper.enableGUIStandardItemLighting(); itemRender.zLevel = -145; //Negates the z-offset of the below method. itemRender.renderItemAndEffectIntoGUI(stack, x, y); itemRender.renderItemOverlayIntoGUI(Minecraft.getMinecraft().fontRendererObj, stack, x, y, text); itemRender.zLevel = 0; RenderHelper.disableStandardItemLighting(); + disableCustomDungColours = false; } public static void drawItemStack(ItemStack stack, int x, int y) { diff --git a/src/main/resources/assets/notenoughupdates/dungeon_map/borders/large/9.json b/src/main/resources/assets/notenoughupdates/dungeon_map/borders/large/9.json new file mode 100644 index 00000000..9576ae4f --- /dev/null +++ b/src/main/resources/assets/notenoughupdates/dungeon_map/borders/large/9.json @@ -0,0 +1,3 @@ +{ + "radiusSq": 1 +}
\ No newline at end of file diff --git a/src/main/resources/assets/notenoughupdates/dungeon_map/borders/large/9.png b/src/main/resources/assets/notenoughupdates/dungeon_map/borders/large/9.png Binary files differnew file mode 100644 index 00000000..c5fedff9 --- /dev/null +++ b/src/main/resources/assets/notenoughupdates/dungeon_map/borders/large/9.png diff --git a/src/main/resources/assets/notenoughupdates/dungeon_map/borders/medium/9.json b/src/main/resources/assets/notenoughupdates/dungeon_map/borders/medium/9.json new file mode 100644 index 00000000..9576ae4f --- /dev/null +++ b/src/main/resources/assets/notenoughupdates/dungeon_map/borders/medium/9.json @@ -0,0 +1,3 @@ +{ + "radiusSq": 1 +}
\ No newline at end of file diff --git a/src/main/resources/assets/notenoughupdates/dungeon_map/borders/medium/9.png b/src/main/resources/assets/notenoughupdates/dungeon_map/borders/medium/9.png Binary files differnew file mode 100644 index 00000000..a42870f2 --- /dev/null +++ b/src/main/resources/assets/notenoughupdates/dungeon_map/borders/medium/9.png diff --git a/src/main/resources/assets/notenoughupdates/dungeon_win/a.png b/src/main/resources/assets/notenoughupdates/dungeon_win/a.png Binary files differnew file mode 100644 index 00000000..85322946 --- /dev/null +++ b/src/main/resources/assets/notenoughupdates/dungeon_win/a.png diff --git a/src/main/resources/assets/notenoughupdates/dungeon_win/b.png b/src/main/resources/assets/notenoughupdates/dungeon_win/b.png Binary files differnew file mode 100644 index 00000000..11c7384c --- /dev/null +++ b/src/main/resources/assets/notenoughupdates/dungeon_win/b.png diff --git a/src/main/resources/assets/notenoughupdates/dungeon_win/c.png b/src/main/resources/assets/notenoughupdates/dungeon_win/c.png Binary files differnew file mode 100644 index 00000000..2009179f --- /dev/null +++ b/src/main/resources/assets/notenoughupdates/dungeon_win/c.png diff --git a/src/main/resources/assets/notenoughupdates/dungeon_win/confetti.png b/src/main/resources/assets/notenoughupdates/dungeon_win/confetti.png Binary files differnew file mode 100644 index 00000000..a5529dc8 --- /dev/null +++ b/src/main/resources/assets/notenoughupdates/dungeon_win/confetti.png diff --git a/src/main/resources/assets/notenoughupdates/dungeon_win/d.png b/src/main/resources/assets/notenoughupdates/dungeon_win/d.png Binary files differnew file mode 100644 index 00000000..c08baaf4 --- /dev/null +++ b/src/main/resources/assets/notenoughupdates/dungeon_win/d.png diff --git a/src/main/resources/assets/notenoughupdates/dungeon_win/s.png b/src/main/resources/assets/notenoughupdates/dungeon_win/s.png Binary files differnew file mode 100644 index 00000000..a514f285 --- /dev/null +++ b/src/main/resources/assets/notenoughupdates/dungeon_win/s.png diff --git a/src/main/resources/assets/notenoughupdates/dungeon_win/splus.png b/src/main/resources/assets/notenoughupdates/dungeon_win/splus.png Binary files differnew file mode 100644 index 00000000..732d30a3 --- /dev/null +++ b/src/main/resources/assets/notenoughupdates/dungeon_win/splus.png |