aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDoKM <54663875+DoKM@users.noreply.github.com>2021-08-30 22:35:18 +0200
committerGitHub <noreply@github.com>2021-08-30 22:35:18 +0200
commit946817f3d840d83c5855df889a6c5949e54a67f0 (patch)
treec3030869e7062c2385517bc0e01d4975f122afb1 /src
parentd7f9b39792d17d8ee204a46b5ff8be3c217ea2a1 (diff)
parentb0164aa3994e4b74c6d7a15c1fe5d03f16dcba2e (diff)
downloadNotEnoughUpdates-946817f3d840d83c5855df889a6c5949e54a67f0.tar.gz
NotEnoughUpdates-946817f3d840d83c5855df889a6c5949e54a67f0.tar.bz2
NotEnoughUpdates-946817f3d840d83c5855df889a6c5949e54a67f0.zip
Merge pull request #29 from DeDiamondPro/master
Fixes
Diffstat (limited to 'src')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java4
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/StorageManager.java41
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java29
3 files changed, 44 insertions, 30 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java
index 97c31a58..cdbfd433 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java
@@ -1420,7 +1420,8 @@ public class NEUEventListener {
if(containerName.contains(" Profile") && eventGui.getSlotUnderMouse() != null &&
eventGui.getSlotUnderMouse().getSlotIndex() == 42 && Mouse.getEventButton() >= 0) {
event.setCanceled(true);
- if(eventGui.inventorySlots.inventorySlots.get(22).getStack() != null && eventGui.inventorySlots.inventorySlots.get(22).getStack().getTagCompound() != null){
+ if(Mouse.getEventButtonState() && eventGui.inventorySlots.inventorySlots.get(22).getStack() != null &&
+ eventGui.inventorySlots.inventorySlots.get(22).getStack().getTagCompound() != null){
NBTTagCompound tag = eventGui.inventorySlots.inventorySlots.get(22).getStack().getTagCompound();
if(tag.hasKey("SkullOwner") && tag.getCompoundTag("SkullOwner").hasKey("Name")){
String username = tag.getCompoundTag("SkullOwner").getString("Name");
@@ -1428,7 +1429,6 @@ public class NEUEventListener {
NotEnoughUpdates.INSTANCE.viewProfileRunnable.processCommand(null, new String[]{username});
}
}
-
}
}
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 03e6b98e..3a3aec6d 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/StorageManager.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/StorageManager.java
@@ -166,6 +166,7 @@ public class StorageManager {
public static class StorageConfig {
public HashMap<String, StoragePage[]> pages = new HashMap<>();
public final HashMap<Integer, Integer> displayToStorageIdMap = new HashMap<>();
+ public final HashMap<Integer, Integer> displayToStorageIdMapRender = new HashMap<>();
}
public StorageConfig storageConfig = new StorageConfig();
@@ -387,6 +388,16 @@ public class StorageManager {
return -1;
}
+ public int getDisplayIdForStorageIdRender(int storageId) {
+ if(storageId < 0) return -1;
+ for(Map.Entry<Integer, Integer> entry : storageConfig.displayToStorageIdMapRender.entrySet()) {
+ if(entry.getValue() == storageId) {
+ return entry.getKey();
+ }
+ }
+ return -1;
+ }
+
public boolean onAnyClick() {
if(onStorageMenu && desiredStoragePage >= 0) {
if(desiredStoragePage < 9) {
@@ -491,21 +502,22 @@ public class StorageManager {
if(changed) {
synchronized(storageConfig.displayToStorageIdMap) {
storageConfig.displayToStorageIdMap.clear();
+ storageConfig.displayToStorageIdMapRender.clear();
int displayIndex = 0;
for(int i=0; i<storagePresent.length; i++) {
if(storagePresent[i]) {
- if(lastSearch == null || lastSearch.isEmpty()) {
- storageConfig.displayToStorageIdMap.put(displayIndex++, i);
- } else {
+ storageConfig.displayToStorageIdMap.put(displayIndex, i);
+ if(lastSearch != null && !lastSearch.isEmpty()){
StoragePage page = getPage(i, false);
if(page != null) {
updateSearchForPage(lastSearch, page);
if(page.matchesSearch) {
- storageConfig.displayToStorageIdMap.put(displayIndex++, i);
+ storageConfig.displayToStorageIdMapRender.put(displayIndex++, i);
}
}
- }
+ } else
+ storageConfig.displayToStorageIdMapRender.put(displayIndex++, i);
}
}
}
@@ -530,21 +542,22 @@ public class StorageManager {
if(changed) {
synchronized(storageConfig.displayToStorageIdMap) {
storageConfig.displayToStorageIdMap.clear();
+ storageConfig.displayToStorageIdMapRender.clear();
int displayIndex = 0;
for(int i=0; i<storagePresent.length; i++) {
if(storagePresent[i]) {
- if(lastSearch == null || lastSearch.isEmpty()) {
- storageConfig.displayToStorageIdMap.put(displayIndex++, i);
- } else {
+ storageConfig.displayToStorageIdMap.put(displayIndex, i);
+ if(lastSearch != null && !lastSearch.isEmpty()){
StoragePage page = getPage(i, false);
if(page != null) {
updateSearchForPage(lastSearch, page);
if(page.matchesSearch) {
- storageConfig.displayToStorageIdMap.put(displayIndex++, i);
+ storageConfig.displayToStorageIdMapRender.put(displayIndex++, i);
}
}
- }
+ } else
+ storageConfig.displayToStorageIdMapRender.put(displayIndex++, i);
}
}
}
@@ -590,8 +603,8 @@ public class StorageManager {
public void searchDisplay(String searchStr) {
if(storagePresent == null) return;
- synchronized(storageConfig.displayToStorageIdMap) {
- storageConfig.displayToStorageIdMap.clear();
+ synchronized(storageConfig.displayToStorageIdMapRender) {
+ storageConfig.displayToStorageIdMapRender.clear();
lastSearch = searchStr;
int sid = searchId.incrementAndGet();
@@ -603,10 +616,10 @@ public class StorageManager {
if(page.rows > 0) {
updateSearchForPage(searchStr, page);
if(page.matchesSearch) {
- storageConfig.displayToStorageIdMap.put(displayIndex++, i);
+ storageConfig.displayToStorageIdMapRender.put(displayIndex++, i);
}
} else {
- storageConfig.displayToStorageIdMap.put(displayIndex++, i);
+ storageConfig.displayToStorageIdMapRender.put(displayIndex++, i);
page.matchesSearch = true;
page.searchedId = sid;
}
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 6b459ecb..d80a5daf 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java
@@ -125,12 +125,12 @@ public class StorageOverlay extends GuiElement {
private LerpingInteger scroll = new LerpingInteger(0, 200);
private int getMaximumScroll() {
- synchronized(StorageManager.getInstance().storageConfig.displayToStorageIdMap) {
+ synchronized(StorageManager.getInstance().storageConfig.displayToStorageIdMapRender) {
int maxH = 0;
for(int i=0; i<3; i++) {
- int lastDisplayId = StorageManager.getInstance().storageConfig.displayToStorageIdMap.size()-1;
+ int lastDisplayId = StorageManager.getInstance().storageConfig.displayToStorageIdMapRender.size()-1;
int coords = (int)Math.ceil(lastDisplayId/3f)*3+1+i;
int h = getPageCoords(coords).y+scroll.getValue()-getStorageViewSize()-14;
@@ -305,8 +305,8 @@ public class StorageOverlay extends GuiElement {
int startY = getPageCoords(0).y;
if(OpenGlHelper.isFramebufferEnabled()) {
int h;
- synchronized(StorageManager.getInstance().storageConfig.displayToStorageIdMap) {
- int lastDisplayId = StorageManager.getInstance().storageConfig.displayToStorageIdMap.size()-1;
+ synchronized(StorageManager.getInstance().storageConfig.displayToStorageIdMapRender) {
+ int lastDisplayId = StorageManager.getInstance().storageConfig.displayToStorageIdMapRender.size()-1;
int coords = (int)Math.ceil(lastDisplayId/3f)*3+3;
h = getPageCoords(coords).y+scroll.getValue();
@@ -363,7 +363,7 @@ public class StorageOverlay extends GuiElement {
if(doItemRender) {
enchantGlintRenderLocations.clear();
- for(Map.Entry<Integer, Integer> entry : StorageManager.getInstance().storageConfig.displayToStorageIdMap.entrySet()) {
+ for(Map.Entry<Integer, Integer> entry : StorageManager.getInstance().storageConfig.displayToStorageIdMapRender.entrySet()) {
int displayId = entry.getKey();
int storageId = entry.getValue();
@@ -583,7 +583,7 @@ public class StorageOverlay extends GuiElement {
}
GlScissorStack.push(0, guiTop+3, width, guiTop+3+storageViewSize, scaledResolution);
- for(Map.Entry<Integer, Integer> entry : StorageManager.getInstance().storageConfig.displayToStorageIdMap.entrySet()) {
+ for(Map.Entry<Integer, Integer> entry : StorageManager.getInstance().storageConfig.displayToStorageIdMapRender.entrySet()) {
int displayId = entry.getKey();
int storageId = entry.getValue();
@@ -1427,10 +1427,10 @@ public class StorageOverlay extends GuiElement {
for(int j=i; j<i+3; j++) {
if(NotEnoughUpdates.INSTANCE.config.storageGUI.masonryMode && displayId%3 != j%3) continue;
- if(!StorageManager.getInstance().storageConfig.displayToStorageIdMap.containsKey(j)) {
+ if(!StorageManager.getInstance().storageConfig.displayToStorageIdMapRender.containsKey(j)) {
continue;
}
- int storageId = StorageManager.getInstance().storageConfig.displayToStorageIdMap.get(j);
+ int storageId = StorageManager.getInstance().storageConfig.displayToStorageIdMapRender.get(j);
StorageManager.StoragePage page = StorageManager.getInstance().getPage(storageId, false);
if(page == null || page.rows <= 0) {
maxRows = Math.max(maxRows, 3);
@@ -1543,13 +1543,14 @@ public class StorageOverlay extends GuiElement {
if(mouseX > guiLeft+181 && mouseX < guiLeft+181+162 &&
mouseY > guiTop+storageViewSize+18 && mouseY < guiTop+storageViewSize+94) {
+ if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT))
+ dirty = true;
return false;
}
if(mouseY > guiTop+3 && mouseY < guiTop+storageViewSize+3) {
int currentPage = StorageManager.getInstance().getCurrentPageId();
-
- for(Map.Entry<Integer, Integer> entry : StorageManager.getInstance().storageConfig.displayToStorageIdMap.entrySet()) {
+ for(Map.Entry<Integer, Integer> entry : StorageManager.getInstance().storageConfig.displayToStorageIdMapRender.entrySet()) {
IntPair pageCoords = getPageCoords(entry.getKey());
if(pageCoords.y > storageViewSize+3 || pageCoords.y+90 < 3) continue;
@@ -1704,7 +1705,7 @@ public class StorageOverlay extends GuiElement {
} else if(Mouse.getEventButtonState() && Mouse.getEventButton() == 0) {
for(int i=0; i<9; i++) {
int storageId = i;
- int displayId = StorageManager.getInstance().getDisplayIdForStorageId(i);
+ int displayId = StorageManager.getInstance().getDisplayIdForStorageIdRender(i);
StorageManager.StoragePage page = StorageManager.getInstance().getPage(storageId, false);
if(page != null) {
@@ -1721,7 +1722,7 @@ public class StorageOverlay extends GuiElement {
}
for(int i=0; i<18; i++) {
int storageId = i+StorageManager.MAX_ENDER_CHEST_PAGES;
- int displayId = StorageManager.getInstance().getDisplayIdForStorageId(i);
+ int displayId = StorageManager.getInstance().getDisplayIdForStorageIdRender(i);
StorageManager.StoragePage page = StorageManager.getInstance().getPage(storageId, false);
if(page != null) {
@@ -1804,7 +1805,7 @@ public class StorageOverlay extends GuiElement {
}
} else {
int currentPage = StorageManager.getInstance().getCurrentPageId();
- int displayId = StorageManager.getInstance().getDisplayIdForStorageId(currentPage);
+ int displayId = StorageManager.getInstance().getDisplayIdForStorageIdRender(currentPage);
if(displayId >= 0) {
IntPair pageCoords = getPageCoords(displayId);
@@ -1854,7 +1855,7 @@ public class StorageOverlay extends GuiElement {
if(Keyboard.getEventKeyState()) {
if(NotEnoughUpdates.INSTANCE.config.slotLocking.enableSlotLocking &&
- KeybindHelper.isKeyPressed(NotEnoughUpdates.INSTANCE.config.slotLocking.slotLockKey)) {
+ KeybindHelper.isKeyPressed(NotEnoughUpdates.INSTANCE.config.slotLocking.slotLockKey) && !searchBar.getFocus()) {
if(!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) return true;
GuiContainer container = (GuiContainer) Minecraft.getMinecraft().currentScreen;