Apply all patches

This commit is contained in:
Nassim Jahnke 2023-12-06 19:18:53 +01:00
parent 286f49b866
commit 4ce929d6da
38 changed files with 139 additions and 124 deletions

View file

@ -94,8 +94,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- Vec3 startPos = CraftLocation.toVec3D(start);
+ Vec3 startPos = io.papermc.paper.util.MCUtil.toVec3(start); // Paper
Vec3 endPos = startPos.add(dir.getX(), dir.getY(), dir.getZ());
- HitResult nmsHitResult = this.getHandle().clip(new ClipContext(startPos, endPos, ignorePassableBlocks ? ClipContext.Block.COLLIDER : ClipContext.Block.OUTLINE, CraftFluidCollisionMode.toNMS(fluidCollisionMode), null));
+ HitResult nmsHitResult = this.getHandle().clip(new ClipContext(startPos, endPos, ignorePassableBlocks ? ClipContext.Block.COLLIDER : ClipContext.Block.OUTLINE, CraftFluidCollisionMode.toNMS(fluidCollisionMode), null), canCollide); // Paper - use method with canCollide predicate
- HitResult nmsHitResult = this.getHandle().clip(new ClipContext(startPos, endPos, ignorePassableBlocks ? ClipContext.Block.COLLIDER : ClipContext.Block.OUTLINE, CraftFluidCollisionMode.toNMS(fluidCollisionMode), CollisionContext.empty()));
+ HitResult nmsHitResult = this.getHandle().clip(new ClipContext(startPos, endPos, ignorePassableBlocks ? ClipContext.Block.COLLIDER : ClipContext.Block.OUTLINE, CraftFluidCollisionMode.toNMS(fluidCollisionMode), CollisionContext.empty()), canCollide); // Paper - use method with canCollide predicate
return CraftRayTraceResult.fromNMS(this, nmsHitResult);
}

View file

@ -9,8 +9,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -0,0 +0,0 @@ public final class CraftMagicNumbers implements UnsafeValues {
JsonObject jsonobject = GsonHelper.convertToJsonObject(jsonelement, "advancement");
net.minecraft.advancements.Advancement nms = net.minecraft.advancements.Advancement.fromJson(jsonobject, new DeserializationContext(minecraftkey, MinecraftServer.getServer().getLootData()));
JsonElement jsonelement = ServerAdvancementManager.GSON.fromJson(advancement, JsonElement.class);
net.minecraft.advancements.Advancement nms = Util.getOrThrow(net.minecraft.advancements.Advancement.CODEC.parse(JsonOps.INSTANCE, jsonelement), JsonParseException::new);
if (nms != null) {
- MinecraftServer.getServer().getAdvancements().advancements.put(minecraftkey, new AdvancementHolder(minecraftkey, nms));
+ // Paper start - Fix throw UnsupportedOperationException

View file

@ -22,7 +22,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
for(CriterionTrigger.Listener<T> listener : set) {
T simpleInstance = listener.trigger();
if (predicate.test(simpleInstance)) {
Optional<ContextAwarePredicate> optional = simpleInstance.playerPredicate();
Optional<ContextAwarePredicate> optional = simpleInstance.player();
- if (optional.isEmpty() || optional.get().matches(lootContext)) {
+ if (optional.isEmpty() || optional.get().matches(lootContext = (lootContext == null ? EntityPredicate.createContext(player, player) : lootContext))) { // Paper - lazily create LootContext for criterions
if (list == null) {

View file

@ -192,38 +192,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
@@ -0,0 +0,0 @@ public class ServerChunkCache extends ChunkSource {
this.lastSpawnState = spawnercreature_d;
gameprofilerfiller.popPush("filteringLoadedChunks");
- List<ServerChunkCache.ChunkAndHolder> list = Lists.newArrayListWithCapacity(l);
gameprofilerfiller.push("pollingChunks");
gameprofilerfiller.push("filteringLoadedChunks");
- List<ServerChunkCache.ChunkAndHolder> list = Lists.newArrayListWithCapacity(this.chunkMap.size());
- Iterator iterator = this.chunkMap.getChunks().iterator();
+ // Paper - optimise chunk tick iteration
+ // Paper - optimise chunk tick iteration
this.level.timings.chunkTicks.startTiming(); // Paper
- while (iterator.hasNext()) {
- ChunkHolder playerchunk = (ChunkHolder) iterator.next();
- LevelChunk chunk = playerchunk.getTickingChunk();
-
- if (chunk != null) {
- list.add(new ServerChunkCache.ChunkAndHolder(chunk, playerchunk));
- }
- }
+ // Paper - optimise chunk tick iteration
gameprofilerfiller.popPush("spawnAndTick");
boolean flag2 = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !this.level.players().isEmpty(); // CraftBukkit
- Collections.shuffle(list);
- // Paper start - call player naturally spawn event
- int chunkRange = level.spigotConfig.mobSpawnRange;
- chunkRange = (chunkRange > level.spigotConfig.viewDistance) ? (byte) level.spigotConfig.viewDistance : chunkRange;
- chunkRange = Math.min(chunkRange, 8);
- for (ServerPlayer entityPlayer : this.level.players()) {
- entityPlayer.playerNaturallySpawnedEvent = new com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent(entityPlayer.getBukkitEntity(), (byte) chunkRange);
- entityPlayer.playerNaturallySpawnedEvent.callEvent();
- };
- // Paper end
- Iterator iterator1 = list.iterator();
+ // Paper start - optimise chunk tick iteration
+ ChunkMap playerChunkMap = this.chunkMap;
+ for (ServerPlayer player : this.level.players) {
@ -235,7 +212,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ }
+
+ int viewDistance = io.papermc.paper.chunk.system.ChunkSystem.getTickViewDistance(player);
+
- if (chunk != null) {
- list.add(new ServerChunkCache.ChunkAndHolder(chunk, playerchunk));
+ // copied and modified from isOutisdeRange
+ int chunkRange = (int)level.spigotConfig.mobSpawnRange;
+ chunkRange = (chunkRange > viewDistance) ? viewDistance : chunkRange;
@ -248,7 +227,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ player.playerNaturallySpawnedEvent = null;
+ player.lastEntitySpawnRadiusSquared = -1.0;
+ continue;
+ }
}
+
+ int range = Math.min(event.getSpawnRadius(), DistanceManager.MOB_SPAWN_RANGE); // limit to max spawn range
+ int chunkX = io.papermc.paper.util.CoordinateUtils.getChunkCoordinate(player.getX());
@ -257,80 +236,137 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ playerChunkMap.playerMobSpawnMap.addOrUpdate(player, chunkX, chunkZ, range);
+ player.lastEntitySpawnRadiusSquared = (double)((range << 4) * (range << 4)); // used in anyPlayerCloseEnoughForSpawning
+ player.playerNaturallySpawnedEvent = event;
+ }
}
+ // Paper end - optimise chunk tick iteration
int chunksTicked = 0; // Paper
+ // Paper start - optimise chunk tick iteration
+ io.papermc.paper.util.player.NearbyPlayers nearbyPlayers = this.chunkMap.getNearbyPlayers(); // Paper - optimise chunk tick iteration
+ Iterator<LevelChunk> iterator1;
+ if (this.level.paperConfig().entities.spawning.perPlayerMobSpawns) {
+ iterator1 = this.tickingChunks.iterator();
+ } else {
+ iterator1 = this.tickingChunks.unsafeIterator();
+ List<LevelChunk> shuffled = Lists.newArrayListWithCapacity(this.tickingChunks.size());
+ while (iterator1.hasNext()) {
+ shuffled.add(iterator1.next());
+ }
+ Collections.shuffle(shuffled);
+ iterator1 = shuffled.iterator();
+ }
+ try {
+ // Paper end - optimise chunk tick iteration
while (iterator1.hasNext()) {
- ServerChunkCache.ChunkAndHolder chunkproviderserver_a = (ServerChunkCache.ChunkAndHolder) iterator1.next();
- LevelChunk chunk1 = chunkproviderserver_a.chunk;
+ LevelChunk chunk1 = iterator1.next(); // Paper - optimise chunk tick iteration
ChunkPos chunkcoordintpair = chunk1.getPos();
if (this.level.getServer().tickRateManager().runsNormally()) {
gameprofilerfiller.popPush("naturalSpawnCount");
@@ -0,0 +0,0 @@ public class ServerChunkCache extends ChunkSource {
gameprofilerfiller.popPush("spawnAndTick");
boolean flag = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !this.level.players().isEmpty(); // CraftBukkit
- if (this.level.isNaturalSpawningAllowed(chunkcoordintpair) && this.chunkMap.anyPlayerCloseEnoughForSpawning(chunkcoordintpair)) {
- Util.shuffle(list, this.level.random);
- // Paper start - call player naturally spawn event
- int chunkRange = level.spigotConfig.mobSpawnRange;
- chunkRange = (chunkRange > level.spigotConfig.viewDistance) ? (byte) level.spigotConfig.viewDistance : chunkRange;
- chunkRange = Math.min(chunkRange, 8);
- for (ServerPlayer entityPlayer : this.level.players()) {
- entityPlayer.playerNaturallySpawnedEvent = new com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent(entityPlayer.getBukkitEntity(), (byte) chunkRange);
- entityPlayer.playerNaturallySpawnedEvent.callEvent();
+ // Paper start - optimise chunk tick iteration
+ com.destroystokyo.paper.util.maplist.ReferenceList<ServerPlayer> playersNearby
+ = nearbyPlayers.getPlayers(chunkcoordintpair, io.papermc.paper.util.player.NearbyPlayers.NearbyMapType.SPAWN_RANGE);
+ if (playersNearby == null) {
+ continue;
+ }
+ Object[] rawData = playersNearby.getRawData();
+ boolean spawn = false;
+ boolean tick = false;
+ for (int itr = 0, len = playersNearby.size(); itr < len; ++itr) {
+ ServerPlayer player = (ServerPlayer)rawData[itr];
+ if (player.isSpectator()) {
+ for (ServerPlayer player : this.level.players) {
+ if (!player.affectsSpawning || player.isSpectator()) {
+ playerChunkMap.playerMobSpawnMap.remove(player);
+ player.playerNaturallySpawnedEvent = null;
+ player.lastEntitySpawnRadiusSquared = -1.0;
+ continue;
+ }
+
+ double distance = ChunkMap.euclideanDistanceSquared(chunkcoordintpair, player);
+ spawn |= player.lastEntitySpawnRadiusSquared >= distance;
+ tick |= ((double)io.papermc.paper.util.player.NearbyPlayers.SPAWN_RANGE_VIEW_DISTANCE_BLOCKS) * ((double)io.papermc.paper.util.player.NearbyPlayers.SPAWN_RANGE_VIEW_DISTANCE_BLOCKS) >= distance;
+ if (spawn & tick) {
+ break;
+ int viewDistance = io.papermc.paper.chunk.system.ChunkSystem.getTickViewDistance(player);
+
+ // copied and modified from isOutisdeRange
+ int chunkRange = (int)level.spigotConfig.mobSpawnRange;
+ chunkRange = (chunkRange > viewDistance) ? viewDistance : chunkRange;
+ chunkRange = (chunkRange > DistanceManager.MOB_SPAWN_RANGE) ? DistanceManager.MOB_SPAWN_RANGE : chunkRange;
+
+ com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent event = new com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent(player.getBukkitEntity(), (byte)chunkRange);
+ event.callEvent();
+ if (event.isCancelled() || event.getSpawnRadius() < 0) {
+ playerChunkMap.playerMobSpawnMap.remove(player);
+ player.playerNaturallySpawnedEvent = null;
+ player.lastEntitySpawnRadiusSquared = -1.0;
+ continue;
+ }
+
+ int range = Math.min(event.getSpawnRadius(), DistanceManager.MOB_SPAWN_RANGE); // limit to max spawn range
+ int chunkX = io.papermc.paper.util.CoordinateUtils.getChunkCoordinate(player.getX());
+ int chunkZ = io.papermc.paper.util.CoordinateUtils.getChunkCoordinate(player.getZ());
+
+ playerChunkMap.playerMobSpawnMap.addOrUpdate(player, chunkX, chunkZ, range);
+ player.lastEntitySpawnRadiusSquared = (double)((range << 4) * (range << 4)); // used in anyPlayerCloseEnoughForSpawning
+ player.playerNaturallySpawnedEvent = event;
}
- // Paper end
+ // Paper end - optimise chunk tick iteration
int l = this.level.getGameRules().getInt(GameRules.RULE_RANDOMTICKING);
boolean flag1 = this.level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) != 0L && this.level.getLevelData().getGameTime() % this.level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) == 0L; // CraftBukkit
- Iterator iterator1 = list.iterator();
int chunksTicked = 0; // Paper
- while (iterator1.hasNext()) {
- ServerChunkCache.ChunkAndHolder chunkproviderserver_a = (ServerChunkCache.ChunkAndHolder) iterator1.next();
- LevelChunk chunk1 = chunkproviderserver_a.chunk;
+ // Paper start - optimise chunk tick iteration
+ io.papermc.paper.util.player.NearbyPlayers nearbyPlayers = this.chunkMap.getNearbyPlayers(); // Paper - optimise chunk tick iteration
+ Iterator<LevelChunk> chunkIterator;
+ if (this.level.paperConfig().entities.spawning.perPlayerMobSpawns) {
+ chunkIterator = this.tickingChunks.iterator();
+ } else {
+ chunkIterator = this.tickingChunks.unsafeIterator();
+ List<LevelChunk> shuffled = Lists.newArrayListWithCapacity(this.tickingChunks.size());
+ while (chunkIterator.hasNext()) {
+ shuffled.add(chunkIterator.next());
+ }
+ Util.shuffle(shuffled, this.level.random);
+ chunkIterator = shuffled.iterator();
+ }
+ try {
+ // Paper end - optimise chunk tick iteration
+ while (chunkIterator.hasNext()) {
+ LevelChunk chunk1 = chunkIterator.next(); // Paper - optimise chunk tick iteration
ChunkPos chunkcoordintpair = chunk1.getPos();
- if (this.level.isNaturalSpawningAllowed(chunkcoordintpair) && this.chunkMap.anyPlayerCloseEnoughForSpawning(chunkcoordintpair)) {
+ // Paper start - optimise chunk tick iteration
+ com.destroystokyo.paper.util.maplist.ReferenceList<ServerPlayer> playersNearby
+ = nearbyPlayers.getPlayers(chunkcoordintpair, io.papermc.paper.util.player.NearbyPlayers.NearbyMapType.SPAWN_RANGE);
+ if (playersNearby == null) {
+ continue;
+ }
+
+ Object[] rawData = playersNearby.getRawData();
+ boolean spawn = false;
+ boolean tick = false;
+ for (int itr = 0, len = playersNearby.size(); itr < len; ++itr) {
+ ServerPlayer player = (ServerPlayer)rawData[itr];
+ if (player.isSpectator()) {
+ continue;
+ }
+
+ double distance = ChunkMap.euclideanDistanceSquared(chunkcoordintpair, player);
+ spawn |= player.lastEntitySpawnRadiusSquared >= distance;
+ tick |= ((double)io.papermc.paper.util.player.NearbyPlayers.SPAWN_RANGE_VIEW_DISTANCE_BLOCKS) * ((double)io.papermc.paper.util.player.NearbyPlayers.SPAWN_RANGE_VIEW_DISTANCE_BLOCKS) >= distance;
+ if (spawn & tick) {
+ break;
+ }
+ }
+ if (tick && chunk1.chunkStatus.isOrAfter(net.minecraft.server.level.FullChunkStatus.ENTITY_TICKING)) {
+ // Paper end - optimise chunk tick iteration
chunk1.incrementInhabitedTime(j);
- if (flag && (this.spawnEnemies || this.spawnFriendlies) && this.level.getWorldBorder().isWithinBounds(chunkcoordintpair) && this.chunkMap.anyPlayerCloseEnoughForSpawning(chunkcoordintpair, true)) { // Spigot
+ if (spawn && flag && (this.spawnEnemies || this.spawnFriendlies) && this.level.getWorldBorder().isWithinBounds(chunkcoordintpair)) { // Spigot // Paper - optimise chunk tick iteration
NaturalSpawner.spawnForChunk(this.level, chunk1, spawnercreature_d, this.spawnFriendlies, this.spawnEnemies, flag1);
}
- if (this.level.shouldTickBlocksAt(chunkcoordintpair.toLong())) {
+ if (true || this.level.shouldTickBlocksAt(chunkcoordintpair.toLong())) { // Paper - optimise chunk tick iteration
this.level.timings.doTickTiles.startTiming(); // Spigot
this.level.tickChunk(chunk1, l);
if ((chunksTicked++ & 1) == 0) net.minecraft.server.MinecraftServer.getServer().executeMidTickTasks(); // Paper
@@ -0,0 +0,0 @@ public class ServerChunkCache extends ChunkSource {
}
}
}
+ // Paper start - optimise chunk tick iteration
+ } finally {
+ if (chunkIterator instanceof io.papermc.paper.util.maplist.IteratorSafeOrderedReferenceSet.Iterator safeIterator) {
+ safeIterator.finishedIterating();
+ }
+ }
+ // Paper end - optimise chunk tick iteration
+ if (tick && chunk1.chunkStatus.isOrAfter(net.minecraft.server.level.FullChunkStatus.ENTITY_TICKING)) { // Paper - optimise chunk tick iteration
chunk1.incrementInhabitedTime(j);
- if (flag2 && (this.spawnEnemies || this.spawnFriendlies) && this.level.getWorldBorder().isWithinBounds(chunkcoordintpair) && this.chunkMap.anyPlayerCloseEnoughForSpawning(chunkcoordintpair, true)) { // Spigot
+ if (spawn && flag2 && (this.spawnEnemies || this.spawnFriendlies) && this.level.getWorldBorder().isWithinBounds(chunkcoordintpair)) { // Spigot // Paper - optimise chunk tick iteration
NaturalSpawner.spawnForChunk(this.level, chunk1, spawnercreature_d, this.spawnFriendlies, this.spawnEnemies, flag1);
}
- if (this.level.shouldTickBlocksAt(chunkcoordintpair.toLong())) {
+ if (true || this.level.shouldTickBlocksAt(chunkcoordintpair.toLong())) { // Paper - optimise chunk tick iteration
this.level.tickChunk(chunk1, k);
if ((chunksTicked++ & 1) == 0) net.minecraft.server.MinecraftServer.getServer().executeMidTickTasks(); // Paper
}
}
}
+ // Paper start - optimise chunk tick iteration
+ } finally {
+ if (iterator1 instanceof io.papermc.paper.util.maplist.IteratorSafeOrderedReferenceSet.Iterator safeIterator) {
+ safeIterator.finishedIterating();
+ }
+ }
+ // Paper end - optimise chunk tick iteration
this.level.timings.chunkTicks.stopTiming(); // Paper
gameprofilerfiller.popPush("customSpawners");
if (flag2) {
gameprofilerfiller.popPush("customSpawners");
if (flag) {
@@ -0,0 +0,0 @@ public class ServerChunkCache extends ChunkSource {
}
@ -357,7 +393,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper - optimise chunk tick iteration
gameprofilerfiller.pop();
gameprofilerfiller.pop();
this.chunkMap.tick();
}
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java

View file

@ -42,7 +42,7 @@ diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/jav
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@Nullable
public ItemEntity spawnAtLocation(ItemStack stack, float yOffset) {
@ -68,7 +68,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (stack.isEmpty()) {
return null;
} else if (this.level().isClientSide) {
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
} else {
// CraftBukkit start - Capture drops for death event
if (this instanceof net.minecraft.world.entity.LivingEntity && !((net.minecraft.world.entity.LivingEntity) this).forceDrops) {
@ -89,7 +89,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- entityitem.setDefaultPickUpDelay();
+ entityitem.setDefaultPickUpDelay(); // Paper - diff on change (in dropConsumer)
// Paper start
// Paper start
return this.spawnAtLocation(entityitem);
}
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java

View file

@ -9,15 +9,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
@@ -0,0 +0,0 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
@Override
public boolean enforceSecureProfile() {
DedicatedServerProperties dedicatedserverproperties = this.getProperties();
-
- return dedicatedserverproperties.enforceSecureProfile && dedicatedserverproperties.onlineMode && this.services.profileKeySignatureValidator() != null;
- return dedicatedserverproperties.enforceSecureProfile && dedicatedserverproperties.onlineMode && this.services.canValidateProfileKeys();
+ // Paper start - fix secure profile with proxy online mode
+ return dedicatedserverproperties.enforceSecureProfile
+ && io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode()
+ && this.services.profileKeySignatureValidator() != null;
+ && this.services.canValidateProfileKeys();
+ // Paper end
}

View file

@ -1,20 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Tue, 7 Nov 2023 18:59:04 -0800
Subject: [PATCH] Don't unpack loot table for TEs not in world
Fixed by 23w44a/1.20.3. Remove it then
diff --git a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
@@ -0,0 +0,0 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc
}
public void unpackLootTable(@Nullable Player player) {
- if (this.lootableData.shouldReplenish(player) && this.level.getServer() != null) { // Paper
+ if (this.level != null && this.lootableData.shouldReplenish(player) && this.level.getServer() != null) { // Paper - don't unpack loot table if not in world
LootTable lootTable = this.level.getServer().getLootData().getLootTable(this.lootTable);
if (player instanceof ServerPlayer) {
CriteriaTriggers.GENERATE_LOOT.trigger((ServerPlayer)player, this.lootTable);