Fix Decorative Blocks keybind being unconfigurable

This commit is contained in:
embeddedt 2023-07-09 21:15:39 -04:00
parent 4962d855af
commit a189927b22
No known key found for this signature in database
GPG Key ID: A69433EC199B5613
2 changed files with 23 additions and 0 deletions

View File

@ -31,6 +31,7 @@ public class ModernFixClientFabric implements ClientModInitializer {
ServerLifecycleEvents.SERVER_STARTED.register(server -> {
commonMod.onServerStarted(server);
});
org.embeddedt.modernfix.fabric.modfixs.DecorativeBlocksFix.fix();
if(FabricLoader.getInstance().isModLoaded("fabric-data-generation-api-v1")) {
RuntimeDatagen.init();
}

View File

@ -0,0 +1,22 @@
package org.embeddedt.modernfix.fabric.modfixs;
import net.minecraft.client.KeyMapping;
import org.embeddedt.modernfix.util.CommonModUtil;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
public class DecorativeBlocksFix {
public static void fix() {
CommonModUtil.runWithoutCrash(() -> {
Class<?> decorativeBlocksSetup = Class.forName("lilypuree.decorative_blocks.client.ClientSetup");
Field keybindField = decorativeBlocksSetup.getDeclaredField("switchItemState");
keybindField.setAccessible(true);
KeyMapping keybinding = (KeyMapping)keybindField.get(null);
Class<?> keyBindHelper = Class.forName("net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper");
Method keyBindRegister = keyBindHelper.getDeclaredMethod("registerKeyBinding", KeyMapping.class);
keyBindRegister.setAccessible(true);
keyBindRegister.invoke(null, keybinding);
}, "registering Decorative Blocks keybind to allow configuration");
}
}