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 56061b5..2d95d6e 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,7 @@ package com.extendedae_plus.api.storage; import appeng.api.config.Actionable; +import appeng.api.config.IncludeExclude; import appeng.api.networking.security.IActionSource; import appeng.api.stacks.AEItemKey; import appeng.api.stacks.AEKey; @@ -8,7 +9,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.items.InfinityBigIntegerCellItem; import com.extendedae_plus.util.storage.InfinityConstants; import com.extendedae_plus.util.storage.InfinityDataStorage; @@ -41,6 +46,8 @@ public class InfinityBigIntegerCellInventory implements StorageCell { private final InfinityStorageManager storageManager; // AE2 提供的保存提供者,用于在容器中批量保存时触发回调 private final ISaveProvider container; + private final IPartitionList partitionList; + private final IncludeExclude partitionListMode; // 存储物品键和数量的映射 private Object2ObjectMap AEKey2AmountsMap; // 存储的物品种类数量 @@ -64,6 +71,17 @@ public class InfinityBigIntegerCellInventory implements StorageCell { // 初始化 storedAmounts 为 null,延迟加载物品数据 this.AEKey2AmountsMap = null; this.storageManager = storageManager; + 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(); // 初始化磁盘数据 this.initData(); } @@ -166,6 +184,7 @@ public class InfinityBigIntegerCellInventory implements StorageCell { this.self.set(DataComponents.CUSTOM_DATA, CustomData.of(tag)); + this.isPersisted = true; this.initData(); } return; @@ -302,6 +321,18 @@ public class InfinityBigIntegerCellInventory implements StorageCell { } } + private ConfigInventory getConfigInventory() { + return this.cell.getConfigInventory(this.self); + } + + private IUpgradeInventory getUpgradesInventory() { + return this.cell.getUpgrades(this.self); + } + + private appeng.api.config.FuzzyMode getFuzzyMode() { + return this.cell.getFuzzyMode(this.self); + } + // 插入物品到存储单元 @Override public long insert(AEKey what, long amount, Actionable mode, IActionSource source) { @@ -309,6 +340,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 && @@ -405,7 +439,7 @@ public class InfinityBigIntegerCellInventory implements StorageCell { // 获取存储单元的描述(此处返回null,可自定义) @Override public Component getDescription() { - return null; + return this.self.getHoverName(); } // 获取存储单元内所有物品的总数量(格式化字符串) diff --git a/src/main/java/com/extendedae_plus/init/UpgradeCards.java b/src/main/java/com/extendedae_plus/init/UpgradeCards.java index c07f6b7..94c398e 100644 --- a/src/main/java/com/extendedae_plus/init/UpgradeCards.java +++ b/src/main/java/com/extendedae_plus/init/UpgradeCards.java @@ -62,10 +62,14 @@ public class UpgradeCards { Upgrades.add(ModItems.CHANNEL_CARD.get(), com.glodblock.github.extendedae.common.EAESingletons.PRECISE_STORAGE_BUS, 1, storageGroup); Upgrades.add(ModItems.CHANNEL_CARD.get(), com.glodblock.github.extendedae.common.EAESingletons.PRECISE_EXPORT_BUS, 1, ioBusGroup); Upgrades.add(ModItems.CHANNEL_CARD.get(), com.glodblock.github.extendedae.common.EAESingletons.THRESHOLD_EXPORT_BUS, 1, ioBusGroup); + + String storageCellGroup = GuiText.StorageCells.getTranslationKey(); + Upgrades.add(AEItems.FUZZY_CARD, ModItems.INFINITY_BIGINTEGER_CELL_ITEM.get(), 1, storageCellGroup); + Upgrades.add(AEItems.INVERTER_CARD, ModItems.INFINITY_BIGINTEGER_CELL_ITEM.get(), 1, storageCellGroup); // 超大接口 Upgrades.add(ModItems.CHANNEL_CARD.get(), com.glodblock.github.extendedae.common.EAESingletons.OVERSIZE_INTERFACE, 1, interfaceGroup); Upgrades.add(ModItems.CHANNEL_CARD.get(), com.glodblock.github.extendedae.common.EAESingletons.OVERSIZE_INTERFACE_PART, 1, interfaceGroup); }); } -} \ 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 6aa9795..948e24b 100644 --- a/src/main/java/com/extendedae_plus/items/InfinityBigIntegerCellItem.java +++ b/src/main/java/com/extendedae_plus/items/InfinityBigIntegerCellItem.java @@ -1,7 +1,12 @@ package com.extendedae_plus.items; import appeng.api.config.FuzzyMode; +import appeng.api.ids.AEComponents; 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; @@ -25,8 +30,7 @@ public class InfinityBigIntegerCellItem extends Item implements ICellWorkbenchIt @Override public void appendHoverText(ItemStack stack, TooltipContext context, List tooltip, TooltipFlag tooltipFlag) { - tooltip.add(Component.translatable("tooltip.extendedae_plus.infinity_biginteger_cell.summon1")); - tooltip.add(Component.translatable("tooltip.extendedae_plus.infinity_biginteger_cell.summon2")); + tooltip.add(Component.translatable("tooltip.extendedae_plus.infinity_biginteger_cell")); Preconditions.checkArgument(stack.getItem() == this); // 仅在 ItemStack 自身存在 UUID 时显示 UUID,避免触发持久化或加载逻辑 @@ -77,12 +81,23 @@ public class InfinityBigIntegerCellItem extends Item implements ICellWorkbenchIt } } + @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; + return itemStack.getOrDefault(AEComponents.STORAGE_CELL_FUZZY_MODE, FuzzyMode.IGNORE_ALL); } @Override public void setFuzzyMode(ItemStack itemStack, FuzzyMode fuzzyMode) { + itemStack.set(AEComponents.STORAGE_CELL_FUZZY_MODE, fuzzyMode); } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/extendedae_plus/lang/en_us.json b/src/main/resources/assets/extendedae_plus/lang/en_us.json index 3e0001c..41981ea 100644 --- a/src/main/resources/assets/extendedae_plus/lang/en_us.json +++ b/src/main/resources/assets/extendedae_plus/lang/en_us.json @@ -48,8 +48,7 @@ "item.extendedae_plus.entity_speed_card.x8": "Entity Speed Card (x8)", "item.extendedae_plus.entity_speed_card.x16": "Entity Speed Card (x16)", "item.extendedae_plus.infinity_biginteger_cell": "§4De§cvou§6rer §eof §aCo§bsmic §dSilence", - "tooltip.extendedae_plus.infinity_biginteger_cell.summon1": "§6Through ninefold sacrifice, the Void echoes§r—§8Iava, Lord of the Void§r, bestows upon thee this artifact", - "tooltip.extendedae_plus.infinity_biginteger_cell.summon2": "§b—§4A §dUni§cverse §eWith§ain §6A §bSin§5gle §9Point", + "tooltip.extendedae_plus.infinity_biginteger_cell": "§7—§bThe tangible projection of absolute storage§r, §ewhere '§6The Finite§e' §chas been deemed illegal§r\n§bIts very existence§r §bis the ultimate negation of §dentropy§r", "tooltip.extendedae_plus.entity_speed_card.multiplier": "Multiplier: %s", "tooltip.extendedae_plus.entity_speed_card.max": "Maximum Effect: %s Times", diff --git a/src/main/resources/assets/extendedae_plus/lang/zh_cn.json b/src/main/resources/assets/extendedae_plus/lang/zh_cn.json index abb9125..97e90ca 100644 --- a/src/main/resources/assets/extendedae_plus/lang/zh_cn.json +++ b/src/main/resources/assets/extendedae_plus/lang/zh_cn.json @@ -48,8 +48,7 @@ "item.extendedae_plus.entity_speed_card.x8": "实体加速卡 (x8)", "item.extendedae_plus.entity_speed_card.x16": "实体加速卡 (x16)", "item.extendedae_plus.infinity_biginteger_cell": "§4吞§c噬§6万§e籁§a的§b寂§d静", - "tooltip.extendedae_plus.infinity_biginteger_cell.summon1": "§6九重献祭, 终得虚空回响§r——觐见§8虚空之主Iava§r, 赐汝此物", - "tooltip.extendedae_plus.infinity_biginteger_cell.summon2": "§b——§4方§d寸§c之§e间§a, §6自§b有§5千§9寰", + "tooltip.extendedae_plus.infinity_biginteger_cell": "§7——§b绝对存储的现实投影,§e\"有限\"§6已被定义为§c非法\n§b其存在本身,即是对§d熵增§b的终极否定", "tooltip.extendedae_plus.entity_speed_card.multiplier": "乘数: %s", "tooltip.extendedae_plus.entity_speed_card.max": "最大生效: %s 倍",