@@ -34,6 +34,7 @@ public final class SyncedKeyMapping {
3434
3535 @ OnlyIn (Dist .CLIENT )
3636 private KeyMapping keyMapping ;
37+ private final boolean needsRegister ;
3738 @ OnlyIn (Dist .CLIENT )
3839 private int keyCode ;
3940 @ OnlyIn (Dist .CLIENT )
@@ -49,20 +50,27 @@ private SyncedKeyMapping(Supplier<Supplier<KeyMapping>> mcKeyMapping) {
4950 if (GTCEu .isClientSide ()) {
5051 this .keyMapping = mcKeyMapping .get ().get ();
5152 }
53+ // Does not need to be registered, will be registered by MC
54+ this .needsRegister = false ;
55+
5256 KEYMAPPINGS .put (syncIndex ++, this );
5357 }
5458
5559 private SyncedKeyMapping (int keyCode ) {
5660 if (GTCEu .isClientSide ()) {
5761 this .keyCode = keyCode ;
5862 }
63+ // Does not need to be registered, is not a configurable key mapping
64+ this .needsRegister = false ;
65+
5966 KEYMAPPINGS .put (syncIndex ++, this );
6067 }
6168
62- private SyncedKeyMapping (String nameKey , IKeyConflictContext ctx , int keyCode ) {
69+ private SyncedKeyMapping (String nameKey , IKeyConflictContext ctx , int keyCode , String category ) {
6370 if (GTCEu .isClientSide ()) {
64- this .keyMapping = (KeyMapping ) createKeyMapping (nameKey , ctx , keyCode );
71+ this .keyMapping = (KeyMapping ) createKeyMapping (nameKey , ctx , keyCode , category );
6572 }
73+ this .needsRegister = true ;
6674 KEYMAPPINGS .put (syncIndex ++, this );
6775 }
6876
@@ -87,19 +95,33 @@ public static SyncedKeyMapping create(int keyCode) {
8795
8896 /**
8997 * Create a new SyncedKeyMapping with server held and pressed syncing to server.<br>
90- * Will automatically create a keymapping entry in the MC options page.
98+ * Will automatically create a keymapping entry in the MC options page under the GregTechCEu category .
9199 *
92100 * @param nameKey Translation key for the keymapping name.
93101 * @param ctx Conflict context for the keymapping options category.
94102 * @param keyCode The key code, from {@link InputConstants}.
95103 */
96104 public static SyncedKeyMapping createConfigurable (String nameKey , IKeyConflictContext ctx , int keyCode ) {
97- return new SyncedKeyMapping (nameKey , ctx , keyCode );
105+ return createConfigurable (nameKey , ctx , keyCode , GTCEu .NAME );
106+ }
107+
108+ /**
109+ * Create a new SyncedKeyMapping with server held and pressed syncing to server.<br>
110+ * Will automatically create a keymapping entry in the MC options page under the specified category.
111+ *
112+ * @param nameKey Translation key for the keymapping name.
113+ * @param ctx Conflict context for the keymapping options category.
114+ * @param keyCode The key code, from {@link InputConstants}.
115+ * @param category The category in the MC options page.
116+ */
117+ public static SyncedKeyMapping createConfigurable (String nameKey , IKeyConflictContext ctx , int keyCode ,
118+ String category ) {
119+ return new SyncedKeyMapping (nameKey , ctx , keyCode , category );
98120 }
99121
100122 @ OnlyIn (Dist .CLIENT )
101- private Object createKeyMapping (String nameKey , IKeyConflictContext ctx , int keyCode ) {
102- return new KeyMapping (nameKey , ctx , InputConstants .Type .KEYSYM , keyCode , GTCEu . NAME );
123+ private Object createKeyMapping (String nameKey , IKeyConflictContext ctx , int keyCode , String category ) {
124+ return new KeyMapping (nameKey , ctx , InputConstants .Type .KEYSYM , keyCode , category );
103125 }
104126
105127 /**
@@ -137,11 +159,9 @@ public SyncedKeyMapping registerPlayerListener(ServerPlayer player, IKeyPressedL
137159
138160 public static void onRegisterKeyBinds (RegisterKeyMappingsEvent event ) {
139161 for (SyncedKeyMapping value : KEYMAPPINGS .values ()) {
140- if (value .keyMapping != null ) {
162+ if (value .keyMapping != null && value . needsRegister ) {
141163 event .register (value .keyMapping );
142164 }
143- // no need to register keycode only keybinds?
144- // dont think they would show up in the binds menu
145165 }
146166 }
147167
0 commit comments