From a1fa5a67caebf754a0fcc43168672823ede0db93 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Fri, 4 Jun 2021 01:18:28 +0800 Subject: merge is pain --- .../notenoughupdates/NEUEventListener.java | 44 +- .../moulberry/notenoughupdates/NEUManager.java | 25 +- .../moulberry/notenoughupdates/NEUOverlay.java | 6 +- .../notenoughupdates/NotEnoughUpdates.java | 30 +- .../collectionlog/CollectionConstant.java | 17 + .../collectionlog/GuiCollectionLog.java | 103 +++++ .../notenoughupdates/core/BackgroundBlur.java | 96 +++-- .../notenoughupdates/core/GuiElement.java | 4 +- .../notenoughupdates/cosmetics/CapeManager.java | 12 +- .../miscfeatures/CollectionLogManager.java | 46 +++ .../miscfeatures/FishingHelper.java | 51 ++- .../miscfeatures/PetInfoOverlay.java | 1 - .../notenoughupdates/miscfeatures/SlotLocking.java | 74 +++- .../notenoughupdates/miscgui/GuiCustomEnchant.java | 451 +++++++++++++++++++++ .../notenoughupdates/miscgui/TradeWindow.java | 92 +++-- .../notenoughupdates/mixins/MixinGuiContainer.java | 2 + .../mixins/MixinNetHandlerPlayClient.java | 5 + .../notenoughupdates/options/NEUConfig.java | 70 +++- .../profileviewer/GuiProfileViewer.java | 38 +- .../moulberry/notenoughupdates/util/Constants.java | 55 ++- .../notenoughupdates/util/SBAIntegration.java | 217 ---------- .../moulberry/notenoughupdates/util/SBInfo.java | 19 +- .../moulberry/notenoughupdates/util/Utils.java | 23 +- .../notenoughupdates/util/XPInformation.java | 52 ++- .../assets/notenoughupdates/capes/furf.png | Bin 12443 -> 15699 bytes .../assets/notenoughupdates/collectionlog.png | Bin 0 -> 12083 bytes .../assets/notenoughupdates/custom_enchant_gui.png | Bin 0 -> 5086 bytes src/main/resources/mixins.notenoughupdates.json | 50 +-- 28 files changed, 1149 insertions(+), 434 deletions(-) create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/collectionlog/CollectionConstant.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/collectionlog/GuiCollectionLog.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CollectionLogManager.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiCustomEnchant.java delete mode 100644 src/main/java/io/github/moulberry/notenoughupdates/util/SBAIntegration.java create mode 100644 src/main/resources/assets/notenoughupdates/collectionlog.png create mode 100644 src/main/resources/assets/notenoughupdates/custom_enchant_gui.png (limited to 'src/main') 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 getJsonFromFile(File file, Class 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 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 items; + } + + public List 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 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 blurOutput = new HashMap<>(); private static HashMap lastBlurUse = new HashMap<>(); private static long lastBlur = 0; private static HashSet 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 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 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 applicable = new ArrayList<>(); + private static List 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 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 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)