mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-23 15:00:30 +01:00
More more more more more more more more more more more more more more more more more work
This commit is contained in:
parent
011df7dc84
commit
dabbf5b193
374 changed files with 427 additions and 472 deletions
|
@ -6,10 +6,10 @@ Subject: [PATCH] Add Git information to version command/on startup
|
|||
|
||||
diff --git a/src/main/java/io/papermc/paper/util/JarManifests.java b/src/main/java/io/papermc/paper/util/JarManifests.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..cfd5fa044f58c8a5493f8efc08280b22c401a1da
|
||||
index 0000000000000000000000000000000000000000..2b06b17e20826fb95c9ad58101b4102308ea4b29
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/util/JarManifests.java
|
||||
@@ -0,0 +1,32 @@
|
||||
@@ -0,0 +1,34 @@
|
||||
+package io.papermc.paper.util;
|
||||
+
|
||||
+import java.io.IOException;
|
||||
|
@ -18,8 +18,10 @@ index 0000000000000000000000000000000000000000..cfd5fa044f58c8a5493f8efc08280b22
|
|||
+import java.util.Map;
|
||||
+import java.util.WeakHashMap;
|
||||
+import java.util.jar.Manifest;
|
||||
+import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
+
|
||||
+import org.jetbrains.annotations.ApiStatus;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+
|
||||
+@ApiStatus.Internal
|
||||
+public final class JarManifests {
|
||||
|
@ -28,7 +30,7 @@ index 0000000000000000000000000000000000000000..cfd5fa044f58c8a5493f8efc08280b22
|
|||
+
|
||||
+ private static final Map<ClassLoader, Manifest> MANIFESTS = Collections.synchronizedMap(new WeakHashMap<>());
|
||||
+
|
||||
+ public static Manifest manifest(final ClassLoader loader) {
|
||||
+ public static @NotNull Manifest manifest(final @NotNull ClassLoader loader) {
|
||||
+ return MANIFESTS.computeIfAbsent(loader, classLoader -> {
|
||||
+ final @Nullable InputStream stream = classLoader.getResourceAsStream("META-INF/MANIFEST.MF");
|
||||
+ if (stream == null) {
|
||||
|
|
|
@ -6,12 +6,12 @@ Subject: [PATCH] Optimize isOutsideRange to use distance maps
|
|||
Use a distance map to find the players in range quickly
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java
|
||||
index a3ba56f437fe9e4dac59370463052341eb9b7524..c6c4d2fd3205dfcaff9e0f1a6b92b74903275991 100644
|
||||
index 51175994b37e966af8983df1f15a0fc5a638a0b5..347cf5d00d986ae8ad60af7f6eabde9fbfd78561 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ChunkHolder.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java
|
||||
@@ -100,6 +100,18 @@ public class ChunkHolder {
|
||||
}
|
||||
// Paper end
|
||||
@@ -73,6 +73,18 @@ public class ChunkHolder {
|
||||
boolean isUpdateQueued = false; // Paper
|
||||
private final ChunkMap chunkMap; // Paper
|
||||
|
||||
+ // Paper start - optimise isOutsideOfRange
|
||||
+ // cached here to avoid a map lookup
|
||||
|
@ -28,7 +28,7 @@ index a3ba56f437fe9e4dac59370463052341eb9b7524..c6c4d2fd3205dfcaff9e0f1a6b92b749
|
|||
public ChunkHolder(ChunkPos pos, int level, LevelHeightAccessor world, LevelLightEngine lightingProvider, ChunkHolder.LevelChangeListener levelUpdateListener, ChunkHolder.PlayerProvider playersWatchingChunkProvider) {
|
||||
this.futures = new AtomicReferenceArray(ChunkHolder.CHUNK_STATUSES.size());
|
||||
this.fullChunkFuture = ChunkHolder.UNLOADED_LEVEL_CHUNK_FUTURE;
|
||||
@@ -121,6 +133,7 @@ public class ChunkHolder {
|
||||
@@ -94,6 +106,7 @@ public class ChunkHolder {
|
||||
this.setTicketLevel(level);
|
||||
this.changedBlocksPerSection = new ShortSet[world.getSectionsCount()];
|
||||
this.chunkMap = (ChunkMap)playersWatchingChunkProvider; // Paper
|
||||
|
@ -37,13 +37,13 @@ index a3ba56f437fe9e4dac59370463052341eb9b7524..c6c4d2fd3205dfcaff9e0f1a6b92b749
|
|||
|
||||
// CraftBukkit start
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
index 1a2e2f629840b3311b51f3810ab3a8c7257d103a..790761848d0ea0934b07c852675e8f746edac211 100644
|
||||
index 7f4b68199b0cd8adb09ef09539b43e62885e19c5..4aad2cee76f4368f607475425c5bf516f51f830d 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
@@ -205,6 +205,17 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
return MinecraftServer.getServer().getScaledTrackingDistance(vanilla);
|
||||
}
|
||||
// Paper end - use distance map to optimise tracker
|
||||
@@ -176,21 +176,40 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
final CallbackExecutor chunkLoadConversionCallbackExecutor = new CallbackExecutor(); // Paper
|
||||
// Paper start - distance maps
|
||||
private final com.destroystokyo.paper.util.misc.PooledLinkedHashSets<ServerPlayer> pooledLinkedPlayerHashSets = new com.destroystokyo.paper.util.misc.PooledLinkedHashSets<>();
|
||||
+ // Paper start - optimise PlayerChunkMap#isOutsideRange
|
||||
+ // A note about the naming used here:
|
||||
+ // Previously, mojang used a "spawn range" of 8 for controlling both ticking and
|
||||
|
@ -58,53 +58,34 @@ index 1a2e2f629840b3311b51f3810ab3a8c7257d103a..790761848d0ea0934b07c852675e8f74
|
|||
|
||||
void addPlayerToDistanceMaps(ServerPlayer player) {
|
||||
int chunkX = MCUtil.getChunkCoordinate(player.getX());
|
||||
@@ -218,6 +229,12 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
trackMap.add(player, chunkX, chunkZ, Math.min(trackRange, this.getEffectiveViewDistance()));
|
||||
}
|
||||
// Paper end - use distance map to optimise entity tracker
|
||||
int chunkZ = MCUtil.getChunkCoordinate(player.getZ());
|
||||
// Note: players need to be explicitly added to distance maps before they can be updated
|
||||
+ // Paper start - optimise PlayerChunkMap#isOutsideRange
|
||||
+ this.playerChunkTickRangeMap.update(player, chunkX, chunkZ, DistanceManager.MOB_SPAWN_RANGE);
|
||||
+ // Paper end - optimise PlayerChunkMap#isOutsideRange
|
||||
+ // Paper start - optimise PlayerChunkMap#isOutsideRange
|
||||
+ this.playerChunkTickRangeMap.add(player, chunkX, chunkZ, DistanceManager.MOB_SPAWN_RANGE);
|
||||
+ // Paper end - optimise PlayerChunkMap#isOutsideRange
|
||||
// Paper start - no-tick view distance
|
||||
int effectiveTickViewDistance = this.getEffectiveViewDistance();
|
||||
int effectiveNoTickViewDistance = Math.max(this.getEffectiveNoTickViewDistance(), effectiveTickViewDistance);
|
||||
@@ -239,6 +256,10 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
this.playerEntityTrackerTrackMaps[i].remove(player);
|
||||
}
|
||||
// Paper end - use distance map to optimise tracker
|
||||
}
|
||||
|
||||
void removePlayerFromDistanceMaps(ServerPlayer player) {
|
||||
-
|
||||
+ // Paper start - optimise PlayerChunkMap#isOutsideRange
|
||||
+ this.playerMobSpawnMap.remove(player);
|
||||
+ this.playerChunkTickRangeMap.remove(player);
|
||||
+ // Paper end - optimise PlayerChunkMap#isOutsideRange
|
||||
// Paper start - no-tick view distance
|
||||
this.playerViewDistanceBroadcastMap.remove(player);
|
||||
this.playerViewDistanceTickMap.remove(player);
|
||||
@@ -258,6 +279,9 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
trackMap.update(player, chunkX, chunkZ, Math.min(trackRange, this.getEffectiveViewDistance()));
|
||||
}
|
||||
// Paper end - use distance map to optimise entity tracker
|
||||
+ // Paper start - optimise PlayerChunkMap#isOutsideRange
|
||||
+ this.playerChunkTickRangeMap.update(player, chunkX, chunkZ, DistanceManager.MOB_SPAWN_RANGE);
|
||||
+ // Paper end - optimise PlayerChunkMap#isOutsideRange
|
||||
// Paper start - no-tick view distance
|
||||
int effectiveTickViewDistance = this.getEffectiveViewDistance();
|
||||
int effectiveNoTickViewDistance = Math.max(this.getEffectiveNoTickViewDistance(), effectiveTickViewDistance);
|
||||
@@ -336,7 +360,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
this.mainThreadMailbox = this.queueSorter.getProcessor(mailbox, false);
|
||||
this.mailboxLight = this.queueSorter.getProcessor(lightthreaded, false);// Paper
|
||||
this.lightEngine = new ThreadedLevelLightEngine(chunkProvider, this, this.level.dimensionType().hasSkyLight(), threadedmailbox1, this.queueSorter.getProcessor(threadedmailbox1, false));
|
||||
- this.distanceManager = new ChunkMap.ChunkDistanceManager(executor, mainThreadExecutor);
|
||||
+ this.distanceManager = new ChunkMap.ChunkDistanceManager(executor, mainThreadExecutor); this.distanceManager.chunkMap = this; // Paper
|
||||
this.overworldDataStorage = persistentStateManagerFactory;
|
||||
this.poiManager = new PoiManager(new File(file, "poi"), dataFixer, dsync, world);
|
||||
this.setViewDistance(viewDistance);
|
||||
@@ -423,6 +447,38 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
this.playerEntityTrackerTrackMaps[ordinal] = new com.destroystokyo.paper.util.misc.PlayerAreaMap(this.pooledLinkedPlayerHashSets);
|
||||
}
|
||||
// Paper end - use distance map to optimise entity tracker
|
||||
}
|
||||
|
||||
void updateMaps(ServerPlayer player) {
|
||||
int chunkX = MCUtil.getChunkCoordinate(player.getX());
|
||||
int chunkZ = MCUtil.getChunkCoordinate(player.getZ());
|
||||
// Note: players need to be explicitly added to distance maps before they can be updated
|
||||
+ this.playerChunkTickRangeMap.update(player, chunkX, chunkZ, DistanceManager.MOB_SPAWN_RANGE); // Paper - optimise PlayerChunkMap#isOutsideRange
|
||||
}
|
||||
// Paper end
|
||||
// Paper start
|
||||
@@ -265,6 +284,38 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
this.regionManagers.add(this.dataRegionManager);
|
||||
// Paper end
|
||||
this.playerMobDistanceMap = this.level.paperConfig.perPlayerMobSpawns ? new com.destroystokyo.paper.util.PlayerMobDistanceMap() : null; // Paper
|
||||
+ // Paper start - optimise PlayerChunkMap#isOutsideRange
|
||||
+ this.playerChunkTickRangeMap = new com.destroystokyo.paper.util.misc.PlayerAreaMap(this.pooledLinkedPlayerHashSets,
|
||||
+ (ServerPlayer player, int rangeX, int rangeZ, int currPosX, int currPosZ, int prevPosX, int prevPosZ,
|
||||
|
@ -139,8 +120,8 @@ index 1a2e2f629840b3311b51f3810ab3a8c7257d103a..790761848d0ea0934b07c852675e8f74
|
|||
+ // Paper end - optimise PlayerChunkMap#isOutsideRange
|
||||
}
|
||||
|
||||
// Paper start
|
||||
@@ -610,6 +666,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
protected ChunkGenerator generator() {
|
||||
@@ -493,6 +544,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
} else {
|
||||
if (holder != null) {
|
||||
holder.setTicketLevel(level);
|
||||
|
@ -148,127 +129,127 @@ index 1a2e2f629840b3311b51f3810ab3a8c7257d103a..790761848d0ea0934b07c852675e8f74
|
|||
}
|
||||
|
||||
if (holder != null) {
|
||||
@@ -1431,29 +1488,50 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
return this.isOutsideOfRange(chunkPos, false);
|
||||
@@ -1342,43 +1394,48 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
return this.anyPlayerCloseEnoughForSpawning(pos, false);
|
||||
}
|
||||
|
||||
- boolean isOutsideOfRange(ChunkPos chunkcoordintpair, boolean reducedRange) {
|
||||
- boolean anyPlayerCloseEnoughForSpawning(ChunkPos chunkcoordintpair, boolean reducedRange) {
|
||||
- int chunkRange = level.spigotConfig.mobSpawnRange;
|
||||
- chunkRange = (chunkRange > level.spigotConfig.viewDistance) ? (byte) level.spigotConfig.viewDistance : chunkRange;
|
||||
- chunkRange = (chunkRange > 8) ? 8 : chunkRange;
|
||||
-
|
||||
- final int finalChunkRange = chunkRange; // Paper for lambda below
|
||||
- //double blockRange = (reducedRange) ? Math.pow(chunkRange << 4, 2) : 16384.0D; // Paper - use from event
|
||||
- double blockRange = 16384.0D; // Paper
|
||||
- // Spigot end
|
||||
- long i = chunkcoordintpair.toLong();
|
||||
+ // Paper start - optimise isOutsideOfRange
|
||||
+ final boolean isOutsideOfRange(ChunkPos chunkcoordintpair, boolean reducedRange) {
|
||||
+ return this.isOutsideOfRange(this.getUpdatingChunkIfPresent(chunkcoordintpair.toLong()), chunkcoordintpair, reducedRange);
|
||||
+ final boolean anyPlayerCloseEnoughForSpawning(ChunkPos chunkcoordintpair, boolean reducedRange) {
|
||||
+ return this.anyPlayerCloseEnoughForSpawning(this.getUpdatingChunkIfPresent(chunkcoordintpair.toLong()), chunkcoordintpair, reducedRange);
|
||||
+ }
|
||||
+ final boolean isOutsideOfRange(ChunkHolder playerchunk, ChunkPos chunkcoordintpair, boolean reducedRange) {
|
||||
|
||||
- if (!this.distanceManager.hasPlayersNearby(i)) {
|
||||
+ final boolean anyPlayerCloseEnoughForSpawning(ChunkHolder playerchunk, ChunkPos chunkcoordintpair, boolean reducedRange) {
|
||||
+ // this function is so hot that removing the map lookup call can have an order of magnitude impact on its performance
|
||||
+ // tested and confirmed via System.nanoTime()
|
||||
+ com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<ServerPlayer> playersInRange = reducedRange ? playerchunk.playersInMobSpawnRange : playerchunk.playersInChunkTickRange;
|
||||
+ if (playersInRange == null) {
|
||||
+ return true;
|
||||
return false;
|
||||
- } else {
|
||||
- Iterator iterator = this.playerMap.getPlayers(i).iterator();
|
||||
-
|
||||
- ServerPlayer entityplayer;
|
||||
+ }
|
||||
+ Object[] backingSet = playersInRange.getBackingSet();
|
||||
|
||||
- final int finalChunkRange = chunkRange; // Paper for lambda below
|
||||
- //double blockRange = (reducedRange) ? Math.pow(chunkRange << 4, 2) : 16384.0D; // Paper - use from event
|
||||
- // Spigot end
|
||||
- long i = chunkcoordintpair.toLong();
|
||||
-
|
||||
- return !this.distanceManager.hasPlayersNearby(i) ? true : this.playerMap.getPlayers(i).noneMatch((entityplayer) -> {
|
||||
- // Paper start - add PlayerNaturallySpawnCreaturesEvent
|
||||
- com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent event;
|
||||
- double blockRange = 16384.0D;
|
||||
- if (reducedRange) {
|
||||
- event = entityplayer.playerNaturallySpawnedEvent;
|
||||
- if (event == null || event.isCancelled()) return false;
|
||||
- blockRange = (double) ((event.getSpawnRadius() << 4) * (event.getSpawnRadius() << 4));
|
||||
- do {
|
||||
- if (!iterator.hasNext()) {
|
||||
- return false;
|
||||
+ if (reducedRange) {
|
||||
+ for (int i = 0, len = backingSet.length; i < len; ++i) {
|
||||
+ Object raw = backingSet[i];
|
||||
+ if (!(raw instanceof ServerPlayer)) {
|
||||
+ if (!(raw instanceof ServerPlayer player)) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ ServerPlayer player = (ServerPlayer) raw;
|
||||
}
|
||||
-
|
||||
- entityplayer = (ServerPlayer) iterator.next();
|
||||
- // Paper start - add PlayerNaturallySpawnCreaturesEvent
|
||||
- com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent event;
|
||||
- blockRange = 16384.0D;
|
||||
- if (reducedRange) {
|
||||
- event = entityplayer.playerNaturallySpawnedEvent;
|
||||
- if (event == null || event.isCancelled()) return false;
|
||||
- blockRange = (double) ((event.getSpawnRadius() << 4) * (event.getSpawnRadius() << 4));
|
||||
+ // don't check spectator and whatnot, already handled by mob spawn map update
|
||||
+ if (player.lastEntitySpawnRadiusSquared > euclideanDistanceSquared(chunkcoordintpair, player)) {
|
||||
+ return false; // in range
|
||||
+ }
|
||||
}
|
||||
- // Paper end
|
||||
- return !entityplayer.isSpectator() && ChunkMap.euclideanDistanceSquared(chunkcoordintpair, (Entity) entityplayer) < blockRange; // Spigot
|
||||
- });
|
||||
+ if (this.playerIsCloseEnoughForSpawning(player, chunkcoordintpair, player.lastEntitySpawnRadiusSquared)) {
|
||||
+ return true; // in range
|
||||
}
|
||||
- // Paper end
|
||||
- } while (!this.playerIsCloseEnoughForSpawning(entityplayer, chunkcoordintpair, blockRange)); // Spigot
|
||||
-
|
||||
- return true;
|
||||
+ }
|
||||
+ } else {
|
||||
+ final double range = (DistanceManager.MOB_SPAWN_RANGE * 16) * (DistanceManager.MOB_SPAWN_RANGE * 16);
|
||||
+ // before spigot, mob spawn range was actually mob spawn range + tick range, but it was split
|
||||
+ for (int i = 0, len = backingSet.length; i < len; ++i) {
|
||||
+ Object raw = backingSet[i];
|
||||
+ if (!(raw instanceof ServerPlayer)) {
|
||||
+ if (!(raw instanceof ServerPlayer player)) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ ServerPlayer player = (ServerPlayer) raw;
|
||||
+ // don't check spectator and whatnot, already handled by mob spawn map update
|
||||
+ if (range > euclideanDistanceSquared(chunkcoordintpair, player)) {
|
||||
+ return false; // in range
|
||||
+ if (this.playerIsCloseEnoughForSpawning(player, chunkcoordintpair, range)) {
|
||||
+ return true; // in range
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
+ // no players in range
|
||||
+ return true;
|
||||
+ return false;
|
||||
+ // Paper end - optimise isOutsideOfRange
|
||||
}
|
||||
+ // Paper end - optimise isOutsideOfRange
|
||||
|
||||
private boolean skipPlayer(ServerPlayer player) {
|
||||
return player.isSpectator() && !this.level.getGameRules().getBoolean(GameRules.RULE_SPECTATORSGENERATECHUNKS);
|
||||
public List<ServerPlayer> getPlayersCloseForSpawning(ChunkPos pos) {
|
||||
diff --git a/src/main/java/net/minecraft/server/level/DistanceManager.java b/src/main/java/net/minecraft/server/level/DistanceManager.java
|
||||
index b49d380ef088aed3204ec71abc437c348ef004fa..577b391dcba1db712c1e2c83296e1c87b3e34ab2 100644
|
||||
index 8868ffcda194e8c2300181a2cdda9337dbde6284..95f195980e28bb59f43e5ca1d5e79ebe8c3ddaea 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/DistanceManager.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/DistanceManager.java
|
||||
@@ -45,7 +45,7 @@ public abstract class DistanceManager {
|
||||
@@ -48,7 +48,7 @@ public abstract class DistanceManager {
|
||||
final Long2ObjectMap<ObjectSet<ServerPlayer>> playersPerChunk = new Long2ObjectOpenHashMap();
|
||||
public final Long2ObjectOpenHashMap<SortedArraySet<Ticket<?>>> tickets = new Long2ObjectOpenHashMap();
|
||||
private final DistanceManager.ChunkTicketTracker ticketTracker = new DistanceManager.ChunkTicketTracker();
|
||||
- private final DistanceManager.FixedPlayerDistanceChunkTracker naturalSpawnChunkCounter = new DistanceManager.FixedPlayerDistanceChunkTracker(8);
|
||||
+ public static final int MOB_SPAWN_RANGE = 8; // private final ChunkMapDistance.b f = new ChunkMapDistance.b(8); // Paper - no longer used
|
||||
private final TickingTracker tickingTicketsTracker = new TickingTracker();
|
||||
private final DistanceManager.PlayerTicketTracker playerTicketManager = new DistanceManager.PlayerTicketTracker(33);
|
||||
// Paper start use a queue, but still keep unique requirement
|
||||
public final java.util.Queue<ChunkHolder> pendingChunkUpdates = new java.util.ArrayDeque<ChunkHolder>() {
|
||||
@@ -64,6 +64,8 @@ public abstract class DistanceManager {
|
||||
final Executor mainThreadExecutor;
|
||||
private long ticketTickCounter;
|
||||
|
||||
+ ChunkMap chunkMap; // Paper
|
||||
+
|
||||
protected DistanceManager(Executor workerExecutor, Executor mainThreadExecutor) {
|
||||
Objects.requireNonNull(mainThreadExecutor);
|
||||
ProcessorHandle<Runnable> mailbox = ProcessorHandle.of("player ticket throttler", mainThreadExecutor::execute);
|
||||
@@ -108,7 +110,7 @@ public abstract class DistanceManager {
|
||||
@@ -125,7 +125,7 @@ public abstract class DistanceManager {
|
||||
protected abstract ChunkHolder updateChunkScheduling(long pos, int level, @Nullable ChunkHolder holder, int k);
|
||||
|
||||
public boolean runAllUpdates(ChunkMap playerchunkmap) {
|
||||
public boolean runAllUpdates(ChunkMap chunkStorage) {
|
||||
- this.naturalSpawnChunkCounter.runAllUpdates();
|
||||
+ //this.f.a(); // Paper - no longer used
|
||||
this.tickingTicketsTracker.runAllUpdates();
|
||||
this.playerTicketManager.runAllUpdates();
|
||||
int i = Integer.MAX_VALUE - this.ticketTracker.runDistanceUpdates(Integer.MAX_VALUE);
|
||||
boolean flag = i != 0;
|
||||
@@ -244,7 +246,7 @@ public abstract class DistanceManager {
|
||||
@@ -272,7 +272,7 @@ public abstract class DistanceManager {
|
||||
((ObjectSet) this.playersPerChunk.computeIfAbsent(i, (j) -> {
|
||||
return new ObjectOpenHashSet();
|
||||
})).add(player);
|
||||
- this.naturalSpawnChunkCounter.update(i, 0, true);
|
||||
+ //this.f.update(i, 0, true); // Paper - no longer used
|
||||
this.playerTicketManager.update(i, 0, true);
|
||||
this.tickingTicketsTracker.addTicket(TicketType.PLAYER, chunkcoordintpair, this.getPlayerTicketLevel(), chunkcoordintpair);
|
||||
}
|
||||
|
||||
@@ -256,7 +258,7 @@ public abstract class DistanceManager {
|
||||
@@ -286,7 +286,7 @@ public abstract class DistanceManager {
|
||||
if (objectset != null) objectset.remove(player); // Paper - some state corruption happens here, don't crash, clean up gracefully.
|
||||
if (objectset == null || objectset.isEmpty()) { // Paper
|
||||
this.playersPerChunk.remove(i);
|
||||
- this.naturalSpawnChunkCounter.update(i, Integer.MAX_VALUE, false);
|
||||
+ //this.f.update(i, Integer.MAX_VALUE, false); // Paper - no longer used
|
||||
this.playerTicketManager.update(i, Integer.MAX_VALUE, false);
|
||||
this.tickingTicketsTracker.removeTicket(TicketType.PLAYER, chunkcoordintpair, this.getPlayerTicketLevel(), chunkcoordintpair);
|
||||
}
|
||||
|
||||
@@ -280,13 +282,17 @@ public abstract class DistanceManager {
|
||||
@@ -324,13 +324,17 @@ public abstract class DistanceManager {
|
||||
}
|
||||
|
||||
public int getNaturalSpawnChunkCount() {
|
||||
|
@ -280,62 +261,24 @@ index b49d380ef088aed3204ec71abc437c348ef004fa..577b391dcba1db712c1e2c83296e1c87
|
|||
+ // Paper end - use distance map to implement
|
||||
}
|
||||
|
||||
public boolean hasPlayersNearby(long i) {
|
||||
public boolean hasPlayersNearby(long chunkPos) {
|
||||
- this.naturalSpawnChunkCounter.runAllUpdates();
|
||||
- return this.naturalSpawnChunkCounter.chunks.containsKey(i);
|
||||
- return this.naturalSpawnChunkCounter.chunks.containsKey(chunkPos);
|
||||
+ // Paper start - use distance map to implement
|
||||
+ // note: this is the is spawn chunk method
|
||||
+ return this.chunkMap.playerChunkTickRangeMap.getObjectsInRange(i) != null;
|
||||
+ return this.chunkMap.playerChunkTickRangeMap.getObjectsInRange(chunkPos) != null;
|
||||
+ // Paper end - use distance map to implement
|
||||
}
|
||||
|
||||
public String getDebugStatus() {
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
index fe9711daa67151187906128c9d07ad967b72e677..0ce86c72cb829b816ec7bfb8f0d19396e1b12eb6 100644
|
||||
index a66d9d6df1fc0ad68f51ea96d4e1a2d725c73b05..00305a06885b2457615b6bd35bb1a84721ca1d77 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
@@ -892,6 +892,37 @@ public class ServerChunkCache extends ChunkSource {
|
||||
boolean flag1 = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !this.level.players().isEmpty(); // CraftBukkit
|
||||
@@ -928,15 +928,7 @@ public class ServerChunkCache extends ChunkSource {
|
||||
boolean flag2 = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !this.level.players().isEmpty(); // CraftBukkit
|
||||
|
||||
if (!flag) {
|
||||
+ // Paper start - optimize isOutisdeRange
|
||||
+ ChunkMap playerChunkMap = this.chunkMap;
|
||||
+ for (ServerPlayer player : this.level.players) {
|
||||
+ if (!player.affectsSpawning || player.isSpectator()) {
|
||||
+ playerChunkMap.playerMobSpawnMap.remove(player);
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ int viewDistance = this.chunkMap.getEffectiveViewDistance();
|
||||
+
|
||||
+ // copied and modified from isOutisdeRange
|
||||
+ int chunkRange = level.spigotConfig.mobSpawnRange;
|
||||
+ chunkRange = (chunkRange > viewDistance) ? (byte)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.playerChunkTickRangeMap.getLastViewDistance(player) == -1) {
|
||||
+ playerChunkMap.playerMobSpawnMap.remove(player);
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ int range = Math.min(event.getSpawnRadius(), 32); // limit to max view distance
|
||||
+ int chunkX = net.minecraft.server.MCUtil.getChunkCoordinate(player.getX());
|
||||
+ int chunkZ = net.minecraft.server.MCUtil.getChunkCoordinate(player.getZ());
|
||||
+
|
||||
+ playerChunkMap.playerMobSpawnMap.addOrUpdate(player, chunkX, chunkZ, range);
|
||||
+ player.lastEntitySpawnRadiusSquared = (double)((range << 4) * (range << 4)); // used in isOutsideRange
|
||||
+ player.playerNaturallySpawnedEvent = event;
|
||||
+ }
|
||||
+ // Paper end - optimize isOutisdeRange
|
||||
this.level.getProfiler().push("pollingChunks");
|
||||
int k = this.level.getGameRules().getInt(GameRules.RULE_RANDOMTICKING);
|
||||
boolean flag2 = level.ticksPerAnimalSpawns != 0L && worlddata.getGameTime() % level.ticksPerAnimalSpawns == 0L; // CraftBukkit
|
||||
@@ -922,15 +953,7 @@ public class ServerChunkCache extends ChunkSource {
|
||||
List<ChunkHolder> list = Lists.newArrayList(this.chunkMap.getChunks());
|
||||
|
||||
Collections.shuffle(list);
|
||||
//Collections.shuffle(list); // Paper - no... just no...
|
||||
- // Paper start - call player naturally spawn event
|
||||
- int chunkRange = level.spigotConfig.mobSpawnRange;
|
||||
- chunkRange = (chunkRange > level.spigotConfig.viewDistance) ? (byte) level.spigotConfig.viewDistance : chunkRange;
|
||||
|
@ -346,30 +289,30 @@ index fe9711daa67151187906128c9d07ad967b72e677..0ce86c72cb829b816ec7bfb8f0d19396
|
|||
- };
|
||||
- // Paper end
|
||||
+ // Paper - moved natural spawn event up
|
||||
this.level.timings.chunkTicks.startTiming(); // Paper
|
||||
list.forEach((playerchunk) -> {
|
||||
Optional<LevelChunk> optional = ((Either) playerchunk.getTickingChunkFuture().getNow(ChunkHolder.UNLOADED_LEVEL_CHUNK)).left();
|
||||
@@ -939,9 +962,9 @@ public class ServerChunkCache extends ChunkSource {
|
||||
LevelChunk chunk = (LevelChunk) optional.get();
|
||||
ChunkPos chunkcoordintpair = chunk.getPos();
|
||||
Iterator iterator1 = list.iterator();
|
||||
|
||||
- if (this.level.isPositionEntityTicking(chunkcoordintpair) && !this.chunkMap.noPlayersCloseForSpawning(chunkcoordintpair)) {
|
||||
+ if (this.level.isPositionEntityTicking(chunkcoordintpair) && !this.chunkMap.isOutsideOfRange(playerchunk, chunkcoordintpair, false)) { // Paper - optimise isOutsideOfRange
|
||||
chunk.setInhabitedTime(chunk.getInhabitedTime() + j);
|
||||
- if (flag1 && (this.spawnEnemies || this.spawnFriendlies) && this.level.getWorldBorder().isWithinBounds(chunk.getPos()) && !this.chunkMap.isOutsideOfRange(chunkcoordintpair, true)) { // Spigot
|
||||
+ if (flag1 && (this.spawnEnemies || this.spawnFriendlies) && this.level.getWorldBorder().isWithinBounds(chunk.getPos()) && !this.chunkMap.isOutsideOfRange(playerchunk, chunkcoordintpair, true)) { // Spigot // Paper - optimise isOutsideOfRange
|
||||
NaturalSpawner.spawnForChunk(this.level, chunk, spawnercreature_d, this.spawnFriendlies, this.spawnEnemies, flag2);
|
||||
}
|
||||
while (iterator1.hasNext()) {
|
||||
@@ -944,9 +936,9 @@ public class ServerChunkCache extends ChunkSource {
|
||||
LevelChunk chunk1 = chunkproviderserver_a.chunk;
|
||||
ChunkPos chunkcoordintpair = chunk1.getPos();
|
||||
|
||||
- if (this.level.isPositionEntityTicking(chunkcoordintpair) && this.chunkMap.anyPlayerCloseEnoughForSpawning(chunkcoordintpair)) {
|
||||
+ if (this.level.isPositionEntityTicking(chunkcoordintpair) && this.chunkMap.anyPlayerCloseEnoughForSpawning(chunkproviderserver_a.holder, chunkcoordintpair, false)) { // Paper - optimise isOutsideOfRange
|
||||
chunk1.incrementInhabitedTime(j);
|
||||
- if (flag2 && (this.spawnEnemies || this.spawnFriendlies) && this.level.getWorldBorder().isWithinBounds(chunkcoordintpair) && !this.chunkMap.anyPlayerCloseEnoughForSpawning(chunkcoordintpair, true)) { // Spigot
|
||||
+ if (flag2 && (this.spawnEnemies || this.spawnFriendlies) && this.level.getWorldBorder().isWithinBounds(chunkcoordintpair) && !this.chunkMap.anyPlayerCloseEnoughForSpawning(chunkproviderserver_a.holder, chunkcoordintpair, true)) { // Spigot // Paper - optimise isOutsideOfRange
|
||||
NaturalSpawner.spawnForChunk(this.level, chunk1, spawnercreature_d, this.spawnFriendlies, this.spawnEnemies, flag1);
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
index 40692f3559eec910a653e89d3bc199fb9f17db27..0f4f07513f4fe43c059a50257fcad5c30d1cc81d 100644
|
||||
index beebb7a0e6b8b1fa4e7d2f9fdf1962357cc2ebc3..2f13055a39c26fe12d2c1094103186635e536166 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -250,6 +250,7 @@ public class ServerPlayer extends Player {
|
||||
@@ -253,6 +253,7 @@ public class ServerPlayer extends Player {
|
||||
// CraftBukkit end
|
||||
public PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper
|
||||
|
||||
+ public double lastEntitySpawnRadiusSquared; // Paper - optimise isOutsideRange, this field is in blocks
|
||||
public final com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<ServerPlayer> cachedSingleHashSet; // Paper
|
||||
boolean needsChunkCenterUpdate; // Paper - no-tick view distance
|
||||
|
||||
public ServerPlayer(MinecraftServer server, ServerLevel world, GameProfile profile) {
|
|
@ -6,10 +6,10 @@ Subject: [PATCH] Use distance map to optimise entity tracker
|
|||
Use the distance map to find candidate players for tracking.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
index 3a546b879d093702e36118231020cf41fe972410..1a2e2f629840b3311b51f3810ab3a8c7257d103a 100644
|
||||
index 4aad2cee76f4368f607475425c5bf516f51f830d..0bd55c5a43bfed7d5c80f6859b2827b7da3d0804 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
@@ -63,6 +63,7 @@ import net.minecraft.network.protocol.game.ClientboundSetEntityLinkPacket;
|
||||
@@ -66,6 +66,7 @@ import net.minecraft.network.protocol.game.ClientboundSetEntityLinkPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundSetPassengersPacket;
|
||||
import net.minecraft.network.protocol.game.DebugPackets;
|
||||
import net.minecraft.server.MCUtil;
|
||||
|
@ -17,10 +17,10 @@ index 3a546b879d093702e36118231020cf41fe972410..1a2e2f629840b3311b51f3810ab3a8c7
|
|||
import net.minecraft.server.level.progress.ChunkProgressListener;
|
||||
import net.minecraft.server.network.ServerPlayerConnection;
|
||||
import net.minecraft.util.CsvOutput;
|
||||
@@ -187,11 +188,36 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
public final com.destroystokyo.paper.util.misc.PlayerAreaMap playerViewDistanceTickMap;
|
||||
public final com.destroystokyo.paper.util.misc.PlayerAreaMap playerViewDistanceNoTickMap;
|
||||
// Paper end - no-tick view distance
|
||||
@@ -187,10 +188,35 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
public final com.destroystokyo.paper.util.misc.PlayerAreaMap playerMobSpawnMap; // this map is absent from updateMaps since it's controlled at the start of the chunkproviderserver tick
|
||||
public final com.destroystokyo.paper.util.misc.PlayerAreaMap playerChunkTickRangeMap;
|
||||
// Paper end - optimise PlayerChunkMap#isOutsideRange
|
||||
+ // Paper start - use distance map to optimise tracker
|
||||
+ public static boolean isLegacyTrackingEntity(Entity entity) {
|
||||
+ return entity.isLegacyTrackingEntity;
|
||||
|
@ -42,7 +42,6 @@ index 3a546b879d093702e36118231020cf41fe972410..1a2e2f629840b3311b51f3810ab3a8c7
|
|||
void addPlayerToDistanceMaps(ServerPlayer player) {
|
||||
int chunkX = MCUtil.getChunkCoordinate(player.getX());
|
||||
int chunkZ = MCUtil.getChunkCoordinate(player.getZ());
|
||||
// Note: players need to be explicitly added to distance maps before they can be updated
|
||||
+ // Paper start - use distance map to optimise entity tracker
|
||||
+ for (int i = 0, len = TRACKING_RANGE_TYPES.length; i < len; ++i) {
|
||||
+ com.destroystokyo.paper.util.misc.PlayerAreaMap trackMap = this.playerEntityTrackerTrackMaps[i];
|
||||
|
@ -51,23 +50,22 @@ index 3a546b879d093702e36118231020cf41fe972410..1a2e2f629840b3311b51f3810ab3a8c7
|
|||
+ trackMap.add(player, chunkX, chunkZ, Math.min(trackRange, this.getEffectiveViewDistance()));
|
||||
+ }
|
||||
+ // Paper end - use distance map to optimise entity tracker
|
||||
// Paper start - no-tick view distance
|
||||
int effectiveTickViewDistance = this.getEffectiveViewDistance();
|
||||
int effectiveNoTickViewDistance = Math.max(this.getEffectiveNoTickViewDistance(), effectiveTickViewDistance);
|
||||
@@ -208,7 +234,11 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
// Note: players need to be explicitly added to distance maps before they can be updated
|
||||
// Paper start - optimise PlayerChunkMap#isOutsideRange
|
||||
this.playerChunkTickRangeMap.update(player, chunkX, chunkZ, DistanceManager.MOB_SPAWN_RANGE);
|
||||
@@ -199,6 +225,11 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
}
|
||||
|
||||
void removePlayerFromDistanceMaps(ServerPlayer player) {
|
||||
-
|
||||
+ // Paper start - use distance map to optimise tracker
|
||||
+ for (int i = 0, len = TRACKING_RANGE_TYPES.length; i < len; ++i) {
|
||||
+ this.playerEntityTrackerTrackMaps[i].remove(player);
|
||||
+ }
|
||||
+ // Paper end - use distance map to optimise tracker
|
||||
// Paper start - no-tick view distance
|
||||
this.playerViewDistanceBroadcastMap.remove(player);
|
||||
this.playerViewDistanceTickMap.remove(player);
|
||||
@@ -220,6 +250,14 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
// Paper start - optimise PlayerChunkMap#isOutsideRange
|
||||
this.playerMobSpawnMap.remove(player);
|
||||
this.playerChunkTickRangeMap.remove(player);
|
||||
@@ -209,6 +240,14 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
int chunkX = MCUtil.getChunkCoordinate(player.getX());
|
||||
int chunkZ = MCUtil.getChunkCoordinate(player.getZ());
|
||||
// Note: players need to be explicitly added to distance maps before they can be updated
|
||||
|
@ -79,12 +77,12 @@ index 3a546b879d093702e36118231020cf41fe972410..1a2e2f629840b3311b51f3810ab3a8c7
|
|||
+ trackMap.update(player, chunkX, chunkZ, Math.min(trackRange, this.getEffectiveViewDistance()));
|
||||
+ }
|
||||
+ // Paper end - use distance map to optimise entity tracker
|
||||
// Paper start - no-tick view distance
|
||||
int effectiveTickViewDistance = this.getEffectiveViewDistance();
|
||||
int effectiveNoTickViewDistance = Math.max(this.getEffectiveNoTickViewDistance(), effectiveTickViewDistance);
|
||||
@@ -346,6 +384,45 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
});
|
||||
// Paper end - no-tick view distance
|
||||
this.playerChunkTickRangeMap.update(player, chunkX, chunkZ, DistanceManager.MOB_SPAWN_RANGE); // Paper - optimise PlayerChunkMap#isOutsideRange
|
||||
}
|
||||
// Paper end
|
||||
@@ -284,6 +323,45 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
this.regionManagers.add(this.dataRegionManager);
|
||||
// Paper end
|
||||
this.playerMobDistanceMap = this.level.paperConfig.perPlayerMobSpawns ? new com.destroystokyo.paper.util.PlayerMobDistanceMap() : null; // Paper
|
||||
+ // Paper start - use distance map to optimise entity tracker
|
||||
+ this.playerEntityTrackerTrackMaps = new com.destroystokyo.paper.util.misc.PlayerAreaMap[TRACKING_RANGE_TYPES.length];
|
||||
|
@ -125,10 +123,10 @@ index 3a546b879d093702e36118231020cf41fe972410..1a2e2f629840b3311b51f3810ab3a8c7
|
|||
+ this.playerEntityTrackerTrackMaps[ordinal] = new com.destroystokyo.paper.util.misc.PlayerAreaMap(this.pooledLinkedPlayerHashSets);
|
||||
+ }
|
||||
+ // Paper end - use distance map to optimise entity tracker
|
||||
}
|
||||
|
||||
// Paper start
|
||||
@@ -1418,17 +1495,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
// Paper start - optimise PlayerChunkMap#isOutsideRange
|
||||
this.playerChunkTickRangeMap = new com.destroystokyo.paper.util.misc.PlayerAreaMap(this.pooledLinkedPlayerHashSets,
|
||||
(ServerPlayer player, int rangeX, int rangeZ, int currPosX, int currPosZ, int prevPosX, int prevPosZ,
|
||||
@@ -1517,17 +1595,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
}
|
||||
|
||||
public void move(ServerPlayer player) {
|
||||
|
@ -147,7 +145,7 @@ index 3a546b879d093702e36118231020cf41fe972410..1a2e2f629840b3311b51f3810ab3a8c7
|
|||
|
||||
int i = SectionPos.blockToSectionCoord(player.getBlockX());
|
||||
int j = SectionPos.blockToSectionCoord(player.getBlockZ());
|
||||
@@ -1583,7 +1650,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
@@ -1657,7 +1725,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
|
||||
entity.tracker = playerchunkmap_entitytracker; // Paper - Fast access to tracker
|
||||
this.entityMap.put(entity.getId(), playerchunkmap_entitytracker);
|
||||
|
@ -156,7 +154,7 @@ index 3a546b879d093702e36118231020cf41fe972410..1a2e2f629840b3311b51f3810ab3a8c7
|
|||
if (entity instanceof ServerPlayer) {
|
||||
ServerPlayer entityplayer = (ServerPlayer) entity;
|
||||
|
||||
@@ -1627,7 +1694,37 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
@@ -1701,7 +1769,37 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
entity.tracker = null; // Paper - We're no longer tracked
|
||||
}
|
||||
|
||||
|
@ -193,8 +191,8 @@ index 3a546b879d093702e36118231020cf41fe972410..1a2e2f629840b3311b51f3810ab3a8c7
|
|||
+ // Paper end - optimized tracker
|
||||
List<ServerPlayer> list = Lists.newArrayList();
|
||||
List<ServerPlayer> list1 = this.level.players();
|
||||
|
||||
@@ -1735,23 +1832,31 @@ Sections go from 0..16. Now whenever a section is not empty, it can potentially
|
||||
ObjectIterator objectiterator = this.entityMap.values().iterator();
|
||||
@@ -1772,23 +1870,31 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
DebugPackets.sendPoiPacketsForChunk(this.level, chunk.getPos());
|
||||
List<Entity> list = Lists.newArrayList();
|
||||
List<Entity> list1 = Lists.newArrayList();
|
||||
|
@ -238,7 +236,7 @@ index 3a546b879d093702e36118231020cf41fe972410..1a2e2f629840b3311b51f3810ab3a8c7
|
|||
|
||||
Iterator iterator;
|
||||
Entity entity1;
|
||||
@@ -1834,6 +1939,42 @@ Sections go from 0..16. Now whenever a section is not empty, it can potentially
|
||||
@@ -1864,6 +1970,42 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
this.lastSectionPos = SectionPos.of(entity);
|
||||
}
|
||||
|
||||
|
@ -282,10 +280,10 @@ index 3a546b879d093702e36118231020cf41fe972410..1a2e2f629840b3311b51f3810ab3a8c7
|
|||
return object instanceof ChunkMap.TrackedEntity ? ((ChunkMap.TrackedEntity) object).entity.getId() == this.entity.getId() : false;
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index fbcbe0443f843d04738938f10b433bfe1631fe78..ee461f8da2663acc45896a9ae418c2f2129e3319 100644
|
||||
index 95fcf31b0ea68312f6c3475c1b4a01ca2b269536..9d4dc7d8d8b6633a3e88a8fc43d3d798683ef1d9 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -50,6 +50,7 @@ import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
@@ -51,6 +51,7 @@ import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
import net.minecraft.network.syncher.SynchedEntityData;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
@ -293,7 +291,7 @@ index fbcbe0443f843d04738938f10b433bfe1631fe78..ee461f8da2663acc45896a9ae418c2f2
|
|||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
@@ -350,6 +351,39 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n
|
||||
@@ -353,6 +354,39 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i
|
||||
}
|
||||
// Paper end
|
||||
|
||||
|
@ -334,10 +332,18 @@ index fbcbe0443f843d04738938f10b433bfe1631fe78..ee461f8da2663acc45896a9ae418c2f2
|
|||
this.id = Entity.ENTITY_COUNTER.incrementAndGet();
|
||||
this.passengers = ImmutableList.of();
|
||||
diff --git a/src/main/java/org/spigotmc/TrackingRange.java b/src/main/java/org/spigotmc/TrackingRange.java
|
||||
index 24b1dfcf91d36947c87e9e5c2524317f8775ba95..e5bcbfe175a697e04886d04543e1278b7e83a184 100644
|
||||
index 55ce69b5fe097841d00ef5c241459dce9bb0d4db..daaf057380a55e6841831f56657cafb5ac97fb27 100644
|
||||
--- a/src/main/java/org/spigotmc/TrackingRange.java
|
||||
+++ b/src/main/java/org/spigotmc/TrackingRange.java
|
||||
@@ -24,6 +24,7 @@ public class TrackingRange
|
||||
@@ -6,6 +6,7 @@ import net.minecraft.world.entity.ExperienceOrb;
|
||||
import net.minecraft.world.entity.decoration.ItemFrame;
|
||||
import net.minecraft.world.entity.decoration.Painting;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
+import net.minecraft.world.entity.monster.Ghast;
|
||||
|
||||
public class TrackingRange
|
||||
{
|
||||
@@ -24,6 +25,7 @@ public class TrackingRange
|
||||
{
|
||||
return defaultRange;
|
||||
}
|
||||
|
@ -345,11 +351,11 @@ index 24b1dfcf91d36947c87e9e5c2524317f8775ba95..e5bcbfe175a697e04886d04543e1278b
|
|||
SpigotWorldConfig config = entity.level.spigotConfig;
|
||||
if ( entity instanceof ServerPlayer )
|
||||
{
|
||||
@@ -47,8 +48,48 @@ public class TrackingRange
|
||||
@@ -47,8 +49,48 @@ public class TrackingRange
|
||||
return config.miscTrackingRange;
|
||||
} else
|
||||
{
|
||||
- if (entity instanceof net.minecraft.world.entity.boss.enderdragon.EnderDragon) return ((net.minecraft.server.level.ServerLevel)(entity.getCommandSenderWorld())).getChunkSource().chunkMap.getLoadViewDistance(); // Paper - enderdragon is exempt
|
||||
- if (entity instanceof net.minecraft.world.entity.boss.enderdragon.EnderDragon) return ((net.minecraft.server.level.ServerLevel)(entity.getCommandSenderWorld())).getChunkSource().chunkMap.getEffectiveViewDistance(); // Paper - enderdragon is exempt
|
||||
return config.otherTrackingRange;
|
||||
}
|
||||
}
|
|
@ -8,10 +8,10 @@ so inline where possible, and avoid the abstraction of the
|
|||
Either class.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index cdacb26699a54659d1e43ec0f73640556a743700..32bfde94533fcba205e0de3bc55baa8359f8fae6 100644
|
||||
index cda574e825164587bd126029d5b556c049c18015..a5f0fe87bd5d75bf9a12ef284b0d635d8f6dd3a1 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -2136,15 +2136,18 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
@@ -2139,15 +2139,18 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
}
|
||||
|
||||
private boolean isPositionTickingWithEntitiesLoaded(long chunkPos) {
|
||||
|
@ -34,10 +34,10 @@ index cdacb26699a54659d1e43ec0f73640556a743700..32bfde94533fcba205e0de3bc55baa83
|
|||
|
||||
private final class EntityCallbacks implements LevelCallback<Entity> {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/ChunkPos.java b/src/main/java/net/minecraft/world/level/ChunkPos.java
|
||||
index 18c8988dcb5b475c8738a313f1775b73c9d961f4..32037377737cd45fa55ecbe19c201f424a127714 100644
|
||||
index 4c5f8a103b550a681178926096d5f758654c61a7..d2952a1a84ae7326e2d4a1f19497db8f978e4688 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/ChunkPos.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/ChunkPos.java
|
||||
@@ -49,7 +49,7 @@ public class ChunkPos {
|
||||
@@ -50,7 +50,7 @@ public class ChunkPos {
|
||||
}
|
||||
|
||||
public static long asLong(BlockPos pos) {
|
|
@ -5,10 +5,10 @@ Subject: [PATCH] Ensure Entity AABB's are never invalid
|
|||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 95fcf31b0ea68312f6c3475c1b4a01ca2b269536..7b6f23136330e14e977dd4fe24b18339ca25be6e 100644
|
||||
index 9d4dc7d8d8b6633a3e88a8fc43d3d798683ef1d9..8f634603a871567ea7f7e237856e844caf867dc0 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -555,8 +555,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i
|
||||
@@ -589,8 +589,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i
|
||||
}
|
||||
|
||||
public void setPos(double x, double y, double z) {
|
||||
|
@ -19,7 +19,7 @@ index 95fcf31b0ea68312f6c3475c1b4a01ca2b269536..7b6f23136330e14e977dd4fe24b18339
|
|||
}
|
||||
|
||||
protected AABB makeBoundingBox() {
|
||||
@@ -3727,6 +3727,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i
|
||||
@@ -3761,6 +3761,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i
|
||||
}
|
||||
|
||||
public final void setPosRaw(double x, double y, double z) {
|
||||
|
@ -31,7 +31,7 @@ index 95fcf31b0ea68312f6c3475c1b4a01ca2b269536..7b6f23136330e14e977dd4fe24b18339
|
|||
if (this.position.x != x || this.position.y != y || this.position.z != z) {
|
||||
this.position = new Vec3(x, y, z);
|
||||
int i = Mth.floor(x);
|
||||
@@ -3749,6 +3754,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i
|
||||
@@ -3783,6 +3788,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i
|
||||
}
|
||||
}
|
||||
|
|
@ -5,7 +5,7 @@ Subject: [PATCH] Remove streams from classes related villager gossip
|
|||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/gossip/GossipContainer.java b/src/main/java/net/minecraft/world/entity/ai/gossip/GossipContainer.java
|
||||
index 5498ec7049318dc2d10bb2ef7fbfefcf1e6e1e72..d45d14394320e87513f70a9e821fb7d179450cd9 100644
|
||||
index 971ef3d98057ede1316e07cc1e9dcb2742a42187..616e0b8e7a9846ad8ee0874c5dc3bce06de7156f 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/gossip/GossipContainer.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/gossip/GossipContainer.java
|
||||
@@ -8,6 +8,7 @@ import com.mojang.serialization.Dynamic;
|
|
@ -5,10 +5,10 @@ Subject: [PATCH] Add entity liquid API
|
|||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 7b6f23136330e14e977dd4fe24b18339ca25be6e..b61f728c83e006197fdb158e83d04b5498133cc3 100644
|
||||
index 8f634603a871567ea7f7e237856e844caf867dc0..fb2d5c768b7dc5255db7dc7199ed750809a8fb94 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -1314,7 +1314,6 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i
|
||||
@@ -1348,7 +1348,6 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i
|
||||
return this.isInWater() || this.isInRain();
|
||||
}
|
||||
|
|
@ -5,7 +5,7 @@ Subject: [PATCH] Don't check chunk for portal on world gen entity add
|
|||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index 6c4fd054a06830947dbb4728e62dc320a51f43f0..2e02fc6d9c54bd246602b8535553dd04c4e26679 100644
|
||||
index d23b82e5b6168ea618922f46a0e1ee7f46fad8f9..8fa36430da31346caa0fb1fc0b376d62bd6e247a 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -3362,7 +3362,7 @@ public abstract class LivingEntity extends Entity {
|
|
@ -80,7 +80,7 @@ index 2fe519d4059fac06781c30e140895b604e13104f..35949e9c15eb998aa89842d34d0999cd
|
|||
chunkData.addProperty("queued-for-unload", chunkMap.toDrop.contains(playerChunk.pos.longKey));
|
||||
chunkData.addProperty("status", status == null ? "unloaded" : status.toString());
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java
|
||||
index 51175994b37e966af8983df1f15a0fc5a638a0b5..675c13c629e77ba50ecdad8cae43cc6b8aee5eaa 100644
|
||||
index 347cf5d00d986ae8ad60af7f6eabde9fbfd78561..64fa9affc32057f09268a6f92dbc88c9decd6ed8 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ChunkHolder.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java
|
||||
@@ -57,7 +57,7 @@ public class ChunkHolder {
|
||||
|
@ -100,7 +100,7 @@ index 51175994b37e966af8983df1f15a0fc5a638a0b5..675c13c629e77ba50ecdad8cae43cc6b
|
|||
boolean isUpdateQueued = false; // Paper
|
||||
private final ChunkMap chunkMap; // Paper
|
||||
|
||||
@@ -394,12 +395,18 @@ public class ChunkHolder {
|
||||
@@ -407,12 +408,18 @@ public class ChunkHolder {
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -119,7 +119,7 @@ index 51175994b37e966af8983df1f15a0fc5a638a0b5..675c13c629e77ba50ecdad8cae43cc6b
|
|||
ChunkStatus chunkstatus = ChunkHolder.getStatus(this.oldTicketLevel);
|
||||
ChunkStatus chunkstatus1 = ChunkHolder.getStatus(this.ticketLevel);
|
||||
boolean flag = this.oldTicketLevel <= ChunkMap.MAX_CHUNK_DISTANCE;
|
||||
@@ -410,9 +417,22 @@ public class ChunkHolder {
|
||||
@@ -423,9 +430,22 @@ public class ChunkHolder {
|
||||
// ChunkUnloadEvent: Called before the chunk is unloaded: isChunkLoaded is still true and chunk can still be modified by plugins.
|
||||
if (playerchunk_state.isOrAfter(ChunkHolder.FullChunkStatus.BORDER) && !playerchunk_state1.isOrAfter(ChunkHolder.FullChunkStatus.BORDER)) {
|
||||
this.getFutureIfPresentUnchecked(ChunkStatus.FULL).thenAccept((either) -> {
|
||||
|
@ -143,7 +143,7 @@ index 51175994b37e966af8983df1f15a0fc5a638a0b5..675c13c629e77ba50ecdad8cae43cc6b
|
|||
// Minecraft will apply the chunks tick lists to the world once the chunk got loaded, and then store the tick
|
||||
// lists again inside the chunk once the chunk becomes inaccessible and set the chunk's needsSaving flag.
|
||||
// These actions may however happen deferred, so we manually set the needsSaving flag already here.
|
||||
@@ -457,12 +477,14 @@ public class ChunkHolder {
|
||||
@@ -470,12 +490,14 @@ public class ChunkHolder {
|
||||
this.scheduleFullChunkPromotion(chunkStorage, this.fullChunkFuture, executor, ChunkHolder.FullChunkStatus.BORDER);
|
||||
// Paper start - cache ticking ready status
|
||||
this.fullChunkFuture.thenAccept(either -> {
|
||||
|
@ -158,7 +158,7 @@ index 51175994b37e966af8983df1f15a0fc5a638a0b5..675c13c629e77ba50ecdad8cae43cc6b
|
|||
}
|
||||
});
|
||||
this.updateChunkToSave(this.fullChunkFuture, "full");
|
||||
@@ -483,6 +505,7 @@ public class ChunkHolder {
|
||||
@@ -496,6 +518,7 @@ public class ChunkHolder {
|
||||
this.scheduleFullChunkPromotion(chunkStorage, this.tickingChunkFuture, executor, ChunkHolder.FullChunkStatus.TICKING);
|
||||
// Paper start - cache ticking ready status
|
||||
this.tickingChunkFuture.thenAccept(either -> {
|
||||
|
@ -166,7 +166,7 @@ index 51175994b37e966af8983df1f15a0fc5a638a0b5..675c13c629e77ba50ecdad8cae43cc6b
|
|||
either.ifLeft(chunk -> {
|
||||
// note: Here is a very good place to add callbacks to logic waiting on this.
|
||||
ChunkHolder.this.isTickingReady = true;
|
||||
@@ -518,6 +541,7 @@ public class ChunkHolder {
|
||||
@@ -531,6 +554,7 @@ public class ChunkHolder {
|
||||
this.scheduleFullChunkPromotion(chunkStorage, this.entityTickingChunkFuture, executor, ChunkHolder.FullChunkStatus.ENTITY_TICKING);
|
||||
// Paper start - cache ticking ready status
|
||||
this.entityTickingChunkFuture.thenAccept(either -> {
|
||||
|
@ -174,7 +174,7 @@ index 51175994b37e966af8983df1f15a0fc5a638a0b5..675c13c629e77ba50ecdad8cae43cc6b
|
|||
either.ifLeft(chunk -> {
|
||||
ChunkHolder.this.isEntityTickingReady = true;
|
||||
// Paper start - entity ticking chunk set
|
||||
@@ -544,16 +568,45 @@ public class ChunkHolder {
|
||||
@@ -557,16 +581,45 @@ public class ChunkHolder {
|
||||
this.demoteFullChunk(chunkStorage, playerchunk_state1);
|
||||
}
|
||||
|
||||
|
@ -223,7 +223,7 @@ index 51175994b37e966af8983df1f15a0fc5a638a0b5..675c13c629e77ba50ecdad8cae43cc6b
|
|||
});
|
||||
}
|
||||
}).exceptionally((throwable) -> {
|
||||
@@ -644,7 +697,134 @@ public class ChunkHolder {
|
||||
@@ -657,7 +710,134 @@ public class ChunkHolder {
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -360,10 +360,10 @@ index 51175994b37e966af8983df1f15a0fc5a638a0b5..675c13c629e77ba50ecdad8cae43cc6b
|
|||
return this.isEntityTickingReady;
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
index 7f4b68199b0cd8adb09ef09539b43e62885e19c5..896bca9ac8017ace5bc95d4ab1c2f96a63bd921b 100644
|
||||
index 0bd55c5a43bfed7d5c80f6859b2827b7da3d0804..373ac9909666302fd6b9c6891866a9baf3977316 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
@@ -125,6 +125,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
@@ -126,6 +126,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
public final ServerLevel level;
|
||||
private final ThreadedLevelLightEngine lightEngine;
|
||||
private final BlockableEventLoop<Runnable> mainThreadExecutor;
|
||||
|
@ -371,7 +371,7 @@ index 7f4b68199b0cd8adb09ef09539b43e62885e19c5..896bca9ac8017ace5bc95d4ab1c2f96a
|
|||
public ChunkGenerator generator;
|
||||
public final Supplier<DimensionDataStorage> overworldDataStorage;
|
||||
private final PoiManager poiManager;
|
||||
@@ -242,6 +243,15 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
@@ -300,6 +301,15 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
this.level = world;
|
||||
this.generator = chunkGenerator;
|
||||
this.mainThreadExecutor = mainThreadExecutor;
|
||||
|
@ -387,7 +387,7 @@ index 7f4b68199b0cd8adb09ef09539b43e62885e19c5..896bca9ac8017ace5bc95d4ab1c2f96a
|
|||
ProcessorMailbox<Runnable> threadedmailbox = ProcessorMailbox.create(executor, "worldgen");
|
||||
|
||||
Objects.requireNonNull(mainThreadExecutor);
|
||||
@@ -282,6 +292,37 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
@@ -411,6 +421,37 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -425,7 +425,7 @@ index 7f4b68199b0cd8adb09ef09539b43e62885e19c5..896bca9ac8017ace5bc95d4ab1c2f96a
|
|||
// Paper start
|
||||
public void updatePlayerMobTypeMap(Entity entity) {
|
||||
if (!this.level.paperConfig.perPlayerMobSpawns) {
|
||||
@@ -423,6 +464,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
@@ -552,6 +593,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
List<CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>>> list = Lists.newArrayList();
|
||||
int j = centerChunk.x;
|
||||
int k = centerChunk.z;
|
||||
|
@ -433,7 +433,7 @@ index 7f4b68199b0cd8adb09ef09539b43e62885e19c5..896bca9ac8017ace5bc95d4ab1c2f96a
|
|||
|
||||
for (int l = -margin; l <= margin; ++l) {
|
||||
for (int i1 = -margin; i1 <= margin; ++i1) {
|
||||
@@ -441,6 +483,14 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
@@ -570,6 +612,14 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
|
||||
ChunkStatus chunkstatus = (ChunkStatus) distanceToStatus.apply(j1);
|
||||
CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>> completablefuture = playerchunk.getOrScheduleFuture(chunkstatus, this);
|
||||
|
@ -448,7 +448,7 @@ index 7f4b68199b0cd8adb09ef09539b43e62885e19c5..896bca9ac8017ace5bc95d4ab1c2f96a
|
|||
|
||||
list.add(completablefuture);
|
||||
}
|
||||
@@ -712,11 +762,19 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
@@ -842,11 +892,19 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
if (requiredStatus == ChunkStatus.EMPTY) {
|
||||
return this.scheduleChunkLoad(chunkcoordintpair);
|
||||
} else {
|
||||
|
@ -469,7 +469,7 @@ index 7f4b68199b0cd8adb09ef09539b43e62885e19c5..896bca9ac8017ace5bc95d4ab1c2f96a
|
|||
|
||||
if (optional.isPresent() && ((ChunkAccess) optional.get()).getStatus().isOrAfter(requiredStatus)) {
|
||||
CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>> completablefuture = requiredStatus.load(this.level, this.structureManager, this.lightEngine, (ichunkaccess) -> {
|
||||
@@ -728,6 +786,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
@@ -858,6 +916,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
} else {
|
||||
return this.scheduleChunkGeneration(holder, requiredStatus);
|
||||
}
|
||||
|
@ -477,7 +477,7 @@ index 7f4b68199b0cd8adb09ef09539b43e62885e19c5..896bca9ac8017ace5bc95d4ab1c2f96a
|
|||
}
|
||||
}
|
||||
|
||||
@@ -784,14 +843,24 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
@@ -914,14 +973,24 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
};
|
||||
|
||||
CompletableFuture<CompoundTag> chunkSaveFuture = this.level.asyncChunkTaskManager.getChunkSaveFuture(pos.x, pos.z);
|
||||
|
@ -507,7 +507,7 @@ index 7f4b68199b0cd8adb09ef09539b43e62885e19c5..896bca9ac8017ace5bc95d4ab1c2f96a
|
|||
return ret;
|
||||
// Paper end
|
||||
}
|
||||
@@ -843,7 +912,10 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
@@ -973,7 +1042,10 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
this.releaseLightTicket(chunkcoordintpair);
|
||||
return CompletableFuture.completedFuture(Either.right(playerchunk_failure));
|
||||
});
|
||||
|
@ -519,7 +519,7 @@ index 7f4b68199b0cd8adb09ef09539b43e62885e19c5..896bca9ac8017ace5bc95d4ab1c2f96a
|
|||
}
|
||||
|
||||
protected void releaseLightTicket(ChunkPos pos) {
|
||||
@@ -927,7 +999,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
@@ -1057,7 +1129,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
long i = chunkHolder.getPos().toLong();
|
||||
|
||||
Objects.requireNonNull(chunkHolder);
|
||||
|
@ -529,7 +529,7 @@ index 7f4b68199b0cd8adb09ef09539b43e62885e19c5..896bca9ac8017ace5bc95d4ab1c2f96a
|
|||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/DistanceManager.java b/src/main/java/net/minecraft/server/level/DistanceManager.java
|
||||
index 8868ffcda194e8c2300181a2cdda9337dbde6284..4ec7fc8081c2c3d2e2d2cfcce336e5b0a35aabda 100644
|
||||
index 95f195980e28bb59f43e5ca1d5e79ebe8c3ddaea..bf18dbe5dc137dc40f67aa9ae4cb35e7c8358f0d 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/DistanceManager.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/DistanceManager.java
|
||||
@@ -113,6 +113,7 @@ public abstract class DistanceManager {
|
||||
|
@ -542,7 +542,7 @@ index 8868ffcda194e8c2300181a2cdda9337dbde6284..4ec7fc8081c2c3d2e2d2cfcce336e5b0
|
|||
|
||||
@@ -127,6 +128,7 @@ public abstract class DistanceManager {
|
||||
public boolean runAllUpdates(ChunkMap chunkStorage) {
|
||||
this.naturalSpawnChunkCounter.runAllUpdates();
|
||||
//this.f.a(); // Paper - no longer used
|
||||
this.tickingTicketsTracker.runAllUpdates();
|
||||
+ org.spigotmc.AsyncCatcher.catchOp("DistanceManagerTick"); // Paper
|
||||
this.playerTicketManager.runAllUpdates();
|
||||
|
@ -711,7 +711,7 @@ index 8868ffcda194e8c2300181a2cdda9337dbde6284..4ec7fc8081c2c3d2e2d2cfcce336e5b0
|
|||
Ticket<ChunkPos> ticket = new Ticket<>(TicketType.FORCED, 31, pos);
|
||||
long i = pos.toLong();
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
index a66d9d6df1fc0ad68f51ea96d4e1a2d725c73b05..add33f9f0c568bbae2eb32a1b87fa8c20aaf1415 100644
|
||||
index 00305a06885b2457615b6bd35bb1a84721ca1d77..93b8c5c21a6a6c2475f4589014852a5178dfc13f 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
@@ -601,6 +601,26 @@ public class ServerChunkCache extends ChunkSource {
|
||||
|
@ -796,7 +796,7 @@ index a66d9d6df1fc0ad68f51ea96d4e1a2d725c73b05..add33f9f0c568bbae2eb32a1b87fa8c2
|
|||
boolean flag1 = this.chunkMap.promoteChunkMap();
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
index beebb7a0e6b8b1fa4e7d2f9fdf1962357cc2ebc3..42d0e3bce81b1f0ea6cb65191a87fed4054cadb4 100644
|
||||
index 2f13055a39c26fe12d2c1094103186635e536166..84f78e2b3bf51eae1d486852464df032861c5a0b 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -185,6 +185,7 @@ public class ServerPlayer extends Player {
|
||||
|
@ -807,7 +807,7 @@ index beebb7a0e6b8b1fa4e7d2f9fdf1962357cc2ebc3..42d0e3bce81b1f0ea6cb65191a87fed4
|
|||
private float lastSentHealth = -1.0E8F;
|
||||
private int lastSentFood = -99999999;
|
||||
private boolean lastFoodSaturationZero = true;
|
||||
@@ -327,6 +328,21 @@ public class ServerPlayer extends Player {
|
||||
@@ -328,6 +329,21 @@ public class ServerPlayer extends Player {
|
||||
this.maxHealthCache = this.getMaxHealth();
|
||||
this.cachedSingleMobDistanceMap = new com.destroystokyo.paper.util.PooledHashSets.PooledObjectLinkedOpenHashSet<>(this); // Paper
|
||||
}
|
||||
|
@ -1127,19 +1127,6 @@ index 78fbb4c3e52e900956ae0811aaf934c81ee5ea48..23d13600d6925f6746dfde08e17ba578
|
|||
|
||||
private final String name;
|
||||
private final Comparator<T> comparator;
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index 0bcafeb8008bd2556bcdc556b17d00ff936d7aa9..f9733ec478fe5aa0fa678a5f4482ab6e7045c033 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -1550,7 +1550,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||
// CraftBukkit end
|
||||
|
||||
this.awaitingTeleportTime = this.tickCount;
|
||||
- this.player.absMoveTo(d0, d1, d2, f, f1);
|
||||
+ this.player.moveTo(d0, d1, d2, f, f1); // Paper - use proper setPositionRotation for teleportation
|
||||
this.player.connection.send(new ClientboundPlayerPositionPacket(d0 - d3, d1 - d4, d2 - d5, f - f2, f1 - f3, set, this.awaitingTeleport, flag));
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
index 4710c9d12feb12b75c497373c172ce0d4f4ab96e..338e89a2951f6f79d4dd7abf0b378b6e2ddf1f58 100644
|
||||
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
|
@ -1164,10 +1151,10 @@ index 4710c9d12feb12b75c497373c172ce0d4f4ab96e..338e89a2951f6f79d4dd7abf0b378b6e
|
|||
if (updatingChunk != null) {
|
||||
return updatingChunk.getEntityTickingChunkFuture();
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index b61f728c83e006197fdb158e83d04b5498133cc3..a6e732274018cf4864a0a3e3258bf0381f3a0c79 100644
|
||||
index fb2d5c768b7dc5255db7dc7199ed750809a8fb94..9b254d00eb0cf0c4d4fe73e7a955b0b6493a5892 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -222,7 +222,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i
|
||||
@@ -223,7 +223,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i
|
||||
private BlockPos blockPosition;
|
||||
private ChunkPos chunkPosition;
|
||||
private Vec3 deltaMovement;
|
|
@ -5,7 +5,7 @@ Subject: [PATCH] Move range check for block placing up
|
|||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index f9733ec478fe5aa0fa678a5f4482ab6e7045c033..851bbe0bab26f39f19aa85cb2779fb06c77f7e46 100644
|
||||
index 0bcafeb8008bd2556bcdc556b17d00ff936d7aa9..26bd27d3dd6e99488fd0a77257866b1eb1b191b8 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -1666,6 +1666,14 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
|
@ -5,7 +5,7 @@ Subject: [PATCH] Brand support
|
|||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index 851bbe0bab26f39f19aa85cb2779fb06c77f7e46..77c98907372faa4b9dc0cfb11ceed82e03d7b6eb 100644
|
||||
index 26bd27d3dd6e99488fd0a77257866b1eb1b191b8..c5fc4a2470093202f38472df84355ba0404645c5 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -4,6 +4,7 @@ import com.google.common.collect.Lists;
|
|
@ -5,7 +5,7 @@ Subject: [PATCH] Fix SpawnChangeEvent not firing for all use-cases
|
|||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index cda574e825164587bd126029d5b556c049c18015..01b4bd2176b751f895e39002f105a171a32d65af 100644
|
||||
index a5f0fe87bd5d75bf9a12ef284b0d635d8f6dd3a1..64f5901049258c327e3fef8723da58756ce05cc6 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -1689,6 +1689,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
|
@ -9,7 +9,7 @@ as this is how Vanilla teleports entities.
|
|||
Cancel any pending motion when teleported.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index 77c98907372faa4b9dc0cfb11ceed82e03d7b6eb..2074760beee6fdc2e94bb0f5dcfbae7b5813e8c9 100644
|
||||
index c5fc4a2470093202f38472df84355ba0404645c5..2074760beee6fdc2e94bb0f5dcfbae7b5813e8c9 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -680,7 +680,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||
|
@ -21,11 +21,20 @@ index 77c98907372faa4b9dc0cfb11ceed82e03d7b6eb..2074760beee6fdc2e94bb0f5dcfbae7b
|
|||
this.lastGoodX = this.awaitingPositionFromClient.x;
|
||||
this.lastGoodY = this.awaitingPositionFromClient.y;
|
||||
this.lastGoodZ = this.awaitingPositionFromClient.z;
|
||||
@@ -1554,7 +1554,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||
// CraftBukkit end
|
||||
|
||||
this.awaitingTeleportTime = this.tickCount;
|
||||
- this.player.absMoveTo(d0, d1, d2, f, f1);
|
||||
+ this.player.moveTo(d0, d1, d2, f, f1); // Paper - use proper setPositionRotation for teleportation
|
||||
this.player.connection.send(new ClientboundPlayerPositionPacket(d0 - d3, d1 - d4, d2 - d5, f - f2, f1 - f3, set, this.awaitingTeleport, flag));
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index a6e732274018cf4864a0a3e3258bf0381f3a0c79..dc34a9140811858ac6fc6d03b7c63aac81e67ab9 100644
|
||||
index 9b254d00eb0cf0c4d4fe73e7a955b0b6493a5892..d5455fda54047ad3723772a352d35a371727f0cd 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -150,6 +150,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i
|
||||
@@ -151,6 +151,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i
|
||||
|
||||
// CraftBukkit start
|
||||
private static final int CURRENT_LEVEL = 2;
|
||||
|
@ -33,7 +42,7 @@ index a6e732274018cf4864a0a3e3258bf0381f3a0c79..dc34a9140811858ac6fc6d03b7c63aac
|
|||
static boolean isLevelAtLeast(CompoundTag tag, int level) {
|
||||
return tag.contains("Bukkit.updateLevel") && tag.getInt("Bukkit.updateLevel") >= level;
|
||||
}
|
||||
@@ -1517,6 +1518,13 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i
|
||||
@@ -1551,6 +1552,13 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i
|
||||
}
|
||||
|
||||
public void moveTo(double x, double y, double z, float yaw, float pitch) {
|
|
@ -6,7 +6,7 @@ Subject: [PATCH] Extend block drop capture to capture all items added to the
|
|||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index 01b4bd2176b751f895e39002f105a171a32d65af..5c236b0330b298bcae61112409a4a6c7f51d0530 100644
|
||||
index 64f5901049258c327e3fef8723da58756ce05cc6..22e8a349254bcf6ba39fcede60bc59d5b7190cf2 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -1226,6 +1226,13 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
|
@ -5,10 +5,10 @@ Subject: [PATCH] Don't mark dirty in invalid locations (SPIGOT-6086)
|
|||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java
|
||||
index d03aeed657fc7e427d847e0b8e2d58c59e6851fa..3d38a5cd7db0436b4d3fe6b3476025b30d5186dc 100644
|
||||
index 64fa9affc32057f09268a6f92dbc88c9decd6ed8..04fe3432216c9a1e4d3dbfa159faf2332de422fb 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ChunkHolder.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java
|
||||
@@ -207,6 +207,7 @@ public class ChunkHolder {
|
||||
@@ -220,6 +220,7 @@ public class ChunkHolder {
|
||||
}
|
||||
|
||||
public void blockChanged(BlockPos pos) {
|
|
@ -6,10 +6,10 @@ Subject: [PATCH] Expose the Entity Counter to allow plugins to use valid and
|
|||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index dc34a9140811858ac6fc6d03b7c63aac81e67ab9..f8c268fc2986eb5de7b4ffed39cbde0eb1c2ca5d 100644
|
||||
index d5455fda54047ad3723772a352d35a371727f0cd..f5198f23e6147adb69aa95d5da816eaef971f259 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -3927,4 +3927,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i
|
||||
@@ -3961,4 +3961,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i
|
||||
|
||||
void accept(Entity entity, double x, double y, double z);
|
||||
}
|
|
@ -5,18 +5,18 @@ Subject: [PATCH] Entity#isTicking
|
|||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index f8c268fc2986eb5de7b4ffed39cbde0eb1c2ca5d..8e3c69e53af1e79da5fd96d722fe08e49923113f 100644
|
||||
index f5198f23e6147adb69aa95d5da816eaef971f259..8dec785700303d9206ca77ff19dc9e3628b581e5 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -52,6 +52,7 @@ import net.minecraft.network.syncher.SynchedEntityData;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
@@ -53,6 +53,7 @@ import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.MCUtil;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
+import net.minecraft.server.level.ServerChunkCache;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.level.TicketType;
|
||||
@@ -3932,5 +3933,9 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i
|
||||
@@ -3966,5 +3967,9 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i
|
||||
public static int nextEntityId() {
|
||||
return ENTITY_COUNTER.incrementAndGet();
|
||||
}
|
|
@ -25,12 +25,12 @@ index d30bc3f1da336b421d9a42070184e07169dd14e4..a6eadf71957b37e2acc5d09f0ce4ee96
|
|||
Connection.LOGGER.debug("Failed to sent packet", throwable);
|
||||
ConnectionProtocol enumprotocol = this.getCurrentProtocol();
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
index 42d0e3bce81b1f0ea6cb65191a87fed4054cadb4..8932fb6ab89e4de71661c0eec8397350ea4ce6f6 100644
|
||||
index 84f78e2b3bf51eae1d486852464df032861c5a0b..a32551253f12bd6f4a9008dd5d99fece6464effe 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -255,6 +255,7 @@ public class ServerPlayer extends Player {
|
||||
public PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper
|
||||
@@ -256,6 +256,7 @@ public class ServerPlayer extends Player {
|
||||
|
||||
public double lastEntitySpawnRadiusSquared; // Paper - optimise isOutsideRange, this field is in blocks
|
||||
public final com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<ServerPlayer> cachedSingleHashSet; // Paper
|
||||
+ public org.bukkit.event.player.PlayerQuitEvent.QuitReason quitReason = null; // Paper - there are a lot of changes to do if we change all methods leading to the event
|
||||
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue