feat: 调整
This commit is contained in:
parent
049a3fc182
commit
1f16460372
|
|
@ -49,8 +49,6 @@ public abstract class AdvPatternProviderScreenMixin extends AEBaseScreen<AdvPatt
|
|||
@Unique private boolean eap$SmartDoublingEnabled = false;
|
||||
// 当前智能翻倍上限
|
||||
@Unique private int eap$PerProviderScalingLimit = 0;
|
||||
// 输入框上次是否处于焦点
|
||||
@Unique private boolean eap$PerProviderLimitWasFocused = false;
|
||||
|
||||
public AdvPatternProviderScreenMixin(AdvPatternProviderMenu menu, Inventory playerInventory, Component title, ScreenStyle style) {
|
||||
super(menu, playerInventory, title, style);
|
||||
|
|
@ -189,15 +187,6 @@ public abstract class AdvPatternProviderScreenMixin extends AEBaseScreen<AdvPatt
|
|||
String cur = this.eap$PerProviderLimitInput.getValue();
|
||||
if (cur.isBlank()) cur = "0";
|
||||
this.eap$PerProviderLimitInput.setTooltip(Tooltip.create(Component.literal("单样物品发配数量上限: " + cur)));
|
||||
|
||||
// 失焦时提交最新值
|
||||
boolean focusedNow = this.eap$PerProviderLimitInput.isFocused();
|
||||
if (this.eap$PerProviderLimitWasFocused && !focusedNow) {
|
||||
int value = Integer.parseInt(cur);
|
||||
this.eap$PerProviderScalingLimit = value;
|
||||
ModNetwork.CHANNEL.sendToServer(new SetPerProviderScalingLimitC2SPacket(value));
|
||||
}
|
||||
this.eap$PerProviderLimitWasFocused = focusedNow;
|
||||
} else {
|
||||
// 智能翻倍未启用时,移除输入框
|
||||
this.removeWidget(this.eap$PerProviderLimitInput);
|
||||
|
|
|
|||
|
|
@ -50,8 +50,6 @@ public abstract class SmallAdvPatternProviderScreenMixin extends AEBaseScreen<Sm
|
|||
@Unique private boolean eap$SmartDoublingEnabled = false;
|
||||
// 当前智能翻倍上限
|
||||
@Unique private int eap$PerProviderScalingLimit = 0;
|
||||
// 输入框上次是否处于焦点
|
||||
@Unique private boolean eap$PerProviderLimitWasFocused = false;
|
||||
|
||||
public SmallAdvPatternProviderScreenMixin(SmallAdvPatternProviderMenu menu, Inventory playerInventory, Component title, ScreenStyle style) {
|
||||
super(menu, playerInventory, title, style);
|
||||
|
|
@ -190,15 +188,6 @@ public abstract class SmallAdvPatternProviderScreenMixin extends AEBaseScreen<Sm
|
|||
String cur = this.eap$PerProviderLimitInput.getValue();
|
||||
if (cur.isBlank()) cur = "0";
|
||||
this.eap$PerProviderLimitInput.setTooltip(Tooltip.create(Component.literal("单样物品发配数量上限: " + cur)));
|
||||
|
||||
// 失焦时提交最新值
|
||||
boolean focusedNow = this.eap$PerProviderLimitInput.isFocused();
|
||||
if (this.eap$PerProviderLimitWasFocused && !focusedNow) {
|
||||
int value = Integer.parseInt(cur);
|
||||
this.eap$PerProviderScalingLimit = value;
|
||||
ModNetwork.CHANNEL.sendToServer(new SetPerProviderScalingLimitC2SPacket(value));
|
||||
}
|
||||
this.eap$PerProviderLimitWasFocused = focusedNow;
|
||||
} else {
|
||||
// 智能翻倍未启用时,移除输入框
|
||||
this.removeWidget(this.eap$PerProviderLimitInput);
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ 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() {
|
||||
|
|
@ -33,14 +34,7 @@ public class AdvPatternProviderLogicDoublingMixin implements ISmartDoublingHolde
|
|||
@Override
|
||||
public void eap$setSmartDoubling(boolean value) {
|
||||
this.eap$smartDoubling = value;
|
||||
// 立即将开关状态应用到当前 Provider 的样板上,避免等待下一次 updatePatterns
|
||||
try {
|
||||
var list = ((AdvPatternProviderLogicPatternsAccessor) this).eap$patterns();
|
||||
for (IPatternDetails details : list) {
|
||||
if (details instanceof AEProcessingPattern proc && proc instanceof ISmartDoublingAwarePattern aware) {
|
||||
aware.eap$setAllowScaling(value);
|
||||
}
|
||||
}
|
||||
// 触发一次刷新,让网络及时拿到最新状态(也会触发 ICraftingProvider.requestUpdate(mainNode))
|
||||
((AdvPatternProviderLogic) (Object) this).updatePatterns();
|
||||
} catch (Throwable ignored) {}
|
||||
|
|
@ -53,11 +47,11 @@ 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) {}
|
||||
// 更新供应器级别上限,用于 UI 显示
|
||||
this.eap$providerScalingLimit = Math.max(0, limit);
|
||||
}
|
||||
|
||||
@Inject(method = "writeToNBT", at = @At("TAIL"))
|
||||
|
|
@ -86,10 +80,18 @@ public class AdvPatternProviderLogicDoublingMixin implements ISmartDoublingHolde
|
|||
for (IPatternDetails details : list) {
|
||||
if (details instanceof AEProcessingPattern proc && proc instanceof ISmartDoublingAwarePattern pattern) {
|
||||
pattern.eap$setAllowScaling(allow);
|
||||
pattern.eap$setMultiplierLimit(getComputedMul(proc, limit));
|
||||
if (this.eap$multiplierDirty) {
|
||||
pattern.eap$setMultiplierLimit(getComputedMul(proc, limit));
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Throwable ignored) {}
|
||||
// 如果刚刚重建了 multiplier 清除脏标记
|
||||
if (this.eap$multiplierDirty) {
|
||||
this.eap$multiplierDirty = false;
|
||||
}
|
||||
} catch (Throwable ignored) {
|
||||
this.eap$multiplierDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Shadow
|
||||
|
|
|
|||
|
|
@ -52,8 +52,6 @@ public abstract class PatternProviderScreenMixin<C extends PatternProviderMenu>
|
|||
@Unique private boolean eap$SmartDoublingEnabled = false;
|
||||
// 当前智能翻倍上限
|
||||
@Unique private int eap$PerProviderScalingLimit = 0;
|
||||
// 输入框上次是否处于焦点
|
||||
@Unique private boolean eap$PerProviderLimitWasFocused = false;
|
||||
|
||||
public PatternProviderScreenMixin(C menu, Inventory playerInventory, Component title, ScreenStyle style) {
|
||||
super(menu, playerInventory, title, style);
|
||||
|
|
@ -193,15 +191,6 @@ public abstract class PatternProviderScreenMixin<C extends PatternProviderMenu>
|
|||
String cur = this.eap$PerProviderLimitInput.getValue();
|
||||
if (cur.isBlank()) cur = "0";
|
||||
this.eap$PerProviderLimitInput.setTooltip(Tooltip.create(Component.literal("单样物品发配数量上限: " + cur)));
|
||||
|
||||
// 失焦时提交最新值
|
||||
boolean focusedNow = this.eap$PerProviderLimitInput.isFocused();
|
||||
if (this.eap$PerProviderLimitWasFocused && !focusedNow) {
|
||||
int value = Integer.parseInt(cur);
|
||||
this.eap$PerProviderScalingLimit = value;
|
||||
ModNetwork.CHANNEL.sendToServer(new SetPerProviderScalingLimitC2SPacket(value));
|
||||
}
|
||||
this.eap$PerProviderLimitWasFocused = focusedNow;
|
||||
} else {
|
||||
// 智能翻倍未启用时,移除输入框
|
||||
this.removeWidget(this.eap$PerProviderLimitInput);
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ 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() {
|
||||
|
|
@ -33,15 +34,8 @@ public class PatternProviderLogicDoublingMixin implements ISmartDoublingHolder {
|
|||
@Override
|
||||
public void eap$setSmartDoubling(boolean value) {
|
||||
this.eap$smartDoubling = value;
|
||||
// 立即将开关状态应用到当前 Provider 的样板上,避免等待下一次 updatePatterns
|
||||
// 触发一次刷新
|
||||
try {
|
||||
var list = ((PatternProviderLogicAccessor) this).eap$patterns();
|
||||
for (IPatternDetails details : list) {
|
||||
if (details instanceof AEProcessingPattern proc && proc instanceof ISmartDoublingAwarePattern aware) {
|
||||
aware.eap$setAllowScaling(value);
|
||||
}
|
||||
}
|
||||
// 触发一次刷新,让网络及时拿到最新状态(也会触发 ICraftingProvider.requestUpdate(mainNode))
|
||||
((PatternProviderLogic) (Object) this).updatePatterns();
|
||||
} catch (Throwable ignored) {}
|
||||
}
|
||||
|
|
@ -53,11 +47,11 @@ 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) {}
|
||||
// 更新供应器级别上限,用于 UI 显示
|
||||
this.eap$providerScalingLimit = Math.max(0, limit);
|
||||
}
|
||||
|
||||
@Inject(method = "writeToNBT", at = @At("TAIL"))
|
||||
|
|
@ -87,10 +81,18 @@ public class PatternProviderLogicDoublingMixin implements ISmartDoublingHolder {
|
|||
for (IPatternDetails details : list) {
|
||||
if (details instanceof AEProcessingPattern proc && proc instanceof ISmartDoublingAwarePattern pattern) {
|
||||
pattern.eap$setAllowScaling(allow);
|
||||
pattern.eap$setMultiplierLimit(getComputedMul(proc, limit));
|
||||
if (this.eap$multiplierDirty) {
|
||||
pattern.eap$setMultiplierLimit(getComputedMul(proc, limit));
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Throwable ignored) {}
|
||||
// 如果刚刚重建了 multiplier 清除脏标记
|
||||
if (this.eap$multiplierDirty) {
|
||||
this.eap$multiplierDirty = false;
|
||||
}
|
||||
} catch (Throwable ignored) {
|
||||
this.eap$multiplierDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Shadow
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user