mirror of
https://github.com/TeamMidnightDust/MidnightControls.git
synced 2025-12-14 07:35:10 +01:00
fix: correctly register keybind category
This drastically changed in 1.21.9
This commit is contained in:
@@ -420,18 +420,9 @@ public class InputManager {
|
||||
* @param code the code
|
||||
* @param category the category of the key binding
|
||||
* @return the key binding
|
||||
* @see #makeKeyBinding(Identifier, InputUtil.Type, int, String)
|
||||
* @see #makeKeyBinding(Identifier, InputUtil.Type, int, net.minecraft.client.option.KeyBinding.Category)
|
||||
*/
|
||||
public static @NotNull KeyBinding makeKeyBinding(@NotNull Identifier id, InputUtil.Type type, int code, @NotNull String category) {
|
||||
return new KeyBinding(String.format("key.%s.%s", id.getNamespace(), id.getPath()), type, code, new KeyBinding.Category(validVanillaId(category)));
|
||||
}
|
||||
|
||||
private static Identifier validVanillaId(String path) {
|
||||
for(int i = 0; i < path.length(); ++i) {
|
||||
if (!Identifier.isPathCharacterValid(path.charAt(i))) {
|
||||
path = path.replace(path.charAt(i), '_');
|
||||
}
|
||||
}
|
||||
return Identifier.ofVanilla(path);
|
||||
public static @NotNull KeyBinding makeKeyBinding(@NotNull Identifier id, InputUtil.Type type, int code, @NotNull KeyBinding.Category category) {
|
||||
return new KeyBinding(String.format("key.%s.%s", id.getNamespace(), id.getPath()), type, code, category);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user