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.19.2] Persistently save XP saves for entities #20

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

Conversation

Jonathing
Copy link

@Jonathing Jonathing commented Dec 14, 2024

This PR adds a forge capability to replace XPHelper.XP_SAVES. This allows for XP stats saved by Sortilege to also be saved to disk, eliminating the root cause of various XP loss issues.

Additionally, .gitignore and .gitattributes files were added to streamline the process of comitting files to the repository. Also, a small closure was added to the buildscript to assist with IntelliJ IDEA refusing to download linked source and javadoc files.

Copy link
Author

@Jonathing Jonathing left a comment

Choose a reason for hiding this comment

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

Here are some additional comments on some of my implementation details.

Copy link
Author

Choose a reason for hiding this comment

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

The way I wrote the capability for this PR is entirely in my style. I don't exactly know how you would write them since this mod doesn't have any in the first place. It probably isn't a big deal since it doesn't seem like you currently have plans to port the Forge version to 1.20.1, but I wanted to let you know regardless.

Comment on lines +70 to +72
public static void setSavedXp(LivingEntity entity, int xp, boolean onlyIfZero) {
EntityXpStorage.ifPresent(entity, storage -> storage.setXp(xp, onlyIfZero));
}
Copy link
Author

Choose a reason for hiding this comment

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

There were a couple of spots in ModEvents where you used XPHelper.XP_STATS.putIfAbsent(), which wouldn't have replaced the original value if there was one already there. I don't know if this is a bug on your part, but just in case, this parameter onlyIfZero mimics the putIfAbsent behavior of the old code.

@Jonathing Jonathing force-pushed the feat/jonathing/1.19.2/persistent-xp-saves branch from d703dda to 6114923 Compare December 14, 2024 22:53
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.

[1.19.2] XP Stats are not presistently saved
1 participant