feat: 修正逻辑
This commit is contained in:
parent
e7add431ce
commit
8ba6aa4fcd
|
|
@ -69,7 +69,10 @@ public class EntitySpeedTickerPart extends UpgradeablePart implements IGridTicka
|
||||||
|
|
||||||
// 静态块:初始化缓存
|
// 静态块:初始化缓存
|
||||||
static {
|
static {
|
||||||
cachedAttempts = ModConfig.INSTANCE.prioritizeDiskEnergy ? new boolean[]{false, true, true} : new boolean[]{true, false, true};
|
// 优先磁盘 -> FE 然后 AE;否则 AE 然后 FE
|
||||||
|
cachedAttempts = ModConfig.INSTANCE.prioritizeDiskEnergy ?
|
||||||
|
new boolean[]{ true, true, false } :
|
||||||
|
new boolean[]{ false, true, true };
|
||||||
if (ModList.get().isLoaded("appflux")) {
|
if (ModList.get().isLoaded("appflux")) {
|
||||||
try {
|
try {
|
||||||
Class<?> helperClass = Class.forName("com.extendedae_plus.util.FluxEnergyHelper");
|
Class<?> helperClass = Class.forName("com.extendedae_plus.util.FluxEnergyHelper");
|
||||||
|
|
@ -118,10 +121,14 @@ public class EntitySpeedTickerPart extends UpgradeablePart implements IGridTicka
|
||||||
*/
|
*/
|
||||||
public static void updateCachedAttempts(boolean prioritizeDiskEnergy) {
|
public static void updateCachedAttempts(boolean prioritizeDiskEnergy) {
|
||||||
synchronized (EntitySpeedTickerPart.class) {
|
synchronized (EntitySpeedTickerPart.class) {
|
||||||
cachedAttempts = prioritizeDiskEnergy ? new boolean[]{false, true, true} : new boolean[]{true, false, true};
|
// 优先磁盘 -> FE 然后 AE;否则 AE 然后 FE
|
||||||
|
cachedAttempts = prioritizeDiskEnergy ?
|
||||||
|
new boolean[]{ true, true, false } :
|
||||||
|
new boolean[]{ false, true, true };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean getAccelerateEnabled() {
|
public boolean getAccelerateEnabled() {
|
||||||
return this.getConfigManager().getSetting(com.extendedae_plus.ae.api.config.Settings.ACCELERATE) == YesNo.YES;
|
return this.getConfigManager().getSetting(com.extendedae_plus.ae.api.config.Settings.ACCELERATE) == YesNo.YES;
|
||||||
}
|
}
|
||||||
|
|
@ -336,35 +343,39 @@ public class EntitySpeedTickerPart extends UpgradeablePart implements IGridTicka
|
||||||
|
|
||||||
for (int i = 0; i < cachedAttempts.length; i++) {
|
for (int i = 0; i < cachedAttempts.length; i++) {
|
||||||
if (!cachedAttempts[i]) continue;
|
if (!cachedAttempts[i]) continue;
|
||||||
if (i == 0 || i == 2) { // FE 提取
|
|
||||||
if (!FE_UNAVAILABLE && cachedFEExtractMethod != null) {
|
// FE 提取
|
||||||
try {
|
if ((i == 0 || i == 2) && !FE_UNAVAILABLE && cachedFEExtractMethod != null) {
|
||||||
long feRequired = (long) requiredPower << 1;
|
try {
|
||||||
long feExtracted = (long) cachedFEExtractMethod.invoke(null, energyService, storage, feRequired, source);
|
long feRequired = (long) requiredPower << 1;
|
||||||
if (feExtracted >= feRequired) {
|
long feExtracted = (long) cachedFEExtractMethod.invoke(null, energyService, storage, feRequired, source);
|
||||||
updateNetworkEnergySufficient(true);
|
if (feExtracted >= feRequired) {
|
||||||
return true;
|
updateNetworkEnergySufficient(true);
|
||||||
}
|
return true;
|
||||||
} catch (Exception e) {
|
|
||||||
FE_UNAVAILABLE = true;
|
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
FE_UNAVAILABLE = true;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
} else { // AE 提取
|
}
|
||||||
|
// AE 提取
|
||||||
|
else {
|
||||||
double simulated = energyService.extractAEPower(requiredPower, Actionable.SIMULATE, PowerMultiplier.CONFIG);
|
double simulated = energyService.extractAEPower(requiredPower, Actionable.SIMULATE, PowerMultiplier.CONFIG);
|
||||||
if (simulated >= requiredPower) {
|
if (simulated >= requiredPower) { // 模拟足够
|
||||||
double extracted = energyService.extractAEPower(requiredPower, Actionable.MODULATE, PowerMultiplier.CONFIG);
|
double extracted = energyService.extractAEPower(requiredPower, Actionable.MODULATE, PowerMultiplier.CONFIG);
|
||||||
boolean sufficient = extracted >= requiredPower;
|
boolean sufficient = extracted >= requiredPower;
|
||||||
updateNetworkEnergySufficient(sufficient);
|
updateNetworkEnergySufficient(sufficient);
|
||||||
if (sufficient) {
|
if (sufficient) return true;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 所有尝试都不够
|
||||||
updateNetworkEnergySufficient(false);
|
updateNetworkEnergySufficient(false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 执行加速 tick 操作。
|
* 执行加速 tick 操作。
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user