Paper/patches/server/0759-check-global-player-list-where-appropriate.patch

86 lines
5.0 KiB
Diff
Raw Normal View History

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Tue, 22 Nov 2022 13:16:01 -0800
Subject: [PATCH] check global player list where appropriate
Makes certain entities check all players when searching for a player
instead of just checking players in their world.
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 6db3418d839c0f4cd75ad822e605dc2105c3df53..77c1ddc6fd14e0b033825909e5c814abd2306f8d 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -2358,4 +2358,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
entity.updateDynamicGameEventListener(DynamicGameEventListener::move);
}
}
+
+ // Paper start - check global player list where appropriate
+ @Override
+ @Nullable
+ public Player getGlobalPlayerByUUID(UUID uuid) {
+ return this.server.getPlayerList().getPlayer(uuid);
+ }
+ // Paper end - check global player list where appropriate
}
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 18c56cef30fca0174703e775b3bbbf6df4272585..d239108bd98fe885eba50a17855f2d62de02c70e 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -3866,7 +3866,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
}
public void onItemPickup(ItemEntity item) {
- Entity entity = item.getOwner();
+ Entity entity = item.thrower != null ? this.level().getGlobalPlayerByUUID(item.thrower) : null; // Paper - check global player list where appropriate
if (entity instanceof ServerPlayer) {
CriteriaTriggers.THROWN_ITEM_PICKED_UP_BY_ENTITY.trigger((ServerPlayer) entity, item.getItem(), this);
diff --git a/src/main/java/net/minecraft/world/entity/monster/ZombieVillager.java b/src/main/java/net/minecraft/world/entity/monster/ZombieVillager.java
2024-10-24 00:08:29 +02:00
index 533cb2eff3d56e7e8a70aba5e1047250e192bf2c..18c19e4b675000aacb74344909fc104964231008 100644
--- a/src/main/java/net/minecraft/world/entity/monster/ZombieVillager.java
+++ b/src/main/java/net/minecraft/world/entity/monster/ZombieVillager.java
2024-10-24 00:08:29 +02:00
@@ -262,7 +262,7 @@ public class ZombieVillager extends Zombie implements VillagerDataHolder {
entityvillager.finalizeSpawn(world, world.getCurrentDifficultyAt(entityvillager.blockPosition()), EntitySpawnReason.CONVERSION, (SpawnGroupData) null);
2024-06-14 03:30:23 +02:00
entityvillager.refreshBrain(world);
if (this.conversionStarter != null) {
- Player entityhuman = world.getPlayerByUUID(this.conversionStarter);
+ Player entityhuman = world.getGlobalPlayerByUUID(this.conversionStarter); // Paper - check global player list where appropriate
2024-06-14 03:30:23 +02:00
if (entityhuman instanceof ServerPlayer) {
CriteriaTriggers.CURED_ZOMBIE_VILLAGER.trigger((ServerPlayer) entityhuman, this, entityvillager);
diff --git a/src/main/java/net/minecraft/world/level/EntityGetter.java b/src/main/java/net/minecraft/world/level/EntityGetter.java
2024-10-24 00:08:29 +02:00
index dac8305f1c897e6f82a2dde67c5b1b6b8b649b19..e185a33b5b1f8e8e0a0e666b24ba3e9186a8a7ff 100644
--- a/src/main/java/net/minecraft/world/level/EntityGetter.java
+++ b/src/main/java/net/minecraft/world/level/EntityGetter.java
2024-10-24 00:08:29 +02:00
@@ -165,4 +165,11 @@ public interface EntityGetter {
return null;
}
+
+ // Paper start - check global player list where appropriate
+ @Nullable
+ default Player getGlobalPlayerByUUID(UUID uuid) {
+ return this.getPlayerByUUID(uuid);
+ }
+ // Paper end - check global player list where appropriate
}
diff --git a/src/main/java/net/minecraft/world/level/block/entity/SculkShriekerBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/SculkShriekerBlockEntity.java
2024-10-24 00:08:29 +02:00
index ea53c25c350c0cf8e0360ea409cd1f69a62054a8..275721d8b3d653b38af505dde30396c0b7b6a3da 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/SculkShriekerBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/SculkShriekerBlockEntity.java
2024-06-14 03:30:23 +02:00
@@ -105,6 +105,13 @@ public class SculkShriekerBlockEntity extends BlockEntity implements GameEventLi
@Nullable
public static ServerPlayer tryGetPlayer(@Nullable Entity entity) {
+ // Paper start - check global player list where appropriate; ensure level is the same for sculk events
+ final ServerPlayer player = tryGetPlayer0(entity);
2023-06-08 22:56:13 +02:00
+ return player != null && player.level() == entity.level() ? player : null;
+ }
+ @Nullable
+ private static ServerPlayer tryGetPlayer0(@Nullable Entity entity) {
+ // Paper end - check global player list where appropriate
if (entity instanceof ServerPlayer) {
return (ServerPlayer)entity;
} else {