mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-01 04:32:11 -07:00
Add combat tracker API (#11853)
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
--- a/net/minecraft/world/damagesource/CombatTracker.java
|
||||
+++ b/net/minecraft/world/damagesource/CombatTracker.java
|
||||
@@ -38,6 +_,13 @@
|
||||
this.recheckStatus();
|
||||
FallLocation currentFallLocation = FallLocation.getCurrentFallLocation(this.mob);
|
||||
CombatEntry combatEntry = new CombatEntry(source, damage, currentFallLocation, (float)this.mob.fallDistance);
|
||||
+ // Paper start - Combat tracker API
|
||||
+ recordDamageAndCheckCombatState(combatEntry);
|
||||
+ }
|
||||
+
|
||||
+ public void recordDamageAndCheckCombatState(final CombatEntry combatEntry) {
|
||||
+ final DamageSource source = combatEntry.source();
|
||||
+ // Paper end - Combat tracker API
|
||||
this.entries.add(combatEntry);
|
||||
this.lastDamageTime = this.mob.tickCount;
|
||||
this.takingDamage = true;
|
||||
@@ -147,6 +_,13 @@
|
||||
public void recheckStatus() {
|
||||
int i = this.inCombat ? 300 : 100;
|
||||
if (this.takingDamage && (!this.mob.isAlive() || this.mob.tickCount - this.lastDamageTime > i)) {
|
||||
+ // Paper start - Combat tracker API
|
||||
+ resetCombatState();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public void resetCombatState() {{
|
||||
+ // Paper end - Combat tracker API
|
||||
boolean flag = this.inCombat;
|
||||
this.takingDamage = false;
|
||||
this.inCombat = false;
|
Reference in New Issue
Block a user