Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AutoConfig can't read ModifierKeyCode from config #277

Open
MrMasrozYTLIVE opened this issue Jul 30, 2024 · 1 comment
Open

AutoConfig can't read ModifierKeyCode from config #277

MrMasrozYTLIVE opened this issue Jul 30, 2024 · 1 comment

Comments

@MrMasrozYTLIVE
Copy link

MrMasrozYTLIVE commented Jul 30, 2024

Whenever I try to use ModifierKeyCode(Impl) in my config it just fails to read it:

me.shedaniel.autoconfig.serializer.ConfigSerializer$SerializationException: com.google.gson.JsonIOException: Interfaces can't be instantiated! Register an InstanceCreator or a TypeAdapter for this type. Interface name: java.util.function.Supplier
	at me.shedaniel.autoconfig.serializer.GsonConfigSerializer.deserialize(GsonConfigSerializer.java:83) ~[cloth-config-fabric-15.0.128-fabric.jar:?]
	at me.shedaniel.autoconfig.ConfigManager.load(ConfigManager.java:92) ~[cloth-config-fabric-15.0.128-fabric.jar:?]
	at me.shedaniel.autoconfig.ConfigManager.<init>(ConfigManager.java:53) ~[cloth-config-fabric-15.0.128-fabric.jar:?]
	at me.shedaniel.autoconfig.AutoConfig.register(AutoConfig.java:66) ~[cloth-config-fabric-15.0.128-fabric.jar:?]

It only happens when launched in IDE though

@MrMasrozYTLIVE
Copy link
Author

MrMasrozYTLIVE commented Jul 30, 2024

Forgot to mention, this is how I register type:

AutoConfig.getGuiRegistry(ModConfig.class).registerTypeProvider((i18n, field, config, defaults, registry) -> {
            Point point = (Point) config;
            ModifierKeyCodeImpl keyCode = Utils.getUnsafely(field, point, CTPMod.DEFAULT_KEYBIND);

            List<AbstractConfigListEntry> list = new ArrayList<>();
            ConfigEntryBuilder builder = ConfigEntryBuilder.create();
            list.add(builder.startModifierKeyCodeField(Text.translatable(i18n), keyCode)
                    .setModifierSaveConsumer(point::setKeyBind)
                    .setAllowMouse(false)
                    .build());

            return list;
        }, ModifierKeyCodeImpl.class);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant