样板供应器增加升级槽
This commit is contained in:
parent
6d7e82e793
commit
655c17c7f9
|
|
@ -0,0 +1,34 @@
|
|||
package com.extendedae_plus.mixin.ae2.menu;
|
||||
|
||||
import appeng.menu.AEBaseMenu;
|
||||
import appeng.menu.SlotSemantics;
|
||||
import appeng.menu.implementations.PatternProviderMenu;
|
||||
import appeng.api.upgrades.IUpgradeInventory;
|
||||
import com.extendedae_plus.util.ExtendedAELogger;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
/**
|
||||
* 去重样板供应器升级槽的菜单注入:
|
||||
* - 多个模组(AppliedFlux、expandedae等)都会在 PatternProviderMenu 的构造中调用 setupUpgrades,
|
||||
* 导致同一套升级槽 UI 被重复添加(渲染为四个)。
|
||||
* - 拦截 AEBaseMenu.setupUpgrades,在目标菜单为 PatternProviderMenu 且已存在升级槽时取消后续注入。
|
||||
*/
|
||||
@Mixin(value = AEBaseMenu.class, priority = 2000, remap = false)
|
||||
public abstract class AEBaseMenuUpgradesDedupMixin {
|
||||
|
||||
@Inject(method = "setupUpgrades(Lappeng/api/upgrades/IUpgradeInventory;)V", at = @At("HEAD"), cancellable = true)
|
||||
private void eap$dedupPatternProviderUpgradeSlots(IUpgradeInventory upgrades, CallbackInfo ci) {
|
||||
// 仅对样板供应器菜单去重,避免影响其他菜单
|
||||
if (((Object) this) instanceof PatternProviderMenu) {
|
||||
var self = (AEBaseMenu) (Object) this;
|
||||
var existing = self.getSlots(SlotSemantics.UPGRADE);
|
||||
if (existing != null && !existing.isEmpty()) {
|
||||
ExtendedAELogger.LOGGER.debug("[样板供应器][菜单] 检测到升级槽已存在({}),取消重复注入", existing.size());
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -34,19 +34,12 @@ public abstract class PatternProviderMenuUpgradesMixin extends AEBaseMenu implem
|
|||
private void eap$initUpgrades(MenuType<?> menuType, int id, Inventory playerInventory, PatternProviderLogicHost host, CallbackInfo ci) {
|
||||
this.eap$toolbox = new ToolboxMenu(this);
|
||||
|
||||
// 现在 PatternProviderLogic 始终实现 IUpgradeableObject(通过我们的 mixin)
|
||||
if (this.logic instanceof IUpgradeableObject upgradeableLogic) {
|
||||
IUpgradeInventory upgrades = upgradeableLogic.getUpgrades();
|
||||
if (upgrades != null && upgrades != appeng.api.upgrades.UpgradeInventories.empty()) {
|
||||
ExtendedAELogger.LOGGER.debug("[样板供应器][菜单] 设置升级槽 UI,槽位数: {}", upgrades.size());
|
||||
this.setupUpgrades(upgrades);
|
||||
} else {
|
||||
ExtendedAELogger.LOGGER.debug("[样板供应器][菜单] 升级槽为空或未初始化");
|
||||
}
|
||||
} else if (UpgradeSlotCompat.shouldEnableUpgradeSlots()) {
|
||||
// 备用方案:使用 compat 升级槽
|
||||
ExtendedAELogger.LOGGER.debug("[样板供应器][菜单] 备用方案:使用 compat 升级槽");
|
||||
// 当未安装 AppliedFlux 时,我们负责注入升级槽;安装了 AF 则由 AF 的菜单 Mixin 负责,避免重复渲染
|
||||
if (UpgradeSlotCompat.shouldEnableUpgradeSlots()) {
|
||||
ExtendedAELogger.LOGGER.debug("[样板供应器][菜单] 注入升级槽: 使用自带 compat 槽");
|
||||
this.setupUpgrades(((CompatUpgradeProvider) this.logic).eap$getCompatUpgrades());
|
||||
} else {
|
||||
ExtendedAELogger.LOGGER.debug("[样板供应器][菜单] 跳过注入升级槽: 由 AE2/AppliedFlux 负责渲染");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@
|
|||
"ae2.helpers.PatternProviderLogicUpgradesMixin",
|
||||
"ae2.helpers.patternprovider.PatternProviderLogicTickerMixin",
|
||||
"ae2.menu.InterfaceMenuUpgradesMixin",
|
||||
"ae2.menu.AEBaseMenuUpgradesDedupMixin",
|
||||
"ae2.menu.PatternProviderMenuUpgradesMixin",
|
||||
"ae2.parts.automation.IOBusPartChannelCardMixin",
|
||||
"ae2.parts.storagebus.StorageBusPartChannelCardMixin",
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user