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

API for custom default values during parsing. #7256

Open
wants to merge 2 commits into
base: dev/feature
Choose a base branch
from

Conversation

sovdeeth
Copy link
Member

Description

Adds an api for declaring custom default values during parsing. Does not apply to runtime defaults like arithmetic.
The goal of this is to provide a slightly easier method for section to provide section-specific defaults without having to create an entire custom event and change the context.

I think this implementation might be a little rough and would welcome critiques.

Example:

		// Add custom default value
		data.addDefaultValue(Number.class, new SimpleLiteral((Number) 7, true));

		// parse section with custom value
		loadCode(sectionNode);

		// remove custom value
		data.removeDefaultValue(Number.class);

Target Minecraft Versions: any
Requirements: none
Related Issues: none

@sovdeeth sovdeeth added the enhancement Feature request, an issue about something that could be improved, or a PR improving something. label Dec 12, 2024
@sovdeeth
Copy link
Member Author

sovdeeth commented Dec 12, 2024

Just realized this needs to support multiple layers of default values. Will fix Friday.

default value A:
  default B:
    # default is B
  # default should be A

@sovdeeth
Copy link
Member Author

I would like some thoughts on how/whether to handle cases where context completely changes.
Perhaps a clearDefaults() and restoreDefaults() method? Maybe defaults should be tied to event/a context generic?
not sure, would like suggestions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature request, an issue about something that could be improved, or a PR improving something.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants