mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-25 03:55:14 +01:00
8c5b837e05
Firstly, the old methods all routed to the CompletableFuture method. However, the CF method could not guarantee that if the caller was off-main that the future would be "completed" on-main. Since the callback methods used the CF one, this meant that the callback methods did not guarantee that the callbacks were to be called on the main thread. Now, all methods route to getChunkAtAsync(x, z, gen, urgent, cb) so that the methods with the callback are guaranteed to invoke the callback on the main thread. The CF behavior remains unchanged; it may still appear to complete on main if invoked off-main. Secondly, remove the scheduleOnMain invocation in the async chunk completion. This unnecessarily delays the callback by 1 tick. Thirdly, add getChunksAtAsync(minX, minZ, maxX, maxZ, ...) which will load chunks within an area. This method is provided as a helper as keeping all chunks loaded within an area can be complicated to implement for plugins (due to the lacking ticket API), and is already implemented internally anyways. Fourthly, remove the ticket addition that occured with getChunkAt and getChunkAtAsync. The ticket addition may delay the unloading of the chunk unnecessarily. It also fixes a very rare timing bug where the future/callback would be completed after the chunk unloads.
51 lines
2.9 KiB
Diff
51 lines
2.9 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
|
Date: Sat, 27 Apr 2024 09:44:53 -0700
|
|
Subject: [PATCH] Revert to vanilla handling of LivingEntity#actuallyHurt
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
index d08eec460a67fbd0b2ed2e0dd6d557dc629f4dfe..555d1b05ef6278567de598488b9486db965b8587 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
@@ -1455,7 +1455,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
|
amount = 0.0F;
|
|
}
|
|
|
|
- float f1 = amount;
|
|
+ float f1 = amount; final float originalAmount = f1; // Paper - revert to vanilla #hurt - OBFHELPER
|
|
boolean flag = amount > 0.0F && this.isDamageSourceBlocked(source); // Copied from below
|
|
float f2 = 0.0F;
|
|
|
|
@@ -1513,6 +1513,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
|
if (!this.actuallyHurt(world, source, (float) event.getFinalDamage() - this.lastHurt, event)) {
|
|
return false;
|
|
}
|
|
+ if (this instanceof ServerPlayer && event.getDamage() == 0 && originalAmount == 0) return false; // Paper - revert to vanilla damage - players are not affected by damage that is 0 - skip damage if the vanilla damage is 0 and was not modified by plugins in the event.
|
|
// CraftBukkit end
|
|
this.lastHurt = amount;
|
|
flag1 = false;
|
|
@@ -1521,6 +1522,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
|
if (!this.actuallyHurt(world, source, (float) event.getFinalDamage(), event)) {
|
|
return false;
|
|
}
|
|
+ if (this instanceof ServerPlayer && event.getDamage() == 0 && originalAmount == 0) return false; // Paper - revert to vanilla damage - players are not affected by damage that is 0 - skip damage if the vanilla damage is 0 and was not modified by plugins in the event.
|
|
this.lastHurt = amount;
|
|
this.invulnerableTime = this.invulnerableDuration; // CraftBukkit - restore use of maxNoDamageTicks
|
|
// this.actuallyHurt(worldserver, damagesource, f);
|
|
@@ -2487,12 +2489,12 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
|
|
|
return true;
|
|
} else {
|
|
- return originalDamage > 0;
|
|
+ return true; // Paper - return false ONLY if event was cancelled
|
|
}
|
|
// CraftBukkit end
|
|
}
|
|
}
|
|
- return false; // CraftBukkit
|
|
+ return true; // CraftBukkit // Paper - return false ONLY if event was cancelled
|
|
}
|
|
|
|
public CombatTracker getCombatTracker() {
|