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
This commit is contained in:
Nassim Jahnke 2021-09-01 14:03:36 +02:00
parent 8a37b1fc5f
commit 8efc0a0cc6
12 changed files with 37 additions and 35 deletions

View file

@ -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<BlockState> getTileEntities();
+
+
+ // Paper start
+ /**

View file

@ -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

View file

@ -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) {

View file

@ -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<Entity> {
} else {
ListTag listTag = new ListTag();
ListTag nbttaglist = new ListTag();
+ final java.util.Map<net.minecraft.world.entity.EntityType<?>, 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)) {

View file

@ -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

View file

@ -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<T extends EntityAccess> implements A
this.addEntity(entityaccess, true);
});
this.chunkLoadStatuses.put(chunkentities.getPos().toLong(), PersistentEntitySectionManager.ChunkLoadStatus.LOADED);
List<Entity> 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)) {

View file

@ -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<T extends EntityAccess> 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) {

View file

@ -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<Entity> {
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
}

View file

@ -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

@ -1 +1 @@
Subproject commit ea7b3a0d809057eb8edfbb2b8f048077468e8ac6
Subproject commit ed7bba95fc031ca8b89d353426990b4bf7f9372f

@ -1 +1 @@
Subproject commit e167f28088ed0d6004d9c2775a98260d765edda2
Subproject commit 422cec08d1308e4ca1e8a2a5739120d9a3664571

@ -1 +1 @@
Subproject commit 3c1fc60ae715a3007908fd34968f5acdf482a46a
Subproject commit 6c1c1b2650e2f166fbba2f670ab37af8ce20156d