mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-25 03:55:14 +01:00
d0dcd7d251
Fixes incorrect spigot handling of the invulnerability damage reduction applied when an already invulnerable entity is damaged with a larger damage amount than the initial damage. Vanilla still damages entities even if invulnerable if the damage to be applied is larger than the previous damage taken. In that case, vanilla applies the difference between the previous damage taken and the proposed damage. Spigot's damage modifier API takes over the computation of damage reducing effects, however spigot invokes this handling with the initial damage before computing the difference to the previous damage amount. This leads to the reduction values to generally be larger than expected, as they are computed on the not-yet-reduced value. Spigot applies these reductions after calling the EntityDamageEvent and *then* subtracts the previous damage point, leading to the final damage amount being smaller than expected. This patch cannot simply call the EntityDamageEvent with the reduced damage, as that would lead to EntityDamageEvent#getDamage() returning the already reduced damage, which breaks its method contract. Instead, this patch makes use of the DamageModifier API, implementing the last-damage-reduction as a DamageModifier.
30 lines
1.7 KiB
Diff
30 lines
1.7 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Bjarne Koll <git@lynxplay.dev>
|
|
Date: Fri, 4 Aug 2023 15:53:36 +0200
|
|
Subject: [PATCH] Only erase allay memory on non-item targets
|
|
|
|
Spigot incorrectly instanceOf checks the EntityTargetEvent#getTarget
|
|
against the internal ItemEntity type and removes the nearest wanted item
|
|
memory if said instanceOf check fails, (which is always the case)
|
|
causing allays to behave differently as they constantly loose their
|
|
target item.
|
|
|
|
This commit fixes the faulty behaviour by instance performing a check
|
|
against the CraftItem type.
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/GoToWantedItem.java b/src/main/java/net/minecraft/world/entity/ai/behavior/GoToWantedItem.java
|
|
index 07db92870f9efd515751453569f0dd7b6fada8fc..7d814e5b4b634674995d55ab97155f949f14ef3b 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/GoToWantedItem.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/GoToWantedItem.java
|
|
@@ -35,8 +35,9 @@ public class GoToWantedItem {
|
|
if (event.isCancelled()) {
|
|
return false;
|
|
}
|
|
- if (!(event.getTarget() instanceof ItemEntity)) {
|
|
+ if (!(event.getTarget() instanceof org.bukkit.craftbukkit.entity.CraftItem)) { // Paper - only erase allay memory on non-item targets
|
|
memoryaccessor2.erase();
|
|
+ return false; // Paper - only erase allay memory on non-item targets
|
|
}
|
|
|
|
entityitem = (ItemEntity) ((org.bukkit.craftbukkit.entity.CraftEntity) event.getTarget()).getHandle();
|