mirror of
https://github.com/PaperMC/Paper.git
synced 2025-05-27 22:21:06 +00:00
42 lines
1.8 KiB
Diff
42 lines
1.8 KiB
Diff
--- a/net/minecraft/world/damagesource/CombatTracker.java
|
|
+++ b/net/minecraft/world/damagesource/CombatTracker.java
|
|
@@ -29,15 +_,24 @@
|
|
private int combatEndTime;
|
|
public boolean inCombat;
|
|
public boolean takingDamage;
|
|
+ public final io.papermc.paper.world.damagesource.PaperCombatTrackerWrapper paperCombatTracker; // Paper - Combat tracker API
|
|
|
|
public CombatTracker(LivingEntity mob) {
|
|
this.mob = mob;
|
|
+ this.paperCombatTracker = new io.papermc.paper.world.damagesource.PaperCombatTrackerWrapper(this); // Paper - Combat tracker API
|
|
}
|
|
|
|
public void recordDamage(DamageSource source, float damage) {
|
|
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;
|