Paper/patches/server/0269-MC-50319-Check-other-worlds-for-shooter-of-projectil.patch
2023-12-05 15:21:44 -07:00

36 lines
1.8 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Wed, 17 Oct 2018 19:17:27 -0400
Subject: [PATCH] MC-50319: Check other worlds for shooter of projectiles
Say a player shoots an arrow through a nether portal, the game
would lose the shooter for determining things such as Player Kills,
because the entity is in another world.
If the projectile fails to find the shooter in the current world, check
other worlds.
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 01a2c6c3ee4e1500b6ee9986943f84dbe8663860..fec4897ffc07f71efb8725efea341ba2878a1462 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
@@ -67,6 +67,18 @@ public abstract class Projectile extends Entity implements TraceableEntity {
ServerLevel worldserver = (ServerLevel) world;
this.cachedOwner = worldserver.getEntity(this.ownerUUID);
+ // Paper start - check all worlds
+ if (this.cachedOwner == null) {
+ for (final ServerLevel level : this.level().getServer().getAllLevels()) {
+ if (level == this.level()) continue;
+ final Entity entity = level.getEntity(this.ownerUUID);
+ if (entity != null) {
+ this.cachedOwner = entity;
+ break;
+ }
+ }
+ }
+ // Paper end
return this.cachedOwner;
}
}