aboutsummaryrefslogtreecommitdiff
path: root/src/main
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/main
parent1b172089ce502803f7644611afd618ce00dcb860 (diff)
downloadNotEnoughUpdates-a1fa5a67caebf754a0fcc43168672823ede0db93.tar.gz
NotEnoughUpdates-a1fa5a67caebf754a0fcc43168672823ede0db93.tar.bz2
NotEnoughUpdates-a1fa5a67caebf754a0fcc43168672823ede0db93.zip
merge is pain
Diffstat (limited to 'src/main')
-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",
+ blurOutputHorz, output.framebuffer);
+ output.blurShaderVert.getShaderManager().getShaderUniform("BlurDir").set(0, 1);
+ output.blurShaderVert.setProjectionMatrix(createProjectionMatrix(width, height));
+ } catch(Exception e) { }
+ }
+ if(output.blurShaderHorz != null && output.blurShaderVert != null) {
+ if(output.blurShaderHorz.getShaderManager().getShaderUniform("Radius") == null) {
//Corrupted shader?
return;
}
- blurShaderHorz.getShaderManager().getShaderUniform("Radius").set(blurFactor);
- blurShaderVert.getShaderManager().getShaderUniform("Radius").set(blurFactor);
+ output.blurShaderHorz.getShaderManager().getShaderUniform("Radius").set(blurFactor);
+ output.blurShaderVert.getShaderManager().getShaderUniform("Radius").set(blurFactor);
GL11.glPushMatrix();
GL30.glBindFramebuffer(GL30.GL_READ_FRAMEBUFFER, Minecraft.getMinecraft().getFramebuffer().framebufferObject);
- GL30.glBindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, output.framebufferObject);
+ GL30.glBindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, output.framebuffer.framebufferObject);
GL30.glBlitFramebuffer(0, 0, width, height,
- 0, 0, output.framebufferWidth, output.framebufferHeight,
+ 0, 0, output.framebuffer.framebufferWidth, output.framebuffer.framebufferHeight,
GL11.GL_COLOR_BUFFER_BIT, GL11.GL_NEAREST);
- blurShaderHorz.loadShader(0);
- blurShaderVert.loadShader(0);
+ output.blurShaderHorz.loadShader(0);
+ output.blurShaderVert.loadShader(0);
GlStateManager.enableDepth();
GL11.glPopMatrix();
@@ -215,9 +243,9 @@ public class BackgroundBlur {
if(blurOutput.isEmpty()) return;
- Framebuffer fb = blurOutput.get(blurStrength);
- if(fb == null) {
- fb = blurOutput.values().iterator().next();
+ OutputStuff out = blurOutput.get(blurStrength);
+ if(out == null) {
+ out = blurOutput.values().iterator().next();
}
float uMin = x/(float)screenWidth;
@@ -227,10 +255,10 @@ public class BackgroundBlur {
GlStateManager.depthMask(false);
Gui.drawRect(x, y, x+blurWidth, y+blurHeight, fogColour);
- fb.bindFramebufferTexture();
+ out.framebuffer.bindFramebufferTexture();
GlStateManager.color(1f, 1f, 1f, 1f);
RenderUtils.drawTexturedRect(x, y, blurWidth, blurHeight, uMin, uMax, vMin, vMax);
- fb.unbindFramebufferTexture();
+ out.framebuffer.unbindFramebufferTexture();
GlStateManager.depthMask(true);
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElement.java b/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElement.java
index 9210d1fb..5969c691 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElement.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElement.java
@@ -1,6 +1,8 @@
package io.github.moulberry.notenoughupdates.core;
-public abstract class GuiElement {
+import net.minecraft.client.gui.Gui;
+
+public abstract class GuiElement extends Gui {
public abstract void render();
public abstract boolean mouseInput(int mouseX, int mouseY);
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java
index a8cd30d8..aeedd5d1 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java
@@ -31,6 +31,8 @@ import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
public class CapeManager {
@@ -242,6 +244,8 @@ public class CapeManager {
}
}
+ private static final ExecutorService capeTicker = Executors.newCachedThreadPool();
+
@SubscribeEvent
public void onTick(TickEvent.ClientTickEvent event) {
if (event.phase != TickEvent.Phase.END) return;
@@ -274,7 +278,9 @@ public class CapeManager {
continue;
}
capeMap.get(playerUUID).getLeft().setCapeTexture(capeName);
- capeMap.get(playerUUID).getLeft().onTick(event, player);
+ capeTicker.submit(() -> {
+ capeMap.get(playerUUID).getLeft().onTick(event, player);
+ });
} else {
toRemove.add(playerUUID);
}
@@ -284,7 +290,9 @@ public class CapeManager {
if(hasLocalCape) {
localCape.getLeft().setCapeTexture(localCape.getValue());
- localCape.getLeft().onTick(event, Minecraft.getMinecraft().thePlayer);
+ capeTicker.submit(() -> {
+ localCape.getLeft().onTick(event, Minecraft.getMinecraft().thePlayer);
+ });
}
for(String playerName : toRemove) {
capeMap.remove(playerName);
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CollectionLogManager.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CollectionLogManager.java
new file mode 100644
index 00000000..00809d87
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CollectionLogManager.java
@@ -0,0 +1,46 @@
+package io.github.moulberry.notenoughupdates.miscfeatures;
+
+import io.github.moulberry.notenoughupdates.collectionlog.CollectionConstant;
+import io.github.moulberry.notenoughupdates.util.Constants;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.multiplayer.WorldClient;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.item.EntityArmorStand;
+
+import java.util.regex.Matcher;
+
+public class CollectionLogManager {
+
+ private static CollectionLogManager INSTANCE = new CollectionLogManager();
+
+ public static CollectionLogManager getInstance() {
+ return INSTANCE;
+ }
+
+ public void onEntityMetadataUpdated(int entityId) {
+ System.out.println("entity created:"+entityId);
+ WorldClient world = Minecraft.getMinecraft().theWorld;
+ if(world != null) {
+ Entity entity = world.getEntityByID(entityId);
+
+ if(entity instanceof EntityArmorStand && entity.hasCustomName()) {
+ String customName = entity.getName();
+ System.out.println("got name:"+customName);
+ for(CollectionConstant.DropEntry entry : Constants.COLLECTIONLOG.dropdata) {
+ System.out.println("iter entry");
+ if(entry.type.equalsIgnoreCase("itemdrop")) {
+ Matcher matcher = entry.regex.matcher(customName);
+ if(matcher.matches()) {
+ System.out.println("Match found!");
+ System.out.println("Count: "+matcher.group("count"));
+ System.out.println("Name: "+matcher.group("itemname"));
+ } else {
+ System.out.println("Doesn't match: " + customName);
+ }
+ }
+ }
+ }
+ }
+ }
+
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java
index 2c59fcd8..71fec1c7 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java
@@ -7,6 +7,7 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.ISound;
import net.minecraft.client.audio.PositionedSound;
import net.minecraft.client.audio.PositionedSoundRecord;
+import net.minecraft.client.audio.SoundCategory;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.Entity;
@@ -144,7 +145,7 @@ public class FishingHelper {
}
int averageMS = totalMS / pingDelayList.size();
- pingDelayTicks = (int)Math.ceil(averageMS/50f);
+ pingDelayTicks = (int)Math.floor(averageMS/50f);
}
}
@@ -347,23 +348,49 @@ public class FishingHelper {
if(newDistance <= 0.2f + 0.1f*pingDelayTicks) {
if(NotEnoughUpdates.INSTANCE.config.fishing.incomingFishHookedSounds &&
hookedWarningStateTicks <= 0) {
- Minecraft.getMinecraft().getSoundHandler().playSound(
- PositionedSoundRecord.create(new ResourceLocation("note.pling"), 2f));
+ float vol = NotEnoughUpdates.INSTANCE.config.fishing.incomingFishHookedSoundsVol/100f;
+ if(vol > 0) {
+ if(vol > 1) vol = 1;
+ final float volF = vol;
+
+ ISound sound = new PositionedSound(new ResourceLocation("note.pling")) {{
+ volume = volF;
+ pitch = 2f;
+ repeat = false;
+ repeatDelay = 0;
+ attenuationType = ISound.AttenuationType.NONE;
+ }};
+
+ float oldLevel = Minecraft.getMinecraft().gameSettings.getSoundLevel(SoundCategory.RECORDS);
+ Minecraft.getMinecraft().gameSettings.setSoundLevel(SoundCategory.RECORDS, 1);
+ Minecraft.getMinecraft().getSoundHandler().playSound(sound);
+ Minecraft.getMinecraft().gameSettings.setSoundLevel(SoundCategory.RECORDS, oldLevel);
+ }
}
hookedWarningStateTicks = 12;
} else if(newDistance >= 0.4f + 0.1f*pingDelayTicks) {
if(NotEnoughUpdates.INSTANCE.config.fishing.incomingFishIncSounds &&
buildupSoundDelay <= 0) {
- ISound sound = new PositionedSound(new ResourceLocation("note.pling")) {{
- volume = 0.1f;
- pitch = calculatePitchFromDistance((float)newDistance - (0.3f+0.1f*pingDelayTicks));
- repeat = false;
- repeatDelay = 0;
- attenuationType = ISound.AttenuationType.NONE;
- }};
- Minecraft.getMinecraft().getSoundHandler().playSound(sound);
- buildupSoundDelay = 4;
+ float vol = NotEnoughUpdates.INSTANCE.config.fishing.incomingFishIncSoundsVol/100f;
+ if(vol > 0) {
+ if(vol > 1) vol = 1;
+ final float volF = vol;
+
+ ISound sound = new PositionedSound(new ResourceLocation("note.pling")) {{
+ volume = volF;
+ pitch = calculatePitchFromDistance((float)newDistance - (0.3f+0.1f*pingDelayTicks));
+ repeat = false;
+ repeatDelay = 0;
+ attenuationType = ISound.AttenuationType.NONE;
+ }};
+
+ float oldLevel = Minecraft.getMinecraft().gameSettings.getSoundLevel(SoundCategory.RECORDS);
+ Minecraft.getMinecraft().gameSettings.setSoundLevel(SoundCategory.RECORDS, 1);
+ Minecraft.getMinecraft().getSoundHandler().playSound(sound);
+ Minecraft.getMinecraft().gameSettings.setSoundLevel(SoundCategory.RECORDS, oldLevel);
+ buildupSoundDelay = 4;
+ }
}
}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java
index ecd38bfd..1a266ca8 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java
@@ -172,7 +172,6 @@ public class PetInfoOverlay extends TextOverlay {
}
private static int getIdForPet(Pet pet) {
- System.out.println("getting for id");
for(Map.Entry<Integer, Pet> entry : config.petMap.entrySet()) {
if(entry.getValue() == pet) {
return entry.getKey();
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SlotLocking.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SlotLocking.java
index e7c5b460..4054c4b2 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SlotLocking.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SlotLocking.java
@@ -8,6 +8,9 @@ import io.github.moulberry.notenoughupdates.core.config.KeybindHelper;
import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils;
import io.github.moulberry.notenoughupdates.util.SBInfo;
import net.minecraft.client.Minecraft;
+import net.minecraft.client.audio.ISound;
+import net.minecraft.client.audio.PositionedSound;
+import net.minecraft.client.audio.SoundCategory;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.gui.inventory.GuiContainer;
@@ -18,6 +21,7 @@ import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
+import net.minecraft.util.ChatComponentText;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.GuiScreenEvent;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
@@ -96,9 +100,11 @@ public class SlotLocking {
private LockedSlot[] getDataForProfile() {
if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() || !NotEnoughUpdates.INSTANCE.config.slotLocking.enableSlotLocking) return null;
- if(SBInfo.getInstance().currentProfile == null) return null;
- SlotLockProfile profile = config.profileData.computeIfAbsent(SBInfo.getInstance().currentProfile,
+ String profileName = SBInfo.getInstance().currentProfile;
+ if(profileName == null) profileName = "generic";
+
+ SlotLockProfile profile = config.profileData.computeIfAbsent(profileName,
k->new SlotLockProfile());
if(profile.currentProfile < 0) profile.currentProfile = 0;
@@ -166,6 +172,28 @@ public class SlotLocking {
lockedSlots[slotNum].locked = !lockedSlots[slotNum].locked;
lockedSlots[slotNum].boundTo = -1;
+ if(NotEnoughUpdates.INSTANCE.config.slotLocking.slotLockSound) {
+ float vol = NotEnoughUpdates.INSTANCE.config.slotLocking.slotLockSoundVol/100f;
+ if(vol > 0) {
+ if(vol > 1) vol = 1;
+ final float volF = vol;
+ final boolean locked = lockedSlots[slotNum].locked;
+
+ ISound sound = new PositionedSound(new ResourceLocation("random.orb")) {{
+ volume = volF;
+ pitch = locked ? 0.943f : 0.1f;
+ repeat = false;
+ repeatDelay = 0;
+ attenuationType = ISound.AttenuationType.NONE;
+ }};
+
+ float oldLevel = Minecraft.getMinecraft().gameSettings.getSoundLevel(SoundCategory.PLAYERS);
+ Minecraft.getMinecraft().gameSettings.setSoundLevel(SoundCategory.PLAYERS, 1);
+ Minecraft.getMinecraft().getSoundHandler().playSound(sound);
+ Minecraft.getMinecraft().gameSettings.setSoundLevel(SoundCategory.PLAYERS, oldLevel);
+ }
+ }
+
if(isHotbar && lockedSlots[slotNum].locked) {
for(int i = 9; i <= 39; i++) {
if(lockedSlots[i] != null && lockedSlots[i].boundTo == slotNum) {
@@ -220,6 +248,7 @@ public class SlotLocking {
if(lockedSlots[pairingNum] == null) {
lockedSlots[pairingNum] = new LockedSlot();
}
+
lockedSlots[pairingNum].boundTo = slotNum;
lockedSlots[pairingNum].locked = false;
@@ -241,6 +270,47 @@ public class SlotLocking {
}
}
+ public void toggleLock(int lockIndex) {
+ LockedSlot[] lockedSlots = getDataForProfile();
+
+ if(lockedSlots != null) {
+ if(lockedSlots[lockIndex] == null) {
+ lockedSlots[lockIndex] = new LockedSlot();
+ }
+ lockedSlots[lockIndex].locked = !lockedSlots[lockIndex].locked;
+ lockedSlots[lockIndex].boundTo = -1;
+
+ if(NotEnoughUpdates.INSTANCE.config.slotLocking.slotLockSound) {
+ float vol = NotEnoughUpdates.INSTANCE.config.slotLocking.slotLockSoundVol/100f;
+ if(vol > 0) {
+ if(vol > 1) vol = 1;
+ final float volF = vol;
+ final boolean locked = lockedSlots[lockIndex].locked;
+
+ ISound sound = new PositionedSound(new ResourceLocation("random.orb")) {{
+ volume = volF;
+ pitch = locked ? 0.943f : 0.1f;
+ repeat = false;
+ repeatDelay = 0;
+ attenuationType = ISound.AttenuationType.NONE;
+ }};
+
+ float oldLevel = Minecraft.getMinecraft().gameSettings.getSoundLevel(SoundCategory.PLAYERS);
+ Minecraft.getMinecraft().gameSettings.setSoundLevel(SoundCategory.PLAYERS, 1);
+ Minecraft.getMinecraft().getSoundHandler().playSound(sound);
+ Minecraft.getMinecraft().gameSettings.setSoundLevel(SoundCategory.PLAYERS, oldLevel);
+ }
+ }
+
+ if(lockIndex < 9 && lockedSlots[lockIndex].locked) {
+ for(int i = 9; i <= 39; i++) {
+ if(lockedSlots[i] != null && lockedSlots[i].boundTo == lockIndex) {
+ lockedSlots[i].boundTo = -1;
+ }
+ }
+ }
+ }
+ }
@SubscribeEvent(priority = EventPriority.LOW)
public void drawScreenEvent(GuiScreenEvent.DrawScreenEvent.Post event) {
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiCustomEnchant.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiCustomEnchant.java
new file mode 100644
index 00000000..2fe42cc9
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiCustomEnchant.java
@@ -0,0 +1,451 @@
+package io.github.moulberry.notenoughupdates.miscgui;
+
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.miscfeatures.SlotLocking;
+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.gui.inventory.GuiContainer;
+import net.minecraft.client.model.ModelBook;
+import net.minecraft.client.renderer.GlStateManager;
+import net.minecraft.client.renderer.RenderHelper;
+import net.minecraft.init.Blocks;
+import net.minecraft.init.Items;
+import net.minecraft.inventory.ContainerChest;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.MathHelper;
+import net.minecraft.util.ResourceLocation;
+import org.lwjgl.input.Keyboard;
+import org.lwjgl.input.Mouse;
+import org.lwjgl.opengl.GL11;
+import org.lwjgl.util.glu.Project;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
+
+import java.util.*;
+
+public class GuiCustomEnchant extends Gui {
+
+ private static final GuiCustomEnchant INSTANCE = new GuiCustomEnchant();
+ private static final ResourceLocation TEXTURE = new ResourceLocation("notenoughupdates:custom_enchant_gui.png");
+ private static final ResourceLocation ENCHANTMENT_TABLE_BOOK_TEXTURE = new ResourceLocation("textures/entity/enchanting_table_book.png");
+ private static final ModelBook MODEL_BOOK = new ModelBook();
+
+ private enum EnchantState {
+ NO_ITEM,
+ INVALID_ITEM,
+ HAS_ITEM
+ }
+
+ private static class Enchantment {
+ public int slotIndex;
+ public String enchantName;
+ public int xpCost = 30;
+
+ public Enchantment(int slotIndex, String enchantName, int xpCost) {
+ this.slotIndex = slotIndex;
+ this.enchantName = enchantName;
+ this.xpCost = xpCost;
+ }
+ }
+
+ private int guiLeft;
+ private int guiTop;
+ private boolean shouldOverrideFast = false;
+
+ public float pageOpen;
+ public float pageOpenLast;
+ public float pageOpenRandom;
+ public float pageOpenVelocity;
+ public float bookOpen;
+ public float bookOpenLast;
+
+ private static List<Enchantment> applicable = new ArrayList<>();
+ private static List<Enchantment> removable = new ArrayList<>();
+
+ public Random random = new Random();
+
+ private EnchantState currentState = EnchantState.NO_ITEM;
+ private EnchantState lastState = EnchantState.NO_ITEM;
+
+ private static final int X_SIZE = 364;
+ private static final int Y_SIZE = 215;
+
+ public static GuiCustomEnchant getInstance() {
+ return INSTANCE;
+ }
+
+ public boolean shouldOverride(String containerName) {
+ shouldOverrideFast = containerName != null &&
+ NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() &&
+ containerName.equalsIgnoreCase("Enchant Item") && !Keyboard.isKeyDown(Keyboard.KEY_K);
+ if(!shouldOverrideFast) {
+ currentState = EnchantState.NO_ITEM;
+ applicable.clear();
+ removable.clear();
+ }
+ return shouldOverrideFast;
+ }
+
+ public void tick() {
+ GuiContainer chest = ((GuiContainer)Minecraft.getMinecraft().currentScreen);
+ ContainerChest cc = (ContainerChest) chest.inventorySlots;
+
+ ItemStack stack = cc.getLowerChestInventory().getStackInSlot(23);
+ ItemStack enchantingItemStack = cc.getLowerChestInventory().getStackInSlot(19);
+
+ if(stack == null || enchantingItemStack == null) {
+ currentState = EnchantState.NO_ITEM;
+ } else if(stack.getItem() != Items.dye) {
+ currentState = EnchantState.HAS_ITEM;
+ } else if(stack.getItemDamage() == 1) {
+ currentState = EnchantState.INVALID_ITEM;
+ } else {
+ currentState = EnchantState.NO_ITEM;
+ }
+
+ applicable.clear();
+ removable.clear();
+ if(currentState == EnchantState.HAS_ITEM) {
+ Set<String> playerEnchantIds = new HashSet<>();
+
+ NBTTagCompound tag = enchantingItemStack.getTagCompound();
+ if(tag != null) {
+ NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
+ if(ea != null) {
+ NBTTagCompound enchantments = ea.getCompoundTag("enchantments");
+ if(enchantments != null) {
+ playerEnchantIds.addAll(enchantments.getKeySet());
+ }
+ }
+ }
+
+ for(int i=0; i<15; i++) {
+ int slotIndex = 12 + (i%5) + (i/5)*9;
+ ItemStack book = cc.getLowerChestInventory().getStackInSlot(slotIndex);
+ if(book != null) {
+ NBTTagCompound tagBook = book.getTagCompound();
+ if(tagBook != null) {
+ NBTTagCompound ea = tagBook.getCompoundTag("ExtraAttributes");
+ if(ea != null) {
+ NBTTagCompound enchantments = ea.getCompoundTag("enchantments");
+ if(enchantments != null) {
+ for(String enchId : enchantments.getKeySet()) {
+ String name = Utils.cleanColour(book.getDisplayName());
+ if(name.equalsIgnoreCase("Bane of Arthropods")) {
+ name = "Bane of Arth.";
+ } else if(name.equalsIgnoreCase("Projectile Protection")) {
+ name = "Projectile Prot";
+ } else if(name.equalsIgnoreCase("Blast Protection")) {
+ name = "Blast Prot";
+ }
+ Enchantment enchantment = new Enchantment(slotIndex, name, 30);
+ if(playerEnchantIds.contains(enchId)) {
+ removable.add(enchantment);
+ } else {
+ applicable.add(enchantment);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ }
+
+ //Update book model state
+ if (lastState != currentState) {
+ this.lastState = currentState;
+
+ while (true) {
+ this.pageOpenRandom += (float)(this.random.nextInt(4) - this.random.nextInt(4));
+
+ if (this.pageOpen > this.pageOpenRandom + 1.0F || this.pageOpen < this.pageOpenRandom - 1.0F) {
+ break;
+ }
+ }
+ }
+
+ this.pageOpenLast = this.pageOpen;
+ this.bookOpenLast = this.bookOpen;
+
+ if (currentState == EnchantState.HAS_ITEM) {
+ this.bookOpen += 0.2F;
+ } else {
+ this.bookOpen -= 0.2F;
+ }
+
+ this.bookOpen = MathHelper.clamp_float(this.bookOpen, 0.0F, 1.0F);
+ float f1 = (this.pageOpenRandom - this.pageOpen) * 0.4F;
+ f1 = MathHelper.clamp_float(f1, -0.2F, 0.2F);
+ this.pageOpenVelocity += (f1 - this.pageOpenVelocity) * 0.9F;
+ this.pageOpen += this.pageOpenVelocity;
+ }
+
+ public void render(float partialTicks) {
+ if(!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) return;
+
+ GuiContainer chest = ((GuiContainer)Minecraft.getMinecraft().currentScreen);
+ ContainerChest cc = (ContainerChest) chest.inventorySlots;
+
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ int width = scaledResolution.getScaledWidth();
+ int height = scaledResolution.getScaledHeight();
+ int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
+ int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
+
+ guiLeft = (width-X_SIZE)/2;
+ guiTop = (height-Y_SIZE)/2;
+
+ List<String> tooltipToDisplay = null;
+ boolean disallowClick = false;
+ ItemStack stackOnMouse = Minecraft.getMinecraft().thePlayer.inventory.getItemStack();
+ int itemHoverX = -1;
+ int itemHoverY = -1;
+ boolean hoverLocked = false;
+
+ drawGradientRect(0, 0, width, height, 0xc0101010, 0xd0101010);
+
+ //Base Texture
+ Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(guiLeft, guiTop, X_SIZE, Y_SIZE,
+ 0, X_SIZE/512f, 0, Y_SIZE/512f, GL11.GL_NEAREST);
+
+ //Enchant book model
+ renderEnchantBook(scaledResolution, partialTicks);
+
+ //Available enchants (left)
+ for(int i=0; i<6; i++) {
+ if(applicable.size() <= i) break;
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(guiLeft+8, guiTop+18+16*i, 96, 16,
+ 0, 96/512f, 249/512f, (249+16)/512f, GL11.GL_NEAREST);
+
+ //Utils.drawTexturedRect(guiLeft+8, guiTop+18+16*i, 16, 16,
+ // 0/512f, 16/512f, 217/512f, (217+16)/512f, GL11.GL_NEAREST);
+
+ String levelStr = "35";
+ int levelWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(levelStr);
+ Minecraft.getMinecraft().fontRendererObj.drawString(levelStr, guiLeft+16-levelWidth/2-1, guiTop+18+16*i+4, 0x2d2102, false);
+ Minecraft.getMinecraft().fontRendererObj.drawString(levelStr, guiLeft+16-levelWidth/2+1, guiTop+18+16*i+4, 0x2d2102, false);
+ Minecraft.getMinecraft().fontRendererObj.drawString(levelStr, guiLeft+16-levelWidth/2, guiTop+18+16*i+4-1, 0x2d2102, false);
+ Minecraft.getMinecraft().fontRendererObj.drawString(levelStr, guiLeft+16-levelWidth/2, guiTop+18+16*i+4+1, 0x2d2102, false);
+ Minecraft.getMinecraft().fontRendererObj.drawString(levelStr, guiLeft+16-levelWidth/2, guiTop+18+16*i+4, 0xc8ff8f, false);
+
+ String name = applicable.get(i).enchantName;
+ Minecraft.getMinecraft().fontRendererObj.drawString(name, guiLeft+8+16+2, guiTop+18+16*i+4, 0xffffffdd, true);
+ }
+
+ //Removable enchants (left)
+ for(int i=0; i<6; i++) {
+ if(removable.size() <= i) break;
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(guiLeft+248, guiTop+18+16*i, 96, 16,
+ 0, 96/512f, 249/512f, (249+16)/512f, GL11.GL_NEAREST);
+
+ //Utils.drawTexturedRect(guiLeft+8, guiTop+18+16*i, 16, 16,
+ // 0/512f, 16/512f, 217/512f, (217+16)/512f, GL11.GL_NEAREST);
+
+ String levelStr = "35";
+ int levelWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(levelStr);
+ Minecraft.getMinecraft().fontRendererObj.drawString(levelStr, guiLeft+256-levelWidth/2-1, guiTop+18+16*i+4, 0x2d2102, false);
+ Minecraft.getMinecraft().fontRendererObj.drawString(levelStr, guiLeft+256-levelWidth/2+1, guiTop+18+16*i+4, 0x2d2102, false);
+ Minecraft.getMinecraft().fontRendererObj.drawString(levelStr, guiLeft+256-levelWidth/2, guiTop+18+16*i+4-1, 0x2d2102, false);
+ Minecraft.getMinecraft().fontRendererObj.drawString(levelStr, guiLeft+256-levelWidth/2, guiTop+18+16*i+4+1, 0x2d2102, false);
+ Minecraft.getMinecraft().fontRendererObj.drawString(levelStr, guiLeft+256-levelWidth/2, guiTop+18+16*i+4, 0xc8ff8f, false);
+
+ String name = removable.get(i).enchantName;
+ Minecraft.getMinecraft().fontRendererObj.drawString(name, guiLeft+248+16+2, guiTop+18+16*i+4, 0xffffffdd, true);
+ }
+
+ //Player Inventory Items
+ Minecraft.getMinecraft().fontRendererObj.drawString(Minecraft.getMinecraft().thePlayer.inventory.getDisplayName().getUnformattedText(),
+ guiLeft+102, guiTop+Y_SIZE - 96 + 2, 0x404040);
+ int inventoryStartIndex = cc.getLowerChestInventory().getSizeInventory();
+ GlStateManager.enableDepth();
+ for(int i=0; i<36; i++) {
+ int itemX = guiLeft+102+18*(i%9);
+ int itemY = guiTop+133+18*(i/9);
+
+ if(i >= 27) {
+ itemY += 4;
+ }
+
+ GlStateManager.pushMatrix();
+ GlStateManager.translate(guiLeft+102-8, guiTop+191-(inventoryStartIndex/9*18+89), 0);
+ Slot slot = cc.getSlot(inventoryStartIndex+i);
+ chest.drawSlot(slot);
+ GlStateManager.popMatrix();
+
+ if(mouseX >= itemX && mouseX < itemX+18 &&
+ mouseY >= itemY && mouseY < itemY+18) {
+ itemHoverX = itemX;
+ itemHoverY = itemY;
+ hoverLocked = SlotLocking.getInstance().isSlotLocked(slot);
+
+ if(slot.getHasStack()) {
+ tooltipToDisplay = slot.getStack().getTooltip(Minecraft.getMinecraft().thePlayer,
+ Minecraft.getMinecraft().gameSettings.advancedItemTooltips);
+ }
+ }
+ }
+
+ //Item enchant input
+ ItemStack itemEnchantInput = cc.getSlot(19).getStack();
+ {
+ int itemX = guiLeft+174;
+ int itemY = guiTop+58;
+
+ if(itemEnchantInput == null) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(itemX, itemY, 16, 16,
+ 0, 16/512f, 281/512f, (281+16)/512f, GL11.GL_NEAREST);
+ } else {
+ Utils.drawItemStack(itemEnchantInput, itemX, itemY);
+
+ }
+
+ if(mouseX >= itemX && mouseX < itemX+18 &&
+ mouseY >= itemY && mouseY < itemY+18) {
+ itemHoverX = itemX;
+ itemHoverY = itemY;
+
+ if(itemEnchantInput != null) {
+ tooltipToDisplay = itemEnchantInput.getTooltip(Minecraft.getMinecraft().thePlayer,
+ Minecraft.getMinecraft().gameSettings.advancedItemTooltips);
+ }
+ }
+ }
+
+
+ if(itemHoverX >= 0 && itemHoverY >= 0) {
+ GlStateManager.disableDepth();
+ GlStateManager.colorMask(true, true, true, false);
+ Gui.drawRect(itemHoverX, itemHoverY, itemHoverX + 16, itemHoverY + 16,
+ hoverLocked ? 0x80ff8080 : 0x80ffffff);
+ GlStateManager.colorMask(true, true, true, true);
+ GlStateManager.enableDepth();
+ }
+
+ GlStateManager.translate(0, 0, 300);
+ if(stackOnMouse != null) {
+ if(disallowClick) {
+ Utils.drawItemStack(new ItemStack(Item.getItemFromBlock(Blocks.barrier)), mouseX - 8, mouseY - 8);
+ } else {
+ Utils.drawItemStack(stackOnMouse, mouseX - 8, mouseY - 8);
+ }
+ } else if(tooltipToDisplay != null) {
+ Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1,
+ Minecraft.getMinecraft().fontRendererObj);
+ }
+ GlStateManager.translate(0, 0, -300);
+ }
+
+ private void renderEnchantBook(ScaledResolution scaledresolution, float partialTicks) {
+ GlStateManager.enableDepth();
+
+ GlStateManager.pushMatrix();
+ GlStateManager.matrixMode(5889);
+ GlStateManager.pushMatrix();
+ GlStateManager.loadIdentity();
+ GlStateManager.viewport((scaledresolution.getScaledWidth() - 320) / 2 * scaledresolution.getScaleFactor(),
+ (scaledresolution.getScaledHeight() - 240) / 2 * scaledresolution.getScaleFactor(),
+ 320 * scaledresolution.getScaleFactor(), 240 * scaledresolution.getScaleFactor());
+ GlStateManager.translate(0.0F, 0.33F, 0.0F);
+ Project.gluPerspective(90.0F, 1.3333334F, 9.0F, 80.0F);
+ GlStateManager.matrixMode(5888);
+ GlStateManager.loadIdentity();
+ RenderHelper.enableStandardItemLighting();
+ GlStateManager.translate(0.0F, 3.3F, -16.0F);
+ GlStateManager.scale(5, 5, 5);
+ GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(ENCHANTMENT_TABLE_BOOK_TEXTURE);
+ GlStateManager.rotate(20.0F, 1.0F, 0.0F, 0.0F);
+ float bookOpenAngle = this.bookOpenLast + (this.bookOpen - this.bookOpenLast) * partialTicks;
+ GlStateManager.translate((1.0F - bookOpenAngle) * 0.2F, (1.0F - bookOpenAngle) * 0.1F, (1.0F - bookOpenAngle) * 0.25F);
+ GlStateManager.rotate(-(1.0F - bookOpenAngle) * 90.0F - 90.0F, 0.0F, 1.0F, 0.0F);
+ GlStateManager.rotate(180.0F, 1.0F, 0.0F, 0.0F);
+ float pageAngle1 = this.pageOpenLast + (this.pageOpen - this.pageOpenLast) * partialTicks + 0.25F;
+ float pageAngle2 = this.pageOpenLast + (this.pageOpen - this.pageOpenLast) * partialTicks + 0.75F;
+ pageAngle1 = (pageAngle1 - (float) MathHelper.truncateDoubleToInt(pageAngle1)) * 1.6F - 0.3F;
+ pageAngle2 = (pageAngle2 - (float)MathHelper.truncateDoubleToInt(pageAngle2)) * 1.6F - 0.3F;
+
+ if (pageAngle1 < 0.0F) pageAngle1 = 0.0F;
+ if (pageAngle1 > 1.0F) pageAngle1 = 1.0F;
+ if (pageAngle2 < 0.0F) pageAngle2 = 0.0F;
+ if (pageAngle2 > 1.0F) pageAngle2 = 1.0F;
+
+ GlStateManager.enableRescaleNormal();
+ MODEL_BOOK.render(null, 0.0F, pageAngle1, pageAngle2, bookOpenAngle, 0.0F, 0.0625F);
+ GlStateManager.disableRescaleNormal();
+ RenderHelper.disableStandardItemLighting();
+ GlStateManager.matrixMode(5889);
+ GlStateManager.viewport(0, 0, Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight);
+ GlStateManager.popMatrix();
+ GlStateManager.matrixMode(5888);
+ GlStateManager.popMatrix();
+ RenderHelper.disableStandardItemLighting();
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+
+ GlStateManager.enableDepth();
+ }
+
+ public void overrideIsMouseOverSlot(Slot slot, int mouseX, int mouseY, CallbackInfoReturnable<Boolean> cir) {
+ if(shouldOverrideFast) {
+ boolean playerInv = slot.inventory == Minecraft.getMinecraft().thePlayer.inventory;
+ int slotId = slot.getSlotIndex();
+ if(playerInv && slotId < 36) {
+ slotId -= 9;
+ if(slotId < 0) slotId += 36;
+
+ int itemX = guiLeft+102+18*(slotId%9);
+ int itemY = guiTop+133+18*(slotId/9);
+
+ if(slotId >= 27) {
+ itemY += 4;
+ }
+
+ if(mouseX >= itemX && mouseX < itemX+18 &&
+ mouseY >= itemY && mouseY < itemY+18) {
+ cir.setReturnValue(true);
+ } else {
+ cir.setReturnValue(false);
+ }
+ } else if(slotId == 19) {
+ cir.setReturnValue(mouseX >= guiLeft+173 && mouseX < guiLeft+173+18 &&
+ mouseY >= guiTop+57 && mouseY < guiTop+57+18);
+ }
+ }
+ }
+
+ public boolean mouseInput(int mouseX, int mouseY) {
+ if(mouseX > guiLeft+102 && mouseX < guiLeft+102+144) {
+ if(mouseY > guiTop+133 && mouseY < guiTop+133+54) {
+ return false;
+ } else if(mouseY > guiTop+133+54+4 && mouseY < guiTop+133+54+4+18) {
+ return false;
+ }
+ }
+ if(mouseX >= guiLeft+173 && mouseX < guiLeft+173+18 &&
+ mouseY >= guiTop+57 && mouseY < guiTop+57+18) {
+ return false;
+ }
+ return true;
+ }
+
+ public boolean keyboardInput() {
+ return Keyboard.getEventKey() != Keyboard.KEY_ESCAPE &&
+ (!NotEnoughUpdates.INSTANCE.config.slotLocking.enableSlotLocking ||
+ Keyboard.getEventKey() != NotEnoughUpdates.INSTANCE.config.slotLocking.slotLockKey);
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java
index 165cb494..d4d9ded3 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java
@@ -2,13 +2,11 @@ package io.github.moulberry.notenoughupdates.miscgui;
import com.google.gson.JsonObject;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
-import io.github.moulberry.notenoughupdates.util.SBAIntegration;
-import io.github.moulberry.notenoughupdates.util.TexLoc;
+import io.github.moulberry.notenoughupdates.core.config.KeybindHelper;
+import io.github.moulberry.notenoughupdates.miscfeatures.SlotLocking;
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.gui.inventory.GuiChest;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.inventory.ContainerChest;
@@ -552,7 +550,13 @@ public class TradeWindow {
int y = 104+18*(index / 9);
if(index < 9) y = 180;
- Utils.drawItemStack(stack, guiLeft+x, guiTop+y);
+ chest.drawSlot(new Slot(Minecraft.getMinecraft().thePlayer.inventory, index, guiLeft+x, guiTop+y));
+ //Utils.drawItemStack(stack, guiLeft+x, guiTop+y);
+
+ int col = 0x80ffffff;
+ if(SlotLocking.getInstance().isSlotIndexLocked(index)) {
+ col = 0x80ff8080;
+ }
if(mouseX > guiLeft+x-1 && mouseX < guiLeft+x+18) {
if(mouseY > guiTop+y-1 && mouseY < guiTop+y+18) {
@@ -562,7 +566,7 @@ public class TradeWindow {
GlStateManager.disableDepth();
GlStateManager.colorMask(true, true, true, false);
Utils.drawGradientRect(guiLeft+x, guiTop+y,
- guiLeft+x + 16, guiTop+y + 16, -2130706433, -2130706433);
+ guiLeft+x + 16, guiTop+y + 16, col, col);
GlStateManager.colorMask(true, true, true, true);
GlStateManager.enableLighting();
GlStateManager.enableDepth();
@@ -890,37 +894,9 @@ public class TradeWindow {
}
}
- if(stackToRender == null && !SBAIntegration.isFreezeBackpack()) lastBackpack = null;
- if(SBAIntegration.isFreezeBackpack()) {
- if(lastBackpack != null) {
- SBAIntegration.setActiveBackpack(lastBackpack, lastBackpackX, lastBackpackY);
- GlStateManager.translate(0, 0, 100);
- SBAIntegration.renderActiveBackpack(mouseX, mouseY, Minecraft.getMinecraft().fontRendererObj);
- GlStateManager.translate(0, 0, -100);
- }
- } else {
- if(stackToRender != null) {
- String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(stackToRender);
- boolean renderedBackpack;
- if(internalname != null && (internalname.endsWith("BACKPACK") || internalname.equals("NEW_YEAR_CAKE_BAG"))) {
- lastBackpack = stackToRender;
- lastBackpackX = mouseX;
- lastBackpackY = mouseY;
- renderedBackpack = SBAIntegration.setActiveBackpack(lastBackpack, lastBackpackX, lastBackpackY);
- if(renderedBackpack) {
- GlStateManager.translate(0, 0, 100);
- renderedBackpack = SBAIntegration.renderActiveBackpack(mouseX, mouseY, Minecraft.getMinecraft().fontRendererObj);
- GlStateManager.translate(0, 0, -100);
- }
- } else {
- renderedBackpack = false;
- }
- if(!renderedBackpack) {
- lastBackpack = null;
- tooltipToDisplay = stackToRender.getTooltip(Minecraft.getMinecraft().thePlayer,
- Minecraft.getMinecraft().gameSettings.advancedItemTooltips);
- }
- }
+ if(stackToRender != null) {
+ tooltipToDisplay = stackToRender.getTooltip(Minecraft.getMinecraft().thePlayer,
+ Minecraft.getMinecraft().gameSettings.advancedItemTooltips);
}
if(tooltipToDisplay != null) {
@@ -956,9 +932,12 @@ public class TradeWindow {
if(mouseX > guiLeft+x && mouseX < guiLeft+x+16) {
if(mouseY > guiTop+y && mouseY < guiTop+y+16) {
Slot slot = chest.inventorySlots.getSlotFromInventory(Minecraft.getMinecraft().thePlayer.inventory, index);
- Minecraft.getMinecraft().playerController.windowClick(
- chest.inventorySlots.windowId,
- slot.slotNumber, 2, 3, Minecraft.getMinecraft().thePlayer);
+ if(!NotEnoughUpdates.INSTANCE.config.slotLocking.lockSlotsInTrade ||
+ !SlotLocking.getInstance().isSlotLocked(slot)) {
+ Minecraft.getMinecraft().playerController.windowClick(
+ chest.inventorySlots.windowId,
+ slot.slotNumber, 2, 3, Minecraft.getMinecraft().thePlayer);
+ }
return;
}
}
@@ -1032,6 +1011,39 @@ public class TradeWindow {
}
public static boolean keyboardInput() {
+ if(NotEnoughUpdates.INSTANCE.config.slotLocking.enableSlotLocking &&
+ NotEnoughUpdates.INSTANCE.config.slotLocking.lockSlotsInTrade &&
+ !Keyboard.isRepeatEvent() &&
+ KeybindHelper.isKeyPressed(NotEnoughUpdates.INSTANCE.config.slotLocking.slotLockKey)) {
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ int width = scaledResolution.getScaledWidth();
+ int height = scaledResolution.getScaledHeight();
+
+ int mouseX = Mouse.getEventX() * width / Minecraft.getMinecraft().displayWidth;
+ int mouseY = height - Mouse.getEventY() * height / Minecraft.getMinecraft().displayHeight - 1;
+
+ int index=0;
+ for(ItemStack stack : Minecraft.getMinecraft().thePlayer.inventory.mainInventory) {
+ if(stack == null) {
+ index++;
+ continue;
+ }
+
+ int x = 8+18*(index % 9);
+ int y = 104+18*(index / 9);
+ if(index < 9) y = 180;
+
+ if(mouseX > guiLeft+x && mouseX < guiLeft+x+16) {
+ if(mouseY > guiTop+y && mouseY < guiTop+y+16) {
+ SlotLocking.getInstance().toggleLock(index);
+ return true;
+ }
+ }
+
+ index++;
+ }
+ }
+
return Keyboard.getEventKey() != Keyboard.KEY_ESCAPE;
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java
index 81f0d857..1312cd17 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java
@@ -7,6 +7,7 @@ import io.github.moulberry.notenoughupdates.miscfeatures.EnchantingSolvers;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.miscfeatures.PetInfoOverlay;
import io.github.moulberry.notenoughupdates.miscfeatures.SlotLocking;
+import io.github.moulberry.notenoughupdates.miscgui.GuiCustomEnchant;
import io.github.moulberry.notenoughupdates.miscgui.StorageOverlay;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
@@ -74,6 +75,7 @@ public abstract class MixinGuiContainer extends GuiScreen {
@Inject(method="isMouseOverSlot", at=@At("HEAD"), cancellable = true)
public void isMouseOverSlot(Slot slotIn, int mouseX, int mouseY, CallbackInfoReturnable<Boolean> cir) {
StorageOverlay.getInstance().overrideIsMouseOverSlot(slotIn, mouseX, mouseY, cir);
+ GuiCustomEnchant.getInstance().overrideIsMouseOverSlot(slotIn, mouseX, mouseY, cir);
}
@Redirect(method="drawScreen", at=@At(value="INVOKE", target = "Lnet/minecraft/client/gui/inventory/GuiContainer;drawGradientRect(IIIIII)V"))
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinNetHandlerPlayClient.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinNetHandlerPlayClient.java
index 85811606..95f2ab0e 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinNetHandlerPlayClient.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinNetHandlerPlayClient.java
@@ -43,6 +43,11 @@ public class MixinNetHandlerPlayClient {
}
}
+ @Inject(method="handleSpawnMob", at=@At("RETURN"))
+ public void handleSpawnMob(S0FPacketSpawnMob packetIn, CallbackInfo ci) {
+ //CollectionLogManager.getInstance().onEntityMetadataUpdated(packetIn.getEntityID());
+ }
+
@Inject(method="handleSetSlot", at=@At("RETURN"))
public void handleSetSlot(S2FPacketSetSlot packetIn, CallbackInfo ci) {
EnchantingSolvers.processInventoryContents(false);
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java
index 0982184a..fbf3a5ae 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java
@@ -564,6 +564,34 @@ public class NEUConfig extends Config {
)
@ConfigEditorKeybind(defaultKey = Keyboard.KEY_L)
public int slotLockKey = Keyboard.KEY_L;
+
+ @Expose
+ @ConfigOption(
+ name = "Lock Slots in Trade",
+ desc = "Prevents trading locked items in the custom trade windows"
+ )
+ @ConfigEditorBoolean
+ public boolean lockSlotsInTrade = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Slot Lock Sound",
+ desc = "Play a ding when locking/unlocking slots"
+ )
+ @ConfigEditorBoolean
+ public boolean slotLockSound = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Slot Lock Sound Vol.",
+ desc = "Set the volume of the ding sound"
+ )
+ @ConfigEditorSlider(
+ minValue = 0,
+ maxValue = 100,
+ minStep = 1
+ )
+ public float slotLockSoundVol = 20;
}
public static class TooltipTweaks {
@@ -1209,7 +1237,7 @@ public class NEUConfig extends Config {
@ConfigAccordionId(id = 1)
public boolean enderchestPreview = true;
- //@Expose
+ @Expose
@ConfigOption(
name = "Backpack Preview",
desc = "THIS FEATURE IS CURRENTLY DISABLED BECAUSE HYPIXEL IS TOO LAZY TO ADD A SINGLE COMMAND LMFAO"//"Preview Backpacks when hovering over the selector on the left side"
@@ -1642,7 +1670,7 @@ public class NEUConfig extends Config {
@Expose
@ConfigOption(
- name = "Approaching Sound",
+ name = "Approach Sound",
desc = "Play low-pitched ding sounds while the yellow '!' is visible"
)
@ConfigEditorBoolean
@@ -1650,6 +1678,40 @@ public class NEUConfig extends Config {
public boolean incomingFishIncSounds = false;
@ConfigOption(
+ name = "Volumes",
+ desc = ""
+ )
+ @ConfigAccordionId(id = 3)
+ @ConfigEditorAccordion(id = 5)
+ public boolean incomingFishVolumeAccordion = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Hooked Sound Vol.",
+ desc = "Set the volume of the hooked sound"
+ )
+ @ConfigEditorSlider(
+ minValue = 0,
+ maxValue = 100,
+ minStep = 1
+ )
+ @ConfigAccordionId(id = 5)
+ public float incomingFishHookedSoundsVol = 25;
+
+ @Expose
+ @ConfigOption(
+ name = "Approach Sound Vol.",
+ desc = "Set the volume of the approaching sound"
+ )
+ @ConfigEditorSlider(
+ minValue = 0,
+ maxValue = 100,
+ minStep = 1
+ )
+ @ConfigAccordionId(id = 5)
+ public float incomingFishIncSoundsVol = 10;
+
+ @ConfigOption(
name = "Fishing Particles",
desc = ""
)
@@ -1677,7 +1739,7 @@ public class NEUConfig extends Config {
@ConfigOption(
name = "Particle Type",
desc = "Change the type of the particle that is spawned\n" +
- "Particle types with (RGB) support custom colours" +
+ "Particle types with (RGB) support custom colours\n" +
"Set to 'NONE' to disable particles"
)
@ConfigEditorDropdown(
@@ -1708,7 +1770,7 @@ public class NEUConfig extends Config {
@ConfigOption(
name = "Particle Type",
desc = "Change the type of the particle that is spawned\n" +
- "Particle types with (RGB) support custom colours" +
+ "Particle types with (RGB) support custom colours\n" +
"Set to 'NONE' to disable particles"
)
@ConfigEditorDropdown(
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java
index 13ada4bf..883a0b7a 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java
@@ -9,7 +9,6 @@ import com.google.gson.JsonPrimitive;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
-import io.github.moulberry.notenoughupdates.util.SBAIntegration;
import io.github.moulberry.notenoughupdates.cosmetics.ShaderManager;
import io.github.moulberry.notenoughupdates.itemeditor.GuiElementTextField;
import io.github.moulberry.notenoughupdates.util.SBInfo;
@@ -435,7 +434,6 @@ public class GuiProfileViewer extends GuiScreen {
@Override
protected void keyTyped(char typedChar, int keyCode) throws IOException {
super.keyTyped(typedChar, keyCode);
- SBAIntegration.keyTyped(keyCode);
switch (currentPage) {
case INVS:
keyTypedInvs(typedChar, keyCode);
@@ -1099,6 +1097,7 @@ public class GuiProfileViewer extends GuiScreen {
MINION_RARITY_TO_NUM.put("RARE", "2");
MINION_RARITY_TO_NUM.put("EPIC", "3");
MINION_RARITY_TO_NUM.put("LEGENDARY", "4");
+ MINION_RARITY_TO_NUM.put("MYTHIC", "5");
}
private void drawPetsPage(int mouseX, int mouseY, float partialTicks) {
JsonObject petsInfo = profile.getPetsInfo(profileId);
@@ -1133,11 +1132,13 @@ public class GuiProfileViewer extends GuiScreen {
sortedPets.sort((pet1, pet2) -> {
String tier1 = pet1.get("tier").getAsString();
String tierNum1 = MINION_RARITY_TO_NUM.get(tier1);
+ if(tierNum1 == null) return 1;
int tierNum1I = Integer.parseInt(tierNum1);
float exp1 = pet1.get("exp").getAsFloat();
String tier2 = pet2.get("tier").getAsString();
String tierNum2 = MINION_RARITY_TO_NUM.get(tier2);
+ if(tierNum2 == null) return -1;
int tierNum2I = Integer.parseInt(tierNum2);
float exp2 = pet2.get("exp").getAsFloat();
@@ -2010,37 +2011,10 @@ public class GuiProfileViewer extends GuiScreen {
}
}
}
- if(stackToRender == null && !SBAIntegration.isFreezeBackpack()) lastBackpack = null;
- if(SBAIntegration.isFreezeBackpack()) {
- if(lastBackpack != null) {
- SBAIntegration.setActiveBackpack(lastBackpack, lastBackpackX, lastBackpackY);
- GlStateManager.translate(0, 0, 100);
- SBAIntegration.renderActiveBackpack(mouseX, mouseY, fontRendererObj);
- GlStateManager.translate(0, 0, -100);
- }
- } else {
- if(stackToRender != null) {
- String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(stackToRender);
- boolean renderedBackpack;
- if(internalname != null && (internalname.endsWith("BACKPACK") || internalname.equals("NEW_YEAR_CAKE_BAG"))) {
- lastBackpack = stackToRender;
- lastBackpackX = mouseX;
- lastBackpackY = mouseY;
- renderedBackpack = SBAIntegration.setActiveBackpack(lastBackpack, lastBackpackX, lastBackpackY);
- if(renderedBackpack) {
- GlStateManager.translate(0, 0, 100);
- renderedBackpack = SBAIntegration.renderActiveBackpack(mouseX, mouseY, fontRendererObj);
- GlStateManager.translate(0, 0, -100);
- }
- } else {
- renderedBackpack = false;
- }
- if(!renderedBackpack) {
- lastBackpack = null;
- tooltipToDisplay = stackToRender.getTooltip(Minecraft.getMinecraft().thePlayer, false);
- }
- }
+ if(stackToRender != null) {
+ tooltipToDisplay = stackToRender.getTooltip(Minecraft.getMinecraft().thePlayer, false);
}
+
}
private String niceUuid(String uuidStr) {
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Constants.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Constants.java
index 485ca19c..f095fc64 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/Constants.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Constants.java
@@ -1,9 +1,28 @@
package io.github.moulberry.notenoughupdates.util;
-import com.google.gson.JsonObject;
+import com.google.gson.*;
+import io.github.moulberry.notenoughupdates.collectionlog.CollectionConstant;
+
+import java.lang.reflect.Type;
+import java.util.concurrent.locks.ReentrantLock;
+import java.util.regex.Pattern;
public class Constants {
+ private static class PatternSerializer implements JsonDeserializer<Pattern>, JsonSerializer<Pattern> {
+ @Override
+ public Pattern deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
+ return Pattern.compile(json.getAsString());
+ }
+ @Override
+ public JsonElement serialize(Pattern src, Type typeOfSrc, JsonSerializationContext context) {
+ return new JsonPrimitive(src.pattern());
+ }
+ }
+
+ private static final Gson gson = new GsonBuilder().setPrettyPrinting()
+ .registerTypeAdapter(Pattern.class, new PatternSerializer()).create();
+
public static JsonObject BONUSES;
public static JsonObject DISABLE;
public static JsonObject ENCHANTS;
@@ -15,23 +34,29 @@ public class Constants {
public static JsonObject ESSENCECOSTS;
public static JsonObject FAIRYSOULS;
public static JsonObject REFORGESTONES;
+ public static CollectionConstant COLLECTIONLOG;
+
+ private static final ReentrantLock lock = new ReentrantLock();
public static void reload() {
- BONUSES = Utils.getConstant("bonuses");
- DISABLE = Utils.getConstant("disable");
- ENCHANTS = Utils.getConstant("enchants");
- LEVELING = Utils.getConstant("leveling");
- MISC = Utils.getConstant("misc");
- PETNUMS = Utils.getConstant("petnums");
- PETS = Utils.getConstant("pets");
- PARENTS = Utils.getConstant("parents");
- ESSENCECOSTS = Utils.getConstant("essencecosts");
- FAIRYSOULS = Utils.getConstant("fairy_souls");
- REFORGESTONES = Utils.getConstant("reforgestones");
- }
+ try {
+ lock.lock();
- static {
- reload();
+ BONUSES = Utils.getConstant("bonuses", gson);
+ DISABLE = Utils.getConstant("disable", gson);
+ ENCHANTS = Utils.getConstant("enchants", gson);
+ LEVELING = Utils.getConstant("leveling", gson);
+ MISC = Utils.getConstant("misc", gson);
+ PETNUMS = Utils.getConstant("petnums", gson);
+ PETS = Utils.getConstant("pets", gson);
+ PARENTS = Utils.getConstant("parents", gson);
+ ESSENCECOSTS = Utils.getConstant("essencecosts", gson);
+ FAIRYSOULS = Utils.getConstant("fairy_souls", gson);
+ REFORGESTONES = Utils.getConstant("reforgestones", gson);
+ //COLLECTIONLOG = Utils.getConstant("collectionlog", gson, CollectionConstant.class);
+ } finally {
+ lock.unlock();
+ }
}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/SBAIntegration.java b/src/main/java/io/github/moulberry/notenoughupdates/util/SBAIntegration.java
deleted file mode 100644
index 04f53bf3..00000000
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/SBAIntegration.java
+++ /dev/null
@@ -1,217 +0,0 @@
-package io.github.moulberry.notenoughupdates.util;
-
-import io.github.moulberry.notenoughupdates.util.Utils;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.FontRenderer;
-import net.minecraft.client.gui.ScaledResolution;
-import net.minecraft.client.gui.inventory.GuiContainer;
-import net.minecraft.client.settings.KeyBinding;
-import net.minecraft.item.ItemStack;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.List;
-
-public class SBAIntegration {
-
- private static boolean hasSBA = true;
- private static Class<?> skyblockAddonsClass = null;
- private static Method skyblockAddons_getInstance = null;
- private static Method skyblockAddons_getUtils = null;
- private static Class<?> backpackManagerClass = null;
- private static Method backpackManager_getFromItem = null;
- private static Class<?> backpackClass = null;
- private static Method backpackClass_setX= null;
- private static Method backpackClass_setY = null;
- private static Class<?> utilsClass = null;
- private static Method utils_setBackpackToPreview = null;
- public static boolean setActiveBackpack(ItemStack stack, int mouseX, int mouseY) {
- if(!hasSBA) return false;
- try {
- if(skyblockAddonsClass == null) {
- skyblockAddonsClass = Class.forName("codes.biscuit.skyblockaddons.SkyblockAddons");
- }
- if(skyblockAddons_getInstance == null) {
- skyblockAddons_getInstance = skyblockAddonsClass.getDeclaredMethod("getInstance");
- }
- if(skyblockAddons_getUtils == null) {
- skyblockAddons_getUtils = skyblockAddonsClass.getDeclaredMethod("getUtils");
- }
- if(backpackManagerClass == null) {
- backpackManagerClass = Class.forName("codes.biscuit.skyblockaddons.features.backpacks.BackpackManager");
- }
- if(backpackManager_getFromItem == null) {
- backpackManager_getFromItem = backpackManagerClass.getDeclaredMethod("getFromItem", ItemStack.class);
- }
- if(backpackClass == null) {
- try { backpackClass = Class.forName("codes.biscuit.skyblockaddons.features.backpacks.Backpack"); } catch(Exception ignored){}
- }
- if(backpackClass == null) {
- backpackClass = Class.forName("codes.biscuit.skyblockaddons.features.backpacks.ContainerPreview");
- }
- if(backpackClass_setX == null) {
- backpackClass_setX = backpackClass.getDeclaredMethod("setX", int.class);
- }
- if(backpackClass_setY == null) {
- backpackClass_setY = backpackClass.getDeclaredMethod("setY", int.class);
- }
- if(utilsClass == null) {
- utilsClass = Class.forName("codes.biscuit.skyblockaddons.utils.Utils");
- }
- if(utils_setBackpackToPreview == null) {
- try { utils_setBackpackToPreview = utilsClass.getDeclaredMethod("setBackpackToPreview", backpackClass); } catch(Exception ignored){}
- }
- if(utils_setBackpackToPreview == null) {
- utils_setBackpackToPreview = utilsClass.getDeclaredMethod("setContainerPreviewToRender", backpackClass);;
- }
- } catch(Exception e) {
- e.printStackTrace();
- hasSBA = false;
- return false;
- }
- try {
- Object skyblockAddons = skyblockAddons_getInstance.invoke(null);
- Object utils = skyblockAddons_getUtils.invoke(skyblockAddons);
- if(stack == null) {
- utils_setBackpackToPreview.invoke(utils, (Object) null);
- } else {
- Object backpack = backpackManager_getFromItem.invoke(null, stack);
- backpackClass_setX.invoke(backpack, mouseX);
- backpackClass_setY.invoke(backpack, mouseY);
- utils_setBackpackToPreview.invoke(utils, backpack);
- }
- } catch(Exception e) {
- e.printStackTrace();
- return false;
- }
- return true;
- }
-
- private static Field guiContainerHook_freezeBackpack = null;
- public static boolean isFreezeBackpack() {
- if(!hasSBA) return false;
- try {
- if(guiContainerHookClass == null) {
- guiContainerHookClass = Class.forName("codes.biscuit.skyblockaddons.asm.hooks.GuiContainerHook");
- }
- if(guiContainerHook_freezeBackpack == null) {
- guiContainerHook_freezeBackpack = guiContainerHookClass.getDeclaredField("freezeBackpack");
- guiContainerHook_freezeBackpack.setAccessible(true);
- }
- } catch(Exception e) {
- e.printStackTrace();
- hasSBA = false;
- return false;
- }
- try {
- return (boolean) guiContainerHook_freezeBackpack.get(null);
- } catch(Exception e) {
- e.printStackTrace();
- return false;
- }
- }
-
- public static boolean setFreezeBackpack(boolean freezeBackpack) {
- if(!hasSBA) return false;
- try {
- if(guiContainerHookClass == null) {
- guiContainerHookClass = Class.forName("codes.biscuit.skyblockaddons.asm.hooks.GuiContainerHook");
- }
- if(guiContainerHook_freezeBackpack == null) {
- guiContainerHook_freezeBackpack = guiContainerHookClass.getDeclaredField("freezeBackpack");
- guiContainerHook_freezeBackpack.setAccessible(true);
- }
- } catch(Exception e) {
- e.printStackTrace();
- hasSBA = false;
- return false;
- }
- try {
- guiContainerHook_freezeBackpack.set(null, freezeBackpack);
- return true;
- } catch(Exception e) {
- e.printStackTrace();
- return false;
- }
- }
-
- private static Method guiContainerHook_keyTyped = null;
- private static Method skyblockAddons_getFreezeBackpackKey = null;
- public static boolean keyTyped(int keyCode) {
- if(!hasSBA) return false;
- try {
- if(skyblockAddonsClass == null) {
- skyblockAddonsClass = Class.forName("codes.biscuit.skyblockaddons.SkyblockAddons");
- }
- if(skyblockAddons_getInstance == null) {
- skyblockAddons_getInstance = skyblockAddonsClass.getDeclaredMethod("getInstance");
- }
- if(skyblockAddons_getFreezeBackpackKey == null) {
- skyblockAddons_getFreezeBackpackKey = skyblockAddonsClass.getDeclaredMethod("getFreezeBackpackKey");
- }
- if(guiContainerHookClass == null) {
- guiContainerHookClass = Class.forName("codes.biscuit.skyblockaddons.asm.hooks.GuiContainerHook");
- }
- if(guiContainerHook_keyTyped == null) {
- guiContainerHook_keyTyped = guiContainerHookClass.getDeclaredMethod("keyTyped", int.class);
- }
- } catch(Exception e) {
- e.printStackTrace();
- hasSBA = false;
- return false;
- }
- try {
- Object skyblockAddons = skyblockAddons_getInstance.invoke(null);
- if(!isFreezeBackpack() && ((KeyBinding)skyblockAddons_getFreezeBackpackKey.invoke(skyblockAddons)).getKeyCode() == keyCode) {
- setFreezeBackpack(true);
- } else {
- guiContainerHook_keyTyped.invoke(null, keyCode);
- }
- } catch(Exception e) {
- e.printStackTrace();
- return false;
- }
- return true;
- }
-
- private static Class<?> guiContainerHookClass = null;
- private static Method guiContainerHook_drawBackpacks = null;
- public static boolean renderActiveBackpack(int mouseX, int mouseY, FontRenderer fontRendererObj) {
- if(!hasSBA) return false;
- try {
- if(guiContainerHookClass == null) {
- guiContainerHookClass = Class.forName("codes.biscuit.skyblockaddons.asm.hooks.GuiContainerHook");
- }
- if(guiContainerHook_drawBackpacks == null) {
- guiContainerHook_drawBackpacks = guiContainerHookClass.getDeclaredMethod("drawBackpacks",
- GuiContainer.class, int.class, int.class, FontRenderer.class);
- }
- } catch(Exception e) {
- e.printStackTrace();
- hasSBA = false;
- return false;
- }
- try {
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- int width = scaledResolution.getScaledWidth();
- int height = scaledResolution.getScaledHeight();
-
- if(Minecraft.getMinecraft().currentScreen instanceof GuiContainer) {
- guiContainerHook_drawBackpacks.invoke(null, Minecraft.getMinecraft().currentScreen, mouseX, mouseY, fontRendererObj);
- } else {
- GuiContainer container = new GuiContainer(null) {
- protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
- }
- };
- container.setWorldAndResolution(Minecraft.getMinecraft(), width, height);
-
- guiContainerHook_drawBackpacks.invoke(null, container, mouseX, mouseY, fontRendererObj);
- }
- } catch(Exception e) {
- e.printStackTrace();
- return false;
- }
- return true;
- }
-
-}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java b/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java
index 73d61a1e..df981359 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java
@@ -2,7 +2,6 @@ package io.github.moulberry.notenoughupdates.util;
import com.google.gson.JsonObject;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
-import io.github.moulberry.notenoughupdates.miscfeatures.EnchantingSolvers;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiChest;
import net.minecraft.client.network.NetworkPlayerInfo;
@@ -17,7 +16,6 @@ import net.minecraftforge.client.event.GuiOpenEvent;
import net.minecraftforge.event.world.WorldEvent;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
-import net.minecraftforge.fml.common.gameevent.TickEvent;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@@ -115,7 +113,14 @@ public class SBInfo {
return mode;
}
+ private static final String profilePrefix = "\u00a7r\u00a7e\u00a7lProfile: \u00a7r\u00a7a";
+ private static final String skillsPrefix = "\u00a7r\u00a7e\u00a7lSkills: \u00a7r\u00a7a";
+
+ private static final Pattern SKILL_LEVEL_PATTERN = Pattern.compile("([^0-9:]+) (\\d{1,2})");
+
public void tick() {
+ isInDungeon = false;
+
long currentTime = System.currentTimeMillis();
if(Minecraft.getMinecraft().thePlayer != null &&
@@ -130,9 +135,17 @@ public class SBInfo {
try {
for(NetworkPlayerInfo info : Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap()) {
String name = Minecraft.getMinecraft().ingameGUI.getTabList().getPlayerName(info);
- final String profilePrefix = "\u00a7r\u00a7e\u00a7lProfile: \u00a7r\u00a7a";
if(name.startsWith(profilePrefix)) {
currentProfile = Utils.cleanColour(name.substring(profilePrefix.length()));
+ } else if(name.startsWith(skillsPrefix)) {
+ String levelInfo = name.substring(skillsPrefix.length()).trim();
+ Matcher matcher = SKILL_LEVEL_PATTERN.matcher(Utils.cleanColour(levelInfo).split(":")[0]);
+ if(matcher.find()) {
+ try {
+ int level = Integer.parseInt(matcher.group(2).trim());
+ XPInformation.getInstance().updateLevel(matcher.group(1).toLowerCase().trim(), level);
+ } catch(Exception ignored) {}
+ }
}
}
} catch(Exception e) {
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 d77f3c9e..4c32c49c 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java
@@ -1,10 +1,7 @@
package io.github.moulberry.notenoughupdates.util;
import com.google.common.base.Splitter;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonPrimitive;
+import com.google.gson.*;
import com.mojang.authlib.Agent;
import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
import com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication;
@@ -43,12 +40,16 @@ import org.lwjgl.util.glu.Project;
import javax.swing.*;
import java.awt.*;
+import java.io.BufferedReader;
import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStreamReader;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.net.Proxy;
import java.nio.FloatBuffer;
+import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.*;
import java.util.List;
@@ -848,14 +849,18 @@ public class Utils {
drawHoveringText(textLines, mouseX, mouseY, screenWidth, screenHeight, maxTextWidth, font, true);
}
- public static JsonObject getConstant(String constant) {
+ public static JsonObject getConstant(String constant, Gson gson) {
+ return getConstant(constant, gson, JsonObject.class);
+ }
+
+ public static <T> T getConstant(String constant, Gson gson, Class<T> clazz) {
File repo = NotEnoughUpdates.INSTANCE.manager.repoLocation;
if(repo.exists()) {
File jsonFile = new File(repo, "constants/"+constant+".json");
- try {
- return NotEnoughUpdates.INSTANCE.manager.getJsonFromFile(jsonFile);
- } catch (Exception ignored) {
- }
+ try(BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(jsonFile), StandardCharsets.UTF_8))) {
+ T obj = gson.fromJson(reader, clazz);
+ return obj;
+ } catch(Exception e) { return null; }
}
return null;
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/XPInformation.java b/src/main/java/io/github/moulberry/notenoughupdates/util/XPInformation.java
index c3535ab4..cde93ddf 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/XPInformation.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/XPInformation.java
@@ -31,9 +31,13 @@ public class XPInformation {
}
private HashMap<String, SkillInfo> skillInfoMap = new HashMap<>();
+ public HashMap<String, Float> updateWithPercentage = new HashMap<>();
+
+ public int correctionCounter = 0;
private static Splitter SPACE_SPLITTER = Splitter.on(" ").omitEmptyStrings().trimResults();
private static Pattern SKILL_PATTERN = Pattern.compile("\\+(\\d+(?:,\\d+)*(?:\\.\\d+)?) (.+) \\((\\d+(?:,\\d+)*(?:\\.\\d+)?)/(\\d+(?:,\\d+)*(?:\\.\\d+)?)\\)");
+ private static Pattern SKILL_PATTERN_ALT = Pattern.compile("\\+(\\d+(?:,\\d+)*(?:\\.\\d+)?) (.+) \\((\\d\\d?(?:\\.\\d\\d?)?)%\\)");
public HashMap<String, SkillInfo> getSkillInfoMap() {
return skillInfoMap;
@@ -43,7 +47,7 @@ public class XPInformation {
return skillInfoMap.get(skillName.toLowerCase());
}
- @SubscribeEvent(priority = EventPriority.HIGHEST)
+ @SubscribeEvent(priority = EventPriority.HIGHEST, receiveCanceled = true)
public void onChatReceived(ClientChatReceivedEvent event) {
if(event.type == 2) {
JsonObject leveling = Constants.LEVELING;
@@ -78,8 +82,54 @@ public class XPInformation {
}
skillInfoMap.put(skillS.toLowerCase(), skillInfo);
+ return;
+ }
+ matcher = SKILL_PATTERN_ALT.matcher(component);
+ if(matcher.matches()) {
+ String skillS = matcher.group(2);
+ String xpPercentageS = matcher.group(3).replace(",","");
+
+ float xpPercentage = Float.parseFloat(xpPercentageS);
+ updateWithPercentage.put(skillS.toLowerCase(), xpPercentage);
+ }
+ }
+ }
+ }
+
+ public void updateLevel(String skill, int level) {
+ if(updateWithPercentage.containsKey(skill)) {
+ JsonObject leveling = Constants.LEVELING;
+ if(leveling == null) return;
+
+ SkillInfo skillInfo = new SkillInfo();
+ skillInfo.totalXp = 0;
+ skillInfo.level = level;
+
+ JsonArray levelingArray = leveling.getAsJsonArray("leveling_xp");
+ for(int i=0; i<levelingArray.size(); i++) {
+ float cap = levelingArray.get(i).getAsFloat();
+ if(i == level) {
+ skillInfo.currentXp += updateWithPercentage.get(skill)/100f * cap;
+ skillInfo.totalXp += skillInfo.currentXp;
+ skillInfo.currentXpMax = cap;
+ } else {
+ skillInfo.totalXp += cap;
}
}
+
+ SkillInfo old = skillInfoMap.get(skill.toLowerCase());
+
+ if(old.totalXp <= skillInfo.totalXp) {
+ correctionCounter--;
+ if(correctionCounter < 0) correctionCounter = 0;
+
+ skillInfoMap.put(skill.toLowerCase(), skillInfo);
+ } else if(++correctionCounter >= 10) {
+ correctionCounter = 0;
+ skillInfoMap.put(skill.toLowerCase(), skillInfo);
+ }
+
+ updateWithPercentage.remove(skill);
}
}
diff --git a/src/main/resources/assets/notenoughupdates/capes/furf.png b/src/main/resources/assets/notenoughupdates/capes/furf.png
index d7d5a99f..ce9f4c19 100644
--- a/src/main/resources/assets/notenoughupdates/capes/furf.png
+++ b/src/main/resources/assets/notenoughupdates/capes/furf.png
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/collectionlog.png b/src/main/resources/assets/notenoughupdates/collectionlog.png
new file mode 100644
index 00000000..c30a0b8f
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/collectionlog.png
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/custom_enchant_gui.png b/src/main/resources/assets/notenoughupdates/custom_enchant_gui.png
new file mode 100644
index 00000000..1ad77d97
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/custom_enchant_gui.png
Binary files differ
diff --git a/src/main/resources/mixins.notenoughupdates.json b/src/main/resources/mixins.notenoughupdates.json
index 4c0261bb..0d415976 100644
--- a/src/main/resources/mixins.notenoughupdates.json
+++ b/src/main/resources/mixins.notenoughupdates.json
@@ -3,39 +3,39 @@
"refmap": "mixins.notenoughupdates.refmap.json",
"compatibilityLevel": "JAVA_8",
"mixins": [
- "MixinItemStack",
- "MixinInventoryEffectRenderer",
- "MixinGuiIngame",
- "MixinRenderItem",
+ "MixinAbstractClientPlayer",
+ "MixinContainer",
+ "MixinEffectRenderer",
+ "MixinEntityPlayer",
+ "MixinEntityPlayerSP",
"MixinEntityRenderer",
- "MixinRenderGlobal",
- "MixinNetHandlerPlayClient",
"MixinGuiChest",
"MixinGuiContainer",
- "MixinVboRenderList",
- "MixinRenderList",
- "MixinEntityPlayer",
- "MixinTileEntitySpecialRenderer",
- "MixinRender",
- "MixinRenderFish",
- "MixinContainer",
- "MixinWorld",
- "MixinPlayerControllerMP",
- "MixinEffectRenderer",
- "MixinRendererLivingEntity",
+ "MixinGuiIngame",
+ "MixinGuiInventory",
"MixinGuiScreen",
- "MixinTileEntitySkullRenderer",
+ "MixinInventoryEffectRenderer",
+ "MixinInventoryPlayer",
"MixinItemCameraTransforms",
- "MixinGuiInventory",
+ "MixinItemRenderer",
+ "MixinItemStack",
"MixinLayerArmorBase",
- "MixinTextureManager",
"MixinLayerCustomHead",
- "MixinMouseHelper",
- "MixinAbstractClientPlayer",
- "MixinInventoryPlayer",
- "MixinItemRenderer",
- "MixinEntityPlayerSP",
"MixinLoadingScreenRenderer",
+ "MixinMouseHelper",
+ "MixinNetHandlerPlayClient",
+ "MixinPlayerControllerMP",
+ "MixinRender",
+ "MixinRendererLivingEntity",
+ "MixinRenderFish",
+ "MixinRenderGlobal",
+ "MixinRenderItem",
+ "MixinRenderList",
+ "MixinTextureManager",
+ "MixinTileEntitySkullRenderer",
+ "MixinTileEntitySpecialRenderer",
+ "MixinVboRenderList",
+ "MixinWorld",
"MixinWorldClient"
]
} \ No newline at end of file