aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2023-07-05 19:58:39 -0400
committerGitHub <noreply@github.com>2023-07-06 09:58:39 +1000
commitc70115a608712e770265c8bc6762a082674e7a68 (patch)
tree7fa27e092119d093ed906be22c9de83c1df85ded /src/main/java/io
parent380cb0ccf3c582f5700a54f65db74c3bb69e7d6a (diff)
downloadNotEnoughUpdates-c70115a608712e770265c8bc6762a082674e7a68.tar.gz
NotEnoughUpdates-c70115a608712e770265c8bc6762a082674e7a68.tar.bz2
NotEnoughUpdates-c70115a608712e770265c8bc6762a082674e7a68.zip
Storage Overlay use /backpack (#740)
Co-authored-by: nopo <nopotheemail@gmail.com>
Diffstat (limited to 'src/main/java/io')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java5
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/StorageManager.java109
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java82
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java10
4 files changed, 29 insertions, 177 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java b/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java
index 9679b886..00877e63 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java
@@ -876,11 +876,6 @@ public class RenderListener {
*/
@SubscribeEvent(priority = EventPriority.LOW)
public void onGuiScreenMouse(GuiScreenEvent.MouseInputEvent.Pre event) {
- if (Mouse.getEventButtonState() && StorageManager.getInstance().onAnyClick()) {
- event.setCanceled(true);
- return;
- }
-
final ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
final int scaledWidth = scaledresolution.getScaledWidth();
final int scaledHeight = scaledresolution.getScaledHeight();
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/StorageManager.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/StorageManager.java
index 25d0588b..e2ede605 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/StorageManager.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/StorageManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2022 NotEnoughUpdates contributors
+ * Copyright (C) 2022-2023 NotEnoughUpdates contributors
*
* This file is part of NotEnoughUpdates.
*
@@ -35,7 +35,6 @@ import io.github.moulberry.notenoughupdates.miscgui.StorageOverlay;
import io.github.moulberry.notenoughupdates.util.SBInfo;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
-import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.gui.inventory.GuiChest;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
@@ -84,7 +83,8 @@ public class StorageManager {
private static final StorageManager INSTANCE = new StorageManager();
private static final Gson GSON = new GsonBuilder()
.registerTypeAdapter(ItemStack.class, new ItemStackSerializer())
- .registerTypeAdapter(ItemStack.class, new ItemStackDeserializer()).create();
+ .registerTypeAdapter(ItemStack.class, new ItemStackDeserializer())
+ .create();
public static class ItemStackSerializer implements JsonSerializer<ItemStack> {
@Override
@@ -151,7 +151,7 @@ public class StorageManager {
private <T> void appendIfNotNull(StringBuilder builder, String key, T value) {
if (value != null) {
- if (builder.indexOf("{") != builder.length()-1) {
+ if (builder.indexOf("{") != builder.length() - 1) {
builder.append(",");
}
builder.append(key).append(":");
@@ -264,8 +264,10 @@ public class StorageManager {
public static int MAX_ENDER_CHEST_PAGES = 9;
public static final ItemStack LOCKED_ENDERCHEST_STACK =
- Utils.createItemStack(Item.getItemFromBlock(Blocks.stained_glass_pane),
- "\u00a7cLocked Page", 14,
+ Utils.createItemStack(
+ Item.getItemFromBlock(Blocks.stained_glass_pane),
+ "\u00a7cLocked Page",
+ 14,
"\u00a77Unlock more Ender Chest",
"\u00a77pages in the community",
"\u00a77shop!"
@@ -286,8 +288,6 @@ public class StorageManager {
private boolean[] storagePresent = null;
- //TODO: Replace with /storage {id} when hypixel becomes not lazy
- public int desiredStoragePage = -1;
public long storageOpenSwitchMillis = 0;
private final ItemStack[] missingBackpackStacks = new ItemStack[18];
@@ -333,8 +333,11 @@ public class StorageManager {
return missingBackpackStacks[storageId];
}
- ItemStack stack = Utils.createItemStack(Item.getItemFromBlock(Blocks.stained_glass_pane),
- "\u00a7cEmpty Backpack Slot " + (storageId + 1), 12,
+ ItemStack stack = Utils.createItemStack(
+ Item.getItemFromBlock(Blocks.stained_glass_pane),
+ "\u00a7eEmpty Backpack Slot " + (storageId + 1),
+ 12,
+ storageId + 1,
"",
"\u00a7eLeft-click a backpack",
"\u00a7eitem on this slot to place",
@@ -438,79 +441,16 @@ public class StorageManager {
}
public void sendToPage(int page) {
- if (desiredStoragePage != getCurrentPageId() &&
- System.currentTimeMillis() - storageOpenSwitchMillis < 100) return;
+ if (System.currentTimeMillis() - storageOpenSwitchMillis < 100) return;
if (getCurrentPageId() == page) return;
- if (page == 0) {
- NotEnoughUpdates.INSTANCE.sendChatMessage("/enderchest");
- } else if (getCurrentWindowId() != -1 && onStorageMenu) {
- if (page < 9) {
- sendMouseClick(getCurrentWindowId(), 9 + page);
- } else {
- sendMouseClick(getCurrentWindowId(), 27 + page - MAX_ENDER_CHEST_PAGES);
- }
+ if (page < MAX_ENDER_CHEST_PAGES) {
+ NotEnoughUpdates.INSTANCE.sendChatMessage("/enderchest " + (page + 1));
} else {
- boolean onEnderchest = page < MAX_ENDER_CHEST_PAGES && currentStoragePage < MAX_ENDER_CHEST_PAGES;
- boolean onStorage = page >= MAX_ENDER_CHEST_PAGES && currentStoragePage >= MAX_ENDER_CHEST_PAGES;
- if (currentStoragePage >= 0 && (onEnderchest || (onStorage))) {
- int currentPageDisplay = getDisplayIdForStorageId(currentStoragePage);
- int desiredPageDisplay = getDisplayIdForStorageId(page);
-
- if (onEnderchest && desiredPageDisplay > currentPageDisplay) {
- boolean isLastPage = true;
- for (int pageN = page + 1; pageN < MAX_ENDER_CHEST_PAGES; pageN++) {
- if (getDisplayIdForStorageId(pageN) >= 0) {
- isLastPage = false;
- break;
- }
- }
- if (isLastPage) {
- sendMouseClick(getCurrentWindowId(), 8);
- return;
- }
- }
-
- if (onStorage && page == MAX_ENDER_CHEST_PAGES) {
- sendMouseClick(getCurrentWindowId(), 5);
- return;
- } else if (onStorage && desiredPageDisplay == storageConfig.displayToStorageIdMap.size() - 1) {
- sendMouseClick(getCurrentWindowId(), 8);
- return;
- } else {
- int delta = desiredPageDisplay - currentPageDisplay;
- if (delta == -1) {
- sendMouseClick(getCurrentWindowId(), 6);
- return;
- } else if (delta == 1) {
- sendMouseClick(getCurrentWindowId(), 7);
- return;
- }
- }
- }
- storageOpenSwitchMillis = System.currentTimeMillis();
-
- if (page < 9) {
- NotEnoughUpdates.INSTANCE.sendChatMessage("/enderchest " + (page + 1));
- } else {
- desiredStoragePage = page;
- NotEnoughUpdates.INSTANCE.sendChatMessage("/storage");
- }
+ NotEnoughUpdates.INSTANCE.sendChatMessage("/backpack " + (page + 1 - MAX_ENDER_CHEST_PAGES));
}
- }
- private void sendMouseClick(int windowId, int slotIndex) {
- EntityPlayerSP playerIn = Minecraft.getMinecraft().thePlayer;
- short short1 = playerIn.openContainer.getNextTransactionID(playerIn.inventory);
- ItemStack itemstack = playerIn.openContainer.getSlot(slotIndex).getStack();
- Minecraft.getMinecraft().getNetHandler().addToSendQueue(new C0EPacketClickWindow(
- windowId,
- slotIndex,
- 0,
- 0,
- itemstack,
- short1
- ));
+ storageOpenSwitchMillis = System.currentTimeMillis();
}
public int getDisplayIdForStorageId(int storageId) {
@@ -533,19 +473,6 @@ public class StorageManager {
return -1;
}
- public boolean onAnyClick() {
- if (onStorageMenu && desiredStoragePage >= 0) {
- if (desiredStoragePage < 9) {
- sendMouseClick(getCurrentWindowId(), 9 + desiredStoragePage);
- } else {
- sendMouseClick(getCurrentWindowId(), 27 + desiredStoragePage - MAX_ENDER_CHEST_PAGES);
- }
- desiredStoragePage = -1;
- return true;
- }
- return false;
- }
-
public void openWindowPacket(S2DPacketOpenWindow packet) {
shouldRenderStorageOverlayCached = false;
if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return;
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java
index d469065d..4a478d1f 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java
@@ -65,7 +65,6 @@ import org.lwjgl.opengl.GL14;
import org.lwjgl.util.vector.Vector2f;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
-import java.awt.*;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
@@ -79,7 +78,6 @@ public class StorageOverlay extends GuiElement {
"notenoughupdates:storage_gui/storage_icons.png");
private static final ResourceLocation STORAGE_PANE_CTM_TEXTURE = new ResourceLocation(
"notenoughupdates:storage_gui/storage_gui_pane_ctm.png");
- private static final ResourceLocation[] LOAD_CIRCLE_SEQ = new ResourceLocation[11];
private static final ResourceLocation[] NOT_RICKROLL_SEQ = new ResourceLocation[19];
private static final StorageOverlay INSTANCE = new StorageOverlay();
private static final String CHROMA_STR = "230:255:255:0:0";
@@ -97,15 +95,6 @@ public class StorageOverlay extends GuiElement {
for (int i = 0; i < NOT_RICKROLL_SEQ.length; i++) {
NOT_RICKROLL_SEQ[i] = new ResourceLocation("notenoughupdates:storage_gui/we_do_a_little_rolling/" + i + ".jpg");
}
-
- 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 final Set<Vector2f> enchantGlintRenderLocations = new HashSet<>();
@@ -123,12 +112,8 @@ public class StorageOverlay extends GuiElement {
private int guiLeft;
private int guiTop;
private boolean fastRender = false;
- private int loadCircleIndex = 0;
private int rollIndex = 0;
- private int loadCircleRotation = 0;
- private long millisAccumIndex = 0;
private long millisAccumRoll = 0;
- private long millisAccumRotation = 0;
private long lastMillis = 0;
private int scrollVelocity = 0;
private long lastScroll = 0;
@@ -397,13 +382,6 @@ public class StorageOverlay extends GuiElement {
long currentTime = System.currentTimeMillis();
if (lastMillis > 0) {
long deltaTime = currentTime - lastMillis;
- millisAccumIndex += deltaTime;
- loadCircleIndex += millisAccumIndex / (1000 / 15);
- millisAccumIndex %= (1000 / 15);
-
- millisAccumRotation += deltaTime;
- loadCircleRotation += millisAccumRotation / (1000 / 107);
- millisAccumRotation %= (1000 / 107);
millisAccumRoll += deltaTime;
rollIndex += millisAccumRoll / 100;
@@ -411,11 +389,8 @@ public class StorageOverlay extends GuiElement {
}
lastMillis = currentTime;
- loadCircleIndex %= LOAD_CIRCLE_SEQ.length;
rollIndex %= NOT_RICKROLL_SEQ.length * 2;
- loadCircleRotation %= 360;
- Color loadCircleColour = Color.getHSBColor(loadCircleRotation / 360f, 0.3f, 0.9f);
ItemStack stackOnMouse = Minecraft.getMinecraft().thePlayer.inventory.getItemStack();
if (stackOnMouse != null) {
String stackDisplay = Utils.cleanColour(stackOnMouse.getDisplayName());
@@ -1199,21 +1174,6 @@ public class StorageOverlay extends GuiElement {
borderColour
); //Bottom
}
- } else if (currentTime - StorageManager.getInstance().storageOpenSwitchMillis < 1000 &&
- StorageManager.getInstance().desiredStoragePage == storageId &&
- StorageManager.getInstance().getCurrentPageId() != storageId) {
- Gui.drawRect(storageX, storageY, storageX + storageW, storageY + storageH, 0x30000000);
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(LOAD_CIRCLE_SEQ[loadCircleIndex]);
- GlStateManager.color(loadCircleColour.getRed() / 255f, loadCircleColour.getGreen() / 255f,
- loadCircleColour.getBlue() / 255f, 1
- );
-
- GlStateManager.pushMatrix();
- GlStateManager.translate(storageX + storageW / 2, storageY + storageH / 2, 0);
- GlStateManager.rotate(loadCircleRotation, 0, 0, 1);
- Utils.drawTexturedRect(-10, -10, 20, 20, GL11.GL_LINEAR);
- GlStateManager.popMatrix();
} else if (whiteOverlay) {
Gui.drawRect(storageX, storageY, storageX + storageW, storageY + storageH, 0x80ffffff);
} else {
@@ -1230,41 +1190,6 @@ public class StorageOverlay extends GuiElement {
}
}
- if (StorageManager.getInstance().desiredStoragePage == storageId &&
- StorageManager.getInstance().onStorageMenu) {
- Utils.drawStringCenteredScaledMaxWidth("Please click again to load...",
- storageX + 81 - 1, storageY + storageH / 2 - 5, false, 150, 0x111111
- );
- Utils.drawStringCenteredScaledMaxWidth("Please click again to load...",
- storageX + 81 + 1, storageY + storageH / 2 - 5, false, 150, 0x111111
- );
- Utils.drawStringCenteredScaledMaxWidth("Please click again to load...",
- storageX + 81, storageY + storageH / 2 - 5 - 1, false, 150, 0x111111
- );
- Utils.drawStringCenteredScaledMaxWidth("Please click again to load...",
- storageX + 81, storageY + storageH / 2 - 5 + 1, false, 150, 0x111111
- );
- Utils.drawStringCenteredScaledMaxWidth("Please click again to load...",
- storageX + 81, storageY + storageH / 2 - 5, false, 150, 0xffdf00
- );
-
- Utils.drawStringCenteredScaledMaxWidth("Use /neustwhy for more info",
- storageX + 81 - 1, storageY + storageH / 2 + 5, false, 150, 0x111111
- );
- Utils.drawStringCenteredScaledMaxWidth("Use /neustwhy for more info",
- storageX + 81 + 1, storageY + storageH / 2 + 5, false, 150, 0x111111
- );
- Utils.drawStringCenteredScaledMaxWidth("Use /neustwhy for more info",
- storageX + 81, storageY + storageH / 2 + 5 - 1, false, 150, 0x111111
- );
- Utils.drawStringCenteredScaledMaxWidth("Use /neustwhy for more info",
- storageX + 81, storageY + storageH / 2 + 5 + 1, false, 150, 0x111111
- );
- Utils.drawStringCenteredScaledMaxWidth("Use /neustwhy for more info",
- storageX + 81, storageY + storageH / 2 + 5, false, 150, 0xffdf00
- );
- }
-
GlStateManager.enableDepth();
}
}
@@ -1921,8 +1846,8 @@ public class StorageOverlay extends GuiElement {
case 2:
vIndex = NotEnoughUpdates.INSTANCE.config.storageGUI.displayStyle;
break;
- /*case 3:
- vIndex = */
+ /*case 3:
+ vIndex = */
}
Utils.drawTexturedRect(
@@ -2199,7 +2124,7 @@ public class StorageOverlay extends GuiElement {
if (Keyboard.getEventKey() == Minecraft.getMinecraft().gameSettings.keyBindFullscreen.getKeyCode()) {
return false;
}
-
+
if (!searchBar.getFocus() && !renameStorageField.getFocus() &&
(Keyboard.getEventKey() == manager.keybindViewRecipe.getKeyCode() ||
Keyboard.getEventKey() == manager.keybindViewUsages.getKeyCode())) {
@@ -2348,5 +2273,4 @@ public class StorageOverlay extends GuiElement {
this.y = y;
}
}
-
}
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 e3d52fe7..54888935 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2022 NotEnoughUpdates contributors
+ * Copyright (C) 2022-2023 NotEnoughUpdates contributors
*
* This file is part of NotEnoughUpdates.
*
@@ -935,7 +935,11 @@ public class Utils {
}
public static ItemStack createItemStack(Item item, String displayName, int damage, String... lore) {
- ItemStack stack = new ItemStack(item, 1, damage);
+ return createItemStack(item, displayName, damage, 1, lore);
+ }
+
+ public static ItemStack createItemStack(Item item, String displayName, int damage, int amount, String... lore) {
+ ItemStack stack = new ItemStack(item, amount, damage);
NBTTagCompound tag = new NBTTagCompound();
addNameAndLore(tag, displayName, lore);
tag.setInteger("HideFlags", 254);
@@ -990,6 +994,7 @@ public class Utils {
return itemStack;
}
+
public static ItemStack createSkull(String displayName, String uuid, String value) {
return createSkull(displayName, uuid, value, null);
}
@@ -1522,6 +1527,7 @@ public class Utils {
Minecraft.getMinecraft().fontRendererObj
);
}
+
public static JsonObject getConstant(String constant, Gson gson) {
return getConstant(constant, gson, JsonObject.class);
}