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

1.20.x ForgeConfigSpec revisit #9814

Draft
wants to merge 14 commits into
base: 1.20.x
Choose a base branch
from

Conversation

SrRapero720
Copy link
Contributor

thats a collection of changes for ForgeConfigSpec, just to enhance it with some additions

@autoforge autoforge bot added Triage This request requires the active attention of the Triage Team. Requires labelling or reviews. 1.20 labels Dec 9, 2023
@autoforge autoforge bot added the Needs Rebase This PR requires a rebase to implement upstream changes (usually to fix merge conflicts). label Dec 11, 2023
@autoforge
Copy link

autoforge bot commented Dec 11, 2023

@SrRapero720, this pull request has conflicts, please resolve them for this PR to move forward.

@LexManos
Copy link
Member

What is the use of FloatValue vs DoubleValue?
Also MapValue isn't used, and has issues with toml style layout. What are you wanting to use that for?
All the other 'fixes' are just automated code 'cleanup'. Which doesn't really matter.

@SrRapero720
Copy link
Contributor Author

SrRapero720 commented Dec 14, 2023

What is the use of FloatValue vs DoubleValue?

Only purpose was avoid downcasting java.lang.Double to double and then cast to float
you cannot directly cast java.lang.Double to float
image

Also MapValue isn't used, and has issues with toml style layout. What are you wanting to use that for?

Thats why i keep this as a Draft, i was looking on nightconfig capabilities and i discover it has not support for Map's
i add it just blueprinting any "MapLike" config, but yeah is not doing nothing ATM until i figure out the most optimal way to support Maps without really support Maps

All the other 'fixes' are just automated code 'cleanup'. Which doesn't really matter.

Yep

@autoforge autoforge bot removed the Needs Rebase This PR requires a rebase to implement upstream changes (usually to fix merge conflicts). label Dec 27, 2023
@SrRapero720 SrRapero720 marked this pull request as ready for review February 29, 2024 12:18
@autoforge autoforge bot requested a review from a team February 29, 2024 12:19
@SrRapero720
Copy link
Contributor Author

SrRapero720 commented Feb 29, 2024

i decide to stop from where i was.
i want to backport this, so breaking changes is outside of this PR scope

SUMARY

  • Added FloatValue, ByteValue and ShortValue
  • Added primitive cache fields on primitive values + methods with primitive returns (see Autoboxing)
  • Added method to get Ordinal on EnumValues
    • Justification: Allows you to use ForgeConfig directly on render methods with no performance impact (specially if your mod is full client-side rendering based.
  • Addec ConfigUpdateHandler, with the only purpose to notify any changes on config values using ConfigValue#set()
  • Removed hell spaces on brackets
  • Usage of Java 17 features (such as if (specValue instanceof Config specConfigValue) {)
  • Basic cleanup

@SrRapero720
Copy link
Contributor Author

SrRapero720 commented Feb 29, 2024

my first intention was add support of Map<String, String> using a List<> and custom parsers to store maps as list values (such as key_string[;]value_string[;]) but might be a bad idea and honestly looks horrible and no very well understandable

@SrRapero720 SrRapero720 marked this pull request as draft March 4, 2024 01:25
@SrRapero720
Copy link
Contributor Author

i will add some extra changes, but not hard breaking

@SrRapero720 SrRapero720 marked this pull request as ready for review March 22, 2024 21:24
Copy link
Contributor

@PaintNinja PaintNinja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's too many vaguely related features in this one big PR. Please split it up into smaller PRs.

As for getting ordinal on EnumValue directly for render methods, this isn't recommended for performance reasons. You should instead read the enum ordinal from the config once and store it in a static final. You can use the deferred holder class idiom to achieve this in a way that only reads the value on first use:

record MyEnumThing() {
    static final int ORDINAL = ENUM.get().ordinal();
}
static int getEnumThingOrdinal() {
    return MyEnumThing.ORDINAL;
}

This allows the JIT to properly inline the value from the start.

@PaintNinja PaintNinja added the BreakingChange This request includes a change that would break compatibility with current versions of Forge. label Apr 7, 2024
@PaintNinja
Copy link
Contributor

Labelled as a breaking change because this PR promotes a userdev-only error to also happen in production

@SrRapero720 SrRapero720 marked this pull request as draft April 7, 2024 22:51
@SrRapero720
Copy link
Contributor Author

marked as draft until i have time to address everything

@autoforge autoforge bot added the Needs Rebase This PR requires a rebase to implement upstream changes (usually to fix merge conflicts). label Apr 13, 2024
@autoforge
Copy link

autoforge bot commented Apr 13, 2024

@SrRapero720, this pull request has conflicts, please resolve them for this PR to move forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.20 BreakingChange This request includes a change that would break compatibility with current versions of Forge. Needs Rebase This PR requires a rebase to implement upstream changes (usually to fix merge conflicts). Triage This request requires the active attention of the Triage Team. Requires labelling or reviews.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants