feat: 调整

This commit is contained in:
C-H716 2025-10-11 02:36:32 +08:00
parent 6aa43a64ee
commit ed336f8aa9
4 changed files with 44 additions and 31 deletions

2
.gitignore vendored
View File

@ -4,7 +4,7 @@ build/
out/
classes/
source/
Applied-Energistics-2-forge-1.20.1/
# Eclipse
*.tmp
*.bak

View File

@ -24,7 +24,6 @@ public class AdvPatternProviderLogicDoublingMixin implements ISmartDoublingHolde
@Unique private boolean eap$smartDoubling = false;
@Unique private int eap$providerScalingLimit = 0; // 供应器级别的上限0 表示不限制
@Unique private boolean eap$multiplierDirty = false; // 标记是否需要重新计算 multiplier
@Override
public boolean eap$getSmartDoubling() {
@ -48,7 +47,6 @@ public class AdvPatternProviderLogicDoublingMixin implements ISmartDoublingHolde
@Override
public void eap$setProviderSmartDoublingLimit(int limit) {
this.eap$providerScalingLimit = limit;
this.eap$multiplierDirty = true;
try {
((AdvPatternProviderLogic) (Object) this).updatePatterns();
} catch (Throwable ignored) {}
@ -80,18 +78,10 @@ public class AdvPatternProviderLogicDoublingMixin implements ISmartDoublingHolde
for (IPatternDetails details : list) {
if (details instanceof AEProcessingPattern proc && proc instanceof ISmartDoublingAwarePattern pattern) {
pattern.eap$setAllowScaling(allow);
if (this.eap$multiplierDirty) {
pattern.eap$setMultiplierLimit(getComputedMul(proc, limit));
}
pattern.eap$setMultiplierLimit(getComputedMul(proc, limit));
}
}
// 如果刚刚重建了 multiplier 清除脏标记
if (this.eap$multiplierDirty) {
this.eap$multiplierDirty = false;
}
} catch (Throwable ignored) {
this.eap$multiplierDirty = true;
}
} catch (Throwable ignored) {}
}
@Shadow

View File

@ -24,7 +24,6 @@ public class PatternProviderLogicDoublingMixin implements ISmartDoublingHolder {
@Unique private boolean eap$smartDoubling = false;
@Unique private int eap$providerScalingLimit = 0; // 供应器级别的上限0 表示不限制
@Unique private boolean eap$multiplierDirty = false; // 标记是否需要重新计算 multiplier
@Override
public boolean eap$getSmartDoubling() {
@ -48,7 +47,6 @@ public class PatternProviderLogicDoublingMixin implements ISmartDoublingHolder {
@Override
public void eap$setProviderSmartDoublingLimit(int limit) {
this.eap$providerScalingLimit = limit;
this.eap$multiplierDirty = true;
try {
((PatternProviderLogic) (Object) this).updatePatterns();
} catch (Throwable ignored) {}
@ -81,18 +79,10 @@ public class PatternProviderLogicDoublingMixin implements ISmartDoublingHolder {
for (IPatternDetails details : list) {
if (details instanceof AEProcessingPattern proc && proc instanceof ISmartDoublingAwarePattern pattern) {
pattern.eap$setAllowScaling(allow);
if (this.eap$multiplierDirty) {
pattern.eap$setMultiplierLimit(getComputedMul(proc, limit));
}
pattern.eap$setMultiplierLimit(getComputedMul(proc, limit));
}
}
// 如果刚刚重建了 multiplier 清除脏标记
if (this.eap$multiplierDirty) {
this.eap$multiplierDirty = false;
}
} catch (Throwable ignored) {
this.eap$multiplierDirty = true;
}
} catch (Throwable ignored) {}
}
@Shadow

View File

@ -1,5 +1,7 @@
package com.extendedae_plus.util.smartDoubling;
import appeng.api.stacks.AEFluidKey;
import appeng.api.stacks.AEItemKey;
import appeng.api.stacks.AEKey;
import appeng.api.stacks.GenericStack;
import appeng.crafting.pattern.AEProcessingPattern;
@ -106,17 +108,48 @@ public final class PatternScaler {
for (var input : proc.getInputs()) {
long amt = input.getMultiplier();
if (amt > 0) {
// 保证翻倍限制至少为 1
long allowedMul = Math.max(1, limit / amt);
minMul = Math.min(minMul, allowedMul);
}
if (amt <= 0) continue;
AEKey key = input.getPossibleInputs()[0].what();
// 使用统一单位换算
long unitMultiplier = getUnitMultiplier(key);
long limitInAEUnit = limit * unitMultiplier;
// 计算该输入允许的倍数
long allowedMul = limitInAEUnit / amt;
// 保证至少为 1
allowedMul = Math.max(1, allowedMul);
// 取最小值保证所有输入都不超过 limit
minMul = Math.min(minMul, allowedMul);
}
if (minMul != Long.MAX_VALUE) {
computedMul = (int) minMul;
computedMul = (int) Math.min(minMul, Integer.MAX_VALUE);
}
}
return computedMul;
}
/**
* 获取 AEKey 的单位换算系数
* 物品默认 1流体默认 1000其它类型可通过扩展接口提供
*/
private static long getUnitMultiplier(AEKey key) {
if (key instanceof AEItemKey) return 1L;
if (key instanceof AEFluidKey) return 1000L;
try {
// 反射判断扩展 Key 类型
if (key.getClass().getName().equals("me.ramidzkh.mekae2.ae2.MekanismKey")) {
return 1000L;
}
// 根据需要继续增加
} catch (Exception ignored) {}
return 1L; // 默认单位
}
}