aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorLulonaut <67191924+Lulonaut@users.noreply.github.com>2022-05-15 11:55:11 +0200
committerGitHub <noreply@github.com>2022-05-15 11:55:11 +0200
commit9f372b3f8b5f07b3dbc6c010e064924d5b4820a4 (patch)
tree54ed21aae68b0076e2f824a495a510bc4fb7f091 /src/main/java
parente2bbc83d80305e7b20292cb6a0fbcfad0fda4eed (diff)
downloadNotEnoughUpdates-9f372b3f8b5f07b3dbc6c010e064924d5b4820a4.tar.gz
NotEnoughUpdates-9f372b3f8b5f07b3dbc6c010e064924d5b4820a4.tar.bz2
NotEnoughUpdates-9f372b3f8b5f07b3dbc6c010e064924d5b4820a4.zip
More Keyboard fixes (#130)
* Allow holding down keys in StorageOverlay and Item list searchbar * don't sleep on the render thread * Remove most calls to Keyboard#enableRepeatEvents Also remove my flawless implementation in the render methods since it's not needed anymore * remove autoclicker
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java3
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java1
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java14
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorText.java1
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditor.java2
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/itemeditor/NEUItemEditor.java4
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/listener/NEUEventListener.java19
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java7
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiInvButtonEditor.java18
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemCustomize.java9
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java380
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/tutorials/TutorialBase.java1
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java1
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java154
14 files changed, 315 insertions, 299 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java
index 201cec86..ff8187f2 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java
@@ -212,7 +212,7 @@ public class NEUOverlay extends Gui {
private boolean redrawItems = false;
- private boolean searchBarHasFocus = false;
+ public static boolean searchBarHasFocus = false;
private static final GuiTextField textField = new GuiTextField(0, null, 0, 0, 0, 0);
private static final int COMPARE_MODE_ALPHABETICAL = 0;
@@ -1044,7 +1044,6 @@ public class NEUOverlay extends Gui {
*/
public boolean keyboardInput(boolean hoverInv) {
if (Minecraft.getMinecraft().currentScreen == null) return false;
- Keyboard.enableRepeatEvents(true);
int keyPressed = Keyboard.getEventKey() == 0 ? Keyboard.getEventCharacter() + 256 : Keyboard.getEventKey();
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
index 0de3fffe..77499d59 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
@@ -275,7 +275,6 @@ public class NotEnoughUpdates {
}
tmp.delete();
}
- //saveConfig();
}));
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java b/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java
index 123da60a..4fae9ea5 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java
@@ -35,14 +35,23 @@ import org.lwjgl.opengl.GL14;
import java.awt.*;
import java.awt.datatransfer.StringSelection;
import java.text.NumberFormat;
+import java.util.ArrayList;
+import java.util.ConcurrentModificationException;
+import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
-import java.util.*;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import static io.github.moulberry.notenoughupdates.util.GuiTextures.*;
+import static io.github.moulberry.notenoughupdates.util.GuiTextures.auction_accept;
+import static io.github.moulberry.notenoughupdates.util.GuiTextures.auction_price;
+import static io.github.moulberry.notenoughupdates.util.GuiTextures.auction_view;
+import static io.github.moulberry.notenoughupdates.util.GuiTextures.auction_view_buttons;
public class CustomAH extends Gui {
private enum PriceFilter {
@@ -1589,7 +1598,6 @@ public class CustomAH extends Gui {
return false;
}
- Keyboard.enableRepeatEvents(true);
if (isEditingPrice() && Keyboard.getEventKey() == Keyboard.KEY_RETURN) {
Minecraft.getMinecraft().displayGuiScreen(null);
} else if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorText.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorText.java
index f98c87ee..7acc074b 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorText.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorText.java
@@ -68,7 +68,6 @@ public class GuiOptionEditorText extends GuiOptionEditor {
@Override
public boolean keyboardInput() {
if (Keyboard.getEventKeyState() && textField.getFocus()) {
- Keyboard.enableRepeatEvents(true);
textField.keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey());
try {
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditor.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditor.java
index 651335ed..80ec3811 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditor.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditor.java
@@ -129,8 +129,6 @@ public class GuiPositionEditor extends GuiScreen {
@Override
protected void keyTyped(char typedChar, int keyCode) throws IOException {
- Keyboard.enableRepeatEvents(true);
-
if (keyCode == Keyboard.KEY_R) {
position.set(originalPosition);
} else if (!clicked) {
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/NEUItemEditor.java b/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/NEUItemEditor.java
index 9f256d65..f2edf8bd 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/NEUItemEditor.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/NEUItemEditor.java
@@ -164,10 +164,6 @@ public class NEUItemEditor extends GuiScreen {
);
}
- public void onGuiClosed() {
- Keyboard.enableRepeatEvents(false);
- }
-
public Supplier<String> addTextFieldWithSupplier(String initialText, int options) {
GuiElementTextField textField = new GuiElementTextField(initialText, options);
this.options.add(textField);
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/listener/NEUEventListener.java b/src/main/java/io/github/moulberry/notenoughupdates/listener/NEUEventListener.java
index b86d5828..d070fc2d 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/listener/NEUEventListener.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/listener/NEUEventListener.java
@@ -6,19 +6,24 @@ import io.github.moulberry.notenoughupdates.core.BackgroundBlur;
import io.github.moulberry.notenoughupdates.cosmetics.CapeManager;
import io.github.moulberry.notenoughupdates.dungeons.DungeonBlocks;
import io.github.moulberry.notenoughupdates.dungeons.DungeonWin;
-import io.github.moulberry.notenoughupdates.miscfeatures.*;
+import io.github.moulberry.notenoughupdates.miscfeatures.CrystalMetalDetectorSolver;
+import io.github.moulberry.notenoughupdates.miscfeatures.CrystalOverlay;
+import io.github.moulberry.notenoughupdates.miscfeatures.FairySouls;
+import io.github.moulberry.notenoughupdates.miscfeatures.ItemCustomizeManager;
+import io.github.moulberry.notenoughupdates.miscfeatures.NPCRetexturing;
import io.github.moulberry.notenoughupdates.miscgui.AccessoryBagOverlay;
import io.github.moulberry.notenoughupdates.miscgui.GuiCustomEnchant;
import io.github.moulberry.notenoughupdates.miscgui.StorageOverlay;
import io.github.moulberry.notenoughupdates.overlays.OverlayManager;
import io.github.moulberry.notenoughupdates.overlays.TextOverlay;
-import io.github.moulberry.notenoughupdates.util.*;
+import io.github.moulberry.notenoughupdates.util.Constants;
+import io.github.moulberry.notenoughupdates.util.ProfileApiSyncer;
+import io.github.moulberry.notenoughupdates.util.SBInfo;
+import io.github.moulberry.notenoughupdates.util.Utils;
+import io.github.moulberry.notenoughupdates.util.XPInformation;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
-import net.minecraft.client.gui.GuiChat;
-import net.minecraft.client.gui.GuiScreenBook;
import net.minecraft.client.gui.inventory.GuiChest;
-import net.minecraft.client.gui.inventory.GuiEditSign;
import net.minecraft.event.ClickEvent;
import net.minecraft.init.Items;
import net.minecraft.inventory.ContainerChest;
@@ -148,10 +153,6 @@ public class NEUEventListener {
if (event.phase != TickEvent.Phase.START) return;
if (Minecraft.getMinecraft().theWorld == null) return;
if (Minecraft.getMinecraft().thePlayer == null) return;
- Keyboard.enableRepeatEvents(Minecraft.getMinecraft().currentScreen != null &&
- (Minecraft.getMinecraft().currentScreen instanceof GuiChat ||
- Minecraft.getMinecraft().currentScreen instanceof GuiEditSign ||
- Minecraft.getMinecraft().currentScreen instanceof GuiScreenBook));
if ((Keyboard.isKeyDown(Keyboard.KEY_NUMPAD1) && Keyboard.isKeyDown(Keyboard.KEY_NUMPAD4) && Keyboard.isKeyDown(
Keyboard.KEY_NUMPAD9))) {
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 6df2dd9a..ef2c67a8 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java
@@ -1018,6 +1018,13 @@ public class RenderListener {
*/
@SubscribeEvent
public void onGuiScreenKeyboard(GuiScreenEvent.KeyboardInputEvent.Pre event) {
+ Keyboard.enableRepeatEvents(true);
+ if (Minecraft.getMinecraft().currentScreen instanceof GuiInventory &&
+ !NEUOverlay.searchBarHasFocus &&
+ Keyboard.isRepeatEvent()) {
+ event.setCanceled(true);
+ return;
+ }
if (typing) {
event.setCanceled(true);
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiInvButtonEditor.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiInvButtonEditor.java
index 7c74c6e2..850d8328 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiInvButtonEditor.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiInvButtonEditor.java
@@ -1,6 +1,11 @@
package io.github.moulberry.notenoughupdates.miscgui;
-import com.google.gson.*;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParseException;
+import com.google.gson.JsonParser;
+import com.google.gson.JsonPrimitive;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.core.GlScissorStack;
import io.github.moulberry.notenoughupdates.core.GuiElementTextField;
@@ -17,7 +22,6 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.ResourceLocation;
-import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
@@ -29,8 +33,15 @@ import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Base64;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
import java.util.List;
-import java.util.*;
+import java.util.Map;
+import java.util.UUID;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
@@ -130,7 +141,6 @@ public class GuiInvButtonEditor extends GuiScreen {
super();
reloadExtraIcons();
reloadPresets();
- Keyboard.enableRepeatEvents(true);
}
private static void reloadExtraIcons() {
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemCustomize.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemCustomize.java
index 12d48991..0645ede7 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemCustomize.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemCustomize.java
@@ -1,7 +1,12 @@
package io.github.moulberry.notenoughupdates.miscgui;
import com.google.common.collect.Lists;
-import io.github.moulberry.notenoughupdates.core.*;
+import io.github.moulberry.notenoughupdates.core.ChromaColour;
+import io.github.moulberry.notenoughupdates.core.GlScissorStack;
+import io.github.moulberry.notenoughupdates.core.GuiElement;
+import io.github.moulberry.notenoughupdates.core.GuiElementBoolean;
+import io.github.moulberry.notenoughupdates.core.GuiElementColour;
+import io.github.moulberry.notenoughupdates.core.GuiElementTextField;
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;
@@ -356,8 +361,6 @@ public class GuiItemCustomize extends GuiScreen {
@Override
protected void keyTyped(char typedChar, int keyCode) throws IOException {
- Keyboard.enableRepeatEvents(true);
-
if (textFieldRename.getFocus()) {
if (keyCode == Keyboard.KEY_ESCAPE) {
textFieldRename.setFocus(false);
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 0d8cb6ec..ac3ddfb8 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java
@@ -2,7 +2,11 @@ package io.github.moulberry.notenoughupdates.miscgui;
import com.google.common.collect.Lists;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
-import io.github.moulberry.notenoughupdates.core.*;
+import io.github.moulberry.notenoughupdates.core.BackgroundBlur;
+import io.github.moulberry.notenoughupdates.core.ChromaColour;
+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.config.KeybindHelper;
import io.github.moulberry.notenoughupdates.core.util.lerp.LerpingInteger;
import io.github.moulberry.notenoughupdates.miscfeatures.BetterContainers;
@@ -38,19 +42,17 @@ 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;
-import java.util.*;
+import java.util.Map;
+import java.util.Set;
public class StorageOverlay extends GuiElement {
+ public static final ResourceLocation[] STORAGE_PREVIEW_TEXTURES = new ResourceLocation[4];
private static final int CHEST_TOP_OFFSET = 17;
private static final int CHEST_SLOT_SIZE = 18;
private static final int CHEST_BOTTOM_OFFSET = 215;
-
- private Framebuffer framebuffer = null;
-
- private final Set<Vector2f> enchantGlintRenderLocations = new HashSet<>();
-
- 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");
@@ -58,6 +60,9 @@ public class StorageOverlay extends GuiElement {
"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";
+ private static final ResourceLocation RES_ITEM_GLINT = new ResourceLocation("textures/misc/enchanted_item_glint.png");
static {
for (int i = 0; i < STORAGE_TEXTURES.length; i++) {
@@ -81,52 +86,193 @@ public class StorageOverlay extends GuiElement {
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 final Set<Vector2f> enchantGlintRenderLocations = new HashSet<>();
private final GuiElementTextField searchBar = new GuiElementTextField("", 88, 10,
GuiElementTextField.SCALE_TEXT | GuiElementTextField.DISABLE_BG
);
private final GuiElementTextField renameStorageField = new GuiElementTextField("", 100, 13,
GuiElementTextField.COLOUR
);
-
+ private final int[][] isPaneCaches = new int[40][];
+ private final int[][] ctmIndexCaches = new int[40][];
+ private final LerpingInteger scroll = new LerpingInteger(0, 200);
+ private Framebuffer framebuffer = null;
private int editingNameId = -1;
-
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;
-
- private final int[][] isPaneCaches = new int[40][];
- private final int[][] ctmIndexCaches = new int[40][];
-
private int desiredHeightSwitch = -1;
private int desiredHeightMX = -1;
private int desiredHeightMY = -1;
-
private boolean dirty = false;
private boolean allowTypingInSearchBar = true;
-
private int scrollGrabOffset = -1;
- private final LerpingInteger scroll = new LerpingInteger(0, 200);
+ public static StorageOverlay getInstance() {
+ return INSTANCE;
+ }
+
+ private static boolean shouldConnect(int paneIndex1, int paneIndex2) {
+ if (paneIndex1 == 16 || paneIndex2 == 16) return false;
+ if (paneIndex1 < 1 || paneIndex2 < 1) return false;
+ return paneIndex1 == paneIndex2;
+
+ }
+
+ public static int getCTMIndex(StorageManager.StoragePage page, int index, int[] isPaneCache, int[] ctmIndexCache) {
+ if (page.items[index] == null) {
+ ctmIndexCache[index] = -1;
+ return -1;
+ }
+
+ int paneType = getPaneType(page.items[index], index, isPaneCache);
+
+ int upIndex = index - 9;
+ int leftIndex = index % 9 > 0 ? index - 1 : -1;
+ int rightIndex = index % 9 < 8 ? index + 1 : -1;
+ int downIndex = index + 9;
+ int upleftIndex = index % 9 > 0 ? index - 10 : -1;
+ int uprightIndex = index % 9 < 8 ? index - 8 : -1;
+ int downleftIndex = index % 9 > 0 ? index + 8 : -1;
+ int downrightIndex = index % 9 < 8 ? index + 10 : -1;
+
+ boolean up = upIndex >= 0 && upIndex < isPaneCache.length && shouldConnect(getPaneType(
+ page.items[upIndex],
+ upIndex,
+ isPaneCache
+ ), paneType);
+ boolean left = leftIndex >= 0 && leftIndex < isPaneCache.length && shouldConnect(getPaneType(
+ page.items[leftIndex],
+ leftIndex,
+ isPaneCache
+ ), paneType);
+ boolean down = downIndex >= 0 && downIndex < isPaneCache.length && shouldConnect(getPaneType(
+ page.items[downIndex],
+ downIndex,
+ isPaneCache
+ ), paneType);
+ boolean right = rightIndex >= 0 && rightIndex < isPaneCache.length && shouldConnect(getPaneType(
+ page.items[rightIndex],
+ rightIndex,
+ isPaneCache
+ ), paneType);
+ boolean upleft = upleftIndex >= 0 && upleftIndex < isPaneCache.length && shouldConnect(getPaneType(
+ page.items[upleftIndex],
+ upleftIndex,
+ isPaneCache
+ ), paneType);
+ boolean upright = uprightIndex >= 0 && uprightIndex < isPaneCache.length && shouldConnect(getPaneType(
+ page.items[uprightIndex],
+ uprightIndex,
+ isPaneCache
+ ), paneType);
+ boolean downleft = downleftIndex >= 0 && downleftIndex < isPaneCache.length && shouldConnect(getPaneType(
+ page.items[downleftIndex],
+ downleftIndex,
+ isPaneCache
+ ), paneType);
+ boolean downright = downrightIndex >= 0 && downrightIndex < isPaneCache.length &&
+ shouldConnect(getPaneType(page.items[downrightIndex], downrightIndex, isPaneCache), paneType);
+
+ int ctmIndex = BetterContainers.getCTMIndex(up, right, down, left, upleft, upright, downright, downleft);
+ ctmIndexCache[index] = ctmIndex;
+ return ctmIndex;
+ }
+
+ public static int getRGBFromPane(int paneType) {
+ int rgb = -1;
+ EnumChatFormatting formatting = EnumChatFormatting.WHITE;
+ switch (paneType) {
+ case 0:
+ formatting = EnumChatFormatting.WHITE;
+ break;
+ case 1:
+ formatting = EnumChatFormatting.GOLD;
+ break;
+ case 2:
+ formatting = EnumChatFormatting.LIGHT_PURPLE;
+ break;
+ case 3:
+ formatting = EnumChatFormatting.BLUE;
+ break;
+ case 4:
+ formatting = EnumChatFormatting.YELLOW;
+ break;
+ case 5:
+ formatting = EnumChatFormatting.GREEN;
+ break;
+ case 6:
+ rgb = 0xfff03c96;
+ break;
+ case 7:
+ formatting = EnumChatFormatting.DARK_GRAY;
+ break;
+ case 8:
+ formatting = EnumChatFormatting.GRAY;
+ break;
+ case 9:
+ formatting = EnumChatFormatting.DARK_AQUA;
+ break;
+ case 10:
+ formatting = EnumChatFormatting.DARK_PURPLE;
+ break;
+ case 11:
+ formatting = EnumChatFormatting.DARK_BLUE;
+ break;
+ case 12:
+ rgb = 0xffA0522D;
+ break;
+ case 13:
+ formatting = EnumChatFormatting.DARK_GREEN;
+ break;
+ case 14:
+ formatting = EnumChatFormatting.DARK_RED;
+ break;
+ case 15:
+ rgb = 0x00000000;
+ break;
+ case 16:
+ rgb = SpecialColour.specialToChromaRGB(CHROMA_STR);
+ break;
+ }
+ if (rgb != -1) return rgb;
+ return 0xff000000 | Minecraft.getMinecraft().fontRendererObj.getColorCode(formatting.toString().charAt(1));
+ }
+
+ public static int getPaneType(ItemStack stack, int index, int[] cache) {
+ if (cache != null && cache[index] != 0) return cache[index];
+
+ if (NotEnoughUpdates.INSTANCE.config.storageGUI.fancyPanes == 2) {
+ if (cache != null) cache[index] = -1;
+ return -1;
+ }
+
+ if (stack != null &&
+ (stack.getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane) || stack.getItem() == Item.getItemFromBlock(
+ Blocks.glass_pane))) {
+ String internalName = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(stack);
+ if (internalName != null) {
+ if (internalName.startsWith("STAINED_GLASS_PANE")) {
+ if (cache != null) cache[index] = stack.getItemDamage() + 1;
+ return stack.getItemDamage() + 1;
+ } else if (internalName.startsWith("THIN_GLASS")) {
+ if (cache != null) cache[index] = 17;
+ return 17;
+ }
+ }
+ }
+ if (cache != null) cache[index] = -1;
+ return -1;
+ }
private int getMaximumScroll() {
synchronized (StorageManager.getInstance().storageConfig.displayToStorageIdMapRender) {
@@ -194,6 +340,7 @@ public class StorageOverlay extends GuiElement {
@Override
public void render() {
if (!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) return;
+
GuiChest guiChest = (GuiChest) Minecraft.getMinecraft().currentScreen;
ContainerChest containerChest = (ContainerChest) guiChest.inventorySlots;
@@ -1537,161 +1684,6 @@ public class StorageOverlay extends GuiElement {
GlStateManager.translate(0, 0, -300);
}
- private static boolean shouldConnect(int paneIndex1, int paneIndex2) {
- if (paneIndex1 == 16 || paneIndex2 == 16) return false;
- if (paneIndex1 < 1 || paneIndex2 < 1) return false;
- return paneIndex1 == paneIndex2;
-
- }
-
- public static int getCTMIndex(StorageManager.StoragePage page, int index, int[] isPaneCache, int[] ctmIndexCache) {
- if (page.items[index] == null) {
- ctmIndexCache[index] = -1;
- return -1;
- }
-
- int paneType = getPaneType(page.items[index], index, isPaneCache);
-
- int upIndex = index - 9;
- int leftIndex = index % 9 > 0 ? index - 1 : -1;
- int rightIndex = index % 9 < 8 ? index + 1 : -1;
- int downIndex = index + 9;
- int upleftIndex = index % 9 > 0 ? index - 10 : -1;
- int uprightIndex = index % 9 < 8 ? index - 8 : -1;
- int downleftIndex = index % 9 > 0 ? index + 8 : -1;
- int downrightIndex = index % 9 < 8 ? index + 10 : -1;
-
- boolean up = upIndex >= 0 && upIndex < isPaneCache.length && shouldConnect(getPaneType(
- page.items[upIndex],
- upIndex,
- isPaneCache
- ), paneType);
- boolean left = leftIndex >= 0 && leftIndex < isPaneCache.length && shouldConnect(getPaneType(
- page.items[leftIndex],
- leftIndex,
- isPaneCache
- ), paneType);
- boolean down = downIndex >= 0 && downIndex < isPaneCache.length && shouldConnect(getPaneType(
- page.items[downIndex],
- downIndex,
- isPaneCache
- ), paneType);
- boolean right = rightIndex >= 0 && rightIndex < isPaneCache.length && shouldConnect(getPaneType(
- page.items[rightIndex],
- rightIndex,
- isPaneCache
- ), paneType);
- boolean upleft = upleftIndex >= 0 && upleftIndex < isPaneCache.length && shouldConnect(getPaneType(
- page.items[upleftIndex],
- upleftIndex,
- isPaneCache
- ), paneType);
- boolean upright = uprightIndex >= 0 && uprightIndex < isPaneCache.length && shouldConnect(getPaneType(
- page.items[uprightIndex],
- uprightIndex,
- isPaneCache
- ), paneType);
- boolean downleft = downleftIndex >= 0 && downleftIndex < isPaneCache.length && shouldConnect(getPaneType(
- page.items[downleftIndex],
- downleftIndex,
- isPaneCache
- ), paneType);
- boolean downright = downrightIndex >= 0 && downrightIndex < isPaneCache.length &&
- shouldConnect(getPaneType(page.items[downrightIndex], downrightIndex, isPaneCache), paneType);
-
- int ctmIndex = BetterContainers.getCTMIndex(up, right, down, left, upleft, upright, downright, downleft);
- ctmIndexCache[index] = ctmIndex;
- return ctmIndex;
- }
-
- private static final String CHROMA_STR = "230:255:255:0:0";
-
- public static int getRGBFromPane(int paneType) {
- int rgb = -1;
- EnumChatFormatting formatting = EnumChatFormatting.WHITE;
- switch (paneType) {
- case 0:
- formatting = EnumChatFormatting.WHITE;
- break;
- case 1:
- formatting = EnumChatFormatting.GOLD;
- break;
- case 2:
- formatting = EnumChatFormatting.LIGHT_PURPLE;
- break;
- case 3:
- formatting = EnumChatFormatting.BLUE;
- break;
- case 4:
- formatting = EnumChatFormatting.YELLOW;
- break;
- case 5:
- formatting = EnumChatFormatting.GREEN;
- break;
- case 6:
- rgb = 0xfff03c96;
- break;
- case 7:
- formatting = EnumChatFormatting.DARK_GRAY;
- break;
- case 8:
- formatting = EnumChatFormatting.GRAY;
- break;
- case 9:
- formatting = EnumChatFormatting.DARK_AQUA;
- break;
- case 10:
- formatting = EnumChatFormatting.DARK_PURPLE;
- break;
- case 11:
- formatting = EnumChatFormatting.DARK_BLUE;
- break;
- case 12:
- rgb = 0xffA0522D;
- break;
- case 13:
- formatting = EnumChatFormatting.DARK_GREEN;
- break;