aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/github/moulberry/notenoughupdates/miscgui
diff options
context:
space:
mode:
authorohowe <42757516+carelesshippo@users.noreply.github.com>2021-05-05 18:13:28 -0600
committerGitHub <noreply@github.com>2021-05-05 18:13:28 -0600
commit4d9e538ced80728bca74491698347333f515bfcc (patch)
treee272c853cb9ebe7eb8334e405060bc820ee129fd /src/main/java/io/github/moulberry/notenoughupdates/miscgui
parent59d3bf67d93d0204d0dc493508d9d9c2a24cd10b (diff)
parent9aa7b49d224bfde055e12bc84f6908ba0a50090d (diff)
downloadnotenoughupdates-4d9e538ced80728bca74491698347333f515bfcc.tar.gz
notenoughupdates-4d9e538ced80728bca74491698347333f515bfcc.tar.bz2
notenoughupdates-4d9e538ced80728bca74491698347333f515bfcc.zip
Merge pull request #2 from Moulberry/master
x
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/miscgui')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/AccessoryBagOverlay.java3
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemCustomize.java372
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/InventoryStorageSelector.java318
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java1026
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java18
5 files changed, 1723 insertions, 14 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/AccessoryBagOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/AccessoryBagOverlay.java
index a6042134..760b7bab 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/AccessoryBagOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/AccessoryBagOverlay.java
@@ -3,6 +3,7 @@ package io.github.moulberry.notenoughupdates.miscgui;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
+import io.github.moulberry.notenoughupdates.NEUEventListener;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.core.util.StringUtils;
import io.github.moulberry.notenoughupdates.profileviewer.PlayerStats;
@@ -578,7 +579,7 @@ public class AccessoryBagOverlay {
}
public static void renderOverlay() {
- if(Minecraft.getMinecraft().currentScreen instanceof GuiChest) {
+ if(Minecraft.getMinecraft().currentScreen instanceof GuiChest && NEUEventListener.inventoryLoaded) {
GuiChest eventGui = (GuiChest) Minecraft.getMinecraft().currentScreen;
ContainerChest cc = (ContainerChest) eventGui.inventorySlots;
String containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText();
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemCustomize.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemCustomize.java
new file mode 100644
index 00000000..166e6ba2
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemCustomize.java
@@ -0,0 +1,372 @@
+package io.github.moulberry.notenoughupdates.miscgui;
+
+import io.github.moulberry.notenoughupdates.core.*;
+import io.github.moulberry.notenoughupdates.core.util.lerp.LerpingFloat;
+import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils;
+import io.github.moulberry.notenoughupdates.miscfeatures.ItemCustomizeManager;
+import io.github.moulberry.notenoughupdates.util.Utils;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.Gui;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.client.gui.ScaledResolution;
+import net.minecraft.client.renderer.GlStateManager;
+import net.minecraft.client.resources.model.IBakedModel;
+import net.minecraft.item.ItemArmor;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.ResourceLocation;
+import org.lwjgl.input.Keyboard;
+import org.lwjgl.input.Mouse;
+import org.lwjgl.opengl.GL11;
+
+import java.awt.*;
+import java.io.*;
+import java.net.URL;
+
+public class GuiItemCustomize extends GuiScreen {
+
+ private static final ResourceLocation RESET = new ResourceLocation("notenoughupdates:itemcustomize/reset.png");
+
+ private final ItemStack stack;
+ private final String itemUUID;
+ private final GuiElementTextField textFieldRename = new GuiElementTextField("", 178, 20, GuiElementTextField.COLOUR);
+ private final GuiElementBoolean enchantGlintButton;
+
+ private int renderHeight = 0;
+
+ private final LerpingFloat enchantGlintCustomColourAnimation = new LerpingFloat(0, 200);
+
+ private boolean enchantGlint;
+ private String customGlintColour = null;
+
+ private String customLeatherColour = null;
+ private final boolean supportCustomLeatherColour;
+
+ private GuiElement editor = null;
+
+ public GuiItemCustomize(ItemStack stack, String itemUUID) {
+ this.stack = stack;
+ this.itemUUID = itemUUID;
+
+ IBakedModel model = Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getItemModel(stack);
+ boolean stackHasEffect = stack.hasEffect() && !model.isBuiltInRenderer();
+
+ ItemCustomizeManager.ItemData data = ItemCustomizeManager.getDataForItem(stack);
+ if(data != null) {
+ this.enchantGlint = data.overrideEnchantGlint ? data.enchantGlintValue : stackHasEffect;
+ if(data.customName != null) {
+ textFieldRename.setText(data.customName);
+ }
+ this.customGlintColour = data.customGlintColour;
+ this.customLeatherColour = data.customLeatherColour;
+ } else {
+ this.enchantGlint = stackHasEffect;
+ }
+
+ supportCustomLeatherColour = stack.getItem() instanceof ItemArmor && ((ItemArmor)stack.getItem()).hasColor(stack);
+
+ enchantGlintCustomColourAnimation.setValue(enchantGlint ? 17 : 0);
+ this.enchantGlintButton = new GuiElementBoolean(0, 0, enchantGlint, (bool) -> {
+ enchantGlint = bool;
+ updateData();
+ });
+
+ }
+
+ @Override
+ public void onGuiClosed() {
+ updateData();
+ }
+
+ public String getChromaStrFromLeatherColour() {
+ return ChromaColour.special(0, 0xff, ((ItemArmor)stack.getItem()).getColor(stack));
+ }
+
+ public void updateData() {
+ ItemCustomizeManager.ItemData data = new ItemCustomizeManager.ItemData();
+
+ IBakedModel model = Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getItemModel(stack);
+ boolean stackHasEffect = stack.hasEffect() && !model.isBuiltInRenderer();
+
+ if(this.enchantGlint != stackHasEffect) {
+ data.overrideEnchantGlint = true;
+ data.enchantGlintValue = this.enchantGlint;
+ }
+
+ if(this.customGlintColour != null && !this.customGlintColour.equals(ItemCustomizeManager.DEFAULT_GLINT_COLOR)) {
+ data.customGlintColour = this.customGlintColour;
+ } else if(model.isBuiltInRenderer() && data.overrideEnchantGlint && data.enchantGlintValue) {
+ data.customGlintColour = ItemCustomizeManager.DEFAULT_GLINT_COLOR;
+ } else {
+ data.customGlintColour = null;
+ }
+
+ if(supportCustomLeatherColour && this.customLeatherColour != null && !this.customLeatherColour.equals(getChromaStrFromLeatherColour())) {
+ data.customLeatherColour = this.customLeatherColour;
+ } else {
+ data.customLeatherColour = null;
+ }
+
+ if(!this.textFieldRename.getText().isEmpty()) {
+ data.customName = this.textFieldRename.getText();
+ }
+
+ ItemCustomizeManager.putItemData(itemUUID, data);
+ }
+
+ private int getGlintColour() {
+ int col = customGlintColour == null ? ChromaColour.specialToChromaRGB(ItemCustomizeManager.DEFAULT_GLINT_COLOR) : ChromaColour.specialToChromaRGB(customGlintColour);
+ return 0xff000000 | col;
+ }
+
+ private int getLeatherColour() {
+ if(!supportCustomLeatherColour) return 0xff000000;
+
+ int col = customLeatherColour == null ? ((ItemArmor)stack.getItem()).getColor(stack) : ChromaColour.specialToChromaRGB(customLeatherColour);
+ return 0xff000000 | col;
+ }
+
+ @Override
+ public void drawScreen(int mouseX, int mouseY, float partialTicks) {
+ drawDefaultBackground();
+
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+
+ int xCenter = scaledResolution.getScaledWidth()/2;
+ int yTopStart = (scaledResolution.getScaledHeight()-renderHeight)/2;
+ int yTop = yTopStart;
+
+ RenderUtils.drawFloatingRectDark(xCenter-100, yTop-9, 200, renderHeight);
+
+ RenderUtils.drawFloatingRectDark(xCenter-90, yTop-5, 180, 14);
+ Utils.renderShadowedString("\u00a75\u00a7lNEU Item Customizer", xCenter, yTop-1, 180);
+
+ yTop += 14;
+
+ if(!textFieldRename.getFocus() && textFieldRename.getText().isEmpty()) {
+ textFieldRename.setOptions(0);
+ textFieldRename.setPrependText("\u00a77Enter Custom Name...");
+ } else {
+ textFieldRename.setOptions(GuiElementTextField.COLOUR);
+ textFieldRename.setPrependText("");
+ }
+
+ textFieldRename.render(xCenter-textFieldRename.getWidth()/2, yTop);
+ yTop += 25;
+
+ RenderUtils.drawFloatingRectDark(xCenter-90, yTop, 180, 110);
+ GlStateManager.enableDepth();
+ GlStateManager.pushMatrix();
+ GlStateManager.translate(xCenter-48, yTop+7, 0);
+ GlStateManager.scale(6, 6, 1);
+ Utils.drawItemStack(stack, 0, 0);
+ GlStateManager.popMatrix();
+
+ yTop += 115;
+
+ RenderUtils.drawFloatingRectDark(xCenter-90, yTop, 180, 20);
+
+ Minecraft.getMinecraft().fontRendererObj.drawString("Enchant Glint",
+ xCenter-85, yTop+6, 0xff8040cc);
+
+ enchantGlintButton.x = xCenter+90-5-48;
+ enchantGlintButton.y = yTop+3;
+ enchantGlintButton.render();
+
+ yTop += 25;
+
+ enchantGlintCustomColourAnimation.tick();
+ if(enchantGlintCustomColourAnimation.getValue() > 0) {
+ yTop -= 5;
+
+ int glintColour = getGlintColour();
+
+ GlScissorStack.push(0, yTop, scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), scaledResolution);
+ GlStateManager.translate(0, enchantGlintCustomColourAnimation.getValue()-17, 0);
+
+ Gui.drawRect(xCenter-90, yTop, xCenter+92, yTop+17, 0x70000000);
+ Gui.drawRect(xCenter-90, yTop, xCenter+90, yTop+15, 0xff101016);
+ Gui.drawRect(xCenter-89, yTop+1, xCenter+89, yTop+14, 0xff000000 | glintColour);
+
+ Utils.renderShadowedString("\u00a7a\u00a7lCustom Glint Colour", xCenter, yTop+4, 180);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(RESET);
+ GlStateManager.color(1, 1, 1, 1);
+ RenderUtils.drawTexturedRect(xCenter+90-12, yTop+2, 10, 11, GL11.GL_NEAREST);
+
+ GlStateManager.translate(0, -enchantGlintCustomColourAnimation.getValue()+17, 0);
+ GlScissorStack.pop(scaledResolution);
+
+ yTop += enchantGlintCustomColourAnimation.getValue()+3;
+ }
+
+ if(supportCustomLeatherColour) {
+ int leatherColour = getLeatherColour();
+
+ Gui.drawRect(xCenter-90, yTop, xCenter+92, yTop+17, 0x70000000);
+ Gui.drawRect(xCenter-90, yTop, xCenter+90, yTop+15, 0xff101016);
+ Gui.drawRect(xCenter-89, yTop+1, xCenter+89, yTop+14, 0xff000000 | leatherColour);
+
+ Utils.renderShadowedString("\u00a7b\u00a7lCustom Leather Colour", xCenter, yTop+4, 180);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(RESET);
+ GlStateManager.color(1, 1, 1, 1);
+ RenderUtils.drawTexturedRect(xCenter+90-12, yTop+2, 10, 11, GL11.GL_NEAREST);
+
+ yTop += 20;
+ }
+
+ /*if(true) {
+ yTop += 20;
+
+ String titleStr = "\u00a76\u00a7lWant other players to see your customized item?";
+ String buttonStr = "\u00a76Purchase Item Customize Tag";
+ if(true) {
+ buttonStr = "\u00a76Use item customize tag (3 remaining)";
+ }
+
+ int w = Minecraft.getMinecraft().fontRendererObj.getStringWidth(titleStr)+8;
+ if(w > scaledResolution.getScaledWidth()/2) w= scaledResolution.getScaledWidth()/2;
+
+ RenderUtils.drawFloatingRectDark(xCenter-w/2, yTop, w, 50);
+ Utils.renderShadowedString(titleStr, xCenter, yTop+8, scaledResolution.getScaledWidth()/2);
+
+ int ctw = Minecraft.getMinecraft().fontRendererObj.getStringWidth(buttonStr)+8;
+
+ RenderUtils.drawFloatingRectDark(xCenter-ctw/2, yTop+25, ctw, 15);
+ Utils.renderShadowedString(buttonStr, xCenter, yTop+28, w);
+
+
+
+ }*/
+
+
+ renderHeight = yTop - yTopStart;
+
+ if(editor != null) {
+ editor.render();
+ }
+
+ super.drawScreen(mouseX, mouseY, partialTicks);
+ }
+
+ @Override
+ public void updateScreen() {
+ if(enchantGlint) {
+ if(enchantGlintCustomColourAnimation.getTarget() != 17) {
+ enchantGlintCustomColourAnimation.setTarget(17);
+ enchantGlintCustomColourAnimation.resetTimer();
+ }
+ } else {
+ if(enchantGlintCustomColourAnimation.getTarget() != 0) {
+ enchantGlintCustomColourAnimation.setTarget(0);
+ enchantGlintCustomColourAnimation.resetTimer();
+ }
+ }
+
+ super.updateScreen();
+ }
+
+ @Override
+ protected void keyTyped(char typedChar, int keyCode) throws IOException {
+ if(textFieldRename.getFocus()) {
+ if(keyCode == Keyboard.KEY_ESCAPE) {
+ textFieldRename.setFocus(false);
+ return;
+ } else {
+ textFieldRename.keyTyped(typedChar, keyCode);
+ }
+ }
+
+ super.keyTyped(typedChar, keyCode);
+ }
+
+ @Override
+ public void handleKeyboardInput() throws IOException {
+ if(editor == null || !editor.keyboardInput()) {
+ if(editor != null && Keyboard.getEventKeyState() && Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
+ editor = null;
+ } else {
+ super.handleKeyboardInput();
+ }
+ }
+ }
+
+ @Override
+ public void handleMouseInput() throws IOException {
+ int mouseX = Mouse.getEventX() * this.width / this.mc.displayWidth;
+ int mouseY = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1;
+
+ if(editor == null || !editor.mouseInput(mouseX, mouseY)) {
+ super.handleMouseInput();
+ enchantGlintButton.mouseInput(mouseX, mouseY);
+ }
+ }
+
+ @Override
+ protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
+ textFieldRename.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick);
+ }
+
+ @Override
+ protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ int xCenter = scaledResolution.getScaledWidth()/2;
+ int yTop = (scaledResolution.getScaledHeight()-renderHeight)/2;
+
+ if(mouseX >= xCenter-textFieldRename.getWidth()/2 && mouseX <= xCenter+textFieldRename.getWidth()/2 &&
+ mouseY >= yTop+14 && mouseY <= yTop+14+textFieldRename.getHeight()) {
+ textFieldRename.mouseClicked(mouseX, mouseY, mouseButton);
+ } else {
+ textFieldRename.unfocus();
+ }
+
+ if(enchantGlint && mouseX >= xCenter-90 && mouseX <= xCenter+90 &&
+ mouseY >= yTop+174 && mouseY <= yTop+174+enchantGlintCustomColourAnimation.getValue()) {
+ if(mouseX >= xCenter+90-12) {
+ editor = null;
+ customGlintColour = ItemCustomizeManager.DEFAULT_GLINT_COLOR;
+ updateData();
+ } else {
+ editor = new GuiElementColour(mouseX, mouseY, customGlintColour == null ? ItemCustomizeManager.DEFAULT_GLINT_COLOR : customGlintColour,
+ (colour) -> {
+ customGlintColour = colour;
+ updateData();
+ }, () -> editor = null);
+ }
+ }
+
+ float belowEnchGlint = yTop+174+enchantGlintCustomColourAnimation.getValue()+5;
+
+ if(supportCustomLeatherColour && mouseX >= xCenter-90 && mouseX <= xCenter+90 &&
+ mouseY >= belowEnchGlint &&
+ mouseY <= belowEnchGlint+15) {
+ if(mouseX >= xCenter+90-12) {
+ editor = null;
+ customLeatherColour = null;
+ updateData();
+ } else {
+ editor = new GuiElementColour(mouseX, mouseY,
+ customLeatherColour == null ? getChromaStrFromLeatherColour() : customLeatherColour,
+ (colour) -> {
+ customLeatherColour = colour;
+ updateData();
+ }, () -> editor = null, false, true);
+ }
+ }
+
+ /*if(mouseX >= xCenter-90 && mouseX <= xCenter+90 &&
+ mouseY >= belowEnchGlint+65 && mouseY <= belowEnchGlint+80) {
+ if(true) {
+ String userName = Minecraft.getMinecraft().thePlayer.getName();
+ String serverId = "1872398172739";
+ try {
+ Desktop.getDesktop().browse(new URL("https://moulberry.codes/purchaseitemtag?uniqueId="+serverId+"&username="+userName).toURI());
+ } catch(Exception ignored) {}
+ } else {
+
+ }
+ }*/
+
+ super.mouseClicked(mouseX, mouseY, mouseButton);
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/InventoryStorageSelector.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/InventoryStorageSelector.java
new file mode 100644
index 00000000..010dc3e2
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/InventoryStorageSelector.java
@@ -0,0 +1,318 @@
+package io.github.moulberry.notenoughupdates.miscgui;
+
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.core.config.KeybindHelper;
+import io.github.moulberry.notenoughupdates.miscfeatures.StorageManager;
+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.renderer.GlStateManager;
+import net.minecraft.client.settings.KeyBinding;
+import net.minecraft.init.Blocks;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.ResourceLocation;
+import net.minecraftforge.client.event.MouseEvent;
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
+import net.minecraftforge.fml.common.gameevent.InputEvent;
+import org.lwjgl.input.Keyboard;
+import org.lwjgl.input.Mouse;
+import org.lwjgl.opengl.GL11;
+
+public class InventoryStorageSelector {
+
+ private static final InventoryStorageSelector INSTANCE = new InventoryStorageSelector();
+
+ private static final ResourceLocation ICONS = new ResourceLocation("notenoughupdates:storage_gui/hotbar_icons.png");
+
+ public boolean isOverridingSlot = false;
+ public int selectedIndex = 0;
+
+ public static InventoryStorageSelector getInstance() {
+ return INSTANCE;
+ }
+
+ public boolean isSlotSelected() {
+ if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() || !NotEnoughUpdates.INSTANCE.config.storageGUI.showInvBackpack) {
+ isOverridingSlot = false;
+ return false;
+ }
+ if(Minecraft.getMinecraft().currentScreen != null) {
+ isOverridingSlot = false;
+ return false;
+ }
+ if(Minecraft.getMinecraft().thePlayer == null) {
+ isOverridingSlot = false;
+ return false;
+ }
+ if(Minecraft.getMinecraft().thePlayer.inventory.currentItem != 0) {
+ isOverridingSlot = false;
+ return false;
+ }
+ return isOverridingSlot;
+ }
+
+ @SubscribeEvent
+ public void onMousePress(MouseEvent event) {
+ if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() || !NotEnoughUpdates.INSTANCE.config.storageGUI.showInvBackpack) {
+ return;
+ }
+
+ if(KeybindHelper.isKeyPressed(NotEnoughUpdates.INSTANCE.config.storageGUI.arrowLeftKey)) {
+ selectedIndex--;
+
+ int max = StorageManager.getInstance().storageConfig.displayToStorageIdMap.size()-1;
+ if(selectedIndex > max) selectedIndex = max;
+ if(selectedIndex < 0) selectedIndex = 0;
+ } else if(KeybindHelper.isKeyPressed(NotEnoughUpdates.INSTANCE.config.storageGUI.arrowRightKey)) {
+ selectedIndex++;
+
+ int max = StorageManager.getInstance().storageConfig.displayToStorageIdMap.size()-1;
+ if(selectedIndex > max) selectedIndex = max;
+ if(selectedIndex < 0) selectedIndex = 0;
+ } else if(KeybindHelper.isKeyPressed(NotEnoughUpdates.INSTANCE.config.storageGUI.arrowDownKey)) {
+ sendToPage(selectedIndex);
+ }
+
+ if(isSlotSelected()) {
+ int useKeycode = Minecraft.getMinecraft().gameSettings.keyBindUseItem.getKeyCode() + 100;
+ int attackKeycode = Minecraft.getMinecraft().gameSettings.keyBindAttack.getKeyCode() + 100;
+
+ if(Mouse.getEventButton() == useKeycode || Mouse.getEventButton() == attackKeycode) {
+ if(Mouse.getEventButtonState() &&
+ Mouse.getEventButton() != NotEnoughUpdates.INSTANCE.config.storageGUI.backpackScrollKey+100) {
+ sendToPage(selectedIndex);
+ }
+
+ event.setCanceled(true);
+ }
+ }
+ }
+
+ private void sendToPage(int displayId) {
+ if(!StorageManager.getInstance().storageConfig.displayToStorageIdMap.containsKey(displayId)) {
+ return;
+ }
+ if(getPage(selectedIndex) == null) {
+ NotEnoughUpdates.INSTANCE.sendChatMessage("/storage");
+ } else {
+ int index = StorageManager.getInstance().storageConfig.displayToStorageIdMap.get(selectedIndex);
+ StorageManager.getInstance().sendToPage(index);
+ }
+ }
+
+ @SubscribeEvent
+ public void onKeyPress(InputEvent.KeyInputEvent event) {
+ if(Minecraft.getMinecraft().gameSettings.keyBindsHotbar[0].isKeyDown()) {
+ isOverridingSlot = false;
+ }
+
+ if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() || !NotEnoughUpdates.INSTANCE.config.storageGUI.showInvBackpack) {
+ return;
+ }
+
+ if(KeybindHelper.isKeyPressed(NotEnoughUpdates.INSTANCE.config.storageGUI.arrowLeftKey)) {
+ selectedIndex--;
+
+ int max = StorageManager.getInstance().storageConfig.displayToStorageIdMap.size()-1;
+ if(selectedIndex > max) selectedIndex = max;
+ if(selectedIndex < 0) selectedIndex = 0;
+ } else if(KeybindHelper.isKeyPressed(NotEnoughUpdates.INSTANCE.config.storageGUI.arrowRightKey)) {
+ selectedIndex++;
+
+ int max = StorageManager.getInstance().storageConfig.displayToStorageIdMap.size()-1;
+ if(selectedIndex > max) selectedIndex = max;
+ if(selectedIndex < 0) selectedIndex = 0;
+ } else if(KeybindHelper.isKeyPressed(NotEnoughUpdates.INSTANCE.config.storageGUI.arrowDownKey)) {
+ sendToPage(selectedIndex);
+ }
+
+ if(isSlotSelected()) {
+ KeyBinding attack = Minecraft.getMinecraft().gameSettings.keyBindAttack;
+ KeyBinding use = Minecraft.getMinecraft().gameSettings.keyBindUseItem;
+
+ if(attack.isPressed() || attack.isKeyDown()) {
+ if(attack.getKeyCode() != NotEnoughUpdates.INSTANCE.config.storageGUI.backpackScrollKey) {
+ sendToPage(selectedIndex);
+ }
+
+ KeyBinding.setKeyBindState(attack.getKeyCode(), false);
+ while(attack.isPressed()){}
+ }
+
+ if(use.isPressed() || use.isKeyDown()) {
+ if(attack.getKeyCode() != NotEnoughUpdates.INSTANCE.config.storageGUI.backpackScrollKey) {
+ sendToPage(selectedIndex);
+ }
+
+ KeyBinding.setKeyBindState(use.getKeyCode(), false);
+ while(use.isPressed()){}
+ }
+ }
+ }
+
+ public int onScroll(int direction, int resultantSlot) {
+ if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() || !NotEnoughUpdates.INSTANCE.config.storageGUI.showInvBackpack) {
+ return resultantSlot;
+ }
+
+ int keyCode = NotEnoughUpdates.INSTANCE.config.storageGUI.backpackScrollKey;
+ if(isOverridingSlot && KeybindHelper.isKeyDown(keyCode)) {
+ selectedIndex -= direction;
+ int max = StorageManager.getInstance().storageConfig.displayToStorageIdMap.size()-1;
+
+ if(selectedIndex > max) selectedIndex = max;
+ if(selectedIndex < 0) selectedIndex = 0;
+ return 0;
+ }
+
+ if(resultantSlot == 0 && direction == -1 && !isOverridingSlot) {
+ isOverridingSlot = true;
+ Minecraft.getMinecraft().getItemRenderer().resetEquippedProgress();
+ return 0;
+ } else if(resultantSlot == 1 && direction == -1 && isOverridingSlot) {
+ isOverridingSlot = false;
+ Minecraft.getMinecraft().getItemRenderer().resetEquippedProgress();
+ return 0;
+ } else if(resultantSlot == 8 && direction == 1 && !isOverridingSlot) {
+ isOverridingSlot = true;
+ Minecraft.getMinecraft().getItemRenderer().resetEquippedProgress();
+ return 0;
+ }
+ return resultantSlot;
+ }
+
+ private StorageManager.StoragePage getPage(int selectedIndex) {
+ if(!StorageManager.getInstance().storageConfig.displayToStorageIdMap.containsKey(selectedIndex)) {
+ return null;
+ }
+ int index = StorageManager.getInstance().storageConfig.displayToStorageIdMap.get(selectedIndex);
+ return StorageManager.getInstance().getPage(index, false);
+ }
+
+ public ItemStack getNamedHeldItemOverride() {
+ StorageManager.StoragePage page = getPage(selectedIndex);
+ if(page != null && page.backpackDisplayStack != null) {
+ return page.backpackDisplayStack;
+ }
+ return new ItemStack(Item.getItemFromBlock(Blocks.chest));
+ }
+
+ public ItemStack getHeldItemOverride() {
+ return getHeldItemOverride(selectedIndex);
+ }
+
+ public ItemStack getHeldItemOverride(int selectedIndex) {
+ StorageManager.StoragePage page = getPage(selectedIndex);
+ if(page != null) {
+ ItemStack stack = page.backpackDisplayStack;
+ if(stack == null || stack.getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane)) {
+ return new ItemStack(Item.getItemFromBlock(Blocks.ender_chest));
+ }
+ return stack;
+ }
+ return new ItemStack(Item.getItemFromBlock(Blocks.chest));
+ }
+
+ public void render(ScaledResolution scaledResolution, float partialTicks) {
+ if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() || !NotEnoughUpdates.INSTANCE.config.storageGUI.showInvBackpack) {
+ return;
+ }
+
+ int max = StorageManager.getInstance().storageConfig.displayToStorageIdMap.size()-1;
+ if(selectedIndex > max) selectedIndex = max;
+ if(selectedIndex < 0) selectedIndex = 0;
+
+ int width = scaledResolution.getScaledWidth();
+ int height = scaledResolution.getScaledHeight();
+ FontRenderer fontRendererObj = Minecraft.getMinecraft().fontRendererObj;
+ int centerX = width / 2;
+
+ int offset = 91 + 10 + 12;
+
+ if(NotEnoughUpdates.INSTANCE.config.storageGUI.backpackHotbarSide == 1) {
+ offset *= -1;
+ }
+
+ ItemStack held = getHeldItemOverride();
+ int left = centerX - offset - 12;
+ int top = scaledResolution.getScaledHeight() - 22;
+
+ if(NotEnoughUpdates.INSTANCE.config.storageGUI.showInvBackpackPreview && isSlotSelected()) {
+ StorageManager.StoragePage page = getPage(selectedIndex);
+
+ if(page != null && page.rows > 0) {
+ int rows = page.rows;
+
+ ResourceLocation storagePreviewTexture = StorageOverlay.STORAGE_PREVIEW_TEXTURES[NotEnoughUpdates.INSTANCE.config.storageGUI.displayStyle];
+
+ int startX = centerX - 172/2;
+ int startY = height - 70 - (10+18*rows);
+
+ GlStateManager.translate(0, 0, 100);
+ GL11.glDepthMask(false);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(storagePreviewTexture);
+ GlStateManager.color(1, 1, 1,
+ NotEnoughUpdates.INSTANCE.config.storageGUI.backpackOpacity/100f);
+ Utils.drawTexturedRect(startX, startY, 176, 7, 0, 1, 0, 7/32f, GL11.GL_NEAREST);
+ for(int i=0; i<rows; i++) {
+ Utils.drawTexturedRect(startX, startY+7+18*i, 176, 18, 0, 1, 7/32f, 25/32f, GL11.GL_NEAREST);
+ }
+ Utils.drawTexturedRect(startX, startY+7+18*rows, 176, 7, 0, 1, 25/32f, 1, GL11.GL_NEAREST);
+
+ GL11.glDepthMask(true);
+
+ for(int i=0; i<rows*9; i++) {
+ ItemStack stack = page.items[i];
+ if(stack != null) {
+ Utils.drawItemStack(stack, startX+8+18*(i%9), startY+8+18*(i/9));
+ }
+ }
+
+ ItemStack named = getNamedHeldItemOverride();
+
+ Utils.drawItemStack(held, centerX-8, startY-8);
+
+ GlStateManager.translate(0, 0, 100);
+ Utils.drawStringCentered(named.getDisplayName(), fontRendererObj, centerX, height - 66, true, 0xffff0000);
+ int keyCode = NotEnoughUpdates.INSTANCE.config.storageGUI.backpackScrollKey;
+ if(KeybindHelper.isKeyValid(keyCode) && !KeybindHelper.isKeyDown(keyCode)) {
+ String keyName = KeybindHelper.getKeyName(keyCode);
+ Utils.drawStringCentered("["+keyName+"] Scroll Backpacks", fontRendererObj, centerX, startY-10, true, 0xff32CD32);
+ }
+ GlStateManager.translate(0, 0, -200);
+
+ } else if(page == null) {
+ Utils.drawStringCentered("Run /storage to enable this feature!", fontRendererObj, centerX, height - 80, true, 0xffff0000);
+ } else {
+ Utils.drawStringCentered("Right-click to load items", fontRendererObj, centerX, height - 80, true, 0xffff0000);
+ }
+ }
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(ICONS);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(left + 1, top,
+ 22, 22, 0, 22/64f, 0, 22/64f, GL11.GL_NEAREST);
+ if(isSlotSelected()) {
+ Utils.drawTexturedRect(left, top - 1,
+ 24, 22, 0, 24/64f, 22/64f, 44/64f, GL11.GL_NEAREST);
+ }
+
+ int index = 1;
+ if(StorageManager.getInstance().storageConfig.displayToStorageIdMap.containsKey(selectedIndex)) {
+ int displayIndex = StorageManager.getInstance().storageConfig.displayToStorageIdMap.get(selectedIndex);
+ if(displayIndex < 9) {
+ index = displayIndex+1;
+ } else {
+ index = displayIndex-8;
+ }
+ }
+
+ Utils.drawItemStackWithText(held, left + 4, top + 3, ""+index);
+
+ GlStateManager.enableBlend();
+ }
+
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java
new file mode 100644
index 00000000..f22ed9ae
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java
@@ -0,0 +1,1026 @@
+package io.github.moulberry.notenoughupdates.miscgui;
+
+import com.google.common.collect.Lists;
+import com.google.gson.stream.JsonWriter;
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.core.BackgroundBlur;
+import io.github.moulberry.notenoughupdates.core.GlScissorStack;
+import io.github.moulberry.notenoughupdates.core.GuiElement;
+import io.github.moulberry.notenoughupdates.core.GuiElementTextField;
+import io.github.moulberry.notenoughupdates.core.util.lerp.LerpingInteger;
+import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils;
+import io.github.moulberry.notenoughupdates.miscfeatures.StorageManager;
+import io.github.moulberry.notenoughupdates.util.Utils;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.FontRenderer;
+import net.minecraft.client.gui.Gui;
+import net.minecraft.client.gui.ScaledResolution;
+import net.minecraft.client.gui.inventory.GuiChest;
+import net.minecraft.client.renderer.GlStateManager;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.init.Blocks;
+import net.minecraft.inventory.Container;
+import net.minecraft.inventory.ContainerChest;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.util.ResourceLocation;
+import org.lwjgl.input.Keyboard;
+import org.lwjgl.input.Mouse;
+import org.lwjgl.opengl.GL11;
+import org.lwjgl.opengl.GLSync;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
+
+import java.awt.*;
+import java.util.List;
+import java.util.Map;
+
+public class StorageOverlay extends GuiElement {
+
+ private static final int CHEST_TOP_OFFSET = 17;
+ private static final int CHEST_SLOT_SIZE = 18;
+ private static final int CHEST_BOTTOM_OFFSET = 215;
+
+ public static final ResourceLocation STORAGE_PREVIEW_TEXTURES[] = new ResourceLocation[4];
+ private static final ResourceLocation STORAGE_TEXTURES[] = new ResourceLocation[4];
+ private static final ResourceLocation STORAGE_ICONS_TEXTURE = new ResourceLocation("notenoughupdates:storage_gui/storage_icons.png");
+ private static final ResourceLocation[] LOAD_CIRCLE_SEQ = new ResourceLocation[11];
+ static {
+ for(int i=0; i<STORAGE_TEXTURES.length; i++) {
+ STORAGE_TEXTURES[i] = new ResourceLocation("notenoughupdates:storage_gui/storage_gui_"+i+".png");
+ }
+ for(int i=0; i<STORAGE_PREVIEW_TEXTURES.length; i++) {
+ STORAGE_PREVIEW_TEXTURES[i] = new ResourceLocation("notenoughupdates:storage_gui/storage_preview_"+i+".png");
+ }
+
+ LOAD_CIRCLE_SEQ[0] = new ResourceLocation("notenoughupdates:loading_circle_seq/1.png");
+ LOAD_CIRCLE_SEQ[1] = new ResourceLocation("notenoughupdates:loading_circle_seq/1.png");
+ LOAD_CIRCLE_SEQ[2] = new ResourceLocation("notenoughupdates:loading_circle_seq/2.png");
+ for(int i=2; i<=7; i++) {
+ LOAD_CIRCLE_SEQ[i+1] = new ResourceLocation("notenoughupdates:loading_circle_seq/"+i+".png");
+ }
+ LOAD_CIRCLE_SEQ[9] = new ResourceLocation("notenoughupdates:loading_circle_seq/7.png");
+ LOAD_CIRCLE_SEQ[10] = new ResourceLocation("notenoughupdates:loading_circle_seq/1.png");
+ }
+
+ private static final StorageOverlay INSTANCE = new StorageOverlay();
+ public static StorageOverlay getInstance() {
+ return INSTANCE;
+ }
+
+ private GuiElementTextField searchBar = new GuiElementTextField("", 88, 10,
+ GuiElementTextField.SCALE_TEXT | GuiElementTextField.DISABLE_BG);
+
+ private int guiLeft;
+ private int guiTop;
+
+ private int loadCircleIndex = 0;
+ private int loadCircleRotation = 0;
+
+ private long millisAccumIndex = 0;
+ private long millisAccumRotation = 0;
+
+ private long lastMillis = 0;
+
+ private int scrollVelocity = 0;
+