-
Notifications
You must be signed in to change notification settings - Fork 5
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
base: master
Are you sure you want to change the base?
[1.19.2] Persistently save XP saves for entities #20
Conversation
There was a problem hiding this 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.
There was a problem hiding this comment.
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.
public static void setSavedXp(LivingEntity entity, int xp, boolean onlyIfZero) { | ||
EntityXpStorage.ifPresent(entity, storage -> storage.setXp(xp, onlyIfZero)); | ||
} |
There was a problem hiding this comment.
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.
d703dda
to
6114923
Compare
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.