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

Add support for Priority in the Resource Pack json files, used to edit Stack Visibility #337

Merged
merged 3 commits into from
Nov 11, 2023

Conversation

Kanzaji
Copy link

@Kanzaji Kanzaji commented Nov 1, 2023

This PR implements a Priority field in Resource Pack json files, used to sort stackData Suppliers in a way the highest priority will edit the Stack Visiblity last, giving it in effect highest Priority.

This feature is implemented to fix load order issues I've been mentioning for past month or two, that caused items added by x.json file being again hidden by y.json file, because it was loaded after the x file.

Priority defaults to value 0, what in result doesn't touch the order of files being loaded, not affecting already live Resource Packs.

Copy link
Owner

@emilyploszaj emilyploszaj left a comment

Choose a reason for hiding this comment

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

I'm not sure why a list of maps is being used here, since the list type is what is returned by each json, in this case, a supplier of IndexStackData. Instead of having priority be a key for the map, there could be a PrioritySupplier type which has both a get like a supplier and a getPriority for the priority, which could be added to the list instead of the Suppliers. At the end, a simple sort over the list could be done. PrioritySupplier could be a public static class inside EmiData. This would let this sorting system be used for other data types easily with minimal changes and be much more reasonable than a list of maps.

Created custom implementation of Supplier Interface, what should keep everything compatible 😅
PrioritySupplier holds two values, integer priority, and supplier itself, what get method is being executed in the implantation of get method of Supplier interface.
This implementation is now used to store suppliers of IndexStackData, additionally achieving the original goal of sorting the list with use of the priority.
@Kanzaji
Copy link
Author

Kanzaji commented Nov 6, 2023

@emilyploszaj Reworked the PR with the feedback I've got, I hope this is better ❤️

Copy link
Owner

@emilyploszaj emilyploszaj left a comment

Choose a reason for hiding this comment

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

This is exactly what I was imagining, this looks great.

@emilyploszaj emilyploszaj merged commit d4c6224 into emilyploszaj:1.19.2 Nov 11, 2023
1 check passed
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

Successfully merging this pull request may close these issues.

2 participants