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
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
2022-12-19 11:46:55 +01:00
|
|
|
index 3af3dd8f151793dbcca46e110bf7fcdaabd847a7..54c2b7fba83d6f06dba95b1bb5b487a02048d6e6 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
|
2022-12-19 11:46:55 +01:00
|
|
|
@@ -2655,4 +2655,12 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
2022-11-25 07:22:19 +01:00
|
|
|
entity.updateDynamicGameEventListener(DynamicGameEventListener::move);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ // Paper start
|
|
|
|
+ @Override
|
|
|
|
+ @Nullable
|
|
|
|
+ public Player getGlobalPlayerByUUID(UUID uuid) {
|
|
|
|
+ return this.server.getPlayerList().getPlayer(uuid);
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
2022-12-19 11:46:55 +01:00
|
|
|
index e3567f8526e289d306cfa8196e60a97a7c1e1266..1274b40a424371b77d8df70ea5f4b2b7300e2a83 100644
|
2022-11-25 07:22:19 +01:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
2022-12-07 23:05:32 +01:00
|
|
|
@@ -3609,7 +3609,7 @@ public abstract class LivingEntity extends Entity {
|
2022-11-25 07:22:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void onItemPickup(ItemEntity item) {
|
|
|
|
- net.minecraft.world.entity.player.Player entityhuman = item.getThrower() != null ? this.level.getPlayerByUUID(item.getThrower()) : null;
|
|
|
|
+ net.minecraft.world.entity.player.Player entityhuman = item.getThrower() != null ? this.level.getGlobalPlayerByUUID(item.getThrower()) : null; // Paper - check all players
|
|
|
|
|
|
|
|
if (entityhuman instanceof ServerPlayer) {
|
|
|
|
CriteriaTriggers.THROWN_ITEM_PICKED_UP_BY_ENTITY.trigger((ServerPlayer) entityhuman, item.getItem(), this);
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/animal/Animal.java b/src/main/java/net/minecraft/world/entity/animal/Animal.java
|
|
|
|
index 6216513805add7c8f52e1ed6c77e2d26786b3ab5..3c4d142e982c34a23bdb5da1f51c8dcacc0532c1 100644
|
|
|
|
--- a/src/main/java/net/minecraft/world/entity/animal/Animal.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/animal/Animal.java
|
|
|
|
@@ -210,7 +210,7 @@ public abstract class Animal extends AgeableMob {
|
|
|
|
if (this.loveCause == null) {
|
|
|
|
return null;
|
|
|
|
} else {
|
|
|
|
- Player entityhuman = this.level.getPlayerByUUID(this.loveCause);
|
|
|
|
+ Player entityhuman = this.level.getGlobalPlayerByUUID(this.loveCause); // Paper - check all players
|
|
|
|
|
|
|
|
return entityhuman instanceof ServerPlayer ? (ServerPlayer) entityhuman : null;
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
2022-12-07 23:05:32 +01:00
|
|
|
index d9da6728d60e97eb9032b0a5aa71757d11f36e22..b0976c20c0b7ff0637809ed2082771f5b6f10b7a 100644
|
2022-11-25 07:22:19 +01:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
2022-12-07 23:05:32 +01:00
|
|
|
@@ -96,7 +96,7 @@ public class ItemEntity extends Entity {
|
2022-11-25 07:22:19 +01:00
|
|
|
Level world = this.level;
|
|
|
|
|
|
|
|
Objects.requireNonNull(this.level);
|
|
|
|
- return (Entity) Util.mapNullable(uuid, world::getPlayerByUUID);
|
|
|
|
+ return (Entity) Util.mapNullable(uuid, world::getGlobalPlayerByUUID); // Paper - check all players
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/monster/ZombieVillager.java b/src/main/java/net/minecraft/world/entity/monster/ZombieVillager.java
|
2022-12-07 23:05:32 +01:00
|
|
|
index aabedf25fa40ffa0d7b378c6006928f806ef0fa6..71a36cf9b976443cca9ab63cd0eb23253f638562 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
|
2022-12-07 23:05:32 +01:00
|
|
|
@@ -269,7 +269,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);
|
|
|
|
+ Player entityhuman = world.getGlobalPlayerByUUID(this.conversionStarter); // Paper - check all players
|
|
|
|
|
|
|
|
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
|
2022-12-07 23:05:32 +01:00
|
|
|
index d860ddae508f53d06f74d8ae0efdfc500c1ddf07..3b959f42d958bf0f426853aee56753d6c455fcdb 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
|
|
|
|
@@ -243,4 +243,11 @@ public interface EntityGetter {
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ // Paper start
|
|
|
|
+ @Nullable
|
|
|
|
+ default Player getGlobalPlayerByUUID(UUID uuid) {
|
|
|
|
+ return this.getPlayerByUUID(uuid);
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
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
|
2022-12-07 23:05:32 +01:00
|
|
|
index f027c2967fcaf5c22abb03c977689485983382c4..0554afa72ae6d2f01886916031c8b90b0d45eb52 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
|
|
|
|
@@ -100,6 +100,13 @@ public class SculkShriekerBlockEntity extends BlockEntity implements VibrationLi
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
public static ServerPlayer tryGetPlayer(@Nullable Entity entity) {
|
|
|
|
+ // Paper start - 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
|
|
|
|
if (entity instanceof ServerPlayer serverPlayer) {
|
|
|
|
return serverPlayer;
|
|
|
|
} else {
|