优化按键设置及操作

This commit is contained in:
GaLi 2026-02-26 18:17:05 +08:00
parent e7d9e02043
commit c517d799a8
3 changed files with 6 additions and 6 deletions

View File

@ -42,6 +42,9 @@ public class ExtendedAEPlus {
// 注册mod初始化事件
modEventBus.addListener(this::commonSetup);
// 注册按键绑定客户端
modEventBus.addListener(com.extendedae_plus.client.ModKeybindings::register);
// 注册方块与方块实体
ModBlocks.BLOCKS.register(modEventBus);
ModBlockEntities.BLOCK_ENTITY_TYPES.register(modEventBus);

View File

@ -3,6 +3,7 @@ package com.extendedae_plus.client;
import com.mojang.blaze3d.platform.InputConstants;
import net.minecraft.client.KeyMapping;
import net.minecraftforge.client.settings.KeyConflictContext;
import net.minecraftforge.client.settings.KeyModifier;
import org.lwjgl.glfw.GLFW;
/**
@ -17,6 +18,7 @@ public final class ModKeybindings {
public static final KeyMapping CREATE_PATTERN_KEY = new KeyMapping(
"key.extendedae_plus.create_pattern", // 翻译键
KeyConflictContext.GUI, // 仅在GUI中生效
KeyModifier.CONTROL, // Ctrl 修饰键
InputConstants.Type.KEYSYM, // 键盘按键类型
GLFW.GLFW_KEY_Q, // Q
"key.categories.extendedae_plus" // 分类

View File

@ -44,16 +44,11 @@ public class CtrlQPatternKeyHandler {
int keyCode = event.getKeyCode();
int scanCode = event.getScanCode();
// 使用 KeyMapping 检测按键而非硬编码
// 使用 KeyMapping 检测按键包含修饰键
if (!ModKeybindings.CREATE_PATTERN_KEY.matches(keyCode, scanCode)) {
return;
}
// 检查 Ctrl 修饰键
if (!Screen.hasControlDown()) {
return;
}
// JEI 必须可用
if (JeiRuntimeProxy.get() == null) {
return;