aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBuildTools <james.jenour@protonmail.com>2021-06-04 01:18:28 +0800
committerBuildTools <james.jenour@protonmail.com>2021-06-04 01:18:28 +0800
commita1fa5a67caebf754a0fcc43168672823ede0db93 (patch)
treec0d7d78dfffaa659835a59952cac6edd2592be87 /src
parent1b172089ce502803f7644611afd618ce00dcb860 (diff)
downloadNotEnoughUpdates-a1fa5a67caebf754a0fcc43168672823ede0db93.tar.gz
NotEnoughUpdates-a1fa5a67caebf754a0fcc43168672823ede0db93.tar.bz2
NotEnoughUpdates-a1fa5a67caebf754a0fcc43168672823ede0db93.zip
merge is pain
Diffstat (limited to 'src')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java44
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java25
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java6
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java30
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/collectionlog/CollectionConstant.java17
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/collectionlog/GuiCollectionLog.java103
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/BackgroundBlur.java96
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/GuiElement.java4
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java12
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CollectionLogManager.java46
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java51
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java1
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SlotLocking.java74
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiCustomEnchant.java451
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java92
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java2
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinNetHandlerPlayClient.java5
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java70
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java38
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/Constants.java55
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/SBAIntegration.java217
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java19
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java23
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/XPInformation.java52
-rw-r--r--src/main/resources/assets/notenoughupdates/capes/furf.pngbin12443 -> 15699 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/collectionlog.pngbin0 -> 12083 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/custom_enchant_gui.pngbin0 -> 5086 bytes
-rw-r--r--src/main/resources/mixins.notenoughupdates.json50
28 files changed, 1149 insertions, 434 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java
index 98300e73..30f0f722 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java
@@ -45,6 +45,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTUtil;
+import net.minecraft.network.play.client.C12PacketUpdateSign;
import net.minecraft.util.*;
import net.minecraftforge.client.ClientCommandHandler;
import net.minecraftforge.client.event.*;
@@ -241,6 +242,17 @@ public class NEUEventListener {
}
DungeonWin.tick();
+ String containerName = null;
+ if(Minecraft.getMinecraft().currentScreen instanceof GuiChest) {
+ GuiChest eventGui = (GuiChest) Minecraft.getMinecraft().currentScreen;
+ ContainerChest cc = (ContainerChest) eventGui.inventorySlots;
+ containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText();
+
+ if(GuiCustomEnchant.getInstance().shouldOverride(containerName)) {
+ GuiCustomEnchant.getInstance().tick();
+ }
+ }
+
if(longUpdate) {
CrystalOverlay.tick();
DwarvenMinesTextures.tick();
@@ -271,10 +283,7 @@ public class NEUEventListener {
neu.updateSkyblockScoreboard();
CapeManager.getInstance().tick();
- if(Minecraft.getMinecraft().currentScreen instanceof GuiChest) {
- GuiChest eventGui = (GuiChest) Minecraft.getMinecraft().currentScreen;
- ContainerChest cc = (ContainerChest) eventGui.inventorySlots;
- String containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText();
+ if(containerName != null) {
if(!containerName.trim().startsWith("Accessory Bag")) {
AccessoryBagOverlay.resetCache();
}
@@ -629,7 +638,7 @@ public class NEUEventListener {
}
}
- @SubscribeEvent
+ /*@SubscribeEvent
public void onPlayerInteract(EntityInteractEvent event) {
if(!event.isCanceled() && NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() &&
Minecraft.getMinecraft().thePlayer.isSneaking() &&
@@ -645,7 +654,7 @@ public class NEUEventListener {
}
}
}
- }
+ }*/
private IChatComponent processChatComponent(IChatComponent chatComponent) {
IChatComponent newComponent;
@@ -843,6 +852,12 @@ public class NEUEventListener {
containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText();
}
+ if(GuiCustomEnchant.getInstance().shouldOverride(containerName)) {
+ GuiCustomEnchant.getInstance().render(event.renderPartialTicks);
+ event.setCanceled(true);
+ return;
+ }
+
boolean tradeWindowActive = TradeWindow.tradeWindowActive(containerName);
boolean storageOverlayActive = StorageManager.getInstance().shouldRenderStorageOverlay(containerName);
boolean customAhActive = event.gui instanceof CustomAHGui || neu.manager.auctionManager.customAH.isRenderOverAuctionView();
@@ -960,6 +975,10 @@ public class NEUEventListener {
containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText();
}
+ if(GuiCustomEnchant.getInstance().shouldOverride(containerName)) {
+ return;
+ }
+
boolean tradeWindowActive = TradeWindow.tradeWindowActive(containerName);
boolean storageOverlayActive = StorageManager.getInstance().shouldRenderStorageOverlay(containerName);
boolean customAhActive = event.gui instanceof CustomAHGui || neu.manager.auctionManager.customAH.isRenderOverAuctionView();
@@ -1250,7 +1269,6 @@ public class NEUEventListener {
return;
}
-
final ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
final int scaledWidth = scaledresolution.getScaledWidth();
final int scaledHeight = scaledresolution.getScaledHeight();
@@ -1265,6 +1283,12 @@ public class NEUEventListener {
containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText();
}
+ if(GuiCustomEnchant.getInstance().shouldOverride(containerName) &&
+ GuiCustomEnchant.getInstance().mouseInput(mouseX, mouseY)) {
+ event.setCanceled(true);
+ return;
+ }
+
boolean tradeWindowActive = TradeWindow.tradeWindowActive(containerName);
boolean storageOverlayActive = StorageManager.getInstance().shouldRenderStorageOverlay(containerName);
boolean customAhActive = event.gui instanceof CustomAHGui || neu.manager.auctionManager.customAH.isRenderOverAuctionView();
@@ -1370,6 +1394,12 @@ public class NEUEventListener {
containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText();
}
+ if(GuiCustomEnchant.getInstance().shouldOverride(containerName) &&
+ GuiCustomEnchant.getInstance().keyboardInput()) {
+ event.setCanceled(true);
+ return;
+ }
+
boolean tradeWindowActive = TradeWindow.tradeWindowActive(containerName);
boolean storageOverlayActive = StorageManager.getInstance().shouldRenderStorageOverlay(containerName);
boolean customAhActive = event.gui instanceof CustomAHGui || neu.manager.auctionManager.customAH.isRenderOverAuctionView();
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
index 24c90c7b..f0b3fc0e 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
@@ -95,6 +95,13 @@ public class NEUManager {
return SBInfo.getInstance().currentProfile;
}
+ public <T> T getJsonFromFile(File file, Class<T> clazz) {
+ try(BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8))) {
+ T obj = gson.fromJson(reader, clazz);
+ return obj;
+ } catch(Exception e) { return null; }
+ }
+
/**
* Parses a file in to a JsonObject.
*/
@@ -237,8 +244,6 @@ public class NEUManager {
} catch (IOException e) {
}
}
-
- Constants.reload();
}
} catch(Exception e) {
e.printStackTrace();
@@ -246,8 +251,6 @@ public class NEUManager {
if(dialog != null) dialog.dispose();
}
- System.err.println("First load");
-
File items = new File(repoLocation, "items");
if(items.exists()) {
File[] itemFiles = new File(repoLocation, "items").listFiles();
@@ -262,9 +265,13 @@ public class NEUManager {
}
}
}
- });
- System.err.println("Second load");
+ try {
+ Constants.reload();
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ });
File items = new File(repoLocation, "items");
if(items.exists()) {
@@ -280,6 +287,12 @@ public class NEUManager {
}
}
}
+
+ try {
+ Constants.reload();
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
}
/**
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java
index 8df3f0eb..895567b4 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java
@@ -1732,12 +1732,14 @@ public class NEUOverlay extends Gui {
//Atomic reference used so that below lambda doesn't complain about non-effectively-final variable
AtomicReference<JsonObject> tooltipToDisplay = new AtomicReference<>(null);
- if(itemPaneOffsetFactor.getValue() < 1) {
+ //System.out.println(itemPaneOffsetFactor.getValue());
+ if(itemPaneOffsetFactor.getValue() < 0.99) {
if(NotEnoughUpdates.INSTANCE.config.itemlist.bgBlurFactor > 0.5) {
BackgroundBlur.renderBlurredBackground(NotEnoughUpdates.INSTANCE.config.itemlist.bgBlurFactor,
width, height,
leftSide+getBoxPadding()-5, getBoxPadding()-5,
- paneWidth-getBoxPadding()*2+10, height-getBoxPadding()*2+10, true);
+ paneWidth-getBoxPadding()*2+10, height-getBoxPadding()*2+10,
+ itemPaneOffsetFactor.getValue() > 0.01);
Gui.drawRect(leftSide+getBoxPadding()-5, getBoxPadding()-5,
leftSide+getBoxPadding()-5+paneWidth-getBoxPadding()*2+10,
getBoxPadding()-5+height-getBoxPadding()*2+10, 0xc8101010);
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
index f9965300..52e4b320 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
@@ -6,6 +6,7 @@ import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import io.github.moulberry.notenoughupdates.auction.CustomAHGui;
+import io.github.moulberry.notenoughupdates.collectionlog.GuiCollectionLog;
import io.github.moulberry.notenoughupdates.commands.SimpleCommand;
import io.github.moulberry.notenoughupdates.core.BackgroundBlur;
import io.github.moulberry.notenoughupdates.core.GuiScreenElementWrapper;
@@ -17,7 +18,6 @@ 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;
import io.github.moulberry.notenoughupdates.miscfeatures.*;
import io.github.moulberry.notenoughupdates.miscgui.*;
import io.github.moulberry.notenoughupdates.options.NEUConfig;
@@ -36,8 +36,6 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.AbstractClientPlayer;
import net.minecraft.client.entity.EntityPlayerSP;
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.resources.IReloadableResourceManager;
import net.minecraft.client.settings.KeyBinding;
@@ -73,7 +71,6 @@ import java.lang.management.ManagementFactory;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.List;
-import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
@@ -104,24 +101,14 @@ public class NotEnoughUpdates {
public GuiScreen openGui = null;
public long lastOpenedGui = 0;
- SimpleCommand collectionLogCommand = new SimpleCommand("neucl", new SimpleCommand.ProcessCommandRunnable() {
+ SimpleCommand.ProcessCommandRunnable collectionLogRun = new SimpleCommand.ProcessCommandRunnable() {
public void processCommand(ICommandSender sender, String[] args) {
- if(true) {
- sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED +
- "This feature has been disabled temporarily."));
- return;
- }
- if(!OpenGlHelper.isFramebufferEnabled()) {
- sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED +
- "This feature requires FBOs to work. Try disabling Optifine's 'Fast Render'."));
- } else {
- if(!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) {
- openGui = new GuiInventory(Minecraft.getMinecraft().thePlayer);
- }
- overlay.displayInformationPane(new CollectionLogInfoPane(overlay, manager));
- }
+ openGui = new GuiCollectionLog();
}
- });
+ };
+
+ SimpleCommand collectionLogCommand = new SimpleCommand("neucl", collectionLogRun);
+ SimpleCommand collectionLogCommand2 = new SimpleCommand("collectionlog", collectionLogRun);
SimpleCommand nullzeeSphereCommand = new SimpleCommand("neuzeesphere", new SimpleCommand.ProcessCommandRunnable() {
public void processCommand(ICommandSender sender, String[] args) {
@@ -1166,7 +1153,8 @@ public class NotEnoughUpdates {
((IReloadableResourceManager)Minecraft.getMinecraft().getResourceManager()).registerReloadListener(new ItemCustomizeManager.ReloadListener());
}
- ClientCommandHandler.instance.registerCommand(collectionLogCommand);
+ //ClientCommandHandler.instance.registerCommand(collectionLogCommand);
+ //ClientCommandHandler.instance.registerCommand(collectionLogCommand2);
ClientCommandHandler.instance.registerCommand(nullzeeSphereCommand);
ClientCommandHandler.instance.registerCommand(cosmeticsCommand);
ClientCommandHandler.instance.registerCommand(linksCommand);
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/collectionlog/CollectionConstant.java b/src/main/java/io/github/moulberry/notenoughupdates/collectionlog/CollectionConstant.java
new file mode 100644
index 00000000..25f6cfca
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/collectionlog/CollectionConstant.java
@@ -0,0 +1,17 @@
+package io.github.moulberry.notenoughupdates.collectionlog;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.regex.Pattern;
+
+public class CollectionConstant {
+
+ public static class DropEntry {
+ public String type;
+ public Pattern regex;
+ public HashMap<String, String> items;
+ }
+
+ public List<DropEntry> dropdata;
+
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/collectionlog/GuiCollectionLog.java b/src/main/java/io/github/moulberry/notenoughupdates/collectionlog/GuiCollectionLog.java
new file mode 100644
index 00000000..a2c8bfa9
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/collectionlog/GuiCollectionLog.java
@@ -0,0 +1,103 @@
+package io.github.moulberry.notenoughupdates.collectionlog;
+
+import io.github.moulberry.notenoughupdates.core.BackgroundBlur;
+import io.github.moulberry.notenoughupdates.core.GlScissorStack;
+import io.github.moulberry.notenoughupdates.util.Utils;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.client.gui.ScaledResolution;
+import net.minecraft.client.renderer.GlStateManager;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.util.ResourceLocation;
+import org.lwjgl.opengl.GL11;
+
+public class GuiCollectionLog extends GuiScreen {
+
+ private static final ResourceLocation COLLECTION_LOG_TEX = new ResourceLocation("notenoughupdates:collectionlog.png");
+
+ @Override
+ public void drawScreen(int mouseX, int mouseY, float partialTicks) {
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ int width = scaledResolution.getScaledWidth();
+ int height = scaledResolution.getScaledHeight();
+
+ int colwidth = 307;
+ int colheight = 187;
+
+ int left = width/2 - colwidth/2;
+ int top = height/2 - colheight/2;
+
+ BackgroundBlur.renderBlurredBackground(10, width, height, left, top, colwidth, colheight);
+ super.drawDefaultBackground();
+
+ Utils.drawStringCentered("\u00a7lCollection Log", fontRendererObj, width/2, top - 27, true, 0xfff5aa00);
+
+ String[] cats = {"Bosses", "Dragons", "Slayer", "Dungeons"};
+
+ GlStateManager.enableDepth();
+
+ GlStateManager.translate(0, 0, 2);
+ for(int i=0; i<4; i++) {
+ if(i == 0) {
+ int offset = i == 0 ? 1 : 2;
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(COLLECTION_LOG_TEX);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(left+i*71, top-21, 71, 25,
+ (71*offset)/512f, (71+71*offset)/512f, 211/512f, (211+25)/512f, GL11.GL_NEAREST);
+
+ Utils.drawStringCentered(cats[i], fontRendererObj, left+i*71+71/2, top - 8, true, 0xfff5aa00);
+ }
+ }
+
+ GlStateManager.translate(0, 0, -1);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(COLLECTION_LOG_TEX);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(left, top, colwidth, colheight,
+ 0, colwidth/512f, 0, colheight/512f, GL11.GL_NEAREST);
+
+ GlScissorStack.push(0, top+3, width, top+colheight-6, scaledResolution);
+ int catIndex = 0;
+ for(int h=top+3; h<top+colheight-6; h+=24) {
+ catIndex += 2;
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(COLLECTION_LOG_TEX);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(left, h, 100, 24,
+ 0, 100/512f, 187/512f, 211/512f, GL11.GL_NEAREST);
+
+ fontRendererObj.drawString("Thing "+catIndex, left+5, h+2, 0xfff5aa00, true);
+ fontRendererObj.drawString("Thing "+(catIndex+1), left+5, h+14, 0xfff5aa00, true);
+ }
+ GlScissorStack.pop(scaledResolution);
+
+ fontRendererObj.drawString("\u00a7lSuperior Dragon", left+119, top+8, 0xfff5aa00, true);
+ fontRendererObj.drawString("Obtained: "+ EnumChatFormatting.YELLOW+"3/5", left+122, top+23, 0xfff5aa00, true);
+
+ String killCountText = "Kills: " + EnumChatFormatting.WHITE + "3";
+ //int killCountLen = fontRendererObj.getStringWidth(killCountText);
+ fontRendererObj.drawString(killCountText, left+122, top+68, 0xfff5aa00, true);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(COLLECTION_LOG_TEX);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(left+colwidth-196, top, 196, colheight,
+ (512-196)/512f, 1, 0/512f, colheight/512f, GL11.GL_NEAREST);
+
+ GlStateManager.translate(0, 0, -1);
+
+ for(int i=0; i<4; i++) {
+ if(i != 0) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(COLLECTION_LOG_TEX);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(left+i*71, top-21, 71, 25,
+ 0, 71/512f, 211/512f, (211+25)/512f, GL11.GL_NEAREST);
+
+ Utils.drawStringCentered(cats[i], fontRendererObj, left+i*71+71/2, top - 8, true, 0xfff5aa00);
+ }
+ }
+
+
+
+ super.drawScreen(mouseX, mouseY, partialTicks);
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/BackgroundBlur.java b/src/main/java/io/github/moulberry/notenoughupdates/core/BackgroundBlur.java
index d27e6bd7..a4001675 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/BackgroundBlur.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/BackgroundBlur.java
@@ -27,7 +27,19 @@ import java.util.Set;
public class BackgroundBlur {
- private static HashMap<Float, Framebuffer> blurOutput = new HashMap<>();
+ private static class OutputStuff {
+ public Framebuffer framebuffer;
+ public Shader blurShaderHorz = null;
+ public Shader blurShaderVert = null;
+
+ public OutputStuff(Framebuffer framebuffer, Shader blurShaderHorz, Shader blurShaderVert) {
+ this.framebuffer = framebuffer;
+ this.blurShaderHorz = blurShaderHorz;
+ this.blurShaderVert = blurShaderVert;
+ }
+ }
+
+ private static HashMap<Float, OutputStuff> blurOutput = new HashMap<>();
private static HashMap<Float, Long> lastBlurUse = new HashMap<>();
private static long lastBlur = 0;
private static HashSet<Float> requestedBlurs = new HashSet<>();
@@ -62,14 +74,21 @@ public class BackgroundBlur {
int width = Minecraft.getMinecraft().displayWidth;
int height = Minecraft.getMinecraft().displayHeight;
- Framebuffer output = blurOutput.computeIfAbsent(blur, k -> {
+ OutputStuff output = blurOutput.computeIfAbsent(blur, k -> {
Framebuffer fb = new Framebuffer(width, height, false);
fb.setFramebufferFilter(GL11.GL_NEAREST);
- return fb;
+ return new OutputStuff(fb, null, null);
});
- output.framebufferWidth = output.framebufferTextureWidth = width;
- output.framebufferHeight = output.framebufferTextureHeight = height;
+ if(output.framebuffer.framebufferWidth != width || output.framebuffer.framebufferHeight != height) {
+ output.framebuffer.createBindFramebuffer(width, height);
+ if(output.blurShaderHorz != null) {
+ output.blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height));
+ }
+ if(output.blurShaderVert != null) {
+ output.blurShaderVert.setProjectionMatrix(createProjectionMatrix(width, height));
+ }
+ }
blurBackground(output, blur);
}
@@ -82,6 +101,14 @@ public class BackgroundBlur {
}
remove.remove((float)NotEnoughUpdates.INSTANCE.config.itemlist.bgBlurFactor);
+ for(Map.Entry<Float, OutputStuff> entry : blurOutput.entrySet()) {
+ if(remove.contains(entry.getKey())) {
+ entry.getValue().framebuffer.deleteFramebuffer();
+ entry.getValue().blurShaderHorz.deleteShader();
+ entry.getValue().blurShaderVert.deleteShader();
+ }
+ }
+
lastBlurUse.keySet().removeAll(remove);
blurOutput.keySet().removeAll(remove);
@@ -104,8 +131,6 @@ public class BackgroundBlur {
fogColour |= (int)(event.blue*255) & 0xFF;
}
- private static Shader blurShaderHorz = null;
- private static Shader blurShaderVert = null;
private static Framebuffer blurOutputHorz = null;
/**
@@ -129,7 +154,7 @@ public class BackgroundBlur {
}
private static double lastBgBlurFactor = -1;
- private static void blurBackground(Framebuffer output, float blurFactor) {
+ private static void blurBackground(OutputStuff output, float blurFactor) {
if(!OpenGlHelper.isFramebufferEnabled() || !OpenGlHelper.areShadersSupported()) return;
int width = Minecraft.getMinecraft().displayWidth;
@@ -151,40 +176,43 @@ public class BackgroundBlur {
}
if(blurOutputHorz.framebufferWidth != width || blurOutputHorz.framebufferHeight != height) {
blurOutputHorz.createBindFramebuffer(width, height);
- blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height));
Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
}
- try {
- blurShaderHorz = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur",
- output, blurOutputHorz);
- blurShaderHorz.getShaderManager().getShaderUniform("BlurDir").set(1, 0);
- blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height));
- } catch(Exception e) { }
- try {
- blurShaderVert = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur",
- blurOutputHorz, output);
- blurShaderVert.getShaderManager().getShaderUniform("BlurDir").set(0, 1);
- blurShaderVert.setProjectionMatrix(createProjectionMatrix(width, height));
- } catch(Exception e) { }
- if(blurShaderHorz != null && blurShaderVert != null) {
- if(blurShaderHorz.getShaderManager().getShaderUniform("Radius") == null) {
+ if(output.blurShaderHorz == null) {
+ try {
+ output.blurShaderHorz = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur",
+ output.framebuffer, blurOutputHorz);
+ output.blurShaderHorz.getShaderManager().getShaderUniform("BlurDir").set(1, 0);
+ output.blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height));
+ } catch(Exception e) { }
+ }
+ if(output.blurShaderVert == null) {
+ try {
+ output.blurShaderVert = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur",
+