智能倍增相关健全性处理
This commit is contained in:
parent
eace9531ea
commit
55c58ff89f
|
|
@ -26,7 +26,10 @@ public abstract class CraftingSimulationStateMixin {
|
||||||
* 替换 CraftingPlan 构建逻辑,在此统一处理样板倍率
|
* 替换 CraftingPlan 构建逻辑,在此统一处理样板倍率
|
||||||
*/
|
*/
|
||||||
@Inject(method = "buildCraftingPlan", at = @At("HEAD"))
|
@Inject(method = "buildCraftingPlan", at = @At("HEAD"))
|
||||||
private static void onBuildCraftingPlan(CraftingSimulationState state, CraftingCalculation calculation, long calculatedAmount, CallbackInfoReturnable<CraftingPlan> cir) {
|
private static void onBuildCraftingPlan(CraftingSimulationState state,
|
||||||
|
CraftingCalculation calculation,
|
||||||
|
long calculatedAmount,
|
||||||
|
CallbackInfoReturnable<CraftingPlan> cir) {
|
||||||
CraftingSimulationStateAccessor accessor = (CraftingSimulationStateAccessor) state;
|
CraftingSimulationStateAccessor accessor = (CraftingSimulationStateAccessor) state;
|
||||||
Map<IPatternDetails, Long> crafts = accessor.getCrafts();
|
Map<IPatternDetails, Long> crafts = accessor.getCrafts();
|
||||||
// 存放最终分配后的 crafts
|
// 存放最终分配后的 crafts
|
||||||
|
|
@ -108,4 +111,4 @@ public abstract class CraftingSimulationStateMixin {
|
||||||
crafts.clear();
|
crafts.clear();
|
||||||
crafts.putAll(finalCrafts);
|
crafts.putAll(finalCrafts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -73,17 +73,19 @@ public final class PatternScaler {
|
||||||
for (IPatternDetails.IInput input : proc.getInputs()) {
|
for (IPatternDetails.IInput input : proc.getInputs()) {
|
||||||
long amt = input.getMultiplier();
|
long amt = input.getMultiplier();
|
||||||
if (amt <= 0) continue;
|
if (amt <= 0) continue;
|
||||||
|
var possible = input.getPossibleInputs();
|
||||||
|
if (possible == null || possible.length == 0) continue;
|
||||||
|
AEKey key = possible[0].what();
|
||||||
|
long unitMul = getUnitMultiplier(key);
|
||||||
|
long limitInUnit = (long) limit * unitMul;
|
||||||
|
|
||||||
AEKey key = input.getPossibleInputs()[0].what();
|
long allowed = limitInUnit / amt;
|
||||||
long unitMultiplier = getUnitMultiplier(key);
|
allowed = Math.max(1L, allowed);
|
||||||
long limitInAEUnit = (long) limit * unitMultiplier;
|
minMul = Math.min(minMul, allowed);
|
||||||
|
|
||||||
long allowedMul = limitInAEUnit / amt;
|
|
||||||
allowedMul = Math.max(1, allowedMul); // 至少 1
|
|
||||||
minMul = Math.min(minMul, allowedMul);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return minMul != Long.MAX_VALUE ? (int) Math.min(minMul, Integer.MAX_VALUE) : 0;
|
if (minMul == Long.MAX_VALUE) return 0; // 无有效输入 → 不限制
|
||||||
|
return minMul > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) minMul;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static long getUnitMultiplier(AEKey key) {
|
private static long getUnitMultiplier(AEKey key) {
|
||||||
|
|
@ -95,8 +97,7 @@ public final class PatternScaler {
|
||||||
if ("me.ramidzkh.mekae2.ae2.MekanismKey".equals(key.getClass().getName())) {
|
if ("me.ramidzkh.mekae2.ae2.MekanismKey".equals(key.getClass().getName())) {
|
||||||
return 1000L;
|
return 1000L;
|
||||||
}
|
}
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {}
|
||||||
}
|
|
||||||
return 1L;
|
return 1L;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user