mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-09 04:09:54 +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 e7ed2d1160d412790b23550f9ae967179b7a61f4..711712f144d7b0e26d1248f53bf7ac3963c5df4a 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
@@ -2385,4 +2385,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 39d9f33e49cc8099e0f6dc9822e6d471b46d6e28..5cc93ed8e082324c12ba55e7d388a8cdc7f67f1a 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
@@ -3677,7 +3677,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 d4ac3e566b47cfc8688bcc2ab08385b6de4693f8..7de9d012e7416eaa0189b513a0972c846e93c4b6 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/monster/ZombieVillager.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/monster/ZombieVillager.java
|
|
@@ -272,7 +272,7 @@ public class ZombieVillager extends Zombie implements VillagerDataHolder {
|
|
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);
|
|
+ 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 e7b6f97d8519a5797903664e5ba2a793e37a4bfc..57d4d2014f33a2f069d6c5aaa8e87e36b63a7177 100644
|
|
--- a/src/main/java/net/minecraft/world/level/EntityGetter.java
|
|
+++ b/src/main/java/net/minecraft/world/level/EntityGetter.java
|
|
@@ -231,4 +231,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 e143f42e71ac774d49b75e6d85591aa1189ee210..c27b97e9f097c824de7c785b4cc9e0a503259b08 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
|
|
@@ -100,6 +100,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 serverPlayer) {
|
|
return serverPlayer;
|
|
} else {
|