2022-11-25 07:22:19 +01:00
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
2023-03-15 01:36:12 +01:00
Makes certain entities check all players when searching for a player
instead of just checking players in their world.
2022-11-25 07:22:19 +01:00
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
2024-10-27 18:11:15 +01:00
index 45e61a08152517a61260e662764d8bb0335537e3..b81d814619e4175f42aee397811b07cae420c2e8 100644
2022-11-25 07:22:19 +01:00
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
2024-10-27 18:11:15 +01:00
@@ -2353,4 +2353,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
2022-11-25 07:22:19 +01:00
entity.updateDynamicGameEventListener(DynamicGameEventListener::move);
}
}
+
2024-01-16 12:41:40 +01:00
+ // Paper start - check global player list where appropriate
2022-11-25 07:22:19 +01:00
+ @Override
+ @Nullable
+ public Player getGlobalPlayerByUUID(UUID uuid) {
+ return this.server.getPlayerList().getPlayer(uuid);
+ }
2024-01-16 12:41:40 +01:00
+ // Paper end - check global player list where appropriate
2022-11-25 07:22:19 +01:00
}
2023-03-15 01:36:12 +01:00
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
2024-11-04 18:42:38 +01:00
index 5986af338ffadbfae32783178dfe0b145c875b73..d121b28c8a79b6f5b690c53ae4fef7cd304afdaa 100644
2023-03-15 01:36:12 +01:00
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
2024-11-04 18:42:38 +01:00
@@ -3866,7 +3866,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
2023-03-15 01:36:12 +01:00
}
public void onItemPickup(ItemEntity item) {
- Entity entity = item.getOwner();
2024-01-16 12:41:40 +01:00
+ Entity entity = item.thrower != null ? this.level().getGlobalPlayerByUUID(item.thrower) : null; // Paper - check global player list where appropriate
2023-03-15 01:36:12 +01:00
if (entity instanceof ServerPlayer) {
CriteriaTriggers.THROWN_ITEM_PICKED_UP_BY_ENTITY.trigger((ServerPlayer) entity, item.getItem(), this);
2022-11-25 07:22:19 +01:00
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
2022-11-25 07:22:19 +01:00
--- 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);
2024-01-16 12:41:40 +01:00
+ Player entityhuman = world.getGlobalPlayerByUUID(this.conversionStarter); // Paper - check global player list where appropriate
2022-11-25 07:22:19 +01:00
2024-06-14 03:30:23 +02:00
if (entityhuman instanceof ServerPlayer) {
CriteriaTriggers.CURED_ZOMBIE_VILLAGER.trigger((ServerPlayer) entityhuman, this, entityvillager);
2022-11-25 07:22:19 +01:00
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
2022-11-25 07:22:19 +01:00
--- 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 {
2022-11-25 07:22:19 +01:00
return null;
}
+
2024-01-16 12:41:40 +01:00
+ // Paper start - check global player list where appropriate
2022-11-25 07:22:19 +01:00
+ @Nullable
+ default Player getGlobalPlayerByUUID(UUID uuid) {
+ return this.getPlayerByUUID(uuid);
+ }
2024-01-16 12:41:40 +01:00
+ // Paper end - check global player list where appropriate
2022-11-25 07:22:19 +01:00
}
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
2022-11-25 07:22:19 +01:00
--- 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
2022-11-25 07:22:19 +01:00
@Nullable
public static ServerPlayer tryGetPlayer(@Nullable Entity entity) {
2024-01-16 12:41:40 +01:00
+ // Paper start - check global player list where appropriate; ensure level is the same for sculk events
2022-11-25 07:22:19 +01:00
+ final ServerPlayer player = tryGetPlayer0(entity);
2023-06-08 22:56:13 +02:00
+ return player != null && player.level() == entity.level() ? player : null;
2022-11-25 07:22:19 +01:00
+ }
+ @Nullable
+ private static ServerPlayer tryGetPlayer0(@Nullable Entity entity) {
2024-01-16 12:41:40 +01:00
+ // Paper end - check global player list where appropriate
2024-04-12 21:14:06 +02:00
if (entity instanceof ServerPlayer) {
return (ServerPlayer)entity;
2022-11-25 07:22:19 +01:00
} else {