From a822f3aecdb4e3c301a9fad8ee91fb6cc45669db Mon Sep 17 00:00:00 2001 From: samolego <34912839+samolego@users.noreply.github.com> Date: Tue, 25 Oct 2022 20:52:18 +0200 Subject: [PATCH] Search immutable array fix --- .../fabric_client/ClientStorageFabric.java | 2 +- .../fabric_client/inventory/RemoteInventory.java | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/fabric-client/src/main/java/org/samo_lego/clientstorage/fabric_client/ClientStorageFabric.java b/fabric-client/src/main/java/org/samo_lego/clientstorage/fabric_client/ClientStorageFabric.java index 01861da..dc4d7da 100644 --- a/fabric-client/src/main/java/org/samo_lego/clientstorage/fabric_client/ClientStorageFabric.java +++ b/fabric-client/src/main/java/org/samo_lego/clientstorage/fabric_client/ClientStorageFabric.java @@ -53,7 +53,7 @@ public void onInitializeClient() { ClientLoginConnectionEvents.INIT.register(evtHandler::onLogin); UseBlockCallback.EVENT.register(ContainerDiscovery::onUseBlock); - WorldRenderEvents.LAST.register(context -> ESPRender.onRender(context)); + WorldRenderEvents.LAST.register(ESPRender::onRender); if (config.allowSyncServer()) { ClientPlayNetworking.registerGlobalReceiver(SERVER_CONFIG_CHANNEL, (client, handler, buf, responseSender) -> config.unpack(buf)); diff --git a/fabric-client/src/main/java/org/samo_lego/clientstorage/fabric_client/inventory/RemoteInventory.java b/fabric-client/src/main/java/org/samo_lego/clientstorage/fabric_client/inventory/RemoteInventory.java index f1a828b..efd8079 100644 --- a/fabric-client/src/main/java/org/samo_lego/clientstorage/fabric_client/inventory/RemoteInventory.java +++ b/fabric-client/src/main/java/org/samo_lego/clientstorage/fabric_client/inventory/RemoteInventory.java @@ -214,7 +214,7 @@ public void refreshSearchResults(String value) { value = value.substring(1); String finalValue = value; - this.searchStacks = (filtered.stream().filter(stackPair -> stackPair.getFirst().getItemHolder().tags().anyMatch(tagKey -> { + this.searchStacks = new ArrayList<>(filtered.stream().filter(stackPair -> stackPair.getFirst().getItemHolder().tags().anyMatch(tagKey -> { ResourceLocation location = tagKey.location(); String tagName; if (finalValue.contains(":")) { @@ -231,17 +231,17 @@ public void refreshSearchResults(String value) { value = value.substring(1); String finalValue = value; - this.searchStacks = filtered.stream().filter(stackPair -> { + this.searchStacks = new ArrayList<>(filtered.stream().filter(stackPair -> { CompoundTag tag = stackPair.getFirst().getTag(); if (tag == null) { return false; } return tag.toString().toLowerCase(Locale.ROOT).contains(finalValue); - }).toList(); + }).toList()); } else if (value.startsWith("@")) { String finalValue = value; - this.searchStacks = filtered.stream().filter(stackPair -> { + this.searchStacks = new ArrayList<>(filtered.stream().filter(stackPair -> { var search = finalValue.substring(1).split(" "); String namespace = search[0]; final var item = stackPair.getFirst(); @@ -253,15 +253,15 @@ public void refreshSearchResults(String value) { } return namespaceFltr; - }).toList(); + }).toList()); } else { String finalValue = value; - this.searchStacks = filtered.stream() + this.searchStacks = new ArrayList<>(filtered.stream() .filter(stack -> stack.getFirst().getDisplayName() .getString().toLowerCase(Locale.ROOT) .contains(finalValue.toLowerCase(Locale.ROOT))) - .toList(); + .toList()); } }