From 20a1fec6fbb86ee85c7bebe2b67d71f417c6e957 Mon Sep 17 00:00:00 2001 From: Neeve Date: Mon, 5 Feb 2024 13:05:31 +1100 Subject: [PATCH] Recache OreDict Buses on RegEx changes & adjust visibility logic (#395) --- src/main/java/appeng/me/storage/MEInventoryHandler.java | 6 +++++- src/main/java/appeng/parts/misc/PartOreDicStorageBus.java | 4 +--- src/main/java/appeng/parts/misc/PartStorageBus.java | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/appeng/me/storage/MEInventoryHandler.java b/src/main/java/appeng/me/storage/MEInventoryHandler.java index 75b27aa7a4b..9d542218cae 100644 --- a/src/main/java/appeng/me/storage/MEInventoryHandler.java +++ b/src/main/java/appeng/me/storage/MEInventoryHandler.java @@ -117,7 +117,7 @@ public IItemList getAvailableItems(final IItemList out) { if (this.storageFilter == StorageFilter.EXTRACTABLE_ONLY) { var stackList = this.internal.getAvailableItems(this.getChannel().createList()); for (final T t : stackList) { - if (this.canExtract(t)) { + if (this.shouldItemBeAvailable(t)) { out.add(t); } } @@ -198,6 +198,10 @@ protected boolean canExtract(T request) { return this.hasReadAccess; } + private boolean shouldItemBeAvailable(T t) { + return this.hasReadAccess && this.passesBlackOrWhitelist(t); + } + public boolean passesBlackOrWhitelist(T input) { if (this.myPartitionList.isEmpty()) { return true; diff --git a/src/main/java/appeng/parts/misc/PartOreDicStorageBus.java b/src/main/java/appeng/parts/misc/PartOreDicStorageBus.java index c5af6ea6161..08d5e37c298 100644 --- a/src/main/java/appeng/parts/misc/PartOreDicStorageBus.java +++ b/src/main/java/appeng/parts/misc/PartOreDicStorageBus.java @@ -165,9 +165,7 @@ public void saveOreMatch(String oreMatch) { this.oreExp = oreMatch; this.priorityList = new OreDictPriorityList<>(OreHelper.INSTANCE.getMatchingOre(oreExp), oreExp); - if (this.handler != null) { - handler.setPartitionList(this.priorityList); - } + this.resetCache(true); this.getHost().markForSave(); } } diff --git a/src/main/java/appeng/parts/misc/PartStorageBus.java b/src/main/java/appeng/parts/misc/PartStorageBus.java index 0bf72bbf95f..55b8e8dda9d 100644 --- a/src/main/java/appeng/parts/misc/PartStorageBus.java +++ b/src/main/java/appeng/parts/misc/PartStorageBus.java @@ -196,7 +196,7 @@ public IItemHandler getInventoryByName(final String name) { return super.getInventoryByName(name); } - private void resetCache(final boolean fullReset) { + protected void resetCache(final boolean fullReset) { if (this.getHost() == null || this.getHost().getTile() == null || this.getHost().getTile().getWorld() == null || this.getHost().getTile().getWorld().isRemote) { return; } @@ -319,7 +319,7 @@ public TickRateModulation tickingRequest(final IGridNode node, final int ticksSi return TickRateModulation.SLEEP; } - private void resetCache() { + protected void resetCache() { final boolean fullReset = this.resetCacheLogic == 2; this.resetCacheLogic = 0;