From 8efc0a0cc64d72c3dbea147d605435ffb41152cc Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Wed, 1 Sep 2021 14:03:36 +0200 Subject: [PATCH] Updated Upstream (Bukkit/CraftBukkit/Spigot) (#6539) 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: ed7bba95 SPIGOT-6547: Chunk#getEntities() doesn't return all entities immediately after chunk load d99a585c SPIGOT-6719: Add getTileEntities() to LimitedRegion CraftBukkit Changes: 422cec08 Rebuild patch 15f27fc7 SPIGOT-6547: Chunk#getEntities() doesn't return all entities immediately after chunk load cbd747af SPIGOT-6719: Add getTileEntities() to LimitedRegion Spigot Changes: 6c1c1b26 Rebuild patches --- patches/api/Add-more-LimitedRegion-API.patch | 9 ++++---- ...ile-Entities-from-a-chunk-without-sn.patch | 2 +- .../server/Add-more-LimitedRegion-API.patch | 8 ------- .../Entity-load-save-limit-per-chunk.patch | 10 ++++---- ...Implemented-BlockFailedDispenseEvent.patch | 2 +- ...imise-TickListServer-by-rewriting-it.patch | 6 ++--- .../server/Optimise-WorldServer-notify.patch | 2 +- .../server/Rewrite-dataconverter-system.patch | 4 ++-- ...ite-entity-bounding-box-lookup-calls.patch | 23 +++++++++++++------ work/Bukkit | 2 +- work/CraftBukkit | 2 +- work/Spigot | 2 +- 12 files changed, 37 insertions(+), 35 deletions(-) diff --git a/patches/api/Add-more-LimitedRegion-API.patch b/patches/api/Add-more-LimitedRegion-API.patch index 2a7f3799c1..383e4ea6bb 100644 --- a/patches/api/Add-more-LimitedRegion-API.patch +++ b/patches/api/Add-more-LimitedRegion-API.patch @@ -358,10 +358,10 @@ diff --git a/src/main/java/org/bukkit/generator/LimitedRegion.java b/src/main/ja index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/generator/LimitedRegion.java +++ b/src/main/java/org/bukkit/generator/LimitedRegion.java -@@ -0,0 +0,0 @@ package org.bukkit.generator; - +@@ -0,0 +0,0 @@ import java.util.List; import org.bukkit.Location; import org.bukkit.RegionAccessor; + import org.bukkit.block.BlockState; +// Paper start +import org.bukkit.World; +import org.bukkit.block.BlockState; @@ -372,9 +372,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 /** @@ -0,0 +0,0 @@ public interface LimitedRegion extends RegionAccessor { - * @return true if the coordinates are in the region, otherwise false. */ - boolean isInRegion(int x, int y, int z); + @NotNull + List getTileEntities(); ++ + + // Paper start + /** diff --git a/patches/server/Ability-to-get-Tile-Entities-from-a-chunk-without-sn.patch b/patches/server/Ability-to-get-Tile-Entities-from-a-chunk-without-sn.patch index 722548d1fb..86662ed565 100644 --- a/patches/server/Ability-to-get-Tile-Entities-from-a-chunk-without-sn.patch +++ b/patches/server/Ability-to-get-Tile-Entities-from-a-chunk-without-sn.patch @@ -16,9 +16,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 import java.util.Arrays; import java.util.Collection; +import java.util.List; + import java.util.Objects; import java.util.function.Predicate; import net.minecraft.core.BlockPos; - import net.minecraft.core.Registry; @@ -0,0 +0,0 @@ public class CraftChunk implements Chunk { @Override diff --git a/patches/server/Add-more-LimitedRegion-API.patch b/patches/server/Add-more-LimitedRegion-API.patch index 83052e62fc..329d44247a 100644 --- a/patches/server/Add-more-LimitedRegion-API.patch +++ b/patches/server/Add-more-LimitedRegion-API.patch @@ -130,14 +130,6 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/generator/CraftLimitedRegion.j index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/generator/CraftLimitedRegion.java +++ b/src/main/java/org/bukkit/craftbukkit/generator/CraftLimitedRegion.java -@@ -0,0 +0,0 @@ import java.util.ArrayList; - import java.util.Collection; - import java.util.List; - import java.util.Random; -+import net.minecraft.core.BlockPos; // Paper - import net.minecraft.nbt.CompoundTag; - import net.minecraft.server.level.WorldGenRegion; - import net.minecraft.world.entity.EntityType; @@ -0,0 +0,0 @@ public class CraftLimitedRegion extends CraftRegionAccessor implements LimitedRe @Override public BlockState getBlockState(int x, int y, int z) { diff --git a/patches/server/Entity-load-save-limit-per-chunk.patch b/patches/server/Entity-load-save-limit-per-chunk.patch index 421ff84a9c..1f93289717 100644 --- a/patches/server/Entity-load-save-limit-per-chunk.patch +++ b/patches/server/Entity-load-save-limit-per-chunk.patch @@ -94,9 +94,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/level/chunk/storage/EntityStorage.java +++ b/src/main/java/net/minecraft/world/level/chunk/storage/EntityStorage.java @@ -0,0 +0,0 @@ public class EntityStorage implements EntityPersistentStorage { - } else { - ListTag listTag = new ListTag(); + ListTag nbttaglist = new ListTag(); + + final java.util.Map, Integer> savedEntityCounts = new java.util.HashMap<>(); // Paper dataList.getEntities().forEach((entity) -> { + // Paper start @@ -109,6 +109,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + savedEntityCounts.merge(entityType, 1, Integer::sum); + } + // Paper end - CompoundTag compoundTag = new CompoundTag(); - if (entity.save(compoundTag)) { - listTag.add(compoundTag); + CompoundTag nbttagcompound = new CompoundTag(); + + if (entity.save(nbttagcompound)) { diff --git a/patches/server/Implemented-BlockFailedDispenseEvent.patch b/patches/server/Implemented-BlockFailedDispenseEvent.patch index 1492d8bc60..dde2471b0c 100644 --- a/patches/server/Implemented-BlockFailedDispenseEvent.patch +++ b/patches/server/Implemented-BlockFailedDispenseEvent.patch @@ -36,8 +36,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -0,0 +0,0 @@ public class CraftEventFactory { + EntitiesUnloadEvent event = new EntitiesUnloadEvent(new CraftChunk((ServerLevel) world, coords.x, coords.z), bukkitEntities); Bukkit.getPluginManager().callEvent(event); - return event; } + + // Paper start diff --git a/patches/server/Optimise-TickListServer-by-rewriting-it.patch b/patches/server/Optimise-TickListServer-by-rewriting-it.patch index bb64d3e995..c563c4a954 100644 --- a/patches/server/Optimise-TickListServer-by-rewriting-it.patch +++ b/patches/server/Optimise-TickListServer-by-rewriting-it.patch @@ -1122,9 +1122,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/level/entity/PersistentEntitySectionManager.java +++ b/src/main/java/net/minecraft/world/level/entity/PersistentEntitySectionManager.java @@ -0,0 +0,0 @@ public class PersistentEntitySectionManager implements A - this.addEntity(entityaccess, true); - }); - this.chunkLoadStatuses.put(chunkentities.getPos().toLong(), PersistentEntitySectionManager.ChunkLoadStatus.LOADED); + List entities = this.getEntities(chunkentities.getPos()); // PAIL rename getChunkPos + CraftEventFactory.callEntitiesLoadEvent(((EntityStorage) this.permanentStorage).level, chunkentities.getPos(), entities); + // CraftBukkit end + // Paper start - rewrite ServerTickList + final net.minecraft.server.level.ServerLevel level = ((net.minecraft.world.level.chunk.storage.EntityStorage) this.permanentStorage).level; + if (level.chunkSource.isPositionTickingReady(chunkentities.getPos().longKey)) { diff --git a/patches/server/Optimise-WorldServer-notify.patch b/patches/server/Optimise-WorldServer-notify.patch index a7442960d4..518cd9e221 100644 --- a/patches/server/Optimise-WorldServer-notify.patch +++ b/patches/server/Optimise-WorldServer-notify.patch @@ -218,8 +218,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/level/entity/PersistentEntitySectionManager.java +++ b/src/main/java/net/minecraft/world/level/entity/PersistentEntitySectionManager.java @@ -0,0 +0,0 @@ public class PersistentEntitySectionManager implements A - this.entityGetter = new LevelEntityGetterAdapter<>(this.visibleEntityStorage, this.sectionStorage); } + // CraftBukkit end + // Paper start - optimise notify() + public final void removeNavigatorsFromData(Entity entity, final int chunkX, final int chunkZ) { diff --git a/patches/server/Rewrite-dataconverter-system.patch b/patches/server/Rewrite-dataconverter-system.patch index a678f60e38..535e7c3e0f 100644 --- a/patches/server/Rewrite-dataconverter-system.patch +++ b/patches/server/Rewrite-dataconverter-system.patch @@ -19602,9 +19602,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/level/chunk/storage/EntityStorage.java +++ b/src/main/java/net/minecraft/world/level/chunk/storage/EntityStorage.java @@ -0,0 +0,0 @@ public class EntityStorage implements EntityPersistentStorage { - private CompoundTag upgradeChunkTag(CompoundTag chunkTag) { - int i = getVersion(chunkTag); + int i = EntityStorage.getVersion(chunkTag); + - return NbtUtils.update(this.fixerUpper, DataFixTypes.ENTITY_CHUNK, chunkTag, i); + return ca.spottedleaf.dataconverter.minecraft.MCDataConverter.convertTag(ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry.ENTITY_CHUNK, chunkTag, i, SharedConstants.getCurrentVersion().getWorldVersion()); // Paper - route to new converter system } diff --git a/patches/server/Rewrite-entity-bounding-box-lookup-calls.patch b/patches/server/Rewrite-entity-bounding-box-lookup-calls.patch index 6a61994c96..04a47d72a4 100644 --- a/patches/server/Rewrite-entity-bounding-box-lookup-calls.patch +++ b/patches/server/Rewrite-entity-bounding-box-lookup-calls.patch @@ -1262,15 +1262,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java @@ -0,0 +0,0 @@ public class CraftChunk implements Chunk { - this.getWorld().getChunkAt(x, z); // Transient load for this tick + long pair = ChunkPos.asLong(x, z); + + if (entityManager.areEntitiesLoaded(pair)) { // PAIL rename isEntitiesLoaded +- return entityManager.getEntities(new ChunkPos(this.x, this.z)).stream() +- .map(net.minecraft.world.entity.Entity::getBukkitEntity) +- .filter(Objects::nonNull).toArray(Entity[]::new); ++ return getCraftWorld().getHandle().getChunkEntities(this.x, this.z); // Paper - optimise this } -- Location location = new Location(null, 0, 0, 0); -- return this.getWorld().getEntities().stream().filter((entity) -> { -- entity.getLocation(location); -- return location.getBlockX() >> 4 == this.x && location.getBlockZ() >> 4 == this.z; -- }).toArray(Entity[]::new); -+ return ((CraftWorld)this.getWorld()).getHandle().getChunkEntities(this.x, this.z); // Paper - optimise this + entityManager.ensureChunkQueuedForLoad(pair); // Start entity loading +@@ -0,0 +0,0 @@ public class CraftChunk implements Chunk { + return entityManager.areEntitiesLoaded(pair); + }); + +- return entityManager.getEntities(new ChunkPos(this.x, this.z)).stream() +- .map(net.minecraft.world.entity.Entity::getBukkitEntity) +- .filter(Objects::nonNull).toArray(Entity[]::new); ++ return getCraftWorld().getHandle().getChunkEntities(this.x, this.z); // Paper - optimise this } @Override diff --git a/work/Bukkit b/work/Bukkit index ea7b3a0d80..ed7bba95fc 160000 --- a/work/Bukkit +++ b/work/Bukkit @@ -1 +1 @@ -Subproject commit ea7b3a0d809057eb8edfbb2b8f048077468e8ac6 +Subproject commit ed7bba95fc031ca8b89d353426990b4bf7f9372f diff --git a/work/CraftBukkit b/work/CraftBukkit index e167f28088..422cec08d1 160000 --- a/work/CraftBukkit +++ b/work/CraftBukkit @@ -1 +1 @@ -Subproject commit e167f28088ed0d6004d9c2775a98260d765edda2 +Subproject commit 422cec08d1308e4ca1e8a2a5739120d9a3664571 diff --git a/work/Spigot b/work/Spigot index 3c1fc60ae7..6c1c1b2650 160000 --- a/work/Spigot +++ b/work/Spigot @@ -1 +1 @@ -Subproject commit 3c1fc60ae715a3007908fd34968f5acdf482a46a +Subproject commit 6c1c1b2650e2f166fbba2f670ab37af8ce20156d