Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import edn.stratodonut.drivebywire.WireItems;
import edn.stratodonut.drivebywire.WirePackets;
import edn.stratodonut.drivebywire.blocks.WireNetworkBackupBlock;
import edn.stratodonut.drivebywire.compat.TweakedControllerWireServerHandler;
import edn.stratodonut.drivebywire.network.WireAddConnectionPacket;
import edn.stratodonut.drivebywire.network.WireLinkNetworksPacket;
import edn.stratodonut.drivebywire.network.WireNetworkRequestSyncPacket;
Expand Down Expand Up @@ -194,7 +195,9 @@ public static void onInputEvent(InputEvent.MouseScrollingEvent event) {

public static void changeChannel(Block source, boolean forward) {
if (source instanceof MultiChannelWireSource channelWireSource) {
if (!channelSet.equals(channelWireSource.wire$getChannelSet())) channelSet = channelWireSource.wire$getChannelSet();
if (!channelSet.equals(channelWireSource.wire$getChannelSet())) {
channelSet = channelWireSource.wire$getChannelSet();
}
if (forward) {
channelSet.nextChannel();
} else {
Expand All @@ -203,8 +206,23 @@ public static void changeChannel(Block source, boolean forward) {
} else {
channelSet = WorldChannelSet.INSTANCE;
}
Player p = Minecraft.getInstance().player;
if (p != null) p.displayClientMessage(Component.literal("Selected Channel: " + channelSet.currentChannel()), true);

String currentChannel = channelSet.currentChannel();

Player player = Minecraft.getInstance().player;
if (player != null) {
// 新版完整映射逻辑(后续添加类即可自动生效)
String langKey = currentChannel;
try {
langKey = TweakedControllerWireServerHandler.CHANNEL_TO_LANG_KEY.getOrDefault(currentChannel, currentChannel);
} catch (Exception ignored) {}

Component displayName = Component.translatable(langKey);
player.displayClientMessage(
Component.translatable("drivebywire.wire.channel.selected", displayName),
true
);
}
}

public static void clearSource() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,48 @@ public class TweakedControllerWireServerHandler {
"axisTriggerLeft",
"axisTriggerRight"
};
// ==============================================
// 强绑定:内部名 → 多语言键(一一对应,永不乱序)
// ==============================================
public static final Map<String, String> CHANNEL_TO_LANG_KEY = Map.ofEntries(
Map.entry("world","drivebywire.wire.channel.world"),
// 按钮映射
Map.entry("buttonA", "drivebywire.controller.button.a"),
Map.entry("buttonB", "drivebywire.controller.button.b"),
Map.entry("buttonX", "drivebywire.controller.button.x"),
Map.entry("buttonY", "drivebywire.controller.button.y"),
Map.entry("shoulderLeft", "drivebywire.controller.button.shoulder_left"),
Map.entry("shoulderRight", "drivebywire.controller.button.shoulder_right"),
Map.entry("buttonBack", "drivebywire.controller.button.back"),
Map.entry("buttonStart", "drivebywire.controller.button.start"),
Map.entry("buttonGuide", "drivebywire.controller.button.guide"),
Map.entry("leftJoyStickClick", "drivebywire.controller.button.left_joystick_click"),
Map.entry("rightJoyStickClick", "drivebywire.controller.button.right_joystick_click"),
Map.entry("dPadUp", "drivebywire.controller.button.dpad_up"),
Map.entry("dPadRight", "drivebywire.controller.button.dpad_right"),
Map.entry("dPadDown", "drivebywire.controller.button.dpad_down"),
Map.entry("dPadLeft", "drivebywire.controller.button.dpad_left"),

// 轴映射
Map.entry("axisLeftX+", "drivebywire.controller.axis.left_x_positive"),
Map.entry("axisLeftX-", "drivebywire.controller.axis.left_x_negative"),
Map.entry("axisLeftY+", "drivebywire.controller.axis.left_y_positive"),
Map.entry("axisLeftY-", "drivebywire.controller.axis.left_y_negative"),
Map.entry("axisRightX+", "drivebywire.controller.axis.right_x_positive"),
Map.entry("axisRightX-", "drivebywire.controller.axis.right_x_negative"),
Map.entry("axisRightY+", "drivebywire.controller.axis.right_y_positive"),
Map.entry("axisRightY-", "drivebywire.controller.axis.right_y_negative"),
Map.entry("axisTriggerLeft", "drivebywire.controller.axis.left_trigger"),
Map.entry("axisTriggerRight", "drivebywire.controller.axis.right_trigger"),

// 键盘按键映射
Map.entry("keyUp", "drivebywire.controller.key.up"),
Map.entry("keyDown", "drivebywire.controller.key.down"),
Map.entry("keyLeft", "drivebywire.controller.key.left"),
Map.entry("keyRight", "drivebywire.controller.key.right"),
Map.entry("keyJump", "drivebywire.controller.key.jump"),
Map.entry("keyShift", "drivebywire.controller.key.shift")
);

static final WorldAttached<Map<Pair<BlockPos, Integer>, Integer>> timeoutButtonMap = new WorldAttached<>(k -> new HashMap<>());
static final WorldAttached<Map<Pair<BlockPos, Integer>, Integer>> timeoutAxisMap = new WorldAttached<>(k -> new HashMap<>());
Expand Down
36 changes: 35 additions & 1 deletion src/main/resources/assets/drivebywire/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,39 @@
"drivebywire.ponder.link.text_1" : "What if you wanted to reload networks across ships placed from schematics?",
"drivebywire.ponder.link.text_2" : "Select the Backup Block on the source ship,",
"drivebywire.ponder.link.text_3" : "and right-click the Backup Block on the target ship.",
"drivebywire.ponder.link.text_4" : "Tada, connections are automatically reloaded!"
"drivebywire.ponder.link.text_4" : "Tada, connections are automatically reloaded!",

"drivebywire.wire.channel.selected": "Selected Channel: %s",
"drivebywire.controller.button.a": "Button A",
"drivebywire.controller.button.b": "Button B",
"drivebywire.controller.button.x": "Button X",
"drivebywire.controller.button.y": "Button Y",
"drivebywire.controller.button.shoulder_left": "Left Shoulder",
"drivebywire.controller.button.shoulder_right": "Right Shoulder",
"drivebywire.controller.button.back": "Back",
"drivebywire.controller.button.start": "Start",
"drivebywire.controller.button.guide": "Guide",
"drivebywire.controller.button.left_joystick_click": "Left Joystick Click",
"drivebywire.controller.button.right_joystick_click": "Right Joystick Click",
"drivebywire.controller.button.dpad_up": "D-Pad Up",
"drivebywire.controller.button.dpad_right": "D-Pad Right",
"drivebywire.controller.button.dpad_down": "D-Pad Down",
"drivebywire.controller.button.dpad_left": "D-Pad Left",
"drivebywire.controller.axis.left_x_positive": "Left Stick X+",
"drivebywire.controller.axis.left_x_negative": "Left Stick X-",
"drivebywire.controller.axis.left_y_positive": "Left Stick Y+",
"drivebywire.controller.axis.left_y_negative": "Left Stick Y-",
"drivebywire.controller.axis.right_x_positive": "Right Stick X+",
"drivebywire.controller.axis.right_x_negative": "Right Stick X-",
"drivebywire.controller.axis.right_y_positive": "Right Stick Y+",
"drivebywire.controller.axis.right_y_negative": "Right Stick Y-",
"drivebywire.controller.axis.left_trigger": "Left Trigger",
"drivebywire.controller.axis.right_trigger": "Right Trigger",
"drivebywire.wire.channel.world": "world",
"drivebywire.controller.key.up": "keyUp",
"drivebywire.controller.key.down": "keyDown",
"drivebywire.controller.key.left": "keyLeft",
"drivebywire.controller.key.right": "keyRight",
"drivebywire.controller.key.jump": "keyJump",
"drivebywire.controller.key.shift": "keyShift"
}
36 changes: 35 additions & 1 deletion src/main/resources/assets/drivebywire/lang/zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,39 @@
"drivebywire.ponder.link.text_1" : "如何让蓝图加载的跨物理结构上的有线网络重新连接?",
"drivebywire.ponder.link.text_2" : "选中源物理结构上的网络备份块,",
"drivebywire.ponder.link.text_3" : "再右击目标物理结构上的网络备份块。",
"drivebywire.ponder.link.text_4" : "看,链接已经自动重连!"
"drivebywire.ponder.link.text_4" : "看,链接已经自动重连!",

"drivebywire.wire.channel.selected": "已选择频道:%s",
"drivebywire.controller.button.a": "按键 A",
"drivebywire.controller.button.b": "按键 B",
"drivebywire.controller.button.x": "按键 X",
"drivebywire.controller.button.y": "按键 Y",
"drivebywire.controller.button.shoulder_left": "左肩键",
"drivebywire.controller.button.shoulder_right": "右肩键",
"drivebywire.controller.button.back": "返回键",
"drivebywire.controller.button.start": "开始键",
"drivebywire.controller.button.guide": "导航键",
"drivebywire.controller.button.left_joystick_click": "左摇杆按下",
"drivebywire.controller.button.right_joystick_click": "右摇杆按下",
"drivebywire.controller.button.dpad_up": "方向键 上",
"drivebywire.controller.button.dpad_right": "方向键 右",
"drivebywire.controller.button.dpad_down": "方向键 下",
"drivebywire.controller.button.dpad_left": "方向键 左",
"drivebywire.controller.axis.left_x_positive": "左摇杆 X+",
"drivebywire.controller.axis.left_x_negative": "左摇杆 X-",
"drivebywire.controller.axis.left_y_positive": "左摇杆 Y+",
"drivebywire.controller.axis.left_y_negative": "左摇杆 Y-",
"drivebywire.controller.axis.right_x_positive": "右摇杆 X+",
"drivebywire.controller.axis.right_x_negative": "右摇杆 X-",
"drivebywire.controller.axis.right_y_positive": "右摇杆 Y+",
"drivebywire.controller.axis.right_y_negative": "右摇杆 Y-",
"drivebywire.controller.axis.left_trigger": "左扳机",
"drivebywire.controller.axis.right_trigger": "右扳机",
"drivebywire.wire.channel.world": "世界",
"drivebywire.controller.key.up": "W 上键",
"drivebywire.controller.key.down": "S 下键",
"drivebywire.controller.key.left": "A 左键",
"drivebywire.controller.key.right": "D 右键",
"drivebywire.controller.key.jump": "空格",
"drivebywire.controller.key.shift": "Shift"
}