This commit is contained in:
GaLicn 2025-09-23 20:11:31 +08:00
parent 48a230386f
commit d3a47ea3d3
3 changed files with 49 additions and 38 deletions

View File

@ -106,7 +106,7 @@ dependencies {
//mae2 //mae2
/* modRuntimeOnly "curse.maven:modern-ae2-additions-1028068:6827727"*/ modRuntimeOnly "curse.maven:modern-ae2-additions-1028068:6827727"
modCompileOnly "curse.maven:modern-ae2-additions-1028068:6827727" modCompileOnly "curse.maven:modern-ae2-additions-1028068:6827727"
//aea //aea

View File

@ -64,6 +64,29 @@ public class MixinConditions implements IMixinConfigPlugin {
return true; // 总是加载在Mixin内部进行运行时检查 return true; // 总是加载在Mixin内部进行运行时检查
} }
// 对于CraftingCPUClusterMixin检查MAE2是否存在
if (mixinClassName.contains("CraftingCPUClusterMixin")) {
try {
// 检查ModList是否已初始化
if (net.minecraftforge.fml.ModList.get() == null) {
System.out.println("[ExtendedAE_Plus] ModList未初始化默认应用CraftingCPU Mixin: " + mixinClassName);
return true; // 未初始化时默认应用
}
boolean mae2Exists = net.minecraftforge.fml.ModList.get().isLoaded("mae2");
boolean shouldApply = !mae2Exists;
System.out.println("[ExtendedAE_Plus] CraftingCPU Mixin检查: " + mixinClassName +
", MAE2存在: " + mae2Exists +
", 应用Mixin: " + shouldApply);
return shouldApply;
} catch (Exception e) {
System.out.println("[ExtendedAE_Plus] ModList检查失败默认跳过CraftingCPU Mixin: " + mixinClassName);
return false; // 出错时默认跳过避免冲突
}
}
// 其他Mixin正常应用 // 其他Mixin正常应用
System.out.println("[ExtendedAE_Plus] 加载Mixin: " + mixinClassName); System.out.println("[ExtendedAE_Plus] 加载Mixin: " + mixinClassName);
return true; return true;

View File

@ -1,48 +1,36 @@
package com.extendedae_plus.mixin.ae2; package com.extendedae_plus.mixin.ae2;
import appeng.blockentity.crafting.CraftingBlockEntity; import appeng.blockentity.crafting.CraftingBlockEntity;
import appeng.blockentity.crafting.CraftingMonitorBlockEntity;
import appeng.me.cluster.implementations.CraftingCPUCluster; import appeng.me.cluster.implementations.CraftingCPUCluster;
import appeng.me.helpers.MachineSource;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
import java.util.List; import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(value = CraftingCPUCluster.class, remap = false, priority = 2000) @Mixin(value = CraftingCPUCluster.class, remap = false, priority = 2000)
public abstract class CraftingCPUClusterMixin { public abstract class CraftingCPUClusterMixin {
// 1) 提升单方块线程上限的常量避免抛出 IAE IllegalArgumentException
@ModifyConstant(
method = "addBlockEntity(Lappeng/blockentity/crafting/CraftingBlockEntity;)V",
constant = @Constant(intValue = 16)
)
private int extendedae_plus$raisePerUnitLimit(int original) {
// 放宽到极大值完全取消单方块 16 线程的硬限制
return Integer.MAX_VALUE;
}
@Shadow private List<CraftingBlockEntity> blockEntities; // 2) 保持统计使用原始线程值若存在多处调用不再返回固定 16
@Shadow private List<CraftingMonitorBlockEntity> status; @Redirect(
@Shadow private MachineSource machineSrc; method = "addBlockEntity(Lappeng/blockentity/crafting/CraftingBlockEntity;)V",
@Shadow private long storage; at = @At(
@Shadow private int accelerator; value = "INVOKE",
target = "Lappeng/blockentity/crafting/CraftingBlockEntity;getAcceleratorThreads()I",
/** ordinal = 1
* 完全重写addBlockEntity方法移除16线程的硬限制 )
* @author ExtendedAE_Plus )
* @reason 移除单方块16线程的硬限制允许更高的线程数 private int extendedae_plus$onGetThreadsForLimitCheck(CraftingBlockEntity te) {
*/ // 返回原始线程数确保总并行单元不被错误下限
@Overwrite return te.getAcceleratorThreads();
void addBlockEntity(CraftingBlockEntity te) {
if (this.machineSrc == null || te.isCoreBlock()) {
this.machineSrc = new MachineSource(te);
}
te.setCoreBlock(false);
te.saveChanges();
this.blockEntities.add(0, te);
if (te instanceof CraftingMonitorBlockEntity) {
this.status.add((CraftingMonitorBlockEntity) te);
}
if (te.getStorageBytes() > 0) {
this.storage += te.getStorageBytes();
}
if (te.getAcceleratorThreads() > 0) {
// 移除原来的16线程限制直接添加线程数
this.accelerator += te.getAcceleratorThreads();
}
} }
} }