优化按键设置及操作
This commit is contained in:
parent
e7d9e02043
commit
c517d799a8
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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" // 分类
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user