port: The Copper Age (1.21.9)

This commit is contained in:
Martin Prokoph
2025-09-27 23:15:20 +02:00
parent e50128d75d
commit db7f1daa02
33 changed files with 138 additions and 95 deletions

View File

@@ -150,20 +150,20 @@ public class MidnightControlsClient extends MidnightControls {
if (PlatformFunctions.isModLoaded("wynntils") && KeyBindingIDAccessor.getKEYS_BY_ID().entrySet().stream().noneMatch(b -> Objects.equals(b.getValue().getCategory(), "Wynntils"))) return;
for (int i = 0; i < KeyBindingIDAccessor.getKEYS_BY_ID().size(); ++i) {
KeyBinding keyBinding = KeyBindingIDAccessor.getKEYS_BY_ID().entrySet().stream().toList().get(i).getValue();
if (MidnightControlsConfig.excludedKeybindings.stream().noneMatch(excluded -> keyBinding.getTranslationKey().startsWith(excluded))) {
if (!keyBinding.getTranslationKey().contains(MidnightControlsConstants.NAMESPACE)) {
if (MidnightControlsConfig.excludedKeybindings.stream().noneMatch(excluded -> keyBinding.getId().startsWith(excluded))) {
if (!keyBinding.getId().contains(MidnightControlsConstants.NAMESPACE)) {
AtomicReference<ButtonCategory> category = new AtomicReference<>();
InputManager.streamCategories().forEach(buttonCategory -> {
if (buttonCategory.getIdentifier().equals(validVanillaId(keyBinding.getCategory())))
if (buttonCategory.getIdentifier().equals(keyBinding.getCategory().id()))
category.set(buttonCategory);
});
if (category.get() == null) {
category.set(new ButtonCategory(validVanillaId(keyBinding.getCategory())));
category.set(new ButtonCategory(keyBinding.getCategory().id()));
InputManager.registerCategory(category.get());
}
ButtonBinding buttonBinding = new ButtonBinding.Builder(keyBinding.getTranslationKey()).category(category.get()).linkKeybind(keyBinding).register();
ButtonBinding buttonBinding = new ButtonBinding.Builder(keyBinding.getId()).category(category.get()).linkKeybind(keyBinding).register();
if (MidnightControlsConfig.debug) {
MidnightControls.log(keyBinding.getTranslationKey());
MidnightControls.log(keyBinding.getId());
MidnightControls.log(String.valueOf(buttonBinding));
}
}
@@ -172,14 +172,6 @@ public class MidnightControlsClient extends MidnightControls {
InputManager.loadButtonBindings();
lateInitDone = true;
}
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);
}
/**
* This method is called every Minecraft tick.