From b7a3f60979d8b027637c238d0f2e6d9438f98780 Mon Sep 17 00:00:00 2001 From: GaLi <3096147684@qq.com> Date: Fri, 17 Apr 2026 16:11:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=9E=E5=99=AC=E7=9B=98=E5=AE=9E=E7=8E=B0?= =?UTF-8?q?=E5=88=86=E5=8C=BA=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../InfinityBigIntegerCellInventory.java | 37 ++++++++++++++++++- .../extendedae_plus/init/UpgradeCards.java | 6 ++- .../items/InfinityBigIntegerCellItem.java | 27 +++++++++++++- 3 files changed, 66 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/extendedae_plus/api/storage/InfinityBigIntegerCellInventory.java b/src/main/java/com/extendedae_plus/api/storage/InfinityBigIntegerCellInventory.java index 72b86fc..74d001c 100644 --- a/src/main/java/com/extendedae_plus/api/storage/InfinityBigIntegerCellInventory.java +++ b/src/main/java/com/extendedae_plus/api/storage/InfinityBigIntegerCellInventory.java @@ -1,6 +1,8 @@ package com.extendedae_plus.api.storage; import appeng.api.config.Actionable; +import appeng.api.config.FuzzyMode; +import appeng.api.config.IncludeExclude; import appeng.api.networking.security.IActionSource; import appeng.api.stacks.AEItemKey; import appeng.api.stacks.AEKey; @@ -8,7 +10,11 @@ import appeng.api.stacks.KeyCounter; import appeng.api.storage.cells.CellState; import appeng.api.storage.cells.ISaveProvider; import appeng.api.storage.cells.StorageCell; +import appeng.api.upgrades.IUpgradeInventory; import appeng.core.AELog; +import appeng.core.definitions.AEItems; +import appeng.util.ConfigInventory; +import appeng.util.prioritylist.IPartitionList; import com.extendedae_plus.ExtendedAEPlus; import com.extendedae_plus.items.InfinityBigIntegerCellItem; import com.extendedae_plus.util.storage.InfinityConstants; @@ -37,6 +43,8 @@ public class InfinityBigIntegerCellInventory implements StorageCell { private final ItemStack self; // AE2 提供的保存提供者,用于在容器中批量保存时触发回调 private final ISaveProvider container; + private final IPartitionList partitionList; + private final IncludeExclude partitionListMode; // 存储物品键和数量的映射 private Object2ObjectMap AEKey2AmountsMap; // 存储的物品种类数量 @@ -59,6 +67,17 @@ public class InfinityBigIntegerCellInventory implements StorageCell { this.container = saveProvider; // 初始化 storedAmounts 为 null,延迟加载物品数据 this.AEKey2AmountsMap = null; + var builder = IPartitionList.builder(); + var upgrades = this.getUpgradesInventory(); + var config = this.getConfigInventory(); + boolean hasInverter = upgrades.isInstalled(AEItems.INVERTER_CARD); + boolean isFuzzy = upgrades.isInstalled(AEItems.FUZZY_CARD); + if (isFuzzy) { + builder.fuzzyMode(this.getFuzzyMode()); + } + builder.addAll(config.keySet()); + this.partitionListMode = hasInverter ? IncludeExclude.BLACKLIST : IncludeExclude.WHITELIST; + this.partitionList = builder.build(); // 初始化磁盘数据 initData(); } @@ -146,6 +165,7 @@ public class InfinityBigIntegerCellInventory implements StorageCell { // backward compat: also remove internal cell item count key if present tag.remove(InfinityConstants.INFINITY_CELL_ITEM_COUNT); } + this.isPersisted = true; initData(); } return; @@ -195,7 +215,7 @@ public class InfinityBigIntegerCellInventory implements StorageCell { // 获取存储单元的描述(此处返回null,可自定义) @Override public Component getDescription() { - return null; + return self.getHoverName(); } // 静态方法,创建存储单元库存 @@ -311,6 +331,18 @@ public class InfinityBigIntegerCellInventory implements StorageCell { return ExtendedAEPlus.STORAGE_INSTANCE; } + private ConfigInventory getConfigInventory() { + return this.cell.getConfigInventory(this.self); + } + + private IUpgradeInventory getUpgradesInventory() { + return this.cell.getUpgrades(this.self); + } + + private FuzzyMode getFuzzyMode() { + return this.cell.getFuzzyMode(this.self); + } + // 标记数据需要保存,并通知容器或直接持久化 private void saveChanges() { // 更新存储的物品种类数量 @@ -339,6 +371,9 @@ public class InfinityBigIntegerCellInventory implements StorageCell { if (amount == 0){ return 0; } + if (!this.partitionList.matchesFilter(what, this.partitionListMode)) { + return 0; + } // 不允许存储有物品的无限单元 if (what instanceof AEItemKey itemKey && itemKey.getItem() instanceof InfinityBigIntegerCellItem && diff --git a/src/main/java/com/extendedae_plus/init/UpgradeCards.java b/src/main/java/com/extendedae_plus/init/UpgradeCards.java index b8c438a..eca8feb 100644 --- a/src/main/java/com/extendedae_plus/init/UpgradeCards.java +++ b/src/main/java/com/extendedae_plus/init/UpgradeCards.java @@ -52,9 +52,13 @@ public final class UpgradeCards { Upgrades.add(ModItems.CHANNEL_CARD.get(), AEParts.EXPORT_BUS, 1, ioBusGroup); Upgrades.add(ModItems.CHANNEL_CARD.get(), AEParts.STORAGE_BUS, 1, storageGroup); + String storageCellGroup = GuiText.StorageCells.getTranslationKey(); + Upgrades.add(AEItems.FUZZY_CARD, ModItems.INFINITY_BIGINTEGER_CELL.get(), 1, storageCellGroup); + Upgrades.add(AEItems.INVERTER_CARD, ModItems.INFINITY_BIGINTEGER_CELL.get(), 1, storageCellGroup); + //EAE 的扩展输入/输出总线支持频道卡(部件) Upgrades.add(ModItems.CHANNEL_CARD.get(), EX_IMPORT_BUS, 1, ioBusGroup); Upgrades.add(ModItems.CHANNEL_CARD.get(), EX_EXPORT_BUS, 1, ioBusGroup); }); } -} \ No newline at end of file +} diff --git a/src/main/java/com/extendedae_plus/items/InfinityBigIntegerCellItem.java b/src/main/java/com/extendedae_plus/items/InfinityBigIntegerCellItem.java index d96b295..60b7c5c 100644 --- a/src/main/java/com/extendedae_plus/items/InfinityBigIntegerCellItem.java +++ b/src/main/java/com/extendedae_plus/items/InfinityBigIntegerCellItem.java @@ -2,6 +2,10 @@ package com.extendedae_plus.items; import appeng.api.config.FuzzyMode; import appeng.api.storage.cells.ICellWorkbenchItem; +import appeng.api.upgrades.IUpgradeInventory; +import appeng.api.upgrades.UpgradeInventories; +import appeng.items.contents.CellConfig; +import appeng.util.ConfigInventory; import com.extendedae_plus.api.storage.InfinityBigIntegerCellInventory; import com.extendedae_plus.util.storage.InfinityConstants; import com.google.common.base.Preconditions; @@ -94,12 +98,31 @@ public class InfinityBigIntegerCellItem extends Item implements ICellWorkbenchIt return stack; } + @Override + public IUpgradeInventory getUpgrades(ItemStack itemStack) { + return UpgradeInventories.forItem(itemStack, 4); + } + + @Override + public ConfigInventory getConfigInventory(ItemStack itemStack) { + return CellConfig.create(itemStack); + } + @Override public FuzzyMode getFuzzyMode(ItemStack itemStack) { - return null; + final String fz = itemStack.getOrCreateTag().getString("FuzzyMode"); + if (fz.isEmpty()) { + return FuzzyMode.IGNORE_ALL; + } + try { + return FuzzyMode.valueOf(fz); + } catch (Throwable t) { + return FuzzyMode.IGNORE_ALL; + } } @Override public void setFuzzyMode(ItemStack itemStack, FuzzyMode fuzzyMode) { + itemStack.getOrCreateTag().putString("FuzzyMode", fuzzyMode.name()); } -} \ No newline at end of file +}