Archiviert
13
0

Some chunk patches

Dieser Commit ist enthalten in:
Owen1212055 2023-06-08 02:31:22 -04:00
Ursprung 74ad522fc5
Commit 6d118492b6
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 2133292072886A30
7 geänderte Dateien mit 105 neuen und 92 gelöschten Zeilen

Datei anzeigen

@ -6,10 +6,10 @@ Subject: [PATCH] Optimize anyPlayerCloseEnoughForSpawning to use distance maps
Use a distance map to find the players in range quickly 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 diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java
index 214e0657035f82e5266de06e31975d6b45405019..51c112656f26f142bd6c126253520e812a338783 100644 index 4b87f5d899e5ac033d78ccdbca21c9c50c46dcef..b705545ecaef9203ef2ff067ed947ad4aa86dc89 100644
--- a/src/main/java/net/minecraft/server/level/ChunkHolder.java --- a/src/main/java/net/minecraft/server/level/ChunkHolder.java
+++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java +++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java
@@ -83,16 +83,29 @@ public class ChunkHolder { @@ -86,16 +86,29 @@ public class ChunkHolder {
// Paper start // Paper start
public void onChunkAdd() { public void onChunkAdd() {
@ -38,17 +38,18 @@ index 214e0657035f82e5266de06e31975d6b45405019..51c112656f26f142bd6c126253520e81
+ com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<ServerPlayer> playersInChunkTickRange; + com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<ServerPlayer> playersInChunkTickRange;
+ // Paper end - optimise anyPlayerCloseEnoughForSpawning + // Paper end - optimise anyPlayerCloseEnoughForSpawning
+ +
public ChunkHolder(ChunkPos pos, LevelHeightAccessor world, LevelLightEngine lightingProvider, ChunkHolder.PlayerProvider playersWatchingChunkProvider, io.papermc.paper.chunk.system.scheduling.NewChunkHolder newChunkHolder) { // Paper - rewrite chunk system // Paper start - replace player chunk loader
this.newChunkHolder = newChunkHolder; // Paper - rewrite chunk system private final com.destroystokyo.paper.util.maplist.ReferenceList<ServerPlayer> playersSentChunkTo = new com.destroystokyo.paper.util.maplist.ReferenceList<>();
this.chunkToSaveHistory = null;
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 1c638f65d33e5890a7a32bf7e89d484ae2afc093..4b7c39595302a738e6d4a1749473ef9c81f84fea 100644 index 8d8bb430e44d7608a8aa44c7feb41797b8bbfb06..7d80cfd701d910badf1feaecaa4ce5129584e21d 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java --- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -159,12 +159,24 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -157,12 +157,25 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
// Paper start - distance maps // Paper start - distance maps
private final com.destroystokyo.paper.util.misc.PooledLinkedHashSets<ServerPlayer> pooledLinkedPlayerHashSets = new com.destroystokyo.paper.util.misc.PooledLinkedHashSets<>(); private final com.destroystokyo.paper.util.misc.PooledLinkedHashSets<ServerPlayer> pooledLinkedPlayerHashSets = new com.destroystokyo.paper.util.misc.PooledLinkedHashSets<>();
public final io.papermc.paper.chunk.PlayerChunkLoader playerChunkManager = new io.papermc.paper.chunk.PlayerChunkLoader(this, this.pooledLinkedPlayerHashSets); // Paper - replace chunk loader + public final io.papermc.paper.chunk.PlayerChunkLoader playerChunkManager = new io.papermc.paper.chunk.PlayerChunkLoader(this, this.pooledLinkedPlayerHashSets); // Paper - replace chunk loader
+ // Paper start - optimise ChunkMap#anyPlayerCloseEnoughForSpawning + // Paper start - optimise ChunkMap#anyPlayerCloseEnoughForSpawning
+ // A note about the naming used here: + // A note about the naming used here:
+ // Previously, mojang used a "spawn range" of 8 for controlling both ticking and + // Previously, mojang used a "spawn range" of 8 for controlling both ticking and
@ -62,7 +63,7 @@ index 1c638f65d33e5890a7a32bf7e89d484ae2afc093..4b7c39595302a738e6d4a1749473ef9c
+ // Paper end - optimise ChunkMap#anyPlayerCloseEnoughForSpawning + // Paper end - optimise ChunkMap#anyPlayerCloseEnoughForSpawning
void addPlayerToDistanceMaps(ServerPlayer player) { void addPlayerToDistanceMaps(ServerPlayer player) {
this.playerChunkManager.addPlayer(player); // Paper - replace chunk loader this.level.playerChunkLoader.addPlayer(player); // Paper - replace chunk loader
int chunkX = MCUtil.getChunkCoordinate(player.getX()); int chunkX = MCUtil.getChunkCoordinate(player.getX());
int chunkZ = MCUtil.getChunkCoordinate(player.getZ()); int chunkZ = MCUtil.getChunkCoordinate(player.getZ());
// Note: players need to be explicitly added to distance maps before they can be updated // Note: players need to be explicitly added to distance maps before they can be updated
@ -70,9 +71,9 @@ index 1c638f65d33e5890a7a32bf7e89d484ae2afc093..4b7c39595302a738e6d4a1749473ef9c
// Paper start - per player mob spawning // Paper start - per player mob spawning
if (this.playerMobDistanceMap != null) { if (this.playerMobDistanceMap != null) {
this.playerMobDistanceMap.add(player, chunkX, chunkZ, io.papermc.paper.chunk.system.ChunkSystem.getTickViewDistance(player)); this.playerMobDistanceMap.add(player, chunkX, chunkZ, io.papermc.paper.chunk.system.ChunkSystem.getTickViewDistance(player));
@@ -175,6 +187,10 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -173,6 +186,10 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
void removePlayerFromDistanceMaps(ServerPlayer player) { void removePlayerFromDistanceMaps(ServerPlayer player) {
this.playerChunkManager.removePlayer(player); // Paper - replace chunk loader this.level.playerChunkLoader.removePlayer(player); // Paper - replace chunk loader
+ // Paper start - optimise ChunkMap#anyPlayerCloseEnoughForSpawning + // Paper start - optimise ChunkMap#anyPlayerCloseEnoughForSpawning
+ this.playerMobSpawnMap.remove(player); + this.playerMobSpawnMap.remove(player);
@ -81,15 +82,15 @@ index 1c638f65d33e5890a7a32bf7e89d484ae2afc093..4b7c39595302a738e6d4a1749473ef9c
// Paper start - per player mob spawning // Paper start - per player mob spawning
if (this.playerMobDistanceMap != null) { if (this.playerMobDistanceMap != null) {
this.playerMobDistanceMap.remove(player); this.playerMobDistanceMap.remove(player);
@@ -187,6 +203,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -185,6 +202,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
int chunkZ = MCUtil.getChunkCoordinate(player.getZ()); int chunkZ = MCUtil.getChunkCoordinate(player.getZ());
// Note: players need to be explicitly added to distance maps before they can be updated // Note: players need to be explicitly added to distance maps before they can be updated
this.playerChunkManager.updatePlayer(player); // Paper - replace chunk loader this.level.playerChunkLoader.updatePlayer(player); // Paper - replace chunk loader
+ this.playerChunkTickRangeMap.update(player, chunkX, chunkZ, DistanceManager.MOB_SPAWN_RANGE); // Paper - optimise ChunkMap#anyPlayerCloseEnoughForSpawning + this.playerChunkTickRangeMap.update(player, chunkX, chunkZ, DistanceManager.MOB_SPAWN_RANGE); // Paper - optimise ChunkMap#anyPlayerCloseEnoughForSpawning
// Paper start - per player mob spawning // Paper start - per player mob spawning
if (this.playerMobDistanceMap != null) { if (this.playerMobDistanceMap != null) {
this.playerMobDistanceMap.update(player, chunkX, chunkZ, io.papermc.paper.chunk.system.ChunkSystem.getTickViewDistance(player)); this.playerMobDistanceMap.update(player, chunkX, chunkZ, io.papermc.paper.chunk.system.ChunkSystem.getTickViewDistance(player));
@@ -278,6 +295,38 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -276,6 +294,38 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
this.regionManagers.add(this.dataRegionManager); this.regionManagers.add(this.dataRegionManager);
// Paper end // Paper end
this.playerMobDistanceMap = this.level.paperConfig().entities.spawning.perPlayerMobSpawns ? new com.destroystokyo.paper.util.misc.PlayerAreaMap(this.pooledLinkedPlayerHashSets) : null; // Paper this.playerMobDistanceMap = this.level.paperConfig().entities.spawning.perPlayerMobSpawns ? new com.destroystokyo.paper.util.misc.PlayerAreaMap(this.pooledLinkedPlayerHashSets) : null; // Paper
@ -128,7 +129,7 @@ index 1c638f65d33e5890a7a32bf7e89d484ae2afc093..4b7c39595302a738e6d4a1749473ef9c
} }
protected ChunkGenerator generator() { protected ChunkGenerator generator() {
@@ -837,43 +886,48 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -850,43 +900,48 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
return this.anyPlayerCloseEnoughForSpawning(pos, false); return this.anyPlayerCloseEnoughForSpawning(pos, false);
} }
@ -209,19 +210,19 @@ index 1c638f65d33e5890a7a32bf7e89d484ae2afc093..4b7c39595302a738e6d4a1749473ef9c
public List<ServerPlayer> getPlayersCloseForSpawning(ChunkPos pos) { 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 diff --git a/src/main/java/net/minecraft/server/level/DistanceManager.java b/src/main/java/net/minecraft/server/level/DistanceManager.java
index d3c3db919e9b0507e8543313d9028394e5163673..52cba8f68d274cce106304aef1249a95474d3238 100644 index fcbdf311e981e010adc78342f0865d3f803354f9..40e17a8f182fea7c99b64cd074ce1757e48758bf 100644
--- a/src/main/java/net/minecraft/server/level/DistanceManager.java --- a/src/main/java/net/minecraft/server/level/DistanceManager.java
+++ b/src/main/java/net/minecraft/server/level/DistanceManager.java +++ b/src/main/java/net/minecraft/server/level/DistanceManager.java
@@ -54,7 +54,7 @@ public abstract class DistanceManager { @@ -50,7 +50,7 @@ public abstract class DistanceManager {
private static final int BLOCK_TICKING_LEVEL_THRESHOLD = 33; private static final int INITIAL_TICKET_LIST_CAPACITY = 4;
final Long2ObjectMap<ObjectSet<ServerPlayer>> playersPerChunk = new Long2ObjectOpenHashMap(); final Long2ObjectMap<ObjectSet<ServerPlayer>> playersPerChunk = new Long2ObjectOpenHashMap();
// Paper - rewrite chunk system // Paper - rewrite chunk system
- private final DistanceManager.FixedPlayerDistanceChunkTracker naturalSpawnChunkCounter = new DistanceManager.FixedPlayerDistanceChunkTracker(8); - private final DistanceManager.FixedPlayerDistanceChunkTracker naturalSpawnChunkCounter = new DistanceManager.FixedPlayerDistanceChunkTracker(8);
+ public static final int MOB_SPAWN_RANGE = 8; // private final DistanceManager.FixedPlayerDistanceChunkTracker naturalSpawnChunkCounter = new DistanceManager.FixedPlayerDistanceChunkTracker(8); // Paper - no longer used + public static final int MOB_SPAWN_RANGE = 8; // private final DistanceManager.FixedPlayerDistanceChunkTracker naturalSpawnChunkCounter = new DistanceManager.FixedPlayerDistanceChunkTracker(8); // Paper - no longer used
//private final TickingTracker tickingTicketsTracker = new TickingTracker(); // Paper - no longer used
//private final DistanceManager.PlayerTicketTracker playerTicketManager = new DistanceManager.PlayerTicketTracker(33); // Paper - no longer used
// Paper - rewrite chunk system // Paper - rewrite chunk system
@@ -142,7 +142,7 @@ public abstract class DistanceManager { private final ChunkMap chunkMap; // Paper
@@ -136,7 +136,7 @@ public abstract class DistanceManager {
long i = chunkcoordintpair.toLong(); long i = chunkcoordintpair.toLong();
// Paper - no longer used // Paper - no longer used
@ -230,7 +231,7 @@ index d3c3db919e9b0507e8543313d9028394e5163673..52cba8f68d274cce106304aef1249a95
//this.playerTicketManager.update(i, 0, true); // Paper - no longer used //this.playerTicketManager.update(i, 0, true); // Paper - no longer used
//this.tickingTicketsTracker.addTicket(TicketType.PLAYER, chunkcoordintpair, this.getPlayerTicketLevel(), chunkcoordintpair); // Paper - no longer used //this.tickingTicketsTracker.addTicket(TicketType.PLAYER, chunkcoordintpair, this.getPlayerTicketLevel(), chunkcoordintpair); // Paper - no longer used
} }
@@ -156,7 +156,7 @@ public abstract class DistanceManager { @@ -150,7 +150,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.remove(player); // Paper - some state corruption happens here, don't crash, clean up gracefully.
if (objectset == null || objectset.isEmpty()) { // Paper if (objectset == null || objectset.isEmpty()) { // Paper
this.playersPerChunk.remove(i); this.playersPerChunk.remove(i);
@ -239,7 +240,7 @@ index d3c3db919e9b0507e8543313d9028394e5163673..52cba8f68d274cce106304aef1249a95
//this.playerTicketManager.update(i, Integer.MAX_VALUE, false); // Paper - no longer used //this.playerTicketManager.update(i, Integer.MAX_VALUE, false); // Paper - no longer used
//this.tickingTicketsTracker.removeTicket(TicketType.PLAYER, chunkcoordintpair, this.getPlayerTicketLevel(), chunkcoordintpair); // Paper - no longer used //this.tickingTicketsTracker.removeTicket(TicketType.PLAYER, chunkcoordintpair, this.getPlayerTicketLevel(), chunkcoordintpair); // Paper - no longer used
} }
@@ -198,13 +198,17 @@ public abstract class DistanceManager { @@ -192,13 +192,17 @@ public abstract class DistanceManager {
} }
public int getNaturalSpawnChunkCount() { public int getNaturalSpawnChunkCount() {
@ -262,10 +263,10 @@ index d3c3db919e9b0507e8543313d9028394e5163673..52cba8f68d274cce106304aef1249a95
public String getDebugStatus() { 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 diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
index 665e088cb0b73f6a0c62f29c56da462bab7c927e..298e4468f7b5346733257f7117f76c66e9a1d8f0 100644 index 604e1f1113457d7dbd368d40a668aab7c7466d40..8f1949cf33bdc35d6d024dd82faae37fec325d6f 100644
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
@@ -658,6 +658,37 @@ public class ServerChunkCache extends ChunkSource { @@ -668,6 +668,37 @@ public class ServerChunkCache extends ChunkSource {
if (flag) { if (flag) {
this.chunkMap.tick(); this.chunkMap.tick();
} else { } else {
@ -303,7 +304,7 @@ index 665e088cb0b73f6a0c62f29c56da462bab7c927e..298e4468f7b5346733257f7117f76c66
LevelData worlddata = this.level.getLevelData(); LevelData worlddata = this.level.getLevelData();
ProfilerFiller gameprofilerfiller = this.level.getProfiler(); ProfilerFiller gameprofilerfiller = this.level.getProfiler();
@@ -701,15 +732,7 @@ public class ServerChunkCache extends ChunkSource { @@ -711,15 +742,7 @@ public class ServerChunkCache extends ChunkSource {
boolean flag2 = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !this.level.players().isEmpty(); // CraftBukkit boolean flag2 = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !this.level.players().isEmpty(); // CraftBukkit
Collections.shuffle(list); Collections.shuffle(list);
@ -320,7 +321,7 @@ index 665e088cb0b73f6a0c62f29c56da462bab7c927e..298e4468f7b5346733257f7117f76c66
Iterator iterator1 = list.iterator(); Iterator iterator1 = list.iterator();
while (iterator1.hasNext()) { while (iterator1.hasNext()) {
@@ -717,9 +740,9 @@ public class ServerChunkCache extends ChunkSource { @@ -727,9 +750,9 @@ public class ServerChunkCache extends ChunkSource {
LevelChunk chunk1 = chunkproviderserver_a.chunk; LevelChunk chunk1 = chunkproviderserver_a.chunk;
ChunkPos chunkcoordintpair = chunk1.getPos(); ChunkPos chunkcoordintpair = chunk1.getPos();
@ -333,14 +334,14 @@ index 665e088cb0b73f6a0c62f29c56da462bab7c927e..298e4468f7b5346733257f7117f76c66
} }
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index 35091999392e7c5e6763aee490020c675e19134b..245ac1e53bfcb1888e8f10d632b181cf31d6d030 100644 index 6fa598820b54559a5c7739f050be08ff36a020e7..c9b07d321a22060086a8608c6ff5f8f0608d988f 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -272,6 +272,7 @@ public class ServerPlayer extends Player { @@ -273,6 +273,7 @@ public class ServerPlayer extends Player {
public String kickLeaveMessage = null; // SPIGOT-3034: Forward leave message to PlayerQuitEvent public Integer clientViewDistance;
// CraftBukkit end // CraftBukkit end
public boolean isRealPlayer; // Paper public boolean isRealPlayer; // Paper
+ public double lastEntitySpawnRadiusSquared; // Paper - optimise isOutsideRange, this field is in blocks + public double lastEntitySpawnRadiusSquared; // Paper - optimise isOutsideRange, this field is in blocks
public final com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<ServerPlayer> cachedSingleHashSet; // Paper public final com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<ServerPlayer> cachedSingleHashSet; // Paper
public PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper public PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // 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

Datei anzeigen

@ -6,10 +6,10 @@ Subject: [PATCH] Optimise chunk tick iteration
Use a dedicated list of entity ticking chunks to reduce the cost Use a dedicated list of entity ticking chunks to reduce the cost
diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java
index 51c112656f26f142bd6c126253520e812a338783..0f2590501d742b1f5a410d45c7781bd18b4a4525 100644 index b705545ecaef9203ef2ff067ed947ad4aa86dc89..3914fae62d3e0c0a9aeb8fd2bd48e76889c25a3a 100644
--- a/src/main/java/net/minecraft/server/level/ChunkHolder.java --- a/src/main/java/net/minecraft/server/level/ChunkHolder.java
+++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java +++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java
@@ -88,6 +88,11 @@ public class ChunkHolder { @@ -91,6 +91,11 @@ public class ChunkHolder {
this.playersInMobSpawnRange = this.chunkMap.playerMobSpawnMap.getObjectsInRange(key); this.playersInMobSpawnRange = this.chunkMap.playerMobSpawnMap.getObjectsInRange(key);
this.playersInChunkTickRange = this.chunkMap.playerChunkTickRangeMap.getObjectsInRange(key); this.playersInChunkTickRange = this.chunkMap.playerChunkTickRangeMap.getObjectsInRange(key);
// Paper end - optimise anyPlayerCloseEnoughForSpawning // Paper end - optimise anyPlayerCloseEnoughForSpawning
@ -21,7 +21,7 @@ index 51c112656f26f142bd6c126253520e812a338783..0f2590501d742b1f5a410d45c7781bd1
} }
public void onChunkRemove() { public void onChunkRemove() {
@@ -95,6 +100,11 @@ public class ChunkHolder { @@ -98,6 +103,11 @@ public class ChunkHolder {
this.playersInMobSpawnRange = null; this.playersInMobSpawnRange = null;
this.playersInChunkTickRange = null; this.playersInChunkTickRange = null;
// Paper end - optimise anyPlayerCloseEnoughForSpawning // Paper end - optimise anyPlayerCloseEnoughForSpawning
@ -33,7 +33,7 @@ index 51c112656f26f142bd6c126253520e812a338783..0f2590501d742b1f5a410d45c7781bd1
} }
// Paper end // Paper end
@@ -210,7 +220,7 @@ public class ChunkHolder { @@ -237,7 +247,7 @@ public class ChunkHolder {
if (i < 0 || i >= this.changedBlocksPerSection.length) return; // CraftBukkit - SPIGOT-6086, SPIGOT-6296 if (i < 0 || i >= this.changedBlocksPerSection.length) return; // CraftBukkit - SPIGOT-6086, SPIGOT-6296
if (this.changedBlocksPerSection[i] == null) { if (this.changedBlocksPerSection[i] == null) {
@ -42,7 +42,7 @@ index 51c112656f26f142bd6c126253520e812a338783..0f2590501d742b1f5a410d45c7781bd1
this.changedBlocksPerSection[i] = new ShortOpenHashSet(); this.changedBlocksPerSection[i] = new ShortOpenHashSet();
} }
@@ -234,6 +244,7 @@ public class ChunkHolder { @@ -261,6 +271,7 @@ public class ChunkHolder {
int k = this.lightEngine.getMaxLightSection(); int k = this.lightEngine.getMaxLightSection();
if (y >= j && y <= k) { if (y >= j && y <= k) {
@ -50,7 +50,7 @@ index 51c112656f26f142bd6c126253520e812a338783..0f2590501d742b1f5a410d45c7781bd1
int l = y - j; int l = y - j;
if (lightType == LightLayer.SKY) { if (lightType == LightLayer.SKY) {
@@ -248,8 +259,19 @@ public class ChunkHolder { @@ -275,8 +286,19 @@ public class ChunkHolder {
} }
} }
@ -69,13 +69,13 @@ index 51c112656f26f142bd6c126253520e812a338783..0f2590501d742b1f5a410d45c7781bd1
- if (this.hasChangedSections || !this.skyChangedLightSectionFilter.isEmpty() || !this.blockChangedLightSectionFilter.isEmpty()) { - if (this.hasChangedSections || !this.skyChangedLightSectionFilter.isEmpty() || !this.blockChangedLightSectionFilter.isEmpty()) {
+ if (this.needsBroadcastChanges()) { // Paper - moved into above, other logic needs to call + if (this.needsBroadcastChanges()) { // Paper - moved into above, other logic needs to call
Level world = chunk.getLevel(); Level world = chunk.getLevel();
int i = 0; List list;
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 503a642165f6f1292c07e8a9e618218bb96a97e9..b0cfdead8a345eaab7747ed6b84271e8e09d1713 100644 index 7d80cfd701d910badf1feaecaa4ce5129584e21d..03b802f9f6e31b1ab23af0ff7b235f64c72ec462 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java --- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -116,6 +116,8 @@ import org.bukkit.craftbukkit.generator.CustomChunkGenerator; @@ -115,6 +115,8 @@ import org.bukkit.craftbukkit.generator.CustomChunkGenerator;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
// CraftBukkit end // CraftBukkit end
@ -84,7 +84,7 @@ index 503a642165f6f1292c07e8a9e618218bb96a97e9..b0cfdead8a345eaab7747ed6b84271e8
public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider { public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider {
private static final byte CHUNK_TYPE_REPLACEABLE = -1; private static final byte CHUNK_TYPE_REPLACEABLE = -1;
@@ -154,6 +156,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -152,6 +154,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
private final Queue<Runnable> unloadQueue; private final Queue<Runnable> unloadQueue;
int viewDistance; int viewDistance;
public final com.destroystokyo.paper.util.misc.PlayerAreaMap playerMobDistanceMap; // Paper public final com.destroystokyo.paper.util.misc.PlayerAreaMap playerMobDistanceMap; // Paper
@ -93,7 +93,7 @@ index 503a642165f6f1292c07e8a9e618218bb96a97e9..b0cfdead8a345eaab7747ed6b84271e8
// Paper - rewrite chunk system // Paper - rewrite chunk system
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
index d1652c237b2b272f0dfe80f774cff16056f39046..b768767b92bf7691a6e57627c69818a1f5fd82c8 100644 index 8f1949cf33bdc35d6d024dd82faae37fec325d6f..d9a14c1c42ce9adc53543e7b95a4083b4109cb33 100644
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
@@ -48,6 +48,7 @@ import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemp @@ -48,6 +48,7 @@ import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemp
@ -104,7 +104,7 @@ index d1652c237b2b272f0dfe80f774cff16056f39046..b768767b92bf7691a6e57627c69818a1
public class ServerChunkCache extends ChunkSource { public class ServerChunkCache extends ChunkSource {
@@ -724,42 +725,59 @@ public class ServerChunkCache extends ChunkSource { @@ -725,42 +726,59 @@ public class ServerChunkCache extends ChunkSource {
this.lastSpawnState = spawnercreature_d; this.lastSpawnState = spawnercreature_d;
gameprofilerfiller.popPush("filteringLoadedChunks"); gameprofilerfiller.popPush("filteringLoadedChunks");
@ -130,7 +130,8 @@ index d1652c237b2b272f0dfe80f774cff16056f39046..b768767b92bf7691a6e57627c69818a1
+ // Paper - only shuffle if per-player mob spawning is disabled + // Paper - only shuffle if per-player mob spawning is disabled
// Paper - moved natural spawn event up // Paper - moved natural spawn event up
- Iterator iterator1 = list.iterator(); - Iterator iterator1 = list.iterator();
+ // Paper start - optimise chunk tick iteration
+ // Paper start - optimise chunk tick iteratio
+ Iterator<LevelChunk> iterator1; + Iterator<LevelChunk> iterator1;
+ if (this.level.paperConfig().entities.spawning.perPlayerMobSpawns) { + if (this.level.paperConfig().entities.spawning.perPlayerMobSpawns) {
+ iterator1 = this.entityTickingChunks.iterator(); + iterator1 = this.entityTickingChunks.iterator();
@ -143,7 +144,6 @@ index d1652c237b2b272f0dfe80f774cff16056f39046..b768767b92bf7691a6e57627c69818a1
+ Collections.shuffle(shuffled); + Collections.shuffle(shuffled);
+ iterator1 = shuffled.iterator(); + iterator1 = shuffled.iterator();
+ } + }
+ try { + try {
while (iterator1.hasNext()) { while (iterator1.hasNext()) {
- ServerChunkCache.ChunkAndHolder chunkproviderserver_a = (ServerChunkCache.ChunkAndHolder) iterator1.next(); - ServerChunkCache.ChunkAndHolder chunkproviderserver_a = (ServerChunkCache.ChunkAndHolder) iterator1.next();
@ -181,7 +181,7 @@ index d1652c237b2b272f0dfe80f774cff16056f39046..b768767b92bf7691a6e57627c69818a1
this.level.timings.chunkTicks.stopTiming(); // Paper this.level.timings.chunkTicks.stopTiming(); // Paper
gameprofilerfiller.popPush("customSpawners"); gameprofilerfiller.popPush("customSpawners");
if (flag2) { if (flag2) {
@@ -767,15 +785,24 @@ public class ServerChunkCache extends ChunkSource { @@ -768,15 +786,24 @@ public class ServerChunkCache extends ChunkSource {
this.level.tickCustomSpawners(this.spawnEnemies, this.spawnFriendlies); this.level.tickCustomSpawners(this.spawnEnemies, this.spawnFriendlies);
} // Paper - timings } // Paper - timings
} }

Datei anzeigen

@ -19,10 +19,10 @@ index 4d861f9a58f8ea238471af22f387854d855b1801..efbf77024d235d8af9f7efc938c17afd
private MinecraftTimings() {} private MinecraftTimings() {}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 416bfdeb0ce8ec1828288a7d84990ed3f027e1fa..24c88555ea85dd2a0656e1f67a4828a5137157b8 100644 index b800249823e413933a5d469e431a003f977f59e7..d8fa1cb0b340f97debceb7e5b90051d29448fc58 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java --- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1306,6 +1306,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa @@ -1305,6 +1305,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
private boolean pollTaskInternal() { private boolean pollTaskInternal() {
if (super.pollTask()) { if (super.pollTask()) {
@ -30,7 +30,7 @@ index 416bfdeb0ce8ec1828288a7d84990ed3f027e1fa..24c88555ea85dd2a0656e1f67a4828a5
return true; return true;
} else { } else {
if (this.haveTime()) { if (this.haveTime()) {
@@ -2715,4 +2716,74 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa @@ -2708,4 +2709,74 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
} }
} }
// Paper end // Paper end
@ -106,18 +106,19 @@ index 416bfdeb0ce8ec1828288a7d84990ed3f027e1fa..24c88555ea85dd2a0656e1f67a4828a5
+ // Paper end - execute chunk tasks mid tick + // Paper end - execute chunk tasks mid tick
} }
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
index b768767b92bf7691a6e57627c69818a1f5fd82c8..ebd0da4f87c74f12d702e1ae4f3206885272e4f7 100644 index d9a14c1c42ce9adc53543e7b95a4083b4109cb33..371f7e71610ddfbdb32dcd493f15d6ff9b90326e 100644
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
@@ -749,6 +749,7 @@ public class ServerChunkCache extends ChunkSource { @@ -750,6 +750,8 @@ public class ServerChunkCache extends ChunkSource {
Collections.shuffle(shuffled);
iterator1 = shuffled.iterator(); iterator1 = shuffled.iterator();
} }
+
+ int chunksTicked = 0; // Paper + int chunksTicked = 0; // Paper
try { try {
while (iterator1.hasNext()) { while (iterator1.hasNext()) {
LevelChunk chunk1 = iterator1.next(); LevelChunk chunk1 = iterator1.next();
@@ -766,6 +767,7 @@ public class ServerChunkCache extends ChunkSource { @@ -767,6 +769,7 @@ public class ServerChunkCache extends ChunkSource {
if (true || this.level.shouldTickBlocksAt(chunkcoordintpair.toLong())) { // Paper - the chunk is known ticking if (true || this.level.shouldTickBlocksAt(chunkcoordintpair.toLong())) { // Paper - the chunk is known ticking
this.level.tickChunk(chunk1, k); this.level.tickChunk(chunk1, k);
@ -126,18 +127,18 @@ index b768767b92bf7691a6e57627c69818a1f5fd82c8..ebd0da4f87c74f12d702e1ae4f320688
} }
// Paper start - optimise chunk tick iteration // Paper start - optimise chunk tick iteration
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 834e5d2ef6045ef703321852f988db3fbf6cbba2..8faf55969232d44b999231b219a208e049a72755 100644 index 00508122ab504b1a84ef050145749fa9fea7a7d1..418bf659d31c5810d786064a76779cfa39943020 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java --- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -212,6 +212,7 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -215,6 +215,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
private final StructureManager structureManager;
private final StructureCheck structureCheck; private final StructureCheck structureCheck;
private final boolean tickTime; private final boolean tickTime;
private final RandomSequences randomSequences;
+ public long lastMidTickExecuteFailure; // Paper - execute chunk tasks mid tick + public long lastMidTickExecuteFailure; // Paper - execute chunk tasks mid tick
// CraftBukkit start // CraftBukkit start
public final LevelStorageSource.LevelStorageAccess convertable; public final LevelStorageSource.LevelStorageAccess convertable;
@@ -1044,6 +1045,7 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -1104,6 +1105,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
if (fluid1.is(fluid)) { if (fluid1.is(fluid)) {
fluid1.tick(this, pos); fluid1.tick(this, pos);
} }
@ -145,7 +146,7 @@ index 834e5d2ef6045ef703321852f988db3fbf6cbba2..8faf55969232d44b999231b219a208e0
} }
@@ -1053,6 +1055,7 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -1113,6 +1115,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
if (iblockdata.is(block)) { if (iblockdata.is(block)) {
iblockdata.tick(this, pos, this.random); iblockdata.tick(this, pos, this.random);
} }
@ -154,10 +155,10 @@ index 834e5d2ef6045ef703321852f988db3fbf6cbba2..8faf55969232d44b999231b219a208e0
} }
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 5f43dbd3b4a50f425b188beb2ed9236ed2db0a06..a0fc6c0dd9754e443a634917d66ac46e170d9dc6 100644 index bce4aa1d7cb7ebeb046ed9f2483d71820c3f0bae..873a375946949a8f48109d5da925933f3956600b 100644
--- a/src/main/java/net/minecraft/world/level/Level.java --- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -832,6 +832,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -822,6 +822,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
// Spigot end // Spigot end
} else if (this.shouldTickBlocksAt(tickingblockentity.getPos())) { } else if (this.shouldTickBlocksAt(tickingblockentity.getPos())) {
tickingblockentity.tick(); tickingblockentity.tick();
@ -169,7 +170,7 @@ index 5f43dbd3b4a50f425b188beb2ed9236ed2db0a06..a0fc6c0dd9754e443a634917d66ac46e
} }
} }
this.blockEntityTickers.removeAll(toRemove); this.blockEntityTickers.removeAll(toRemove);
@@ -846,6 +851,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -836,6 +841,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
public <T extends Entity> void guardEntityTick(Consumer<T> tickConsumer, T entity) { public <T extends Entity> void guardEntityTick(Consumer<T> tickConsumer, T entity) {
try { try {
tickConsumer.accept(entity); tickConsumer.accept(entity);

Datei anzeigen

@ -10,7 +10,7 @@ hoping that at least then we don't swap chunks, and maybe recover
them all. them all.
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java
index f0f38f1a7603cd06aba6adefd370d40b97f2e5b8..34a1976699571608ae19e20dc1b6020759dad909 100644 index b417b175c925049058327c7bc4ed1cc31a644018..603fcf3816d65d0a695e038d5980b1cd98659f4c 100644
--- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java --- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java +++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java
@@ -70,6 +70,18 @@ import net.minecraft.world.ticks.ProtoChunkTicks; @@ -70,6 +70,18 @@ import net.minecraft.world.ticks.ProtoChunkTicks;
@ -30,19 +30,19 @@ index f0f38f1a7603cd06aba6adefd370d40b97f2e5b8..34a1976699571608ae19e20dc1b60207
+ } + }
+ // Paper end + // Paper end
public static final Codec<PalettedContainer<BlockState>> BLOCK_STATE_CODEC = PalettedContainer.codecRW(Block.BLOCK_STATE_REGISTRY, BlockState.CODEC, PalettedContainer.Strategy.SECTION_STATES, Blocks.AIR.defaultBlockState(), null); // Paper - Anti-Xray - Add preset block states public static final Codec<PalettedContainer<BlockState>> BLOCK_STATE_CODEC = PalettedContainer.codecRW(Block.BLOCK_STATE_REGISTRY, BlockState.CODEC, PalettedContainer.Strategy.SECTION_STATES, Blocks.AIR.defaultBlockState());
private static final Logger LOGGER = LogUtils.getLogger(); private static final Logger LOGGER = LogUtils.getLogger();
@@ -485,7 +497,7 @@ public class ChunkSerializer { @@ -434,7 +446,7 @@ public class ChunkSerializer {
nbttagcompound.putInt("xPos", chunkcoordintpair.x); nbttagcompound.putInt("xPos", chunkcoordintpair.x);
nbttagcompound.putInt("yPos", chunk.getMinSection()); nbttagcompound.putInt("yPos", chunk.getMinSection());
nbttagcompound.putInt("zPos", chunkcoordintpair.z); nbttagcompound.putInt("zPos", chunkcoordintpair.z);
- nbttagcompound.putLong("LastUpdate", asyncsavedata != null ? asyncsavedata.worldTime : world.getGameTime()); // Paper - async chunk unloading - nbttagcompound.putLong("LastUpdate", asyncsavedata != null ? asyncsavedata.worldTime : world.getGameTime()); // Paper - async chunk unloading
+ nbttagcompound.putLong("LastUpdate", asyncsavedata != null ? asyncsavedata.worldTime : world.getGameTime()); // Paper - async chunk unloading // Paper - diff on change + nbttagcompound.putLong("LastUpdate", asyncsavedata != null ? asyncsavedata.worldTime : world.getGameTime()); // Paper - async chunk unloading // Paper - diff on change
nbttagcompound.putLong("InhabitedTime", chunk.getInhabitedTime()); nbttagcompound.putLong("InhabitedTime", chunk.getInhabitedTime());
nbttagcompound.putString("Status", chunk.getStatus().getName()); nbttagcompound.putString("Status", BuiltInRegistries.CHUNK_STATUS.getKey(chunk.getStatus()).toString());
BlendingData blendingdata = chunk.getBlendingData(); BlendingData blendingdata = chunk.getBlendingData();
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java
index e9b13e4f70d9a556e6a7d022a952085051c1819d..71abf1c82ee4f5530bd29b3a97dec9fdb7705779 100644 index b4e7c9b317d532d4915932f8f79dfebf2b63ff16..2d93251abb1018381cf00dbbb120c8ea036710c6 100644
--- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java --- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java +++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java
@@ -41,7 +41,7 @@ public class ChunkStorage implements AutoCloseable { @@ -41,7 +41,7 @@ public class ChunkStorage implements AutoCloseable {
@ -87,7 +87,7 @@ index c8298a597818227de33a4afce4698ec0666cf758..6baceb6ce9021c489be6e79d338a9704
this.used.set(start, start + size); this.used.set(start, start + size);
} }
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
index cda87a66fe80bf910f629c64e36c1fecbad81d77..9bae47f99336c377beb72c4b50b7f01cb4db15da 100644 index eee5dfa165203463cb791e33530944c6b09e7eb7..98c436d84e4aedbdb805129fcdb6b871a1b4e3d9 100644
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java --- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java +++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
@@ -51,6 +51,355 @@ public class RegionFile implements AutoCloseable { @@ -51,6 +51,355 @@ public class RegionFile implements AutoCloseable {
@ -685,15 +685,20 @@ index cda87a66fe80bf910f629c64e36c1fecbad81d77..9bae47f99336c377beb72c4b50b7f01c
return bytebuffer; return bytebuffer;
} }
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
index 65fd57609e45ccd49ebfc1ba80d25243da13ab6e..d5b501bcb33a785ef0301bf6bb8d396b9d4fbb6a 100644 index c3d26756a716f151d3909ddfeacc47b28d05c498..5291bbe208397d73e6950e9f196bcd1da55c1fad 100644
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java --- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java +++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
@@ -26,7 +26,15 @@ public class RegionFileStorage implements AutoCloseable { @@ -25,6 +25,7 @@ public class RegionFileStorage implements AutoCloseable {
public final Long2ObjectLinkedOpenHashMap<RegionFile> regionCache = new Long2ObjectLinkedOpenHashMap();
private final Path folder; private final Path folder;
private final boolean sync; private final boolean sync;
+ private final boolean isChunkData; // Paper + private final boolean isChunkData; // Paper
+
// Paper start - cache regionfile does not exist state
static final int MAX_NON_EXISTING_CACHE = 1024 * 64;
@@ -56,6 +57,12 @@ public class RegionFileStorage implements AutoCloseable {
// Paper end - cache regionfile does not exist state
protected RegionFileStorage(Path directory, boolean dsync) { // Paper - protected constructor protected RegionFileStorage(Path directory, boolean dsync) { // Paper - protected constructor
+ // Paper start - add isChunkData param + // Paper start - add isChunkData param
+ this(directory, dsync, false); + this(directory, dsync, false);
@ -704,19 +709,25 @@ index 65fd57609e45ccd49ebfc1ba80d25243da13ab6e..d5b501bcb33a785ef0301bf6bb8d396b
this.folder = directory; this.folder = directory;
this.sync = dsync; this.sync = dsync;
} }
@@ -88,9 +96,9 @@ public class RegionFileStorage implements AutoCloseable { @@ -125,7 +132,7 @@ public class RegionFileStorage implements AutoCloseable {
FileUtil.createDirectoriesSafe(this.folder); // Paper - only create directory if not existing only - moved down
Path path = this.folder; Path path = this.folder;
int j = chunkcoordintpair.getRegionX(); int j = chunkcoordintpair.getRegionX();
- Path path1 = path.resolve("r." + j + "." + chunkcoordintpair.getRegionZ() + ".mca"); - Path path1 = path.resolve("r." + j + "." + chunkcoordintpair.getRegionZ() + ".mca");
+ Path path1 = path.resolve("r." + j + "." + chunkcoordintpair.getRegionZ() + ".mca"); // Paper - diff on change + Path path1 = path.resolve("r." + j + "." + chunkcoordintpair.getRegionZ() + ".mca"); // Paper - diff on change
if (existingOnly && !java.nio.file.Files.exists(path1)) return null; // CraftBukkit if (existingOnly && !java.nio.file.Files.exists(path1)) { // Paper start - cache regionfile does not exist state
this.markNonExisting(regionPos);
return null; // CraftBukkit
@@ -134,7 +141,7 @@ public class RegionFileStorage implements AutoCloseable {
}
// Paper end - cache regionfile does not exist state
FileUtil.createDirectoriesSafe(this.folder); // Paper - only create directory if not existing only - moved from above
- RegionFile regionfile1 = new RegionFile(path1, this.folder, this.sync); - RegionFile regionfile1 = new RegionFile(path1, this.folder, this.sync);
+ RegionFile regionfile1 = new RegionFile(path1, this.folder, this.sync, this.isChunkData); // Paper - allow for chunk regionfiles to regen header + RegionFile regionfile1 = new RegionFile(path1, this.folder, this.sync, this.isChunkData); // Paper - allow for chunk regionfiles to regen header
this.regionCache.putAndMoveToFirst(i, regionfile1); this.regionCache.putAndMoveToFirst(i, regionfile1);
// Paper start // Paper start
@@ -175,6 +183,13 @@ public class RegionFileStorage implements AutoCloseable { @@ -219,6 +226,13 @@ public class RegionFileStorage implements AutoCloseable {
if (regionfile == null) { if (regionfile == null) {
return null; return null;
} }
@ -730,7 +741,7 @@ index 65fd57609e45ccd49ebfc1ba80d25243da13ab6e..d5b501bcb33a785ef0301bf6bb8d396b
// CraftBukkit end // CraftBukkit end
try { // Paper try { // Paper
DataInputStream datainputstream = regionfile.getChunkDataInputStream(pos); DataInputStream datainputstream = regionfile.getChunkDataInputStream(pos);
@@ -191,6 +206,20 @@ public class RegionFileStorage implements AutoCloseable { @@ -235,6 +249,20 @@ public class RegionFileStorage implements AutoCloseable {
try { try {
if (datainputstream != null) { if (datainputstream != null) {
nbttagcompound = NbtIo.read((DataInput) datainputstream); nbttagcompound = NbtIo.read((DataInput) datainputstream);

Datei anzeigen

@ -173,7 +173,7 @@ index 0000000000000000000000000000000000000000..57d0cd3ad6f972e986c72a57f1a6e360
+ } + }
+} +}
diff --git a/src/main/java/net/minecraft/world/level/block/state/StateHolder.java b/src/main/java/net/minecraft/world/level/block/state/StateHolder.java diff --git a/src/main/java/net/minecraft/world/level/block/state/StateHolder.java b/src/main/java/net/minecraft/world/level/block/state/StateHolder.java
index b617f7e7a27284fbbad06d7a9926b938ba87cf18..170f5cb3f01a57ad76e3bbeacd5b7c7e52f29959 100644 index 89ba12d44865ecddebabbc39c769af4cd8c82702..5f285d190186a2ff5a61d05070593e1d633dd79a 100644
--- a/src/main/java/net/minecraft/world/level/block/state/StateHolder.java --- a/src/main/java/net/minecraft/world/level/block/state/StateHolder.java
+++ b/src/main/java/net/minecraft/world/level/block/state/StateHolder.java +++ b/src/main/java/net/minecraft/world/level/block/state/StateHolder.java
@@ -39,11 +39,13 @@ public abstract class StateHolder<O, S> { @@ -39,11 +39,13 @@ public abstract class StateHolder<O, S> {
@ -217,7 +217,7 @@ index b617f7e7a27284fbbad06d7a9926b938ba87cf18..170f5cb3f01a57ad76e3bbeacd5b7c7e
- Comparable<?> comparable = this.values.get(property); - Comparable<?> comparable = this.values.get(property);
- if (comparable == null) { - if (comparable == null) {
- throw new IllegalArgumentException("Cannot set property " + property + " as it does not exist in " + this.owner); - throw new IllegalArgumentException("Cannot set property " + property + " as it does not exist in " + this.owner);
- } else if (comparable == value) { - } else if (comparable.equals(value)) {
- return (S)this; - return (S)this;
- } else { - } else {
- S object = this.neighbours.get(property, value); - S object = this.neighbours.get(property, value);

Datei anzeigen

@ -7,10 +7,10 @@ Subject: [PATCH] Detail more information in watchdog dumps
- Dump player name, player uuid, position, and world for packet handling - Dump player name, player uuid, position, and world for packet handling
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
index d7dd0b806d8d8e3f04f165a2b29097a5c1bcd199..b967c24e9ace2b6539e94bcc63b69e0c934a72be 100644 index 358b41541284392f9a7a0ef3156e8adc8c005cc4..b7b8ac7f0e93c183e0e7f39cb753f28daace843f 100644
--- a/src/main/java/net/minecraft/network/Connection.java --- a/src/main/java/net/minecraft/network/Connection.java
+++ b/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java
@@ -522,7 +522,13 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -349,7 +349,13 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
if (!(this.packetListener instanceof net.minecraft.server.network.ServerLoginPacketListenerImpl loginPacketListener) if (!(this.packetListener instanceof net.minecraft.server.network.ServerLoginPacketListenerImpl loginPacketListener)
|| loginPacketListener.state != net.minecraft.server.network.ServerLoginPacketListenerImpl.State.READY_TO_ACCEPT || loginPacketListener.state != net.minecraft.server.network.ServerLoginPacketListenerImpl.State.READY_TO_ACCEPT
|| Connection.joinAttemptsThisTick++ < MAX_PER_TICK) { || Connection.joinAttemptsThisTick++ < MAX_PER_TICK) {
@ -76,10 +76,10 @@ index 4a1148a76020089caf01f888f87afdbb35788dc0..52a84eeb3b7df782cbf91aac6df42fb8
}); });
throw RunningOnDifferentThreadException.RUNNING_ON_DIFFERENT_THREAD; throw RunningOnDifferentThreadException.RUNNING_ON_DIFFERENT_THREAD;
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 8faf55969232d44b999231b219a208e049a72755..1f683d734b9e272c8f4c48d922f3dcd12d0ffd1a 100644 index 418bf659d31c5810d786064a76779cfa39943020..f8bcf1239c18a6334936cec483f2ae316429a894 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java --- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -1059,7 +1059,26 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -1119,7 +1119,26 @@ public class ServerLevel extends Level implements WorldGenLevel {
} }
@ -106,7 +106,7 @@ index 8faf55969232d44b999231b219a208e049a72755..1f683d734b9e272c8f4c48d922f3dcd1
++TimingHistory.entityTicks; // Paper - timings ++TimingHistory.entityTicks; // Paper - timings
// Spigot start // Spigot start
co.aikar.timings.Timing timer; // Paper co.aikar.timings.Timing timer; // Paper
@@ -1099,7 +1118,13 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -1159,7 +1178,13 @@ public class ServerLevel extends Level implements WorldGenLevel {
this.tickPassenger(entity, entity1); this.tickPassenger(entity, entity1);
} }
// } finally { timer.stopTiming(); } // Paper - timings - move up // } finally { timer.stopTiming(); } // Paper - timings - move up
@ -122,10 +122,10 @@ index 8faf55969232d44b999231b219a208e049a72755..1f683d734b9e272c8f4c48d922f3dcd1
private void tickPassenger(Entity vehicle, Entity passenger) { private void tickPassenger(Entity vehicle, Entity passenger) {
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index c79f7de53d8d61044a756b2a973f71bb5af74bfc..6da3b1d6e09f5c8c09234b4da0aeaba5ab632dd7 100644 index fe750fd202f9a2a02f07752a11b1a4a8368afa5e..eb9f56de921edfefc0655be47449ffbc97145e07 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java --- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -973,7 +973,42 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { @@ -991,7 +991,42 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
return this.onGround; return this.onGround;
} }
@ -168,8 +168,8 @@ index c79f7de53d8d61044a756b2a973f71bb5af74bfc..6da3b1d6e09f5c8c09234b4da0aeaba5
if (this.noPhysics) { if (this.noPhysics) {
this.setPos(this.getX() + movement.x, this.getY() + movement.y, this.getZ() + movement.z); this.setPos(this.getX() + movement.x, this.getY() + movement.y, this.getZ() + movement.z);
} else { } else {
@@ -1146,6 +1181,13 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { @@ -1187,6 +1222,13 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
this.level.getProfiler().pop(); return false;
} }
} }
+ // Paper start - detailed watchdog information + // Paper start - detailed watchdog information
@ -182,7 +182,7 @@ index c79f7de53d8d61044a756b2a973f71bb5af74bfc..6da3b1d6e09f5c8c09234b4da0aeaba5
} }
protected boolean isHorizontalCollisionMinor(Vec3 adjustedMovement) { protected boolean isHorizontalCollisionMinor(Vec3 adjustedMovement) {
@@ -4098,7 +4140,9 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { @@ -4197,7 +4239,9 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
} }
public void setDeltaMovement(Vec3 velocity) { public void setDeltaMovement(Vec3 velocity) {
@ -192,7 +192,7 @@ index c79f7de53d8d61044a756b2a973f71bb5af74bfc..6da3b1d6e09f5c8c09234b4da0aeaba5
} }
public void addDeltaMovement(Vec3 velocity) { public void addDeltaMovement(Vec3 velocity) {
@@ -4184,7 +4228,9 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { @@ -4283,7 +4327,9 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
} }
// Paper end - fix MC-4 // Paper end - fix MC-4
if (this.position.x != x || this.position.y != y || this.position.z != z) { if (this.position.x != x || this.position.y != y || this.position.z != z) {

Datei anzeigen

@ -5,10 +5,10 @@ Subject: [PATCH] Manually inline methods in BlockPosition
diff --git a/src/main/java/net/minecraft/core/BlockPos.java b/src/main/java/net/minecraft/core/BlockPos.java diff --git a/src/main/java/net/minecraft/core/BlockPos.java b/src/main/java/net/minecraft/core/BlockPos.java
index 5a42e0315fb44c2a0390c51b123501498140238a..b37e0ff164a894d2033fb94bbbc2f630a0e66bcd 100644 index 441ea6b9fd55a5288f264472d7297728d0546d6b..83cab746d1d6fe25c043c8aee28c39412b90c127 100644
--- a/src/main/java/net/minecraft/core/BlockPos.java --- a/src/main/java/net/minecraft/core/BlockPos.java
+++ b/src/main/java/net/minecraft/core/BlockPos.java +++ b/src/main/java/net/minecraft/core/BlockPos.java
@@ -474,9 +474,9 @@ public class BlockPos extends Vec3i { @@ -515,9 +515,9 @@ public class BlockPos extends Vec3i {
} }
public BlockPos.MutableBlockPos set(int x, int y, int z) { public BlockPos.MutableBlockPos set(int x, int y, int z) {
@ -21,7 +21,7 @@ index 5a42e0315fb44c2a0390c51b123501498140238a..b37e0ff164a894d2033fb94bbbc2f630
return this; return this;
} }
@@ -540,19 +540,19 @@ public class BlockPos extends Vec3i { @@ -581,19 +581,19 @@ public class BlockPos extends Vec3i {
// Paper start - comment out useless overrides @Override - TODO figure out why this is suddenly important to keep // Paper start - comment out useless overrides @Override - TODO figure out why this is suddenly important to keep
@Override @Override
public BlockPos.MutableBlockPos setX(int i) { public BlockPos.MutableBlockPos setX(int i) {