Skip to content

Add No Damage Tick Utilities#8572

Closed
Owen1212055 wants to merge 2 commits into
PaperMC:masterfrom
Owen1212055:nodamagetick-util
Closed

Add No Damage Tick Utilities#8572
Owen1212055 wants to merge 2 commits into
PaperMC:masterfrom
Owen1212055:nodamagetick-util

Conversation

@Owen1212055
Copy link
Copy Markdown
Member

@Owen1212055 Owen1212055 commented Nov 19, 2022

Generally, this API is a bit misleading,

if ((float) this.invulnerableTime > (float) this.invulnerableDuration / 2.0F) { // CraftBukkit - restore use of maxNoDamageTicks

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

@Owen1212055 Owen1212055 requested a review from a team as a code owner November 19, 2022 02:57
@Owen1212055 Owen1212055 added the publish-pr Enables a workflow to build Paperclip jars on the pull request. label Nov 24, 2022
Comment thread patches/api/0407-Add-No-Damage-Tick-Utilities.patch Outdated
@Owen1212055 Owen1212055 removed the publish-pr Enables a workflow to build Paperclip jars on the pull request. label Apr 7, 2023
@Owen1212055
Copy link
Copy Markdown
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.

@Owen1212055 Owen1212055 deleted the nodamagetick-util branch September 30, 2024 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Closed

Development

Successfully merging this pull request may close these issues.

3 participants