From ede9c0681477c17183f8e4ecdf09bb9e2f799aa6 Mon Sep 17 00:00:00 2001 From: Warrior <50800980+Warriorrrr@users.noreply.github.com> Date: Sun, 17 Sep 2023 00:37:38 +0300 Subject: [PATCH] Fix Projectile#setOwner(null) not clearing owner (#9715) * Fix Projectile#setOwner(null) not clearing owner * rebased and merged into mentioned patch --------- Co-authored-by: Jake Potrebic --- ...resh-ProjectileSource-for-projectiles.patch | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/patches/server/0960-Refresh-ProjectileSource-for-projectiles.patch b/patches/server/0960-Refresh-ProjectileSource-for-projectiles.patch index 4ca39169ca..45d54ebb0a 100644 --- a/patches/server/0960-Refresh-ProjectileSource-for-projectiles.patch +++ b/patches/server/0960-Refresh-ProjectileSource-for-projectiles.patch @@ -8,6 +8,11 @@ the API matches the owner UUID specified in the entity nbt. Previously, after the entity reloaded, Projectile#getShooter would return null, while the entity still had an owner. +Also fixes setting the shooter/owner to null actually +clearing the owner. + +Co-authored-by: Warrior <50800980+Warriorrrr@users.noreply.github.com> + diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java index d9f6b0e0b20f4106ffead6b773b5489b71924c61..cf9393dd02565134a1ce428e84a9f26ac2d39a0d 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java @@ -21,15 +26,22 @@ index d9f6b0e0b20f4106ffead6b773b5489b71924c61..cf9393dd02565134a1ce428e84a9f26a public boolean lastDamageCancelled; // SPIGOT-5339, SPIGOT-6252, SPIGOT-6777: Keep track if the event was canceled public boolean persistentInvisibility = false; diff --git a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java -index 6d7ac0c8c171834fa8da94f158258a4774d80ec4..1b7cf6d06bdf36f146656727511a461f2520762e 100644 +index 6d7ac0c8c171834fa8da94f158258a4774d80ec4..a90317100d32974e481e14476843f66997a2cf3a 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java +++ b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java -@@ -49,14 +49,24 @@ public abstract class Projectile extends Entity implements TraceableEntity { +@@ -49,14 +49,31 @@ public abstract class Projectile extends Entity implements TraceableEntity { this.ownerUUID = entity.getUUID(); this.cachedOwner = entity; } - this.projectileSource = (entity != null && entity.getBukkitEntity() instanceof ProjectileSource) ? (ProjectileSource) entity.getBukkitEntity() : null; // CraftBukkit - ++ // Paper start - Fix null owners not being handled ++ else { ++ this.ownerUUID = null; ++ this.cachedOwner = null; ++ this.projectileSource = null; ++ } ++ // Paper end + this.refreshProjectileSource(false); // Paper + } + // Paper start @@ -51,7 +63,7 @@ index 6d7ac0c8c171834fa8da94f158258a4774d80ec4..1b7cf6d06bdf36f146656727511a461f return this.cachedOwner; } else if (this.ownerUUID != null && this.level() instanceof ServerLevel) { this.cachedOwner = ((ServerLevel) this.level()).getEntity(this.ownerUUID); -@@ -72,6 +82,7 @@ public abstract class Projectile extends Entity implements TraceableEntity { +@@ -72,6 +89,7 @@ public abstract class Projectile extends Entity implements TraceableEntity { } } // Paper end