mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-22 10:35:38 +01:00
86 lines
5.0 KiB
Diff
86 lines
5.0 KiB
Diff
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 66f795168d3e120506aafa3cade78e6e8dcd8619..cff225eab588248f1e6487a4a33da006672b3ba4 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
@@ -2300,4 +2300,12 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
|
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 e6335a55d87444d56d6f20dfc51cc4fc797de2cf..ec656b2505c143e453b540e3e0a2cbfa0b370cd3 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
@@ -3723,7 +3723,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
|
|
index f8c733961015ace508bfe14fd61d5188ca9d551b..e0dabbf6d7a87b8722769c78ef0d2ba4353ed2cb 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/monster/ZombieVillager.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/monster/ZombieVillager.java
|
|
@@ -269,7 +269,7 @@ public class ZombieVillager extends Zombie implements VillagerDataHolder {
|
|
entityvillager.finalizeSpawn(world, world.getCurrentDifficultyAt(entityvillager.blockPosition()), MobSpawnType.CONVERSION, (SpawnGroupData) null);
|
|
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
|
|
|
|
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
|
|
index d465fb01af4c8610f83ecb9c68b83127cf7e95ae..bd20bea7f76a7307f1698fb2dfef37125032d166 100644
|
|
--- a/src/main/java/net/minecraft/world/level/EntityGetter.java
|
|
+++ b/src/main/java/net/minecraft/world/level/EntityGetter.java
|
|
@@ -237,4 +237,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
|
|
index dd86f5ec5b2051aeea4e19ff97146362b1e8d019..0c6561e53db1b82f70dec00729d4d8a70c8fd4a1 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
|
|
@@ -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);
|
|
+ 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 {
|