Add No Damage Tick Utilities#8572
Closed
Owen1212055 wants to merge 2 commits into
Closed
Conversation
Machine-Maker
approved these changes
Dec 12, 2022
lynxplay
reviewed
Jan 31, 2023
98e7250 to
b363dfe
Compare
Member
Author
|
Thinking about this again, should these really be separate methods, or should we fix the current API? As, for the current behavior, I am not sure what use cases would even require older behavior like that. Because in general, it doesn't make sense. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Generally, this API is a bit misleading,
The invulnerability duration is only considered valid until it reaches the invulnerability duration / 2.
Therefore, the no damage tick actions don't work as expected.
When setting it to 20 ticks, the entity will only have an actual invulnerability time frame of 10 ticks due to this invulnerability duration.
This adds new methods, which calculate the limit on top of your specified value in order to make it so when you do
setExactNoDamageTicks(20), the entity will actually have 20 ticks and not 10 ticks of invulnerability.Old methods:
setNoDamageTicks(10)
getNoDamageTicks() -> 10
(getExactNoDamageTicks() will return 0)
Behavior: The entity will have no invulnerability ticks
New methods:
setExactNoDamageTicks(10)
getExactNoDamageTicks() -> 10
(getNoDamageTicks() will return 20)
Behavior: The entity will have 10 invulnerability ticks
This can probably be expanded to the invulnerability duration too, as it's currently divided by 2. But, it's not something I see useful enough and in general could be PRed by someone else.
Download the paperclip jar for this pull request: paper-8572.zip