diff --git a/src/main/java/com/klikli_dev/occultism/client/gui/storage/StorageControllerGuiBase.java b/src/main/java/com/klikli_dev/occultism/client/gui/storage/StorageControllerGuiBase.java index 9c18f9b11..750984075 100644 --- a/src/main/java/com/klikli_dev/occultism/client/gui/storage/StorageControllerGuiBase.java +++ b/src/main/java/com/klikli_dev/occultism/client/gui/storage/StorageControllerGuiBase.java @@ -102,6 +102,9 @@ public abstract class StorageControllerGuiBase cachedStacksToDisplay; + private String cachedSearchString; + public StorageControllerGuiBase(T container, Inventory playerInventory, Component name) { super(container, playerInventory, name); this.storageControllerContainer = container; @@ -725,11 +728,18 @@ protected List applySearchToItems() { String searchText = this.searchBar.getValue(); if (!searchText.equals("")) { + if (this.cachedStacksToDisplay != null && this.cachedSearchString != null && this.cachedSearchString.equals(searchText)) + return this.cachedStacksToDisplay; + List stacksToDisplay = new ArrayList<>(); for (ItemStack stack : this.stacks) { if (this.itemMatchesSearch(stack)) stacksToDisplay.add(stack); } + + this.cachedStacksToDisplay = stacksToDisplay; + this.cachedSearchString = searchText; + return stacksToDisplay; } return new ArrayList<>(this.stacks);