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
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
index b5eda9931a82a667c25ca1a49980b01b042dc0cc..5f1a4a35d2179b7ff5a95390f82d65cacf4fd457 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-24 22:13:08 +01:00
@@ -2385,4 +2385,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-04-12 21:14:06 +02:00
index 09a26622db4bb4b504f735454e2b031f4840b092..b19b5b8678ce2fb912b703382ae79f5755e025e7 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
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
@@ -3698,7 +3698,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-04-12 21:14:06 +02:00
index d465fb01af4c8610f83ecb9c68b83127cf7e95ae..bd20bea7f76a7307f1698fb2dfef37125032d166 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-04-12 21:14:06 +02:00
@@ -237,4 +237,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-04-12 21:14:06 +02:00
index d71a9fb54269f7c7e251e0e3bdd8b5a072af5201..a2ab5291605a3a3c4fda067c23da7d9aafe1cc38 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-04-12 21:14:06 +02:00
@@ -97,6 +97,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 {