feat: 调整
This commit is contained in:
parent
6aa43a64ee
commit
ed336f8aa9
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -4,7 +4,7 @@ build/
|
||||||
out/
|
out/
|
||||||
classes/
|
classes/
|
||||||
source/
|
source/
|
||||||
Applied-Energistics-2-forge-1.20.1/
|
|
||||||
# Eclipse
|
# Eclipse
|
||||||
*.tmp
|
*.tmp
|
||||||
*.bak
|
*.bak
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,6 @@ public class AdvPatternProviderLogicDoublingMixin implements ISmartDoublingHolde
|
||||||
|
|
||||||
@Unique private boolean eap$smartDoubling = false;
|
@Unique private boolean eap$smartDoubling = false;
|
||||||
@Unique private int eap$providerScalingLimit = 0; // 供应器级别的上限,0 表示不限制
|
@Unique private int eap$providerScalingLimit = 0; // 供应器级别的上限,0 表示不限制
|
||||||
@Unique private boolean eap$multiplierDirty = false; // 标记是否需要重新计算 multiplier
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean eap$getSmartDoubling() {
|
public boolean eap$getSmartDoubling() {
|
||||||
|
|
@ -48,7 +47,6 @@ public class AdvPatternProviderLogicDoublingMixin implements ISmartDoublingHolde
|
||||||
@Override
|
@Override
|
||||||
public void eap$setProviderSmartDoublingLimit(int limit) {
|
public void eap$setProviderSmartDoublingLimit(int limit) {
|
||||||
this.eap$providerScalingLimit = limit;
|
this.eap$providerScalingLimit = limit;
|
||||||
this.eap$multiplierDirty = true;
|
|
||||||
try {
|
try {
|
||||||
((AdvPatternProviderLogic) (Object) this).updatePatterns();
|
((AdvPatternProviderLogic) (Object) this).updatePatterns();
|
||||||
} catch (Throwable ignored) {}
|
} catch (Throwable ignored) {}
|
||||||
|
|
@ -80,18 +78,10 @@ public class AdvPatternProviderLogicDoublingMixin implements ISmartDoublingHolde
|
||||||
for (IPatternDetails details : list) {
|
for (IPatternDetails details : list) {
|
||||||
if (details instanceof AEProcessingPattern proc && proc instanceof ISmartDoublingAwarePattern pattern) {
|
if (details instanceof AEProcessingPattern proc && proc instanceof ISmartDoublingAwarePattern pattern) {
|
||||||
pattern.eap$setAllowScaling(allow);
|
pattern.eap$setAllowScaling(allow);
|
||||||
if (this.eap$multiplierDirty) {
|
pattern.eap$setMultiplierLimit(getComputedMul(proc, limit));
|
||||||
pattern.eap$setMultiplierLimit(getComputedMul(proc, limit));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 如果刚刚重建了 multiplier 清除脏标记
|
} catch (Throwable ignored) {}
|
||||||
if (this.eap$multiplierDirty) {
|
|
||||||
this.eap$multiplierDirty = false;
|
|
||||||
}
|
|
||||||
} catch (Throwable ignored) {
|
|
||||||
this.eap$multiplierDirty = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Shadow
|
@Shadow
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,6 @@ public class PatternProviderLogicDoublingMixin implements ISmartDoublingHolder {
|
||||||
|
|
||||||
@Unique private boolean eap$smartDoubling = false;
|
@Unique private boolean eap$smartDoubling = false;
|
||||||
@Unique private int eap$providerScalingLimit = 0; // 供应器级别的上限,0 表示不限制
|
@Unique private int eap$providerScalingLimit = 0; // 供应器级别的上限,0 表示不限制
|
||||||
@Unique private boolean eap$multiplierDirty = false; // 标记是否需要重新计算 multiplier
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean eap$getSmartDoubling() {
|
public boolean eap$getSmartDoubling() {
|
||||||
|
|
@ -48,7 +47,6 @@ public class PatternProviderLogicDoublingMixin implements ISmartDoublingHolder {
|
||||||
@Override
|
@Override
|
||||||
public void eap$setProviderSmartDoublingLimit(int limit) {
|
public void eap$setProviderSmartDoublingLimit(int limit) {
|
||||||
this.eap$providerScalingLimit = limit;
|
this.eap$providerScalingLimit = limit;
|
||||||
this.eap$multiplierDirty = true;
|
|
||||||
try {
|
try {
|
||||||
((PatternProviderLogic) (Object) this).updatePatterns();
|
((PatternProviderLogic) (Object) this).updatePatterns();
|
||||||
} catch (Throwable ignored) {}
|
} catch (Throwable ignored) {}
|
||||||
|
|
@ -81,18 +79,10 @@ public class PatternProviderLogicDoublingMixin implements ISmartDoublingHolder {
|
||||||
for (IPatternDetails details : list) {
|
for (IPatternDetails details : list) {
|
||||||
if (details instanceof AEProcessingPattern proc && proc instanceof ISmartDoublingAwarePattern pattern) {
|
if (details instanceof AEProcessingPattern proc && proc instanceof ISmartDoublingAwarePattern pattern) {
|
||||||
pattern.eap$setAllowScaling(allow);
|
pattern.eap$setAllowScaling(allow);
|
||||||
if (this.eap$multiplierDirty) {
|
pattern.eap$setMultiplierLimit(getComputedMul(proc, limit));
|
||||||
pattern.eap$setMultiplierLimit(getComputedMul(proc, limit));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 如果刚刚重建了 multiplier 清除脏标记
|
} catch (Throwable ignored) {}
|
||||||
if (this.eap$multiplierDirty) {
|
|
||||||
this.eap$multiplierDirty = false;
|
|
||||||
}
|
|
||||||
} catch (Throwable ignored) {
|
|
||||||
this.eap$multiplierDirty = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Shadow
|
@Shadow
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
package com.extendedae_plus.util.smartDoubling;
|
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.AEKey;
|
||||||
import appeng.api.stacks.GenericStack;
|
import appeng.api.stacks.GenericStack;
|
||||||
import appeng.crafting.pattern.AEProcessingPattern;
|
import appeng.crafting.pattern.AEProcessingPattern;
|
||||||
|
|
@ -106,17 +108,48 @@ public final class PatternScaler {
|
||||||
|
|
||||||
for (var input : proc.getInputs()) {
|
for (var input : proc.getInputs()) {
|
||||||
long amt = input.getMultiplier();
|
long amt = input.getMultiplier();
|
||||||
if (amt > 0) {
|
if (amt <= 0) continue;
|
||||||
// 保证翻倍限制至少为 1
|
|
||||||
long allowedMul = Math.max(1, limit / amt);
|
AEKey key = input.getPossibleInputs()[0].what();
|
||||||
minMul = Math.min(minMul, allowedMul);
|
|
||||||
}
|
// 使用统一单位换算
|
||||||
|
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) {
|
if (minMul != Long.MAX_VALUE) {
|
||||||
computedMul = (int) minMul;
|
computedMul = (int) Math.min(minMul, Integer.MAX_VALUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return computedMul;
|
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; // 默认单位
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user