接口槽位
This commit is contained in:
parent
330b80dfec
commit
86aa1dd3da
|
|
@ -69,7 +69,7 @@ public class EntitySpeedTickerPart extends UpgradeablePart implements IGridTicka
|
||||||
|
|
||||||
// 静态块:初始化缓存
|
// 静态块:初始化缓存
|
||||||
static {
|
static {
|
||||||
if (ModCheckUtils.isLoaded(ModCheckUtils.MODID_APPFLUX)) {
|
if (ModCheckUtils.isAppfluxLoading()) {
|
||||||
try {
|
try {
|
||||||
Class<?> helperClass = Class.forName("com.extendedae_plus.util.entitySpeed.FluxEnergyHelper");
|
Class<?> helperClass = Class.forName("com.extendedae_plus.util.entitySpeed.FluxEnergyHelper");
|
||||||
Method method = helperClass.getMethod("extractFE", IEnergyService.class, MEStorage.class, long.class, IActionSource.class);
|
Method method = helperClass.getMethod("extractFE", IEnergyService.class, MEStorage.class, long.class, IActionSource.class);
|
||||||
|
|
|
||||||
|
|
@ -41,10 +41,6 @@ public abstract class InterfaceLogicChannelCardMixin implements IInterfaceWirele
|
||||||
|
|
||||||
@Unique
|
@Unique
|
||||||
private int eap$delayedInitTicks = 0;
|
private int eap$delayedInitTicks = 0;
|
||||||
|
|
||||||
static {
|
|
||||||
// InterfaceLogicChannelCardMixin 已加载
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(method = "onUpgradesChanged", at = @At("TAIL"), remap = false)
|
@Inject(method = "onUpgradesChanged", at = @At("TAIL"), remap = false)
|
||||||
private void eap$onUpgradesChangedTail(CallbackInfo ci) {
|
private void eap$onUpgradesChangedTail(CallbackInfo ci) {
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import appeng.api.upgrades.IUpgradeInventory;
|
||||||
import appeng.api.upgrades.UpgradeInventories;
|
import appeng.api.upgrades.UpgradeInventories;
|
||||||
import appeng.helpers.InterfaceLogic;
|
import appeng.helpers.InterfaceLogic;
|
||||||
import appeng.helpers.InterfaceLogicHost;
|
import appeng.helpers.InterfaceLogicHost;
|
||||||
import com.extendedae_plus.compat.UpgradeSlotCompat;
|
import com.extendedae_plus.util.ModCheckUtils;
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
import org.spongepowered.asm.mixin.Final;
|
import org.spongepowered.asm.mixin.Final;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
|
@ -40,34 +40,14 @@ public class InterfaceLogicUpgradesMixin {
|
||||||
require = 0 // 设置为可选注入,避免在某些情况下导致崩溃
|
require = 0 // 设置为可选注入,避免在某些情况下导致崩溃
|
||||||
)
|
)
|
||||||
private void expandInterfaceUpgrades(IManagedGridNode gridNode, InterfaceLogicHost host, Item is, int slots, CallbackInfo ci) {
|
private void expandInterfaceUpgrades(IManagedGridNode gridNode, InterfaceLogicHost host, Item is, int slots, CallbackInfo ci) {
|
||||||
try {
|
int currentSlots = this.upgrades.size();
|
||||||
// 安全检查
|
|
||||||
if (this.upgrades == null || gridNode == null || host == null || is == null) {
|
// 默认 1 个,有 Applied Flux 时希望至少 3 个,否则至少 2 个
|
||||||
return;
|
int desiredSlots = ModCheckUtils.isAppfluxLoading() ? 3 : 2;
|
||||||
}
|
|
||||||
|
// 仅当当前槽位小于期望值时才扩容;如果已 >= desiredSlots 则不改动(避免降级或叠加)
|
||||||
int currentSlots = this.upgrades.size();
|
if (currentSlots < desiredSlots) {
|
||||||
|
this.upgrades = UpgradeInventories.forMachine(is, desiredSlots, this::onUpgradesChanged);
|
||||||
// 检查Applied Flux是否已经修改了升级槽
|
|
||||||
if (UpgradeSlotCompat.isAppfluxPresent()) {
|
|
||||||
if (currentSlots >= 3) {
|
|
||||||
// Applied Flux已经增加了足够的升级槽,跳过修改
|
|
||||||
return;
|
|
||||||
} else if (currentSlots == 2) {
|
|
||||||
// Applied Flux增加到2个,我们再增加1个到3个
|
|
||||||
this.upgrades = UpgradeInventories.forMachine(is, 3, this::onUpgradesChanged);
|
|
||||||
} else if (currentSlots == 1) {
|
|
||||||
// Applied Flux存在但未生效,直接增加到3个
|
|
||||||
this.upgrades = UpgradeInventories.forMachine(is, 3, this::onUpgradesChanged);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (currentSlots == 1) {
|
|
||||||
// Applied Flux不存在,将升级槽从1个增加到2个
|
|
||||||
this.upgrades = UpgradeInventories.forMachine(is, 2, this::onUpgradesChanged);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
// 发生异常时不修改升级槽,确保不会崩溃
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -78,4 +78,8 @@ public class ModCheckUtils {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isAppfluxLoading() {
|
||||||
|
return ModCheckUtils.isLoaded(ModCheckUtils.MODID_APPFLUX);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user