Minecraftforge: Config GUI Entries and the Annotation-based Config System

Created on 18 Aug 2017  路  11Comments  路  Source: MinecraftForge/MinecraftForge

There's currently no way to specify custom config GUI entries for properties created through the annotation-based config system without reflecting the Configuration instance from ConfigManager and calling Property#setConfigEntryClass manually.

Could an annotation be added that allows a custom Property.Type or IConfigEntry class to be specified for the generated Property?

On a related note, it's currently not possible to use GuiConfigEntries.BooleanEntry, GuiConfigEntries.CycleValueEntry or GuiConfigEntries.ChatColorEntry with Property#setConfigEntryClass because their constructors aren't public. Attempting to do so throws a NoSuchMethodException for the constructor when the config GUI is opened. It's also not possible to extend these and add a public constructor, since the constructors are private or package-private.

I originally posted this on the forums, but I thought it was more likely to be noticed here.

Stale

Most helpful comment

I'm not really sure what there is to say that I didn't say in the PR's original description.

It's still not possible to specify custom config entries through the annotation-based config system without resorting to reflection. It's still not possible to directly use or extend the config entries mentioned above.

All 11 comments

I'd add that this mechanism is missing a way for a modder to add a config entries dependent on other mods. For example, populate config with all registered entities' ids, or add an entry related to other mod... It's because @Config classes are instantiated before mod registration events, right? Or the situation has changed since I last used it?

This issue has been automatically marked as stale because it has not had activity in a long time. If this issue is still relevant and should remain open, please reply with a short explanation (e.g. "I have checked the code and this issue is still relevant because ___." or "Here's a screenshot of this issue on the latest version"). Thank you for your contributions!

Unless I've missed something, I think this is still relevant.

Do not BUMP stale markers with useless messages. Expand on the subject with something relevant if you give enough to care about it.

I'm not really sure what there is to say that I didn't say in the PR's original description.

It's still not possible to specify custom config entries through the annotation-based config system without resorting to reflection. It's still not possible to directly use or extend the config entries mentioned above.

To change the property type will be hard, because it is essential for serialization. However, specifying a non-default GUI component should be doable.

https://github.com/MinecraftForge/MinecraftForge/blob/bea02348e2845ef6b1f49b0692f79dbc097d2706/src/main/java/net/minecraftforge/common/config/ConfigElement.java#L412
This creates the GUI elements. If we would add an Event here, perhaps containing an identifier from an annotation, we could allow modders to change the element.
However, this has some disadvantages. First, a different mod could intercept these events; we would need to enforce a naming system with unique names. Second, There might be a minor perfomance disadvantage compared to alternative methods, but as this code should be called infrequently (only at GUI init), it should be negligible.
Another possibility is to either create a registry for custom GUI elements or pass a callback to some factory. This has a memory overhead (in the registry case) and might be rather ugly and confusing for modders (in the factory case).

This issue has been automatically marked as stale because it has not had activity in a long time. If this issue is still relevant and should remain open, please reply with a short explanation (e.g. "I have checked the code and this issue is still relevant because ___." or "Here's a screenshot of this issue on the latest version"). Thank you for your contributions!

This still hasn't been implemented, but I'm not sure if it still applies to 1.13's config system.

This issue has been automatically marked as stale because it has not had activity in a long time. If this issue is still relevant and should remain open, please reply with a short explanation (e.g. "I have checked the code and this issue is still relevant because ___." or "Here's a screenshot of this issue on the latest version"). Thank you for your contributions!

This issue has been automatically closed because it has not had activity in a long time. Please feel free to reopen it or create a new issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ErikBigDev picture ErikBigDev  路  3Comments

williewillus picture williewillus  路  3Comments

DaedalusGame picture DaedalusGame  路  3Comments

ghost picture ghost  路  3Comments

tterrag1098 picture tterrag1098  路  3Comments