Merge remote-tracking branch 'ae/develop/neoforge_iava' into 1.21.1

This commit is contained in:
GaLicn 2025-09-07 13:38:24 +08:00
commit 6369e2f280
4 changed files with 82 additions and 209 deletions

View File

@ -1,159 +0,0 @@
package com.extendedae_plus.client;
import com.extendedae_plus.config.ModConfigs;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.components.CycleButton;
import net.minecraft.client.gui.components.EditBox;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
public class ModConfigScreen extends Screen {
private final Screen parent;
// 输入控件
private EditBox pageMultiplierBox;
private EditBox wirelessMaxRangeBox;
private CycleButton<Boolean> crossDimToggle;
private CycleButton<Boolean> providerRoundRobinToggle;
private EditBox smartScalingMaxMulBox;
private CycleButton<Boolean> showEncoderToggle;
private CycleButton<Boolean> patternTerminalShowSlotsToggle;
public ModConfigScreen(Screen parent) {
super(Component.translatable("screen.extendedae_plus.title"));
this.parent = parent;
}
@Override
protected void init() {
int centerX = this.width / 2;
int y = this.height / 6 + 24; // 起始高度整体更上方
int row = 0;
int rowHeight = 26;
int boxWidth = 150;
// 左右两列左侧标签起点右侧输入控件起点
int leftX = centerX - 170;
int rightX = centerX + 20;
// pageMultiplier: Int 1-64
pageMultiplierBox = new EditBox(this.font, rightX, y + row * rowHeight, boxWidth, 20, Component.translatable("config.extendedae_plus.pageMultiplier"));
pageMultiplierBox.setValue(String.valueOf(ModConfigs.PAGE_MULTIPLIER.get()));
pageMultiplierBox.setFilter(s -> s.matches("\\d*") && parseIntOrDefault(s, 1) >= 1 && parseIntOrDefault(s, 64) <= 64);
this.addRenderableWidget(pageMultiplierBox);
row++;
// wirelessMaxRange: Double 1-4096
wirelessMaxRangeBox = new EditBox(this.font, rightX, y + row * rowHeight, boxWidth, 20, Component.translatable("config.extendedae_plus.wirelessMaxRange"));
wirelessMaxRangeBox.setValue(String.valueOf(ModConfigs.WIRELESS_MAX_RANGE.get()));
wirelessMaxRangeBox.setFilter(s -> s.isEmpty() || s.matches("\\d*(\\.\\d*)?"));
this.addRenderableWidget(wirelessMaxRangeBox);
row++;
// cross dim toggle
crossDimToggle = this.addRenderableWidget(createToggle(rightX, y + row * rowHeight, boxWidth, 20, ModConfigs.WIRELESS_CROSS_DIM_ENABLE.get()));
row++;
// provider round-robin toggle (smart doubling)
providerRoundRobinToggle = this.addRenderableWidget(createToggle(rightX, y + row * rowHeight, boxWidth, 20, ModConfigs.PROVIDER_ROUND_ROBIN_ENABLE.get()));
row++;
// smartScalingMaxMultiplier: Int 0-1048576 (0 means unlimited)
smartScalingMaxMulBox = new EditBox(this.font, rightX, y + row * rowHeight, boxWidth, 20, Component.translatable("config.extendedae_plus.smartScalingMaxMultiplier"));
smartScalingMaxMulBox.setValue(String.valueOf(ModConfigs.SMART_SCALING_MAX_MULTIPLIER.get()));
smartScalingMaxMulBox.setFilter(s -> s.matches("\\d*") && parseIntOrDefault(s, 0) >= 0 && parseIntOrDefault(s, 1048576) <= 1048576);
this.addRenderableWidget(smartScalingMaxMulBox);
row++;
// show encoder pattern player toggle
showEncoderToggle = this.addRenderableWidget(createToggle(rightX, y + row * rowHeight, boxWidth, 20, ModConfigs.SHOW_ENCOD_PATTERN_PLAYER.get()));
row++;
// pattern terminal show slots default toggle
patternTerminalShowSlotsToggle = this.addRenderableWidget(createToggle(rightX, y + row * rowHeight, boxWidth, 20, ModConfigs.PATTERN_TERMINAL_SHOW_SLOTS_DEFAULT.get()));
row++;
// 按钮保存返回
int btnW = 100;
int gap = 8;
int buttonsY = y + row * rowHeight + 18;
this.addRenderableWidget(Button.builder(Component.translatable("gui.done"), b -> saveAndClose())
.bounds(centerX - btnW - gap/2, buttonsY, btnW, 20)
.build());
this.addRenderableWidget(Button.builder(Component.translatable("gui.cancel"), b -> onClose())
.bounds(centerX + gap/2, buttonsY, btnW, 20)
.build());
}
private void saveAndClose() {
// 读取与校验
int pageMul = clamp(parseIntOrDefault(pageMultiplierBox.getValue(), ModConfigs.PAGE_MULTIPLIER.get()), 1, 64);
double maxRange = clamp(parseDoubleOrDefault(wirelessMaxRangeBox.getValue(), ModConfigs.WIRELESS_MAX_RANGE.get()), 1.0, 4096.0);
boolean crossDim = crossDimToggle.getValue();
boolean providerRoundRobin = providerRoundRobinToggle.getValue();
int smartMaxMul = clamp(parseIntOrDefault(smartScalingMaxMulBox.getValue(), ModConfigs.SMART_SCALING_MAX_MULTIPLIER.get()), 0, 1048576);
boolean showEncoder = showEncoderToggle.getValue();
boolean patternShowSlots = patternTerminalShowSlotsToggle.getValue();
// 应用到 Forge 配置值
ModConfigs.PAGE_MULTIPLIER.set(pageMul);
ModConfigs.WIRELESS_MAX_RANGE.set(maxRange);
ModConfigs.WIRELESS_CROSS_DIM_ENABLE.set(crossDim);
ModConfigs.PROVIDER_ROUND_ROBIN_ENABLE.set(providerRoundRobin);
ModConfigs.SMART_SCALING_MAX_MULTIPLIER.set(smartMaxMul);
ModConfigs.SHOW_ENCOD_PATTERN_PLAYER.set(showEncoder);
ModConfigs.PATTERN_TERMINAL_SHOW_SLOTS_DEFAULT.set(patternShowSlots);
// Forge 会在合适的时机写回到配置文件部分改动可能需要重启游戏或世界才完全生效
onClose();
}
// Helper to create a boolean on/off CycleButton which shows localized on/off text
private CycleButton<Boolean> createToggle(int x, int y, int width, int height, boolean initial) {
CycleButton<Boolean> btn = CycleButton.onOffBuilder(initial)
.create(x, y, width, height, Component.empty(), (b, v) -> b.setMessage(Component.translatable(v ? "config.extendedae_plus.state_on" : "config.extendedae_plus.state_off")));
btn.setMessage(Component.translatable(initial ? "config.extendedae_plus.state_on" : "config.extendedae_plus.state_off"));
return btn;
}
@Override
public void onClose() {
Minecraft.getInstance().setScreen(parent);
}
@Override
public void render(GuiGraphics g, int mouseX, int mouseY, float partialTick) {
this.renderBackground(g, mouseX, mouseY, partialTick);
super.render(g, mouseX, mouseY, partialTick);
int centerX = this.width / 2;
int y = this.height / 6 + 24;
int rowHeight = 26;
int labelColor = 0xFFFFFF;
int leftX = centerX - 170; // 标签左列位置
// 标题
g.drawCenteredString(this.font, this.title, centerX, y - 28, 0xFFFFFF);
// 每行标签
g.drawString(this.font, Component.translatable("config.extendedae_plus.pageMultiplier_with_range"), leftX, y + 0 * rowHeight + 6, labelColor, false);
g.drawString(this.font, Component.translatable("config.extendedae_plus.wirelessMaxRange_with_range"), leftX, y + 1 * rowHeight + 6, labelColor, false);
g.drawString(this.font, Component.translatable("config.extendedae_plus.wirelessCrossDimEnable"), leftX, y + 2 * rowHeight + 6, labelColor, false);
g.drawString(this.font, Component.translatable("config.extendedae_plus.providerRoundRobinEnable"), leftX, y + 3 * rowHeight + 6, labelColor, false);
g.drawString(this.font, Component.translatable("config.extendedae_plus.smartScalingMaxMultiplier_with_range"), leftX, y + 4 * rowHeight + 6, labelColor, false);
g.drawString(this.font, Component.translatable("config.extendedae_plus.showEncoderPatternPlayer"), leftX, y + 5 * rowHeight + 6, labelColor, false);
g.drawString(this.font, Component.translatable("config.extendedae_plus.patternTerminalShowSlotsDefault"), leftX, y + 6 * rowHeight + 6, labelColor, false);
}
private static int parseIntOrDefault(String s, int def) {
try { return Integer.parseInt(s); } catch (Exception e) { return def; }
}
private static double parseDoubleOrDefault(String s, double def) {
try { return Double.parseDouble(s); } catch (Exception e) { return def; }
}
private static int clamp(int v, int min, int max) { return Math.max(min, Math.min(max, v)); }
private static double clamp(double v, double min, double max) { return Math.max(min, Math.min(max, v)); }
}

View File

@ -14,29 +14,17 @@ public final class ModConfigs {
static {
ModConfigSpec.Builder builder = new ModConfigSpec.Builder();
builder.push("extendedae_plus");
// General settings
builder.push("general");
PAGE_MULTIPLIER = builder
.comment(
"扩展样板供应器总槽位容量的倍率",
"基础为36每页仍显示36格倍率会增加总页数/总容量",
"扩展样板供应器总槽位容量的倍率",
"基础为36每页仍显示36格倍率会增加总页数/总容量",
"建议范围 1-16")
.defineInRange("pageMultiplier", 1, 1, 64);
// 无线收发器最大连接距离单位方块
// 一对多从端连接主端时将以该值作为范围限制
WIRELESS_MAX_RANGE = builder
.comment(
"无线收发器最大连接距离(单位:方块)",
"从端与主端的直线距离需小于等于该值才会建立连接。")
.defineInRange("wirelessMaxRange", 256.0D, 1.0D, 4096.0D);
// 是否允许跨维度连接忽略维度差异进行频道传输
WIRELESS_CROSS_DIM_ENABLE = builder
.comment(
"是否允许无线收发器跨维度建立连接",
"开启后,从端可连接到不同维度的主端(忽略距离限制)")
.define("wirelessCrossDimEnable", true);
// 是否显示样板编码玩家通用
SHOW_ENCOD_PATTERN_PLAYER = builder
.comment(
"是否显示样板编码玩家",
@ -44,7 +32,21 @@ public final class ModConfigs {
)
.define("showEncoderPatternPlayer", true);
// 智能倍增后是否在样板供应器间轮询分配请求量开启 provider 均分关闭不拆分
// 模式访问终端ExtendedAE 图样终端默认是否显示槽位渲染SlotsRow
// true: 默认显示可通过界面按钮临时隐藏false: 默认隐藏可通过按钮显示
PATTERN_TERMINAL_SHOW_SLOTS_DEFAULT = builder
.comment(
"样板终端默认是否显示槽位",
"影响进入界面时SlotsRow的默认可见性仅影响客户端显示"
)
.define("patternTerminalShowSlotsDefault", true);
// end general
builder.pop();
// Smart-scaling group
builder.push("smartScaling");
// 智能倍增是否在样板供应器间轮询分配请求量开启 provider 均分关闭不拆分
PROVIDER_ROUND_ROBIN_ENABLE = builder
.comment(
"智能倍增时是否对样板供应器轮询分配",
@ -61,15 +63,28 @@ public final class ModConfigs {
"此倍数是针对单次样板产出的放大倍数上限,用于限制一次推送中按倍增缩放的规模")
.defineInRange("smartScalingMaxMultiplier", 0, 0, 1048576);
// 模式访问终端ExtendedAE 图样终端默认是否显示槽位渲染SlotsRow
// true: 默认显示可通过界面按钮临时隐藏false: 默认隐藏可通过按钮显示
PATTERN_TERMINAL_SHOW_SLOTS_DEFAULT = builder
builder.pop(); // pop smart
// Wireless settings
builder.push("wireless");
// 无线收发器最大连接距离单位方块
// 一对多从端连接主端时将以该值作为范围限制
WIRELESS_MAX_RANGE = builder
.comment(
"样板终端默认是否显示槽位",
"影响进入界面时SlotsRow的默认可见性仅影响客户端显示"
)
.define("patternTerminalShowSlotsDefault", true);
builder.pop();
"无线收发器最大连接距离(单位:方块)",
"从端与主端的直线距离需小于等于该值才会建立连接。")
.defineInRange("wirelessMaxRange", 256.0D, 1.0D, 4096.0D);
// 是否允许跨维度连接忽略维度差异进行频道传输
WIRELESS_CROSS_DIM_ENABLE = builder
.comment(
"是否允许无线收发器跨维度建立连接",
"开启后,从端可连接到不同维度的主端(忽略距离限制)")
.define("wirelessCrossDimEnable", true);
builder.pop(); // pop wireless
// builder.pop(); // pop extendedae_plus
COMMON_SPEC = builder.build();
}

View File

@ -27,14 +27,22 @@
"extendedae_plus.tooltip.locked": "Locked: %s"
,
"screen.extendedae_plus.title": "ExtendedAE Plus Config",
"config.extendedae_plus.pageMultiplier": "Pattern Provider Page Multiplier",
"config.extendedae_plus.pageMultiplier_with_range": "Pattern Provider Page Multiplier (1-64)",
"config.extendedae_plus.wirelessMaxRange": "Wireless Max Range",
"config.extendedae_plus.wirelessMaxRange_with_range": "Wireless Max Range (1-4096)",
"config.extendedae_plus.wirelessCrossDimEnable": "Allow Wireless Cross-Dimension",
"config.extendedae_plus.providerRoundRobinEnable": "Enable Provider Round-Robin (Smart Doubling)",
"config.extendedae_plus.state_on": "On",
"config.extendedae_plus.state_off": "Off",
"config.extendedae_plus.smartScalingMaxMultiplier": "Smart Scaling Max Multiplier",
"config.extendedae_plus.smartScalingMaxMultiplier_with_range": "Smart Scaling Max Multiplier (0 = Unlimited)"
"config.extendedae_plus": "ExtendedAE Plus",
"extendedae_plus.configuration.general": "General",
"extendedae_plus.configuration.pageMultiplier": "Pattern Provider Page Multiplier",
"extendedae_plus.configuration.pageMultiplier_with_range": "Pattern Provider Page Multiplier (1-64)",
"extendedae_plus.configuration.showEncoderPatternPlayer": "Show Encoder Player",
"extendedae_plus.configuration.providerRoundRobinEnable": "Enable Provider Round-Robin",
"extendedae_plus.configuration.patternTerminalShowSlotsDefault": "Pattern Terminal Show Slots by Default",
"extendedae_plus.configuration.smartScaling": "Smart Scaling",
"extendedae_plus.configuration.smartScalingMaxMultiplier": "Smart Scaling Max Multiplier",
"extendedae_plus.configuration.smartScalingMaxMultiplier_with_range": "Smart Scaling Max Multiplier (0 = Unlimited)",
"extendedae_plus.configuration.wireless": "WirelessTransceiverBlock",
"extendedae_plus.configuration.wirelessMaxRange": "Wireless Max Range",
"extendedae_plus.configuration.wirelessMaxRange_with_range": "Wireless Max Range (1-4096)",
"extendedae_plus.configuration.wirelessCrossDimEnable": "Allow Wireless Cross-Dimension",
"extendedae_plus.configuration.state_on": "On",
"extendedae_plus.configuration.state_off": "Off"
}

View File

@ -40,23 +40,32 @@
"extendedae_plus.tooltip.locked": "锁定状态: %s",
"screen.extendedae_plus.title": "ExtendedAE Plus 配置",
"config.extendedae_plus.pageMultiplier": "扩展样板供应器槽位倍率",
"config.extendedae_plus.pageMultiplier_with_range": "扩展样板供应器槽位倍率 (1-64)",
"config.extendedae_plus.wirelessMaxRange": "无线最大距离",
"config.extendedae_plus.wirelessMaxRange_with_range": "无线最大距离 (1-4096)",
"config.extendedae_plus.wirelessCrossDimEnable": "无线收发器允许跨维度连接",
"config.extendedae_plus.providerRoundRobinEnable": "启用样板供应器轮询分配(智能翻倍)",
"config.extendedae_plus.state_on": "开",
"config.extendedae_plus.state_off": "关",
"config.extendedae_plus.showEncoderPatternPlayer": "显示样板编码玩家",
"config.extendedae_plus.patternTerminalShowSlotsDefault": "样板终端默认显示槽位",
"config.extendedae_plus": "ExtendedAE Plus",
"extendedae_plus.configuration.general": "通用",
"extendedae_plus.configuration.pageMultiplier": "扩展样板供应器槽位倍率",
"extendedae_plus.configuration.pageMultiplier_with_range": "扩展样板供应器槽位倍率 (1-64)",
"extendedae_plus.configuration.showEncoderPatternPlayer": "显示样板编码玩家",
"extendedae_plus.configuration.patternTerminalShowSlotsDefault": "样板终端默认显示槽位",
"extendedae_plus.configuration.smartScaling": "智能样板倍增",
"extendedae_plus.configuration.providerRoundRobinEnable": "启用样板供应器轮询分配",
"extendedae_plus.configuration.smartScalingMaxMultiplier": "智能倍增最大倍数",
"extendedae_plus.configuration.smartScalingMaxMultiplier_with_range": "智能倍增最大倍数 (0为不限制)",
"extendedae_plus.configuration.wireless": "无线连接器配置",
"extendedae_plus.configuration.wirelessMaxRange": "无线最大距离",
"extendedae_plus.configuration.wirelessMaxRange_with_range": "无线最大距离 (1-4096)",
"extendedae_plus.configuration.wirelessCrossDimEnable": "无线收发器允许跨维度连接",
"extendedae_plus.configuration.state_on": "开",
"extendedae_plus.configuration.state_off": "关",
"block.extendedae_plus.network_pattern_controller": "样板供应器状态控制器",
"item.extendedae_plus.network_pattern_controller": "样板供应器状态控制器",
"gui.extendedae_plus.global.toggle_blocking": "切换阻挡模式",
"gui.extendedae_plus.global.toggle_adv_blocking": "切换高级阻挡",
"gui.extendedae_plus.global.toggle_smart_doubling": "切换智能翻倍",
"gui.extendedae_plus.global.all_on": "全部开启",
"gui.extendedae_plus.global.all_off": "全部关闭",
"config.extendedae_plus.smartScalingMaxMultiplier": "智能倍增最大倍数",
"config.extendedae_plus.smartScalingMaxMultiplier_with_range": "智能倍增最大倍数 (0为不限制)"
"gui.extendedae_plus.global.all_off": "全部关闭"
}