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-01-21 19:37:09 +01:00
index f1f0056157d209ba5d987b6e09ce1fc020920fd9..5b2de5cdac2440a4043c34525a0852067aa9371f 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-01-21 17:39:05 +01:00
@@ -2744,4 +2744,12 @@ public class ServerLevel extends Level implements WorldGenLevel {
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-01-21 19:37:09 +01:00
index fd0af0cbcef59ff1c23e65a1e214fb9939a56a6e..49fdc6d198cc7af31e6c1d1ba52c8adc0fae433f 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
2023-12-06 17:21:56 +01:00
@@ -3678,7 +3678,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-01-16 12:41:40 +01:00
index d4ac3e566b47cfc8688bcc2ab08385b6de4693f8..7de9d012e7416eaa0189b513a0972c846e93c4b6 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
2023-09-22 17:51:48 +02:00
@@ -272,7 +272,7 @@ public class ZombieVillager extends Zombie implements VillagerDataHolder {
2022-11-25 07:22:19 +01:00
entityvillager.finalizeSpawn(world, world.getCurrentDifficultyAt(entityvillager.blockPosition()), MobSpawnType.CONVERSION, (SpawnGroupData) null, (CompoundTag) null);
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
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-01-16 12:41:40 +01:00
index 9f892de55ab03367daed4c30cc44c9dd8adc29ed..a3d15f30eaab29d85cb6b3d693df9980a880f686 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
2023-09-23 00:54:36 +02:00
@@ -280,4 +280,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-01-21 17:39:05 +01:00
index e143f42e71ac774d49b75e6d85591aa1189ee210..c27b97e9f097c824de7c785b4cc9e0a503259b08 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
2023-06-08 10:47:19 +02:00
@@ -100,6 +100,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
2022-11-25 07:22:19 +01:00
if (entity instanceof ServerPlayer serverPlayer) {
return serverPlayer;
} else {