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

Update visual fire handling with TriState support #12303

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

NonSwag
Copy link
Contributor

@NonSwag NonSwag commented Mar 16, 2025

Replaced the Boolean-based visual fire system with TriState for improved clarity and flexibility, enabling three distinct states: TRUE, FALSE, and NOT_SET. Deprecated older methods in favor of new ones and updated internal handling to reflect these changes. Adjusted serialization and deserialization logic to accommodate the new TriState implementation.

Resolves #12084

david added 2 commits March 16, 2025 11:13
Replaced the Boolean-based visual fire system with TriState for improved clarity and flexibility, enabling three distinct states: TRUE, FALSE, and NOT_SET. Deprecated older methods in favor of new ones and updated internal handling to reflect these changes. Adjusted serialization and deserialization logic to accommodate the new TriState implementation.
Replaced the Boolean-based visual fire system with TriState for improved clarity and flexibility, enabling three distinct states: TRUE, FALSE, and NOT_SET. Deprecated older methods in favor of new ones and updated internal handling to reflect these changes. Adjusted serialization and deserialization logic to accommodate the new TriState implementation.
@NonSwag NonSwag requested a review from a team as a code owner March 16, 2025 10:21
@GliczDev
Copy link
Contributor

I don't think this should be a feature patch, also Paper comments are missing

@NonSwag
Copy link
Contributor Author

NonSwag commented Mar 16, 2025

I don't think this should be a feature patch, also Paper comments are missing

Just took another look at the code and I thought that visualFire was introduced by paper
that's why I thought it is already in between paper start / stop comments and didn't add them

@GliczDev
Copy link
Contributor

Just took another look at the code and I thought that visualFire was introduced by paper
that's why I thought it is already in between paper start / stop comments and didn't add them

Even if the changes are in between Paper start/end comments, new ones should also be added to indicate what the new changes are doing


- if (this.hasVisualFire) {
- compound.putBoolean("HasVisualFire", this.hasVisualFire);
+ if (!this.visualFire.equals(net.kyori.adventure.util.TriState.NOT_SET)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think interfering with vanilla serialization output is a smart choice. Looking at other serializations, I think for such cases HasVisualFire would take this.visualFire.toBooleanOrElse(false) and a Paper.HasVisualFire would take the TriState, the paper one taking priority when deserializing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The getBoolean method always returns false if there is nothing defined
but I agree, even though I don't like adding more values to the file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I can actually leave it how I did it
the created compound is always empty, so vanilla actually only stores the visual Fire if it is enabled
I can just save it if it is not not_set

- this.hasVisualFire = compound.getBoolean("HasVisualFire");
+ // Paper start - improve visual fire API
+ this.visualFire = compound.contains("HasVisualFire")
+ ? net.kyori.adventure.util.TriState.byBoolean(compound.getBoolean("HasVisualFire"))
Copy link
Contributor

Choose a reason for hiding this comment

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

this breaks old behavior, e.g. when loading a vanilla world or a world from an older build.
a custom Paper tag for visual fire TriState would be better here, like @masmc05 stated earlier

Copy link
Contributor Author

Choose a reason for hiding this comment

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

why would this break old worlds?
it still uses the getBoolean while just using NOT_SET if the valua is not present

Copy link
Contributor

Choose a reason for hiding this comment

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

isn't it possible for the value to be set as false in the older builds here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Technically no, it only writes the value if it is true

@Warriorrrr Warriorrrr added type: feature Request for a new Feature. scope: api labels Mar 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: api type: feature Request for a new Feature.
Projects
Status: Awaiting review
Development

Successfully merging this pull request may close these issues.

Inversed visual fire & lock fire ticks
4 participants