Paper
Paper copied to clipboard
Add No Damage Tick Utilities
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
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.