3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-15 04:20:04 +01:00

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 <jake.m.potrebic@gmail.com>
Dieser Commit ist enthalten in:
Warrior 2023-09-17 00:37:38 +03:00 committet von GitHub
Ursprung 0c8e84c20d
Commit ede9c06814
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23

Datei anzeigen

@ -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