From 6745971d4ef5b725ae087e4afc97b13f787c6ad7 Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Mon, 27 Jan 2020 16:16:53 -0800 Subject: [PATCH] Performance patches prerequisite (#2802) Prereq changes for the coming storm of performance patches. Includes optimising incremental saving --- ...ies-option-to-debug-dupe-uuid-issues.patch | 8 +- ...dd-configurable-portal-search-radius.patch | 8 +- .../Add-exception-reporting-event.patch | 22 +- ...dd-some-Debug-to-Chunk-Entity-slices.patch | 6 +- Spigot-Server-Patches/Anti-Xray.patch | 40 +- .../Asynchronous-chunk-IO-and-loading.patch | 92 +- ...uto-fix-bad-Y-levels-on-player-login.patch | 2 +- ...opper-searches-if-there-are-no-items.patch | 6 +- .../Basic-PlayerProfile-API.patch | 18 +- .../Cache-user-authenticator-threads.patch | 2 +- .../Call-player-spectator-target-events.patch | 2 +- ...arseException-in-Entity-and-TE-names.patch | 10 +- .../Chunk-debug-command.patch | 12 +- .../Configurable-Chunk-Inhabited-Time.patch | 4 +- ...le-Keep-Spawn-Loaded-range-per-world.patch | 12 +- ...figurable-container-update-tick-rate.patch | 4 +- .../Configurable-end-credits.patch | 4 +- .../Duplicate-UUID-Resolve-Option.patch | 10 +- ...Entity-AddTo-RemoveFrom-World-Events.patch | 2 +- Spigot-Server-Patches/Entity-Origin-API.patch | 12 +- .../Entity-getEntitySpawnReason.patch | 8 +- ...ld.spawnParticle-API-and-add-Builder.patch | 4 +- .../Fix-Double-World-Add-issues.patch | 2 +- .../Fix-World-isChunkGenerated-calls.patch | 29 +- ...h-entity-loss-due-to-unloaded-chunks.patch | 2 +- .../Fix-spawn-radius-being-treated-as-0.patch | 2 +- ...-sneak-when-changing-worlds-MC-10657.patch | 4 +- ...ead-Entities-in-entityList-iteration.patch | 10 +- .../Implement-PlayerLocaleChangeEvent.patch | 4 +- ...item-frames-performance-and-bug-fixe.patch | 8 +- .../Improve-death-events.patch | 20 +- .../InventoryCloseEvent-Reason-API.patch | 16 +- ...mit-lightning-strike-effect-distance.patch | 6 +- Spigot-Server-Patches/MC-Dev-fixes.patch | 151 +- Spigot-Server-Patches/MC-Utils.patch | 2204 ++++++++++++++++- ...more-aggressive-in-the-chunk-unload-.patch | 2 +- ...-anytime-entities-change-to-guarante.patch | 4 +- ...-being-ticked-when-notifying-navigat.patch | 2 +- ...e-getChunkAt-calls-for-loaded-chunks.patch | 86 + ...Location-getType-and-getBlockData-fo.patch | 8 +- ...tion-to-remove-corrupt-tile-entities.patch | 4 +- .../PlayerDeathEvent-getItemsToKeep.patch | 2 +- ...layerDeathEvent-shouldDropExperience.patch | 2 +- .../PlayerNaturallySpawnCreaturesEvent.patch | 2 +- .../Properly-fix-item-duplication-bug.patch | 4 +- ...nilla-entity-warnings-for-duplicates.patch | 2 +- ...ers-that-dismount-from-other-players.patch | 2 +- Spigot-Server-Patches/Reduce-sync-loads.patch | 10 +- ...ve-invalid-mob-spawner-tile-entities.patch | 2 +- ...Remove-unused-World-Tile-Entity-List.patch | 4 +- .../Reset-players-airTicks-on-respawn.patch | 4 +- ...sition-the-first-time-an-entity-is-s.patch | 4 +- ...ets-from-world-player-list-not-serve.patch | 6 +- .../Speedup-BlockPos-by-fixing-inlining.patch | 7 +- ...ts-for-each-Entity-Block-Entity-Type.patch | 2 +- ...to-current-Chunk-for-Entity-and-Bloc.patch | 8 +- .../String-based-Action-Bar-API.patch | 4 +- Spigot-Server-Patches/Timings-v2.patch | 58 +- ...Status-cache-when-saving-protochunks.patch | 2 +- ...vehicle-tracking-issue-on-disconnect.patch | 2 +- ...entity-dismount-during-teleportation.patch | 8 +- ...ement-optional-per-player-mob-spawns.patch | 20 +- .../incremental-chunk-saving.patch | 160 +- scripts/importmcdev.sh | 1 + 64 files changed, 2783 insertions(+), 385 deletions(-) create mode 100644 Spigot-Server-Patches/Optimise-getChunkAt-calls-for-loaded-chunks.patch diff --git a/Spigot-Server-Patches/Add-Debug-Entities-option-to-debug-dupe-uuid-issues.patch b/Spigot-Server-Patches/Add-Debug-Entities-option-to-debug-dupe-uuid-issues.patch index 16dd249fd9..16bb1f7d1a 100644 --- a/Spigot-Server-Patches/Add-Debug-Entities-option-to-debug-dupe-uuid-issues.patch +++ b/Spigot-Server-Patches/Add-Debug-Entities-option-to-debug-dupe-uuid-issues.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Add Debug Entities option to debug dupe uuid issues Add -Ddebug.entities=true to your JVM flags to gain more information diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index 591e2ad56..e5987be45 100644 +index 591e2ad56c..e5987be450 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -0,0 +0,0 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke @@ -19,7 +19,7 @@ index 591e2ad56..e5987be45 100644 if (bukkitEntity == null) { bukkitEntity = CraftEntity.getEntity(world.getServer(), this); diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java -index 426beb181..7edca1744 100644 +index bf80af2354..e93741a8e8 100644 --- a/src/main/java/net/minecraft/server/PlayerChunkMap.java +++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java @@ -0,0 +0,0 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { @@ -40,7 +40,7 @@ index 426beb181..7edca1744 100644 protected void g() { diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java -index 9987adb6f..9d9e8fed2 100644 +index 9987adb6f4..9d9e8fed27 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -0,0 +0,0 @@ public abstract class World implements GeneratorAccess, AutoCloseable { @@ -52,7 +52,7 @@ index 9987adb6f..9d9e8fed2 100644 public boolean captureBlockStates = false; public boolean captureTreeGeneration = false; diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index 389036405..224f6d151 100644 +index d46a664bdb..3d5a50ddcc 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -0,0 +0,0 @@ public class WorldServer extends World { diff --git a/Spigot-Server-Patches/Add-configurable-portal-search-radius.patch b/Spigot-Server-Patches/Add-configurable-portal-search-radius.patch index 8a65485751..de8363bed1 100644 --- a/Spigot-Server-Patches/Add-configurable-portal-search-radius.patch +++ b/Spigot-Server-Patches/Add-configurable-portal-search-radius.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Add configurable portal search radius diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index 62e793b71..cd47a4ca0 100644 +index 62e793b71b..cd47a4ca06 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -0,0 +0,0 @@ public class PaperWorldConfig { @@ -21,7 +21,7 @@ index 62e793b71..cd47a4ca0 100644 + } } diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index 1ce080287..be39f38d5 100644 +index 1ce0802879..be39f38d56 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -0,0 +0,0 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke @@ -34,7 +34,7 @@ index 1ce080287..be39f38d5 100644 return null; } diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java -index f03395e2d..4289aadc6 100644 +index f0f456983f..b5101af011 100644 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/EntityPlayer.java @@ -0,0 +0,0 @@ public class EntityPlayer extends EntityHuman implements ICrafting { @@ -49,7 +49,7 @@ index f03395e2d..4289aadc6 100644 if (event.isCancelled() || event.getTo() == null) { return null; diff --git a/src/main/java/net/minecraft/server/PortalTravelAgent.java b/src/main/java/net/minecraft/server/PortalTravelAgent.java -index 19c54f1dd..f84dd6d9b 100644 +index 19c54f1dde..f84dd6d9be 100644 --- a/src/main/java/net/minecraft/server/PortalTravelAgent.java +++ b/src/main/java/net/minecraft/server/PortalTravelAgent.java @@ -0,0 +0,0 @@ public class PortalTravelAgent { diff --git a/Spigot-Server-Patches/Add-exception-reporting-event.patch b/Spigot-Server-Patches/Add-exception-reporting-event.patch index 16e6ac8b9d..977e50db24 100644 --- a/Spigot-Server-Patches/Add-exception-reporting-event.patch +++ b/Spigot-Server-Patches/Add-exception-reporting-event.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Add exception reporting event diff --git a/src/main/java/com/destroystokyo/paper/ServerSchedulerReportingWrapper.java b/src/main/java/com/destroystokyo/paper/ServerSchedulerReportingWrapper.java new file mode 100644 -index 000000000..f699ce18c +index 0000000000..f699ce18ca --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/ServerSchedulerReportingWrapper.java @@ -0,0 +0,0 @@ @@ -49,7 +49,7 @@ index 000000000..f699ce18c + } +} diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index f62429277..be32b31e7 100644 +index e7268074b4..6ed23ea6c8 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java @@ -0,0 +0,0 @@ @@ -80,7 +80,7 @@ index f62429277..be32b31e7 100644 } } diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java -index 99afce39a..a3ef6dba7 100644 +index 1ba34cfaa9..3ef7e4561f 100644 --- a/src/main/java/net/minecraft/server/ChunkProviderServer.java +++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java @@ -0,0 +0,0 @@ import java.util.function.BooleanSupplier; @@ -94,7 +94,7 @@ index 99afce39a..a3ef6dba7 100644 public class ChunkProviderServer extends IChunkProvider { diff --git a/src/main/java/net/minecraft/server/NameReferencingFileConverter.java b/src/main/java/net/minecraft/server/NameReferencingFileConverter.java -index c9c2b0025..1422503e1 100644 +index c9c2b00251..1422503e11 100644 --- a/src/main/java/net/minecraft/server/NameReferencingFileConverter.java +++ b/src/main/java/net/minecraft/server/NameReferencingFileConverter.java @@ -0,0 +0,0 @@ @@ -121,7 +121,7 @@ index c9c2b0025..1422503e1 100644 } // CraftBukkit end diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java -index 89433004d..1627aeeef 100644 +index b2260498cb..c575ff57dd 100644 --- a/src/main/java/net/minecraft/server/PlayerChunkMap.java +++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java @@ -0,0 +0,0 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { @@ -141,7 +141,7 @@ index 89433004d..1627aeeef 100644 } } diff --git a/src/main/java/net/minecraft/server/RegionFile.java b/src/main/java/net/minecraft/server/RegionFile.java -index 187c4e0f5..c2312a227 100644 +index 187c4e0f58..c2312a227c 100644 --- a/src/main/java/net/minecraft/server/RegionFile.java +++ b/src/main/java/net/minecraft/server/RegionFile.java @@ -0,0 +0,0 @@ public class RegionFile implements AutoCloseable { @@ -161,7 +161,7 @@ index 187c4e0f5..c2312a227 100644 } finally { if (filechannel != null) { diff --git a/src/main/java/net/minecraft/server/SpawnerCreature.java b/src/main/java/net/minecraft/server/SpawnerCreature.java -index 8ba344df6..02157d051 100644 +index 8ba344df64..02157d051f 100644 --- a/src/main/java/net/minecraft/server/SpawnerCreature.java +++ b/src/main/java/net/minecraft/server/SpawnerCreature.java @@ -0,0 +0,0 @@ import org.apache.logging.log4j.LogManager; @@ -189,7 +189,7 @@ index 8ba344df6..02157d051 100644 } diff --git a/src/main/java/net/minecraft/server/VillageSiege.java b/src/main/java/net/minecraft/server/VillageSiege.java -index d5e9bae70..1bcf01c09 100644 +index d5e9bae709..1bcf01c09a 100644 --- a/src/main/java/net/minecraft/server/VillageSiege.java +++ b/src/main/java/net/minecraft/server/VillageSiege.java @@ -0,0 +0,0 @@ @@ -209,7 +209,7 @@ index d5e9bae70..1bcf01c09 100644 } diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java -index cb369665c..026007891 100644 +index cb369665c4..0260078911 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -0,0 +0,0 @@ package net.minecraft.server; @@ -248,7 +248,7 @@ index cb369665c..026007891 100644 return; // Paper end diff --git a/src/main/java/net/minecraft/server/WorldPersistentData.java b/src/main/java/net/minecraft/server/WorldPersistentData.java -index 19e68a783..a2a25cf6a 100644 +index 19e68a7831..a2a25cf6a4 100644 --- a/src/main/java/net/minecraft/server/WorldPersistentData.java +++ b/src/main/java/net/minecraft/server/WorldPersistentData.java @@ -0,0 +0,0 @@ public class WorldPersistentData { @@ -260,7 +260,7 @@ index 19e68a783..a2a25cf6a 100644 } finally { if (pushbackinputstream != null) { diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java -index 8823f94f7..552daf437 100644 +index 8823f94f7b..552daf4376 100644 --- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java +++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java @@ -0,0 +0,0 @@ import java.util.concurrent.atomic.AtomicInteger; diff --git a/Spigot-Server-Patches/Add-some-Debug-to-Chunk-Entity-slices.patch b/Spigot-Server-Patches/Add-some-Debug-to-Chunk-Entity-slices.patch index 8c6834baa5..20aa4bf878 100644 --- a/Spigot-Server-Patches/Add-some-Debug-to-Chunk-Entity-slices.patch +++ b/Spigot-Server-Patches/Add-some-Debug-to-Chunk-Entity-slices.patch @@ -9,7 +9,7 @@ This should hopefully avoid duplicate entities ever being created if the entity was to end up in 2 different chunk slices diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index 6774c6480..b156f5428 100644 +index 28e5105ffe..2004f7fbe1 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java @@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess { @@ -39,8 +39,8 @@ index 6774c6480..b156f5428 100644 if (!entity.inChunk || entity.getCurrentChunk() != this) entityCounts.increment(entity.getMinecraftKeyString()); // Paper entity.inChunk = true; @@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess { - entity.chunkY = k; entity.chunkZ = this.loc.z; + this.entities.add(entity); // Paper - per chunk entity list this.entitySlices[k].add(entity); + entity.entitySlice = this.entitySlices[k]; // Paper this.markDirty(); // Paper @@ -57,7 +57,7 @@ index 6774c6480..b156f5428 100644 return; } diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index 8e23f336a..e761f7148 100644 +index 8e23f336a8..e761f71487 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -0,0 +0,0 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke diff --git a/Spigot-Server-Patches/Anti-Xray.patch b/Spigot-Server-Patches/Anti-Xray.patch index 9e492fe388..a197a4b9f3 100644 --- a/Spigot-Server-Patches/Anti-Xray.patch +++ b/Spigot-Server-Patches/Anti-Xray.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Anti-Xray diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index 486761521..df24e3297 100644 +index 4867615215..df24e3297b 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -0,0 +0,0 @@ @@ -66,7 +66,7 @@ index 486761521..df24e3297 100644 } diff --git a/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockController.java b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockController.java new file mode 100644 -index 000000000..f7e376ce6 +index 0000000000..f7e376ce6a --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockController.java @@ -0,0 +0,0 @@ @@ -118,7 +118,7 @@ index 000000000..f7e376ce6 +} diff --git a/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java new file mode 100644 -index 000000000..23626bef3 +index 0000000000..23626bef3a --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java @@ -0,0 +0,0 @@ @@ -906,7 +906,7 @@ index 000000000..23626bef3 +} diff --git a/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketInfo.java b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketInfo.java new file mode 100644 -index 000000000..a68bace35 +index 0000000000..a68bace353 --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketInfo.java @@ -0,0 +0,0 @@ @@ -993,7 +993,7 @@ index 000000000..a68bace35 +} diff --git a/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketInfoAntiXray.java b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketInfoAntiXray.java new file mode 100644 -index 000000000..067dfb2f1 +index 0000000000..067dfb2f14 --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketInfoAntiXray.java @@ -0,0 +0,0 @@ @@ -1030,7 +1030,7 @@ index 000000000..067dfb2f1 +} diff --git a/src/main/java/com/destroystokyo/paper/antixray/DataBitsReader.java b/src/main/java/com/destroystokyo/paper/antixray/DataBitsReader.java new file mode 100644 -index 000000000..cc586827a +index 0000000000..cc586827aa --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/antixray/DataBitsReader.java @@ -0,0 +0,0 @@ @@ -1092,7 +1092,7 @@ index 000000000..cc586827a +} diff --git a/src/main/java/com/destroystokyo/paper/antixray/DataBitsWriter.java b/src/main/java/com/destroystokyo/paper/antixray/DataBitsWriter.java new file mode 100644 -index 000000000..37093419c +index 0000000000..37093419cf --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/antixray/DataBitsWriter.java @@ -0,0 +0,0 @@ @@ -1181,7 +1181,7 @@ index 000000000..37093419c + } +} diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index 14ec31f0a..863a2222f 100644 +index 76e87c211b..3fdcc2e5d4 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java @@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess { @@ -1194,7 +1194,7 @@ index 14ec31f0a..863a2222f 100644 } diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java -index 961228e9d..a950ad801 100644 +index 961228e9df..a950ad801d 100644 --- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java +++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java @@ -0,0 +0,0 @@ public class ChunkRegionLoader { @@ -1216,7 +1216,7 @@ index 961228e9d..a950ad801 100644 protochunk.a(biomestorage); object = protochunk; diff --git a/src/main/java/net/minecraft/server/ChunkSection.java b/src/main/java/net/minecraft/server/ChunkSection.java -index 0d5deee36..4526527ac 100644 +index 0d5deee365..4526527aca 100644 --- a/src/main/java/net/minecraft/server/ChunkSection.java +++ b/src/main/java/net/minecraft/server/ChunkSection.java @@ -0,0 +0,0 @@ public class ChunkSection { @@ -1255,7 +1255,7 @@ index 0d5deee36..4526527ac 100644 public IBlockData getType(int i, int j, int k) { diff --git a/src/main/java/net/minecraft/server/DataPaletteBlock.java b/src/main/java/net/minecraft/server/DataPaletteBlock.java -index 2c1d1b1a5..44aed6727 100644 +index 2c1d1b1a55..44aed67274 100644 --- a/src/main/java/net/minecraft/server/DataPaletteBlock.java +++ b/src/main/java/net/minecraft/server/DataPaletteBlock.java @@ -0,0 +0,0 @@ package net.minecraft.server; @@ -1377,7 +1377,7 @@ index 2c1d1b1a5..44aed6727 100644 if (this.h == this.b) { diff --git a/src/main/java/net/minecraft/server/NetworkManager.java b/src/main/java/net/minecraft/server/NetworkManager.java -index e156804f7..96a785af2 100644 +index e156804f7a..96a785af27 100644 --- a/src/main/java/net/minecraft/server/NetworkManager.java +++ b/src/main/java/net/minecraft/server/NetworkManager.java @@ -0,0 +0,0 @@ public class NetworkManager extends SimpleChannelInboundHandler> { @@ -1440,7 +1440,7 @@ index e156804f7..96a785af2 100644 public void a() { this.o(); diff --git a/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java b/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java -index 47710067a..ef7ade797 100644 +index 47710067a6..ef7ade797b 100644 --- a/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java +++ b/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java @@ -0,0 +0,0 @@ @@ -1533,7 +1533,7 @@ index 47710067a..ef7ade797 100644 } diff --git a/src/main/java/net/minecraft/server/PlayerChunk.java b/src/main/java/net/minecraft/server/PlayerChunk.java -index 6f2cca07e..7a1578afa 100644 +index 5108d3ee98..b556a8fefa 100644 --- a/src/main/java/net/minecraft/server/PlayerChunk.java +++ b/src/main/java/net/minecraft/server/PlayerChunk.java @@ -0,0 +0,0 @@ public class PlayerChunk { @@ -1558,7 +1558,7 @@ index 6f2cca07e..7a1578afa 100644 this.a(new PacketPlayOutMultiBlockChange(this.dirtyCount, this.dirtyBlocks, chunk), false); diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java -index 4e9edd759..6728e84b2 100644 +index 8bd212388a..be3dcf375b 100644 --- a/src/main/java/net/minecraft/server/PlayerChunkMap.java +++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java @@ -0,0 +0,0 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { @@ -1580,7 +1580,7 @@ index 4e9edd759..6728e84b2 100644 } diff --git a/src/main/java/net/minecraft/server/PlayerInteractManager.java b/src/main/java/net/minecraft/server/PlayerInteractManager.java -index e2e5c17c2..ce4340a47 100644 +index e2e5c17c24..ce4340a476 100644 --- a/src/main/java/net/minecraft/server/PlayerInteractManager.java +++ b/src/main/java/net/minecraft/server/PlayerInteractManager.java @@ -0,0 +0,0 @@ public class PlayerInteractManager { @@ -1593,7 +1593,7 @@ index e2e5c17c2..ce4340a47 100644 public void a(BlockPosition blockposition, PacketPlayInBlockDig.EnumPlayerDigType packetplayinblockdig_enumplayerdigtype, String s) { diff --git a/src/main/java/net/minecraft/server/ProtoChunk.java b/src/main/java/net/minecraft/server/ProtoChunk.java -index 39339fa27..f376e2106 100644 +index 39339fa275..f376e21068 100644 --- a/src/main/java/net/minecraft/server/ProtoChunk.java +++ b/src/main/java/net/minecraft/server/ProtoChunk.java @@ -0,0 +0,0 @@ public class ProtoChunk implements IChunkAccess { @@ -1636,7 +1636,7 @@ index 39339fa27..f376e2106 100644 return this.j[i]; diff --git a/src/main/java/net/minecraft/server/TicketType.java b/src/main/java/net/minecraft/server/TicketType.java -index a905a29e7..335b64435 100644 +index a905a29e75..335b644351 100644 --- a/src/main/java/net/minecraft/server/TicketType.java +++ b/src/main/java/net/minecraft/server/TicketType.java @@ -0,0 +0,0 @@ public class TicketType { @@ -1648,7 +1648,7 @@ index a905a29e7..335b64435 100644 public static TicketType a(String s, Comparator comparator) { return new TicketType<>(s, comparator, 0L); diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java -index d981dfd43..a1b777ac0 100644 +index d981dfd434..a1b777ac03 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -0,0 +0,0 @@ package net.minecraft.server; @@ -1685,7 +1685,7 @@ index d981dfd43..a1b777ac0 100644 if (iblockdata1 == null) { // CraftBukkit start - remove blockstate if failed diff --git a/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java b/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java -index 7772d5900..4570ed999 100644 +index 7772d59005..4570ed9991 100644 --- a/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java +++ b/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java @@ -0,0 +0,0 @@ public final class CraftChunkData implements ChunkGenerator.ChunkData { diff --git a/Spigot-Server-Patches/Asynchronous-chunk-IO-and-loading.patch b/Spigot-Server-Patches/Asynchronous-chunk-IO-and-loading.patch index 256cb29783..3a4c12782d 100644 --- a/Spigot-Server-Patches/Asynchronous-chunk-IO-and-loading.patch +++ b/Spigot-Server-Patches/Asynchronous-chunk-IO-and-loading.patch @@ -121,7 +121,7 @@ tasks required to be executed by the chunk load task (i.e lighting and some poi tasks). diff --git a/src/main/java/co/aikar/timings/WorldTimingsHandler.java b/src/main/java/co/aikar/timings/WorldTimingsHandler.java -index 3a79cde59..8de6c4816 100644 +index 3a79cde595..8de6c4816c 100644 --- a/src/main/java/co/aikar/timings/WorldTimingsHandler.java +++ b/src/main/java/co/aikar/timings/WorldTimingsHandler.java @@ -0,0 +0,0 @@ public class WorldTimingsHandler { @@ -161,7 +161,7 @@ index 3a79cde59..8de6c4816 100644 public static Timing getTickList(WorldServer worldserver, String timingsType) { diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java -index 546a1cfe0..1d7d1ffbf 100644 +index 546a1cfe0a..1d7d1ffbf7 100644 --- a/src/main/java/com/destroystokyo/paper/PaperConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java @@ -0,0 +0,0 @@ @@ -237,7 +237,7 @@ index 546a1cfe0..1d7d1ffbf 100644 + } } diff --git a/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java -index 23626bef3..1edcecd2e 100644 +index 23626bef3a..1edcecd2ee 100644 --- a/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java +++ b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java @@ -0,0 +0,0 @@ import java.util.concurrent.Executors; @@ -318,7 +318,7 @@ index 23626bef3..1edcecd2e 100644 diff --git a/src/main/java/com/destroystokyo/paper/io/IOUtil.java b/src/main/java/com/destroystokyo/paper/io/IOUtil.java new file mode 100644 -index 000000000..5af0ac3d9 +index 0000000000..5af0ac3d9e --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/io/IOUtil.java @@ -0,0 +0,0 @@ @@ -386,7 +386,7 @@ index 000000000..5af0ac3d9 +} diff --git a/src/main/java/com/destroystokyo/paper/io/PaperFileIOThread.java b/src/main/java/com/destroystokyo/paper/io/PaperFileIOThread.java new file mode 100644 -index 000000000..4f10a8311 +index 0000000000..4f10a8311e --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/io/PaperFileIOThread.java @@ -0,0 +0,0 @@ @@ -1053,7 +1053,7 @@ index 000000000..4f10a8311 +} diff --git a/src/main/java/com/destroystokyo/paper/io/PrioritizedTaskQueue.java b/src/main/java/com/destroystokyo/paper/io/PrioritizedTaskQueue.java new file mode 100644 -index 000000000..78bd238f4 +index 0000000000..78bd238f4c --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/io/PrioritizedTaskQueue.java @@ -0,0 +0,0 @@ @@ -1335,7 +1335,7 @@ index 000000000..78bd238f4 +} diff --git a/src/main/java/com/destroystokyo/paper/io/QueueExecutorThread.java b/src/main/java/com/destroystokyo/paper/io/QueueExecutorThread.java new file mode 100644 -index 000000000..ee906b594 +index 0000000000..ee906b594b --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/io/QueueExecutorThread.java @@ -0,0 +0,0 @@ @@ -1582,7 +1582,7 @@ index 000000000..ee906b594 +} diff --git a/src/main/java/com/destroystokyo/paper/io/chunk/ChunkLoadTask.java b/src/main/java/com/destroystokyo/paper/io/chunk/ChunkLoadTask.java new file mode 100644 -index 000000000..305da4786 +index 0000000000..305da47868 --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/io/chunk/ChunkLoadTask.java @@ -0,0 +0,0 @@ @@ -1737,7 +1737,7 @@ index 000000000..305da4786 +} diff --git a/src/main/java/com/destroystokyo/paper/io/chunk/ChunkSaveTask.java b/src/main/java/com/destroystokyo/paper/io/chunk/ChunkSaveTask.java new file mode 100644 -index 000000000..60312b85f +index 0000000000..60312b85f9 --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/io/chunk/ChunkSaveTask.java @@ -0,0 +0,0 @@ @@ -1855,7 +1855,7 @@ index 000000000..60312b85f +} diff --git a/src/main/java/com/destroystokyo/paper/io/chunk/ChunkTask.java b/src/main/java/com/destroystokyo/paper/io/chunk/ChunkTask.java new file mode 100644 -index 000000000..1dfa8abfd +index 0000000000..1dfa8abfd8 --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/io/chunk/ChunkTask.java @@ -0,0 +0,0 @@ @@ -1901,7 +1901,7 @@ index 000000000..1dfa8abfd +} diff --git a/src/main/java/com/destroystokyo/paper/io/chunk/ChunkTaskManager.java b/src/main/java/com/destroystokyo/paper/io/chunk/ChunkTaskManager.java new file mode 100644 -index 000000000..715a2dd8d +index 0000000000..715a2dd8d2 --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/io/chunk/ChunkTaskManager.java @@ -0,0 +0,0 @@ @@ -2361,7 +2361,7 @@ index 000000000..715a2dd8d + +} diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java -index 761399e28..58299562e 100644 +index 9e75647953..e10035d461 100644 --- a/src/main/java/net/minecraft/server/ChunkProviderServer.java +++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java @@ -0,0 +0,0 @@ public class ChunkProviderServer extends IChunkProvider { @@ -2531,7 +2531,7 @@ index 761399e28..58299562e 100644 } finally { playerChunkMap.callbackExecutor.run(); diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java -index a950ad801..26f1a4b09 100644 +index a950ad801d..26f1a4b095 100644 --- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java +++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java @@ -0,0 +0,0 @@ import it.unimi.dsi.fastutil.longs.LongOpenHashSet; @@ -2800,7 +2800,7 @@ index a950ad801..26f1a4b09 100644 nbttagcompound1.set("PostProcessing", a(ichunkaccess.l())); diff --git a/src/main/java/net/minecraft/server/ChunkStatus.java b/src/main/java/net/minecraft/server/ChunkStatus.java -index 134a4f0b7..88f167461 100644 +index 134a4f0b7d..88f1674616 100644 --- a/src/main/java/net/minecraft/server/ChunkStatus.java +++ b/src/main/java/net/minecraft/server/ChunkStatus.java @@ -0,0 +0,0 @@ public class ChunkStatus { @@ -2812,7 +2812,7 @@ index 134a4f0b7..88f167461 100644 return ChunkStatus.r.getInt(chunkstatus.c()); } diff --git a/src/main/java/net/minecraft/server/IAsyncTaskHandler.java b/src/main/java/net/minecraft/server/IAsyncTaskHandler.java -index 7e5ece9d5..cfe43e882 100644 +index 7e5ece9d50..cfe43e882e 100644 --- a/src/main/java/net/minecraft/server/IAsyncTaskHandler.java +++ b/src/main/java/net/minecraft/server/IAsyncTaskHandler.java @@ -0,0 +0,0 @@ public abstract class IAsyncTaskHandler implements Mailbox { - return ichunkaccess instanceof ProtoChunkExtension || ichunkaccess instanceof Chunk; -- }).filter(this::saveChunk).forEach((ichunkaccess) -> { -+ }).filter((chunk) -> this.saveChunk(chunk, true)).forEach((ichunkaccess) -> { // Paper - async io for chunk save - mutableboolean.setTrue(); - }); - } while (mutableboolean.isTrue()); @@ -0,0 +0,0 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { this.b(() -> { return true; @@ -3130,12 +3112,7 @@ index 6728e84b2..8ce6cf8ec 100644 PlayerChunkMap.LOGGER.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", this.w.getName()); } else { this.visibleChunks.values().stream().filter(PlayerChunk::hasBeenLoaded).forEach((playerchunk) -> { - IChunkAccess ichunkaccess = (IChunkAccess) playerchunk.getChunkSave().getNow(null); // CraftBukkit - decompile error - - if (ichunkaccess instanceof ProtoChunkExtension || ichunkaccess instanceof Chunk) { -- this.saveChunk(ichunkaccess); -+ this.saveChunk(ichunkaccess, true); // Paper - playerchunk.m(); +@@ -0,0 +0,0 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { } }); @@ -3229,14 +3206,15 @@ index 6728e84b2..8ce6cf8ec 100644 if (this.loadedChunks.remove(i) && ichunkaccess instanceof Chunk) { Chunk chunk = (Chunk) ichunkaccess; - this.world.unloadChunk(chunk); +@@ -0,0 +0,0 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { } + this.autoSaveQueue.remove(playerchunk); // Paper + try { + this.asyncSave(ichunkaccess); // Paper - async chunk saving + } catch (Throwable ex) { + LOGGER.fatal("Failed to prepare async save, attempting synchronous save", ex); -+ this.saveChunk(ichunkaccess, true); ++ this.saveChunk(ichunkaccess); + } + this.lightEngine.a(ichunkaccess.getPos()); @@ -3350,7 +3328,7 @@ index 6728e84b2..8ce6cf8ec 100644 public boolean saveChunk(IChunkAccess ichunkaccess) { - this.m.a(ichunkaccess.getPos()); + // Paper start - async param -+ return this.saveChunk(ichunkaccess, false); ++ return this.saveChunk(ichunkaccess, true); + } + public boolean saveChunk(IChunkAccess ichunkaccess, boolean async) { + try (co.aikar.timings.Timing ignored = this.world.timings.chunkSave.startTiming()) { @@ -3568,7 +3546,7 @@ index 6728e84b2..8ce6cf8ec 100644 return this.m; } diff --git a/src/main/java/net/minecraft/server/RegionFile.java b/src/main/java/net/minecraft/server/RegionFile.java -index d37abf2cf..df728e2c0 100644 +index d37abf2cf3..df728e2c0a 100644 --- a/src/main/java/net/minecraft/server/RegionFile.java +++ b/src/main/java/net/minecraft/server/RegionFile.java @@ -0,0 +0,0 @@ public class RegionFile implements AutoCloseable { @@ -3613,7 +3591,7 @@ index d37abf2cf..df728e2c0 100644 } diff --git a/src/main/java/net/minecraft/server/RegionFileCache.java b/src/main/java/net/minecraft/server/RegionFileCache.java -index e07ae9854..0f201000f 100644 +index e07ae98540..0f201000f6 100644 --- a/src/main/java/net/minecraft/server/RegionFileCache.java +++ b/src/main/java/net/minecraft/server/RegionFileCache.java @@ -0,0 +0,0 @@ import java.io.File; @@ -3718,7 +3696,7 @@ index e07ae9854..0f201000f 100644 return regionfile != null ? regionfile.chunkExists(pos) : false; diff --git a/src/main/java/net/minecraft/server/RegionFileSection.java b/src/main/java/net/minecraft/server/RegionFileSection.java -index db9f0196b..a6d8ef5eb 100644 +index db9f0196bd..a6d8ef5eb4 100644 --- a/src/main/java/net/minecraft/server/RegionFileSection.java +++ b/src/main/java/net/minecraft/server/RegionFileSection.java @@ -0,0 +0,0 @@ import javax.annotation.Nullable; @@ -3854,7 +3832,7 @@ index db9f0196b..a6d8ef5eb 100644 + // Paper end } diff --git a/src/main/java/net/minecraft/server/TicketType.java b/src/main/java/net/minecraft/server/TicketType.java -index 335b64435..481d95480 100644 +index 335b644351..481d954808 100644 --- a/src/main/java/net/minecraft/server/TicketType.java +++ b/src/main/java/net/minecraft/server/TicketType.java @@ -0,0 +0,0 @@ public class TicketType { @@ -3866,7 +3844,7 @@ index 335b64435..481d95480 100644 public static TicketType a(String s, Comparator comparator) { return new TicketType<>(s, comparator, 0L); diff --git a/src/main/java/net/minecraft/server/VillagePlace.java b/src/main/java/net/minecraft/server/VillagePlace.java -index c999f8c9b..b59ef1a63 100644 +index c999f8c9bf..b59ef1a633 100644 --- a/src/main/java/net/minecraft/server/VillagePlace.java +++ b/src/main/java/net/minecraft/server/VillagePlace.java @@ -0,0 +0,0 @@ public class VillagePlace extends RegionFileSection { @@ -3955,7 +3933,7 @@ index c999f8c9b..b59ef1a63 100644 HAS_SPACE(VillagePlaceRecord::d), IS_OCCUPIED(VillagePlaceRecord::e), ANY((villageplacerecord) -> { diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index 691ef0048..541c1535e 100644 +index 0f652e58e1..5eb52817f1 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -0,0 +0,0 @@ public class WorldServer extends World { @@ -4048,7 +4026,7 @@ index 691ef0048..541c1535e 100644 // CraftBukkit start diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index f56ec3d34..1a6a88b17 100644 +index f56ec3d341..1a6a88b178 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -0,0 +0,0 @@ public class CraftWorld implements World { @@ -4110,7 +4088,7 @@ index f56ec3d34..1a6a88b17 100644 @Override public int getViewDistance() { diff --git a/src/main/java/org/spigotmc/WatchdogThread.java b/src/main/java/org/spigotmc/WatchdogThread.java -index 07936eeba..5bdcdcf9e 100644 +index 07936eeba2..5bdcdcf9e8 100644 --- a/src/main/java/org/spigotmc/WatchdogThread.java +++ b/src/main/java/org/spigotmc/WatchdogThread.java @@ -0,0 +0,0 @@ import java.lang.management.ThreadInfo; diff --git a/Spigot-Server-Patches/Auto-fix-bad-Y-levels-on-player-login.patch b/Spigot-Server-Patches/Auto-fix-bad-Y-levels-on-player-login.patch index 2e77a513b1..7a366ed32b 100644 --- a/Spigot-Server-Patches/Auto-fix-bad-Y-levels-on-player-login.patch +++ b/Spigot-Server-Patches/Auto-fix-bad-Y-levels-on-player-login.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Auto fix bad Y levels on player login Bring down to a saner Y level if super high, as this can cause the server to crash diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java -index b2c070397..cb4d49b1e 100644 +index ae1f0d5783..a5701623bf 100644 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/EntityPlayer.java @@ -0,0 +0,0 @@ public class EntityPlayer extends EntityHuman implements ICrafting { diff --git a/Spigot-Server-Patches/Avoid-hopper-searches-if-there-are-no-items.patch b/Spigot-Server-Patches/Avoid-hopper-searches-if-there-are-no-items.patch index b551fa7672..35ef190865 100644 --- a/Spigot-Server-Patches/Avoid-hopper-searches-if-there-are-no-items.patch +++ b/Spigot-Server-Patches/Avoid-hopper-searches-if-there-are-no-items.patch @@ -14,7 +14,7 @@ And since minecart hoppers are used _very_ rarely near we can avoid alot of sear Combined, this adds up a lot. diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index 863a2222f..f2a04cb6a 100644 +index 3fdcc2e5d4..59d8a8719e 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java @@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess { @@ -29,8 +29,8 @@ index 863a2222f..f2a04cb6a 100644 public Chunk(World world, ChunkCoordIntPair chunkcoordintpair, BiomeStorage biomestorage, ChunkConverter chunkconverter, TickList ticklist, TickList ticklist1, long i, @Nullable ChunkSection[] achunksection, @Nullable Consumer consumer) { @@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess { - entity.chunkY = k; entity.chunkZ = this.loc.z; + this.entities.add(entity); // Paper - per chunk entity list this.entitySlices[k].add(entity); + // Paper start + if (entity instanceof EntityItem) { @@ -85,7 +85,7 @@ index 863a2222f..f2a04cb6a 100644 T t0 = (T) iterator.next(); // CraftBukkit - decompile error if (t0.shouldBeRemoved) continue; // Paper diff --git a/src/main/java/net/minecraft/server/IEntitySelector.java b/src/main/java/net/minecraft/server/IEntitySelector.java -index 498f38109..a2d1ef360 100644 +index 498f381099..a2d1ef3602 100644 --- a/src/main/java/net/minecraft/server/IEntitySelector.java +++ b/src/main/java/net/minecraft/server/IEntitySelector.java @@ -0,0 +0,0 @@ public final class IEntitySelector { diff --git a/Spigot-Server-Patches/Basic-PlayerProfile-API.patch b/Spigot-Server-Patches/Basic-PlayerProfile-API.patch index 709971abc7..d71ff4239e 100644 --- a/Spigot-Server-Patches/Basic-PlayerProfile-API.patch +++ b/Spigot-Server-Patches/Basic-PlayerProfile-API.patch @@ -7,7 +7,7 @@ Establishes base extension of profile systems for future edits too diff --git a/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java b/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java new file mode 100644 -index 000000000..b151a13c1 +index 0000000000..b151a13c1b --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java @@ -0,0 +0,0 @@ @@ -293,7 +293,7 @@ index 000000000..b151a13c1 +} diff --git a/src/main/java/com/destroystokyo/paper/profile/PaperAuthenticationService.java b/src/main/java/com/destroystokyo/paper/profile/PaperAuthenticationService.java new file mode 100644 -index 000000000..25836b975 +index 0000000000..25836b975b --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/profile/PaperAuthenticationService.java @@ -0,0 +0,0 @@ @@ -329,7 +329,7 @@ index 000000000..25836b975 +} diff --git a/src/main/java/com/destroystokyo/paper/profile/PaperGameProfileRepository.java b/src/main/java/com/destroystokyo/paper/profile/PaperGameProfileRepository.java new file mode 100644 -index 000000000..3bcdb8f93 +index 0000000000..3bcdb8f93f --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/profile/PaperGameProfileRepository.java @@ -0,0 +0,0 @@ @@ -352,7 +352,7 @@ index 000000000..3bcdb8f93 +} diff --git a/src/main/java/com/destroystokyo/paper/profile/PaperMinecraftSessionService.java b/src/main/java/com/destroystokyo/paper/profile/PaperMinecraftSessionService.java new file mode 100644 -index 000000000..4b2a67423 +index 0000000000..4b2a67423f --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/profile/PaperMinecraftSessionService.java @@ -0,0 +0,0 @@ @@ -387,7 +387,7 @@ index 000000000..4b2a67423 +} diff --git a/src/main/java/com/destroystokyo/paper/profile/PaperUserAuthentication.java b/src/main/java/com/destroystokyo/paper/profile/PaperUserAuthentication.java new file mode 100644 -index 000000000..3aceb0ea8 +index 0000000000..3aceb0ea8a --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/profile/PaperUserAuthentication.java @@ -0,0 +0,0 @@ @@ -403,7 +403,7 @@ index 000000000..3aceb0ea8 + } +} diff --git a/src/main/java/net/minecraft/server/MCUtil.java b/src/main/java/net/minecraft/server/MCUtil.java -index 2f10dab36..670f8313a 100644 +index ee2174a9ca..2a22bc6f3e 100644 --- a/src/main/java/net/minecraft/server/MCUtil.java +++ b/src/main/java/net/minecraft/server/MCUtil.java @@ -0,0 +0,0 @@ @@ -429,7 +429,7 @@ index 2f10dab36..670f8313a 100644 * Calculates distance between 2 entities * @param e1 diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 7016dac2d..c15ca642d 100644 +index 7016dac2d7..c15ca642d0 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -0,0 +0,0 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant - License: LGPLv2.1 */ diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java -index a3ef6dba7..0b43e4eb4 100644 +index 3ef7e4561f..35153af515 100644 --- a/src/main/java/net/minecraft/server/ChunkProviderServer.java +++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java @@ -0,0 +0,0 @@ import org.apache.logging.log4j.Logger; @@ -198,7 +198,7 @@ index a3ef6dba7..0b43e4eb4 100644 public final ChunkGenerator chunkGenerator; private final WorldServer world; diff --git a/src/main/java/net/minecraft/server/MCUtil.java b/src/main/java/net/minecraft/server/MCUtil.java -index d49e210a3..25a87c2d3 100644 +index 3a482466ec..b6aeca05f7 100644 --- a/src/main/java/net/minecraft/server/MCUtil.java +++ b/src/main/java/net/minecraft/server/MCUtil.java @@ -0,0 +0,0 @@ import com.destroystokyo.paper.block.TargetBlockInfo; @@ -399,7 +399,7 @@ index d49e210a3..25a87c2d3 100644 + } } diff --git a/src/main/java/net/minecraft/server/PlayerChunk.java b/src/main/java/net/minecraft/server/PlayerChunk.java -index 3c6fe0596..43d9a5634 100644 +index 3093154bb7..3a0f0314b2 100644 --- a/src/main/java/net/minecraft/server/PlayerChunk.java +++ b/src/main/java/net/minecraft/server/PlayerChunk.java @@ -0,0 +0,0 @@ public class PlayerChunk { @@ -412,7 +412,7 @@ index 3c6fe0596..43d9a5634 100644 private int dirtyCount; private int r; diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java -index 314c77767..c17a53915 100644 +index b3fa3bd874..803fda511f 100644 --- a/src/main/java/net/minecraft/server/PlayerChunkMap.java +++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java @@ -0,0 +0,0 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { @@ -434,7 +434,7 @@ index 314c77767..c17a53915 100644 private final DefinedStructureManager definedStructureManager; private final File w; diff --git a/src/main/java/net/minecraft/server/Ticket.java b/src/main/java/net/minecraft/server/Ticket.java -index 77bb6b092..7a8397815 100644 +index 77bb6b092a..7a8397815a 100644 --- a/src/main/java/net/minecraft/server/Ticket.java +++ b/src/main/java/net/minecraft/server/Ticket.java @@ -0,0 +0,0 @@ public final class Ticket implements Comparable> { diff --git a/Spigot-Server-Patches/Configurable-Chunk-Inhabited-Time.patch b/Spigot-Server-Patches/Configurable-Chunk-Inhabited-Time.patch index d389c31480..97eded9ad3 100644 --- a/Spigot-Server-Patches/Configurable-Chunk-Inhabited-Time.patch +++ b/Spigot-Server-Patches/Configurable-Chunk-Inhabited-Time.patch @@ -11,7 +11,7 @@ For people who want all chunks to be treated equally, you can chose a fixed valu This allows to fine-tune vanilla gameplay. diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index 6ef0e1399..5872e6b17 100644 +index 6ef0e1399e..5872e6b171 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -0,0 +0,0 @@ public class PaperWorldConfig { @@ -30,7 +30,7 @@ index 6ef0e1399..5872e6b17 100644 + } } diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index fd9ba8232..034e8684d 100644 +index 7033c6e839..c6a79644ef 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java @@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess { diff --git a/Spigot-Server-Patches/Configurable-Keep-Spawn-Loaded-range-per-world.patch b/Spigot-Server-Patches/Configurable-Keep-Spawn-Loaded-range-per-world.patch index 009f7594c7..8d741e0099 100644 --- a/Spigot-Server-Patches/Configurable-Keep-Spawn-Loaded-range-per-world.patch +++ b/Spigot-Server-Patches/Configurable-Keep-Spawn-Loaded-range-per-world.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Configurable Keep Spawn Loaded range per world This lets you disable it for some worlds and lower it for others. diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index 572679e4d..071e5e7f7 100644 +index 572679e4d1..071e5e7f72 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -0,0 +0,0 @@ public class PaperWorldConfig { @@ -21,7 +21,7 @@ index 572679e4d..071e5e7f7 100644 + } } diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 3ede5ce2a..eaa26e1a5 100644 +index 3ede5ce2a6..eaa26e1a50 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -0,0 +0,0 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant { @@ -101,7 +101,7 @@ index 5406f4c40..d778eac45 100644 if (i >= 0 && i < this.list.size()) { NBTBase nbtbase = (NBTBase) this.list.get(i); diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index bc1ff7d56..948438829 100644 +index ebc252a610..6f07065eb4 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -0,0 +0,0 @@ public class WorldServer extends World { @@ -117,7 +117,7 @@ index bc1ff7d56..948438829 100644 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java -index c82c21326..a29693674 100644 +index c82c213260..a296936748 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -0,0 +0,0 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { diff --git a/Spigot-Server-Patches/Entity-getEntitySpawnReason.patch b/Spigot-Server-Patches/Entity-getEntitySpawnReason.patch index 8fec31a03c..80861329c0 100644 --- a/Spigot-Server-Patches/Entity-getEntitySpawnReason.patch +++ b/Spigot-Server-Patches/Entity-getEntitySpawnReason.patch @@ -10,7 +10,7 @@ persistenting Living Entity, SPAWNER for spawners, or DEFAULT since data was not stored. diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index f8132a1fa..716d30b8d 100644 +index f8132a1fa4..716d30b8de 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -0,0 +0,0 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke @@ -59,7 +59,7 @@ index f8132a1fa..716d30b8d 100644 } catch (Throwable throwable) { diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java -index 9d715d891..49437f212 100644 +index 9d715d891d..49437f2124 100644 --- a/src/main/java/net/minecraft/server/PlayerList.java +++ b/src/main/java/net/minecraft/server/PlayerList.java @@ -0,0 +0,0 @@ public abstract class PlayerList { @@ -72,7 +72,7 @@ index 9d715d891..49437f212 100644 }); diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index b4443f3a6..f8d7bba34 100644 +index 78a9b31891..7492284703 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -0,0 +0,0 @@ public class WorldServer extends World { @@ -84,7 +84,7 @@ index b4443f3a6..f8d7bba34 100644 if (entity.valid) { MinecraftServer.LOGGER.error("Attempted Double World add on " + entity, new Throwable()); diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java -index 915ccb180..dfa15372b 100644 +index 915ccb1807..dfa15372b8 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -0,0 +0,0 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { diff --git a/Spigot-Server-Patches/Expand-World.spawnParticle-API-and-add-Builder.patch b/Spigot-Server-Patches/Expand-World.spawnParticle-API-and-add-Builder.patch index 747fe739bc..7321184807 100644 --- a/Spigot-Server-Patches/Expand-World.spawnParticle-API-and-add-Builder.patch +++ b/Spigot-Server-Patches/Expand-World.spawnParticle-API-and-add-Builder.patch @@ -10,7 +10,7 @@ Adds an option to control the force mode of the particle. This adds a new Builder API which is much friendlier to use. diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index fe1a87ba5..9ee58acf7 100644 +index 69d2e2c3b5..62a16173b9 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -0,0 +0,0 @@ public class WorldServer extends World { @@ -43,7 +43,7 @@ index fe1a87ba5..9ee58acf7 100644 if (this.a(entityplayer, force, d0, d1, d2, packetplayoutworldparticles)) { // CraftBukkit diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index 63b1cb2a4..59036635d 100644 +index 63b1cb2a4c..59036635d7 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -0,0 +0,0 @@ public class CraftWorld implements World { diff --git a/Spigot-Server-Patches/Fix-Double-World-Add-issues.patch b/Spigot-Server-Patches/Fix-Double-World-Add-issues.patch index 9360ba752c..c2dfd7489e 100644 --- a/Spigot-Server-Patches/Fix-Double-World-Add-issues.patch +++ b/Spigot-Server-Patches/Fix-Double-World-Add-issues.patch @@ -8,7 +8,7 @@ Vanilla will double add Spider Jockeys to the world, so ignore already added. Also add debug if something else tries to, and abort before world gets bad state diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index 9c20b5f6f..48737366f 100644 +index 23f3d7eb51..e69f82dcd1 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -0,0 +0,0 @@ public class WorldServer extends World { diff --git a/Spigot-Server-Patches/Fix-World-isChunkGenerated-calls.patch b/Spigot-Server-Patches/Fix-World-isChunkGenerated-calls.patch index 7392109224..5751d9456c 100644 --- a/Spigot-Server-Patches/Fix-World-isChunkGenerated-calls.patch +++ b/Spigot-Server-Patches/Fix-World-isChunkGenerated-calls.patch @@ -8,12 +8,12 @@ This patch also adds a chunk status cache on region files (note that its only purpose is to cache the status on DISK) diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java -index 99ce73c45..761399e28 100644 +index 191b2759a0..9e75647953 100644 --- a/src/main/java/net/minecraft/server/ChunkProviderServer.java +++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java @@ -0,0 +0,0 @@ public class ChunkProviderServer extends IChunkProvider { private final WorldServer world; - private final Thread serverThread; + public final Thread serverThread; // Paper - private -> public private final LightEngineThreaded lightEngine; - private final ChunkProviderServer.a serverThreadQueue; + public final ChunkProviderServer.a serverThreadQueue; // Paper private -> public @@ -43,7 +43,7 @@ index 99ce73c45..761399e28 100644 @Nullable diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java -index 6371f2f5b..961228e9d 100644 +index 6371f2f5b1..961228e9df 100644 --- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java +++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java @@ -0,0 +0,0 @@ public class ChunkRegionLoader { @@ -65,7 +65,7 @@ index 6371f2f5b..961228e9d 100644 if (nbttagcompound != null) { ChunkStatus chunkstatus = ChunkStatus.a(nbttagcompound.getCompound("Level").getString("Status")); diff --git a/src/main/java/net/minecraft/server/ChunkStatus.java b/src/main/java/net/minecraft/server/ChunkStatus.java -index efdf611e6..134a4f0b7 100644 +index efdf611e66..134a4f0b7d 100644 --- a/src/main/java/net/minecraft/server/ChunkStatus.java +++ b/src/main/java/net/minecraft/server/ChunkStatus.java @@ -0,0 +0,0 @@ public class ChunkStatus { @@ -95,7 +95,7 @@ index efdf611e6..134a4f0b7 100644 return (ChunkStatus) IRegistry.CHUNK_STATUS.get(MinecraftKey.a(s)); } diff --git a/src/main/java/net/minecraft/server/IChunkLoader.java b/src/main/java/net/minecraft/server/IChunkLoader.java -index f0a052eec..2f95174fc 100644 +index f0a052eec2..2f95174fcc 100644 --- a/src/main/java/net/minecraft/server/IChunkLoader.java +++ b/src/main/java/net/minecraft/server/IChunkLoader.java @@ -0,0 +0,0 @@ import javax.annotation.Nullable; @@ -108,7 +108,7 @@ index f0a052eec..2f95174fc 100644 @Nullable private PersistentStructureLegacy c; diff --git a/src/main/java/net/minecraft/server/PlayerChunk.java b/src/main/java/net/minecraft/server/PlayerChunk.java -index 43d9a5634..6f2cca07e 100644 +index c91312facf..5108d3ee98 100644 --- a/src/main/java/net/minecraft/server/PlayerChunk.java +++ b/src/main/java/net/minecraft/server/PlayerChunk.java @@ -0,0 +0,0 @@ public class PlayerChunk { @@ -132,7 +132,7 @@ index 43d9a5634..6f2cca07e 100644 public CompletableFuture> getStatusFutureUnchecked(ChunkStatus chunkstatus) { diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java -index 3a02b6269..6257eafe0 100644 +index 40d80f3810..6c4804232a 100644 --- a/src/main/java/net/minecraft/server/PlayerChunkMap.java +++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java @@ -0,0 +0,0 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { @@ -165,8 +165,8 @@ index 3a02b6269..6257eafe0 100644 + RegionFile regionFile = this.getIOWorker().getRegionFileCache().getRegionFileIfLoaded(chunkPos); + + return regionFile == null ? null : regionFile.getStatusIfCached(chunkPos.x, chunkPos.z); -+ } -+ + } + + public ChunkStatus getChunkStatusOnDisk(ChunkCoordIntPair chunkPos) throws IOException { + RegionFile regionFile = this.getIOWorker().getRegionFileCache().getFile(chunkPos, false); + @@ -194,13 +194,14 @@ index 3a02b6269..6257eafe0 100644 + public IChunkAccess getUnloadingChunk(int chunkX, int chunkZ) { + PlayerChunk chunkHolder = this.pendingUnload.get(ChunkCoordIntPair.pair(chunkX, chunkZ)); + return chunkHolder == null ? null : chunkHolder.getAvailableChunkNow(); - } ++ } + // Paper end - ++ boolean isOutsideOfRange(ChunkCoordIntPair chunkcoordintpair) { // Spigot start + return isOutsideOfRange(chunkcoordintpair, false); diff --git a/src/main/java/net/minecraft/server/RegionFile.java b/src/main/java/net/minecraft/server/RegionFile.java -index 6b543f89d..d37abf2cf 100644 +index 6b543f89d4..d37abf2cf3 100644 --- a/src/main/java/net/minecraft/server/RegionFile.java +++ b/src/main/java/net/minecraft/server/RegionFile.java @@ -0,0 +0,0 @@ public class RegionFile implements AutoCloseable { @@ -249,7 +250,7 @@ index 6b543f89d..d37abf2cf 100644 this.c(); } finally { diff --git a/src/main/java/net/minecraft/server/RegionFileCache.java b/src/main/java/net/minecraft/server/RegionFileCache.java -index b3d1bb5fd..e07ae9854 100644 +index b3d1bb5fd8..e07ae98540 100644 --- a/src/main/java/net/minecraft/server/RegionFileCache.java +++ b/src/main/java/net/minecraft/server/RegionFileCache.java @@ -0,0 +0,0 @@ public final class RegionFileCache implements AutoCloseable { @@ -279,7 +280,7 @@ index b3d1bb5fd..e07ae9854 100644 throwable = throwable1; throw throwable1; diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index 9787d5332..f56ec3d34 100644 +index 9787d53326..f56ec3d341 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -0,0 +0,0 @@ import java.util.Objects; diff --git a/Spigot-Server-Patches/Fix-issues-with-entity-loss-due-to-unloaded-chunks.patch b/Spigot-Server-Patches/Fix-issues-with-entity-loss-due-to-unloaded-chunks.patch index 7054cb155d..3865016cd9 100644 --- a/Spigot-Server-Patches/Fix-issues-with-entity-loss-due-to-unloaded-chunks.patch +++ b/Spigot-Server-Patches/Fix-issues-with-entity-loss-due-to-unloaded-chunks.patch @@ -19,7 +19,7 @@ This change ensures the chunks are always loaded when entities are added to the world, or a valid entity moves between chunks. diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index f8d7bba34..3c94aa48c 100644 +index 7492284703..4a648f88ba 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -0,0 +0,0 @@ public class WorldServer extends World { diff --git a/Spigot-Server-Patches/Fix-spawn-radius-being-treated-as-0.patch b/Spigot-Server-Patches/Fix-spawn-radius-being-treated-as-0.patch index 5a71d5c42b..1318524c9d 100644 --- a/Spigot-Server-Patches/Fix-spawn-radius-being-treated-as-0.patch +++ b/Spigot-Server-Patches/Fix-spawn-radius-being-treated-as-0.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Fix spawn radius being treated as 0 diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java -index 41a3ad104..27d529efe 100644 +index 0b35a4b143..4ca28c8b64 100644 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/EntityPlayer.java @@ -0,0 +0,0 @@ public class EntityPlayer extends EntityHuman implements ICrafting { diff --git a/Spigot-Server-Patches/Fix-stuck-in-sneak-when-changing-worlds-MC-10657.patch b/Spigot-Server-Patches/Fix-stuck-in-sneak-when-changing-worlds-MC-10657.patch index a35af25182..9e489db21e 100644 --- a/Spigot-Server-Patches/Fix-stuck-in-sneak-when-changing-worlds-MC-10657.patch +++ b/Spigot-Server-Patches/Fix-stuck-in-sneak-when-changing-worlds-MC-10657.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Fix stuck in sneak when changing worlds (MC-10657) diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java -index 83405b641..41a3ad104 100644 +index 22606d894e..0b35a4b143 100644 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/EntityPlayer.java @@ -0,0 +0,0 @@ public class EntityPlayer extends EntityHuman implements ICrafting { @@ -18,7 +18,7 @@ index 83405b641..41a3ad104 100644 PlayerChangedWorldEvent changeEvent = new PlayerChangedWorldEvent(this.getBukkitEntity(), worldserver.getWorld()); this.world.getServer().getPluginManager().callEvent(changeEvent); diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java -index f702619aa..7b79ee4fe 100644 +index f702619aa2..7b79ee4fe5 100644 --- a/src/main/java/net/minecraft/server/PlayerList.java +++ b/src/main/java/net/minecraft/server/PlayerList.java @@ -0,0 +0,0 @@ public abstract class PlayerList { diff --git a/Spigot-Server-Patches/Ignore-Dead-Entities-in-entityList-iteration.patch b/Spigot-Server-Patches/Ignore-Dead-Entities-in-entityList-iteration.patch index e92287dc3b..051ab02b8a 100644 --- a/Spigot-Server-Patches/Ignore-Dead-Entities-in-entityList-iteration.patch +++ b/Spigot-Server-Patches/Ignore-Dead-Entities-in-entityList-iteration.patch @@ -11,7 +11,7 @@ This will ensure that dead entities are skipped from iteration since they shouldn't of been in the list in the first place. diff --git a/src/main/java/com/destroystokyo/paper/PaperCommand.java b/src/main/java/com/destroystokyo/paper/PaperCommand.java -index eecf27370..d704fc79c 100644 +index eecf27370b..d704fc79c0 100644 --- a/src/main/java/com/destroystokyo/paper/PaperCommand.java +++ b/src/main/java/com/destroystokyo/paper/PaperCommand.java @@ -0,0 +0,0 @@ public class PaperCommand extends Command { @@ -23,7 +23,7 @@ index eecf27370..d704fc79c 100644 MutablePair> info = list.computeIfAbsent(key, k -> MutablePair.of(0, Maps.newHashMap())); ChunkCoordIntPair chunk = new ChunkCoordIntPair(e.getChunkX(), e.getChunkZ()); diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index b156f5428..c7c600b80 100644 +index 2004f7fbe1..7ecff4443a 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java @@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess { @@ -51,7 +51,7 @@ index b156f5428..c7c600b80 100644 if (oclass.isInstance(t0) && t0.getBoundingBox().c(axisalignedbb) && (predicate == null || predicate.test(t0))) { // Spigot - instance check list.add(t0); diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index e761f7148..ca794328a 100644 +index e761f71487..ca794328a7 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -0,0 +0,0 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke @@ -63,7 +63,7 @@ index e761f7148..ca794328a 100644 public float getBukkitYaw() { return this.yaw; diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index 224f6d151..ba0389f2f 100644 +index 3d5a50ddcc..12cdb0cc9a 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -0,0 +0,0 @@ public class WorldServer extends World { @@ -92,7 +92,7 @@ index 224f6d151..ba0389f2f 100644 } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index a257dce8f..0fb47579f 100644 +index a257dce8f0..0fb47579f6 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -0,0 +0,0 @@ public class CraftWorld implements World { diff --git a/Spigot-Server-Patches/Implement-PlayerLocaleChangeEvent.patch b/Spigot-Server-Patches/Implement-PlayerLocaleChangeEvent.patch index e91d43a6a2..6e325d160c 100644 --- a/Spigot-Server-Patches/Implement-PlayerLocaleChangeEvent.patch +++ b/Spigot-Server-Patches/Implement-PlayerLocaleChangeEvent.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Implement PlayerLocaleChangeEvent diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java -index 4289aadc6..1f5145d49 100644 +index b5101af011..d4bba876d0 100644 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/EntityPlayer.java @@ -0,0 +0,0 @@ import org.bukkit.inventory.MainHand; @@ -40,7 +40,7 @@ index 4289aadc6..1f5145d49 100644 this.ci = packetplayinsettings.e(); this.getDataWatcher().set(EntityPlayer.bq, (byte) packetplayinsettings.f()); diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 5647eb135..447ecf636 100644 +index 5647eb135e..447ecf636d 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player { diff --git a/Spigot-Server-Patches/Improve-Maps-in-item-frames-performance-and-bug-fixe.patch b/Spigot-Server-Patches/Improve-Maps-in-item-frames-performance-and-bug-fixe.patch index b7454d8376..d0b520ce3d 100644 --- a/Spigot-Server-Patches/Improve-Maps-in-item-frames-performance-and-bug-fixe.patch +++ b/Spigot-Server-Patches/Improve-Maps-in-item-frames-performance-and-bug-fixe.patch @@ -13,7 +13,7 @@ custom renderers are in use, defaulting to the much simpler Vanilla system. Additionally, numerous issues to player position tracking on maps has been fixed. diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java -index 747f5eeb6..2a54723a6 100644 +index 26adb55409..b407d80ae6 100644 --- a/src/main/java/net/minecraft/server/EntityHuman.java +++ b/src/main/java/net/minecraft/server/EntityHuman.java @@ -0,0 +0,0 @@ public abstract class EntityHuman extends EntityLiving { @@ -30,7 +30,7 @@ index 747f5eeb6..2a54723a6 100644 return entityitem; } diff --git a/src/main/java/net/minecraft/server/WorldMap.java b/src/main/java/net/minecraft/server/WorldMap.java -index a56ac3da8..2f1be1995 100644 +index a56ac3da80..2f1be1995d 100644 --- a/src/main/java/net/minecraft/server/WorldMap.java +++ b/src/main/java/net/minecraft/server/WorldMap.java @@ -0,0 +0,0 @@ public class WorldMap extends PersistentBase { @@ -102,7 +102,7 @@ index a56ac3da8..2f1be1995 100644 for ( org.bukkit.map.MapCursor cursor : render.cursors) { diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index 9121aa2e4..9c20b5f6f 100644 +index 7b3e3487fa..23f3d7eb51 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -0,0 +0,0 @@ public class WorldServer extends World { @@ -114,7 +114,7 @@ index 9121aa2e4..9c20b5f6f 100644 } } diff --git a/src/main/java/org/bukkit/craftbukkit/map/RenderData.java b/src/main/java/org/bukkit/craftbukkit/map/RenderData.java -index 256a13178..5768cd512 100644 +index 256a131781..5768cd512e 100644 --- a/src/main/java/org/bukkit/craftbukkit/map/RenderData.java +++ b/src/main/java/org/bukkit/craftbukkit/map/RenderData.java @@ -0,0 +0,0 @@ import org.bukkit.map.MapCursor; diff --git a/Spigot-Server-Patches/Improve-death-events.patch b/Spigot-Server-Patches/Improve-death-events.patch index bb23fe2623..72894758ac 100644 --- a/Spigot-Server-Patches/Improve-death-events.patch +++ b/Spigot-Server-Patches/Improve-death-events.patch @@ -15,7 +15,7 @@ items and experience which is otherwise only properly possible by using internal code. diff --git a/src/main/java/net/minecraft/server/CombatTracker.java b/src/main/java/net/minecraft/server/CombatTracker.java -index 6daa400d2..38fe29f8a 100644 +index 6daa400d27..38fe29f8a2 100644 --- a/src/main/java/net/minecraft/server/CombatTracker.java +++ b/src/main/java/net/minecraft/server/CombatTracker.java @@ -0,0 +0,0 @@ public class CombatTracker { @@ -27,7 +27,7 @@ index 6daa400d2..38fe29f8a 100644 int i = this.f ? 300 : 100; diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index 845993bb4..16c55a9fa 100644 +index 845993bb4e..16c55a9fa0 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -0,0 +0,0 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke @@ -47,7 +47,7 @@ index 845993bb4..16c55a9fa 100644 protected void k(double d0, double d1, double d2) { diff --git a/src/main/java/net/minecraft/server/EntityArmorStand.java b/src/main/java/net/minecraft/server/EntityArmorStand.java -index 42b9a339e..8ad131e4f 100644 +index 42b9a339e9..8ad131e4fc 100644 --- a/src/main/java/net/minecraft/server/EntityArmorStand.java +++ b/src/main/java/net/minecraft/server/EntityArmorStand.java @@ -0,0 +0,0 @@ public class EntityArmorStand extends EntityLiving { @@ -61,7 +61,7 @@ index 42b9a339e..8ad131e4f 100644 } diff --git a/src/main/java/net/minecraft/server/EntityFox.java b/src/main/java/net/minecraft/server/EntityFox.java -index 2be6c7bde..82a32d5db 100644 +index 2be6c7bde9..82a32d5dbf 100644 --- a/src/main/java/net/minecraft/server/EntityFox.java +++ b/src/main/java/net/minecraft/server/EntityFox.java @@ -0,0 +0,0 @@ public class EntityFox extends EntityAnimal { @@ -94,7 +94,7 @@ index 2be6c7bde..82a32d5db 100644 public static boolean a(EntityFox entityfox, EntityLiving entityliving) { diff --git a/src/main/java/net/minecraft/server/EntityHorseChestedAbstract.java b/src/main/java/net/minecraft/server/EntityHorseChestedAbstract.java -index 80717ad9a..53aac5bcc 100644 +index 80717ad9ac..53aac5bccd 100644 --- a/src/main/java/net/minecraft/server/EntityHorseChestedAbstract.java +++ b/src/main/java/net/minecraft/server/EntityHorseChestedAbstract.java @@ -0,0 +0,0 @@ public abstract class EntityHorseChestedAbstract extends EntityHorseAbstract { @@ -119,7 +119,7 @@ index 80717ad9a..53aac5bcc 100644 public void b(NBTTagCompound nbttagcompound) { super.b(nbttagcompound); diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java -index fa097e055..eed3e7c58 100644 +index fa097e0551..eed3e7c58e 100644 --- a/src/main/java/net/minecraft/server/EntityLiving.java +++ b/src/main/java/net/minecraft/server/EntityLiving.java @@ -0,0 +0,0 @@ public abstract class EntityLiving extends Entity { @@ -279,7 +279,7 @@ index fa097e055..eed3e7c58 100644 return this.isBaby() ? (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.5F : (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F; } diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java -index 5e2e0674a..e6252e5f1 100644 +index a9a16eace9..52bbe4fc02 100644 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/EntityPlayer.java @@ -0,0 +0,0 @@ public class EntityPlayer extends EntityHuman implements ICrafting { @@ -330,7 +330,7 @@ index 5e2e0674a..e6252e5f1 100644 } } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftSound.java b/src/main/java/org/bukkit/craftbukkit/CraftSound.java -index 90fdf89c8..b761a41dc 100644 +index 90fdf89c81..b761a41dcd 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftSound.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftSound.java @@ -0,0 +0,0 @@ public enum CraftSound { @@ -357,7 +357,7 @@ index 90fdf89c8..b761a41dc 100644 this.minecraftKey = minecraftKey; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 352ef3669..a2bda708c 100644 +index 352ef3669d..a2bda708cd 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @@ -378,7 +378,7 @@ index 352ef3669..a2bda708c 100644 public void injectScaledMaxHealth(Collection collection, boolean force) { diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -index f006b441a..39ce40bd5 100644 +index f006b441ad..39ce40bd58 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -0,0 +0,0 @@ public class CraftEventFactory { diff --git a/Spigot-Server-Patches/InventoryCloseEvent-Reason-API.patch b/Spigot-Server-Patches/InventoryCloseEvent-Reason-API.patch index 11700a9cb7..37e127be52 100644 --- a/Spigot-Server-Patches/InventoryCloseEvent-Reason-API.patch +++ b/Spigot-Server-Patches/InventoryCloseEvent-Reason-API.patch @@ -7,7 +7,7 @@ Allows you to determine why an inventory was closed, enabling plugin developers to "confirm" things based on if it was player triggered close or not. diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java -index 4280dacdc..1f3513874 100644 +index 4721c288ba..36748ccb73 100644 --- a/src/main/java/net/minecraft/server/EntityHuman.java +++ b/src/main/java/net/minecraft/server/EntityHuman.java @@ -0,0 +0,0 @@ public abstract class EntityHuman extends EntityLiving { @@ -34,7 +34,7 @@ index 4280dacdc..1f3513874 100644 this.activeContainer = this.defaultContainer; } diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java -index 68b19a3fc..5e2e0674a 100644 +index 1296eb04f0..a9a16eace9 100644 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/EntityPlayer.java @@ -0,0 +0,0 @@ public class EntityPlayer extends EntityHuman implements ICrafting { @@ -88,7 +88,7 @@ index 68b19a3fc..5e2e0674a 100644 this.m(); } diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java -index 8757b6751..4f04410f9 100644 +index 8757b6751e..4f04410f9b 100644 --- a/src/main/java/net/minecraft/server/PlayerConnection.java +++ b/src/main/java/net/minecraft/server/PlayerConnection.java @@ -0,0 +0,0 @@ public class PlayerConnection implements PacketListenerPlayIn { @@ -101,7 +101,7 @@ index 8757b6751..4f04410f9 100644 this.player.m(); } diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java -index 002f7e844..fd0f5c6f2 100644 +index 002f7e844a..fd0f5c6f29 100644 --- a/src/main/java/net/minecraft/server/PlayerList.java +++ b/src/main/java/net/minecraft/server/PlayerList.java @@ -0,0 +0,0 @@ public abstract class PlayerList { @@ -114,7 +114,7 @@ index 002f7e844..fd0f5c6f2 100644 PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(cserver.getPlayer(entityplayer), "\u00A7e" + entityplayer.getName() + " left the game"); cserver.getPluginManager().callEvent(playerQuitEvent); diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index 9ee58acf7..ae7df6141 100644 +index 62a16173b9..f0c912be43 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -0,0 +0,0 @@ public class WorldServer extends World { @@ -136,7 +136,7 @@ index 9ee58acf7..ae7df6141 100644 } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java -index cd8ad2704..e169679c8 100644 +index cd8ad27047..e169679c88 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java @@ -0,0 +0,0 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { @@ -155,7 +155,7 @@ index cd8ad2704..e169679c8 100644 @Override public boolean isBlocking() { diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index f4affa693..c1f392716 100644 +index f4affa693a..c1f3927164 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @@ -168,7 +168,7 @@ index f4affa693..c1f392716 100644 // Check if the fromWorld and toWorld are the same. diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -index caf277439..f931fa48b 100644 +index caf277439a..f931fa48b4 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -0,0 +0,0 @@ public class CraftEventFactory { diff --git a/Spigot-Server-Patches/Limit-lightning-strike-effect-distance.patch b/Spigot-Server-Patches/Limit-lightning-strike-effect-distance.patch index 726fa4b166..7746e5bffb 100644 --- a/Spigot-Server-Patches/Limit-lightning-strike-effect-distance.patch +++ b/Spigot-Server-Patches/Limit-lightning-strike-effect-distance.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Limit lightning strike effect distance diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index 487b0d5cd..b8789c8ec 100644 +index 487b0d5cd6..b8789c8ecc 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -0,0 +0,0 @@ public class PaperWorldConfig { @@ -38,7 +38,7 @@ index 487b0d5cd..b8789c8ec 100644 private void fixedInhabitedTime() { if (PaperConfig.version < 16) { diff --git a/src/main/java/net/minecraft/server/EntityLightning.java b/src/main/java/net/minecraft/server/EntityLightning.java -index 7c518983a..bdb534deb 100644 +index 7c518983a9..bdb534deb4 100644 --- a/src/main/java/net/minecraft/server/EntityLightning.java +++ b/src/main/java/net/minecraft/server/EntityLightning.java @@ -0,0 +0,0 @@ public class EntityLightning extends Entity { @@ -69,7 +69,7 @@ index 7c518983a..bdb534deb 100644 --this.lifeTicks; diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index 1e8079f91..b4443f3a6 100644 +index f12cadc735..78a9b31891 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -0,0 +0,0 @@ public class WorldServer extends World { diff --git a/Spigot-Server-Patches/MC-Dev-fixes.patch b/Spigot-Server-Patches/MC-Dev-fixes.patch index 427d93cb9b..e255259039 100644 --- a/Spigot-Server-Patches/MC-Dev-fixes.patch +++ b/Spigot-Server-Patches/MC-Dev-fixes.patch @@ -4,8 +4,53 @@ Date: Wed, 30 Mar 2016 19:36:20 -0400 Subject: [PATCH] MC Dev fixes +diff --git a/src/main/java/net/minecraft/server/ArraySetSorted.java b/src/main/java/net/minecraft/server/ArraySetSorted.java +index a3afe60b0d..85f799a713 100644 +--- a/src/main/java/net/minecraft/server/ArraySetSorted.java ++++ b/src/main/java/net/minecraft/server/ArraySetSorted.java +@@ -0,0 +0,0 @@ public class ArraySetSorted extends AbstractSet { + } + + public static > ArraySetSorted a(int i) { +- return new ArraySetSorted<>(i, Comparator.naturalOrder()); ++ return new ArraySetSorted<>(i, (Comparator)Comparator.naturalOrder()); // Paper - decompile fix + } + + private static T[] a(Object[] aobject) { +- return (Object[]) aobject; ++ return (T[])aobject; // Paper - decompile fix + } + + private int c(T t0) { +@@ -0,0 +0,0 @@ public class ArraySetSorted extends AbstractSet { + } + + public boolean remove(Object object) { +- int i = this.c(object); ++ int i = this.c((T)object); // Paper - decompile fix + + if (i >= 0) { + this.d(i); +@@ -0,0 +0,0 @@ public class ArraySetSorted extends AbstractSet { + } + + public boolean contains(Object object) { +- int i = this.c(object); ++ int i = this.c((T)object); // Paper - decompile fix + + return i >= 0; + } +@@ -0,0 +0,0 @@ public class ArraySetSorted extends AbstractSet { + + public U[] toArray(U[] au) { + if (au.length < this.c) { +- return (Object[]) Arrays.copyOf(this.b, this.c, au.getClass()); ++ return (U[])Arrays.copyOf(this.b, this.c, au.getClass()); // Paper - decompile fix + } else { + System.arraycopy(this.b, 0, au, 0, this.c); + if (au.length > this.c) { diff --git a/src/main/java/net/minecraft/server/BiomeBase.java b/src/main/java/net/minecraft/server/BiomeBase.java -index 960dce230..253890e53 100644 +index 960dce2307..253890e537 100644 --- a/src/main/java/net/minecraft/server/BiomeBase.java +++ b/src/main/java/net/minecraft/server/BiomeBase.java @@ -0,0 +0,0 @@ public abstract class BiomeBase { @@ -27,7 +72,7 @@ index 960dce230..253890e53 100644 public List> g() { diff --git a/src/main/java/net/minecraft/server/BlockDataAbstract.java b/src/main/java/net/minecraft/server/BlockDataAbstract.java -index ab03b5568..1cf97cefc 100644 +index ab03b55682..1cf97cefc9 100644 --- a/src/main/java/net/minecraft/server/BlockDataAbstract.java +++ b/src/main/java/net/minecraft/server/BlockDataAbstract.java @@ -0,0 +0,0 @@ public abstract class BlockDataAbstract implements IBlockDataHolder { @@ -72,7 +117,7 @@ index ab03b5568..1cf97cefc 100644 S s0 = this.e.get(iblockstate, v0); diff --git a/src/main/java/net/minecraft/server/BlockPosition.java b/src/main/java/net/minecraft/server/BlockPosition.java -index e40f9c153..c88a62f6b 100644 +index e40f9c153b..c88a62f6b7 100644 --- a/src/main/java/net/minecraft/server/BlockPosition.java +++ b/src/main/java/net/minecraft/server/BlockPosition.java @@ -0,0 +0,0 @@ public class BlockPosition extends BaseBlockPosition implements MinecraftSeriali @@ -92,7 +137,7 @@ index e40f9c153..c88a62f6b 100644 }); } diff --git a/src/main/java/net/minecraft/server/BlockStateEnum.java b/src/main/java/net/minecraft/server/BlockStateEnum.java -index 28cfbaae2..1486d460c 100644 +index 28cfbaae28..1486d460c8 100644 --- a/src/main/java/net/minecraft/server/BlockStateEnum.java +++ b/src/main/java/net/minecraft/server/BlockStateEnum.java @@ -0,0 +0,0 @@ public class BlockStateEnum & INamable> extends BlockState @@ -109,7 +154,7 @@ index 28cfbaae2..1486d460c 100644 if (this.b.containsKey(s1)) { diff --git a/src/main/java/net/minecraft/server/ChunkStatus.java b/src/main/java/net/minecraft/server/ChunkStatus.java -index 68a601bac..efdf611e6 100644 +index 68a601bac5..efdf611e66 100644 --- a/src/main/java/net/minecraft/server/ChunkStatus.java +++ b/src/main/java/net/minecraft/server/ChunkStatus.java @@ -0,0 +0,0 @@ public class ChunkStatus { @@ -122,7 +167,7 @@ index 68a601bac..efdf611e6 100644 for (int j = a().size() - 1; j >= 0; --j) { diff --git a/src/main/java/net/minecraft/server/CraftingManager.java b/src/main/java/net/minecraft/server/CraftingManager.java -index 2dd27edc8..6def3616e 100644 +index 2dd27edc83..6def3616ef 100644 --- a/src/main/java/net/minecraft/server/CraftingManager.java +++ b/src/main/java/net/minecraft/server/CraftingManager.java @@ -0,0 +0,0 @@ public class CraftingManager extends ResourceDataJson { @@ -135,7 +180,7 @@ index 2dd27edc8..6def3616e 100644 CraftingManager.LOGGER.info("Loaded {} recipes", map1.size()); } diff --git a/src/main/java/net/minecraft/server/EnderDragonBattle.java b/src/main/java/net/minecraft/server/EnderDragonBattle.java -index f2c0e06ba..909d13c42 100644 +index f2c0e06bab..909d13c427 100644 --- a/src/main/java/net/minecraft/server/EnderDragonBattle.java +++ b/src/main/java/net/minecraft/server/EnderDragonBattle.java @@ -0,0 +0,0 @@ public class EnderDragonBattle { @@ -157,7 +202,7 @@ index f2c0e06ba..909d13c42 100644 private EntityEnderDragon o() { diff --git a/src/main/java/net/minecraft/server/EntityVindicator.java b/src/main/java/net/minecraft/server/EntityVindicator.java -index 7d44348c7..73ecdd22e 100644 +index 7d44348c78..73ecdd22ea 100644 --- a/src/main/java/net/minecraft/server/EntityVindicator.java +++ b/src/main/java/net/minecraft/server/EntityVindicator.java @@ -0,0 +0,0 @@ public class EntityVindicator extends EntityIllagerAbstract { @@ -169,8 +214,21 @@ index 7d44348c7..73ecdd22e 100644 this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, true)); this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget<>(this, EntityVillagerAbstract.class, true)); this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget<>(this, EntityIronGolem.class, true)); +diff --git a/src/main/java/net/minecraft/server/Fluid.java b/src/main/java/net/minecraft/server/Fluid.java +index 035f05e827..7c9ba12862 100644 +--- a/src/main/java/net/minecraft/server/Fluid.java ++++ b/src/main/java/net/minecraft/server/Fluid.java +@@ -0,0 +0,0 @@ public interface Fluid extends IBlockDataHolder { + if (immutablemap.isEmpty()) { + object = dynamicops.createMap(ImmutableMap.of(dynamicops.createString("Name"), dynamicops.createString(IRegistry.FLUID.getKey(fluid.getType()).toString()))); + } else { +- object = dynamicops.createMap(ImmutableMap.of(dynamicops.createString("Name"), dynamicops.createString(IRegistry.FLUID.getKey(fluid.getType()).toString()), dynamicops.createString("Properties"), dynamicops.createMap((Map) immutablemap.entrySet().stream().map((entry) -> { ++ object = dynamicops.createMap(ImmutableMap.of(dynamicops.createString("Name"), dynamicops.createString(IRegistry.FLUID.getKey(fluid.getType()).toString()), dynamicops.createString("Properties"), dynamicops.createMap(immutablemap.entrySet().stream().map((entry) -> { // Paper - decompile fix + return Pair.of(dynamicops.createString(((IBlockState) entry.getKey()).a()), dynamicops.createString(IBlockDataHolder.b((IBlockState) entry.getKey(), (Comparable) entry.getValue()))); + }).collect(Collectors.toMap(Pair::getFirst, Pair::getSecond))))); + } diff --git a/src/main/java/net/minecraft/server/IAsyncTaskHandler.java b/src/main/java/net/minecraft/server/IAsyncTaskHandler.java -index 447f6a55b..1890c760f 100644 +index 447f6a55b6..1890c760f9 100644 --- a/src/main/java/net/minecraft/server/IAsyncTaskHandler.java +++ b/src/main/java/net/minecraft/server/IAsyncTaskHandler.java @@ -0,0 +0,0 @@ public abstract class IAsyncTaskHandler implements Mailbox implements @@ -240,7 +298,7 @@ index 3be9efd22..3a1ad2346 100644 for (i = 0; i < k; ++i) { diff --git a/src/main/java/net/minecraft/server/IEntityAccess.java b/src/main/java/net/minecraft/server/IEntityAccess.java -index 534e70671..d5c284cdd 100644 +index 534e70671a..d5c284cdd1 100644 --- a/src/main/java/net/minecraft/server/IEntityAccess.java +++ b/src/main/java/net/minecraft/server/IEntityAccess.java @@ -0,0 +0,0 @@ public interface IEntityAccess { @@ -301,7 +359,7 @@ index 534e70671..d5c284cdd 100644 if (pathfindertargetcondition.a(entityliving, t0)) { list1.add(t0); diff --git a/src/main/java/net/minecraft/server/IOWorker.java b/src/main/java/net/minecraft/server/IOWorker.java -index a986f2912..c5658c077 100644 +index a986f2912f..c5658c0779 100644 --- a/src/main/java/net/minecraft/server/IOWorker.java +++ b/src/main/java/net/minecraft/server/IOWorker.java @@ -0,0 +0,0 @@ public class IOWorker implements AutoCloseable { @@ -340,8 +398,25 @@ index a986f2912..c5658c077 100644 } catch (Exception exception) { IOWorker.LOGGER.error("Failed to close storage", exception); this.h.completeExceptionally(exception); +diff --git a/src/main/java/net/minecraft/server/LightEngineStorageSky.java b/src/main/java/net/minecraft/server/LightEngineStorageSky.java +index 1e1f7ec6e6..75d9065b32 100644 +--- a/src/main/java/net/minecraft/server/LightEngineStorageSky.java ++++ b/src/main/java/net/minecraft/server/LightEngineStorageSky.java +@@ -0,0 +0,0 @@ public class LightEngineStorageSky extends LightEngineStorage= l) { diff --git a/src/main/java/net/minecraft/server/LootSelectorEntry.java b/src/main/java/net/minecraft/server/LootSelectorEntry.java -index 59bb53543..3ed6a1e78 100644 +index 59bb535431..3ed6a1e785 100644 --- a/src/main/java/net/minecraft/server/LootSelectorEntry.java +++ b/src/main/java/net/minecraft/server/LootSelectorEntry.java @@ -0,0 +0,0 @@ public abstract class LootSelectorEntry extends LootEntryAbstract { @@ -369,7 +444,7 @@ index 59bb53543..3ed6a1e78 100644 } diff --git a/src/main/java/net/minecraft/server/NBTBase.java b/src/main/java/net/minecraft/server/NBTBase.java -index 829a7ae0a..8b9e47b4c 100644 +index 829a7ae0a2..8b9e47b4c7 100644 --- a/src/main/java/net/minecraft/server/NBTBase.java +++ b/src/main/java/net/minecraft/server/NBTBase.java @@ -0,0 +0,0 @@ public interface NBTBase { @@ -382,7 +457,7 @@ index 829a7ae0a..8b9e47b4c 100644 default String asString() { return this.toString(); diff --git a/src/main/java/net/minecraft/server/NBTTagList.java b/src/main/java/net/minecraft/server/NBTTagList.java -index 22035b6c0..5406f4c40 100644 +index 22035b6c0b..5406f4c40f 100644 --- a/src/main/java/net/minecraft/server/NBTTagList.java +++ b/src/main/java/net/minecraft/server/NBTTagList.java @@ -0,0 +0,0 @@ public class NBTTagList extends NBTList { @@ -395,7 +470,7 @@ index 22035b6c0..5406f4c40 100644 private byte type; diff --git a/src/main/java/net/minecraft/server/NextTickListEntry.java b/src/main/java/net/minecraft/server/NextTickListEntry.java -index 8471920b8..e9c405fb5 100644 +index 8471920b8b..e9c405fb53 100644 --- a/src/main/java/net/minecraft/server/NextTickListEntry.java +++ b/src/main/java/net/minecraft/server/NextTickListEntry.java @@ -0,0 +0,0 @@ public class NextTickListEntry { @@ -417,7 +492,7 @@ index 8471920b8..e9c405fb5 100644 } diff --git a/src/main/java/net/minecraft/server/RegionFileSection.java b/src/main/java/net/minecraft/server/RegionFileSection.java -index 737afc7d7..db9f0196b 100644 +index 737afc7d71..db9f0196bd 100644 --- a/src/main/java/net/minecraft/server/RegionFileSection.java +++ b/src/main/java/net/minecraft/server/RegionFileSection.java @@ -0,0 +0,0 @@ public class RegionFileSection implements AutoC @@ -442,7 +517,7 @@ index 737afc7d7..db9f0196b 100644 }, dynamic2); }); diff --git a/src/main/java/net/minecraft/server/RegistryBlockID.java b/src/main/java/net/minecraft/server/RegistryBlockID.java -index 7f89562e9..4efcb8b59 100644 +index 7f89562e90..4efcb8b595 100644 --- a/src/main/java/net/minecraft/server/RegistryBlockID.java +++ b/src/main/java/net/minecraft/server/RegistryBlockID.java @@ -0,0 +0,0 @@ public class RegistryBlockID implements Registry { @@ -455,7 +530,7 @@ index 7f89562e9..4efcb8b59 100644 this.c.set(i, t0); diff --git a/src/main/java/net/minecraft/server/RegistryID.java b/src/main/java/net/minecraft/server/RegistryID.java -index 4cb78c6a3..e15d28671 100644 +index 4cb78c6a3f..e15d286710 100644 --- a/src/main/java/net/minecraft/server/RegistryID.java +++ b/src/main/java/net/minecraft/server/RegistryID.java @@ -0,0 +0,0 @@ public class RegistryID implements Registry { @@ -483,7 +558,7 @@ index 4cb78c6a3..e15d28671 100644 this.f = 0; diff --git a/src/main/java/net/minecraft/server/SystemUtils.java b/src/main/java/net/minecraft/server/SystemUtils.java -index 8534585eb..7b92ecfff 100644 +index 8534585eb1..7b92ecfff9 100644 --- a/src/main/java/net/minecraft/server/SystemUtils.java +++ b/src/main/java/net/minecraft/server/SystemUtils.java @@ -0,0 +0,0 @@ public class SystemUtils { @@ -526,8 +601,21 @@ index 8534585eb..7b92ecfff 100644 acompletablefuture[i] = completablefuture1.whenComplete((object, throwable) -> { if (throwable != null) { completablefuture.completeExceptionally(throwable); +diff --git a/src/main/java/net/minecraft/server/ThreadedMailbox.java b/src/main/java/net/minecraft/server/ThreadedMailbox.java +index 8dbb33e749..8082569022 100644 +--- a/src/main/java/net/minecraft/server/ThreadedMailbox.java ++++ b/src/main/java/net/minecraft/server/ThreadedMailbox.java +@@ -0,0 +0,0 @@ public class ThreadedMailbox implements Mailbox, AutoCloseable, Runnable { + + public void run() { + try { +- this.a((i) -> { ++ this.a((int i) -> { // Paper - decompile fix + return i == 0; + }); + } finally { diff --git a/src/main/java/net/minecraft/server/Ticket.java b/src/main/java/net/minecraft/server/Ticket.java -index ee2059cf8..77bb6b092 100644 +index ee2059cf8e..77bb6b092a 100644 --- a/src/main/java/net/minecraft/server/Ticket.java +++ b/src/main/java/net/minecraft/server/Ticket.java @@ -0,0 +0,0 @@ public final class Ticket implements Comparable> { @@ -540,7 +628,7 @@ index ee2059cf8..77bb6b092 100644 } diff --git a/src/main/java/net/minecraft/server/VillagePlace.java b/src/main/java/net/minecraft/server/VillagePlace.java -index c137484f6..c999f8c9b 100644 +index c137484f66..c999f8c9bf 100644 --- a/src/main/java/net/minecraft/server/VillagePlace.java +++ b/src/main/java/net/minecraft/server/VillagePlace.java @@ -0,0 +0,0 @@ public class VillagePlace extends RegionFileSection { @@ -571,7 +659,7 @@ index c137484f6..c999f8c9b 100644 } diff --git a/src/main/java/net/minecraft/server/VillagerTrades.java b/src/main/java/net/minecraft/server/VillagerTrades.java -index a06a31534..3bcf0b385 100644 +index a06a31534e..3bcf0b385d 100644 --- a/src/main/java/net/minecraft/server/VillagerTrades.java +++ b/src/main/java/net/minecraft/server/VillagerTrades.java @@ -0,0 +0,0 @@ import javax.annotation.Nullable; @@ -590,8 +678,21 @@ index a06a31534..3bcf0b385 100644 hashmap.put(VillagerProfession.CARTOGRAPHER, a(ImmutableMap.of(1, new VillagerTrades.IMerchantRecipeOption[]{new VillagerTrades.b(Items.PAPER, 24, 16, 2), new VillagerTrades.h(Items.MAP, 7, 1, 1)}, 2, new VillagerTrades.IMerchantRecipeOption[]{new VillagerTrades.b(Items.df, 11, 16, 10), new VillagerTrades.k(13, "Monument", MapIcon.Type.MONUMENT, 12, 5)}, 3, new VillagerTrades.IMerchantRecipeOption[]{new VillagerTrades.b(Items.COMPASS, 1, 12, 20), new VillagerTrades.k(14, "Mansion", MapIcon.Type.MANSION, 12, 10)}, 4, new VillagerTrades.IMerchantRecipeOption[]{new VillagerTrades.h(Items.ITEM_FRAME, 7, 1, 15), new VillagerTrades.h(Items.WHITE_BANNER, 3, 1, 15), new VillagerTrades.h(Items.BLUE_BANNER, 3, 1, 15), new VillagerTrades.h(Items.LIGHT_BLUE_BANNER, 3, 1, 15), new VillagerTrades.h(Items.RED_BANNER, 3, 1, 15), new VillagerTrades.h(Items.PINK_BANNER, 3, 1, 15), new VillagerTrades.h(Items.GREEN_BANNER, 3, 1, 15), new VillagerTrades.h(Items.LIME_BANNER, 3, 1, 15), new VillagerTrades.h(Items.GRAY_BANNER, 3, 1, 15), new VillagerTrades.h(Items.BLACK_BANNER, 3, 1, 15), new VillagerTrades.h(Items.PURPLE_BANNER, 3, 1, 15), new VillagerTrades.h(Items.MAGENTA_BANNER, 3, 1, 15), new VillagerTrades.h(Items.CYAN_BANNER, 3, 1, 15), new VillagerTrades.h(Items.BROWN_BANNER, 3, 1, 15), new VillagerTrades.h(Items.YELLOW_BANNER, 3, 1, 15), new VillagerTrades.h(Items.ORANGE_BANNER, 3, 1, 15), new VillagerTrades.h(Items.LIGHT_GRAY_BANNER, 3, 1, 15)}, 5, new VillagerTrades.IMerchantRecipeOption[]{new VillagerTrades.h(Items.GLOBE_BANNER_PATTERN, 8, 1, 30)}))); hashmap.put(VillagerProfession.CLERIC, a(ImmutableMap.of(1, new VillagerTrades.IMerchantRecipeOption[]{new VillagerTrades.b(Items.ROTTEN_FLESH, 32, 16, 2), new VillagerTrades.h(Items.REDSTONE, 1, 2, 1)}, 2, new VillagerTrades.IMerchantRecipeOption[]{new VillagerTrades.b(Items.GOLD_INGOT, 3, 12, 10), new VillagerTrades.h(Items.LAPIS_LAZULI, 1, 1, 5)}, 3, new VillagerTrades.IMerchantRecipeOption[]{new VillagerTrades.b(Items.RABBIT_FOOT, 2, 12, 20), new VillagerTrades.h(Blocks.GLOWSTONE, 4, 1, 12, 10)}, 4, new VillagerTrades.IMerchantRecipeOption[]{new VillagerTrades.b(Items.SCUTE, 4, 12, 30), new VillagerTrades.b(Items.GLASS_BOTTLE, 9, 12, 30), new VillagerTrades.h(Items.ENDER_PEARL, 5, 1, 15)}, 5, new VillagerTrades.IMerchantRecipeOption[]{new VillagerTrades.b(Items.NETHER_WART, 22, 12, 30), new VillagerTrades.h(Items.EXPERIENCE_BOTTLE, 3, 1, 30)}))); hashmap.put(VillagerProfession.ARMORER, a(ImmutableMap.of(1, new VillagerTrades.IMerchantRecipeOption[]{new VillagerTrades.b(Items.COAL, 15, 16, 2), new VillagerTrades.h(new ItemStack(Items.IRON_LEGGINGS), 7, 1, 12, 1, 0.2F), new VillagerTrades.h(new ItemStack(Items.IRON_BOOTS), 4, 1, 12, 1, 0.2F), new VillagerTrades.h(new ItemStack(Items.IRON_HELMET), 5, 1, 12, 1, 0.2F), new VillagerTrades.h(new ItemStack(Items.IRON_CHESTPLATE), 9, 1, 12, 1, 0.2F)}, 2, new VillagerTrades.IMerchantRecipeOption[]{new VillagerTrades.b(Items.IRON_INGOT, 4, 12, 10), new VillagerTrades.h(new ItemStack(Items.pQ), 36, 1, 12, 5, 0.2F), new VillagerTrades.h(new ItemStack(Items.CHAINMAIL_BOOTS), 1, 1, 12, 5, 0.2F), new VillagerTrades.h(new ItemStack(Items.CHAINMAIL_LEGGINGS), 3, 1, 12, 5, 0.2F)}, 3, new VillagerTrades.IMerchantRecipeOption[]{new VillagerTrades.b(Items.LAVA_BUCKET, 1, 12, 20), new VillagerTrades.b(Items.DIAMOND, 1, 12, 20), new VillagerTrades.h(new ItemStack(Items.CHAINMAIL_HELMET), 1, 1, 12, 10, 0.2F), new VillagerTrades.h(new ItemStack(Items.CHAINMAIL_CHESTPLATE), 4, 1, 12, 10, 0.2F), new VillagerTrades.h(new ItemStack(Items.SHIELD), 5, 1, 12, 10, 0.2F)}, 4, new VillagerTrades.IMerchantRecipeOption[]{new VillagerTrades.e(Items.DIAMOND_LEGGINGS, 14, 3, 15, 0.2F), new VillagerTrades.e(Items.DIAMOND_BOOTS, 8, 3, 15, 0.2F)}, 5, new VillagerTrades.IMerchantRecipeOption[]{new VillagerTrades.e(Items.DIAMOND_HELMET, 8, 3, 30, 0.2F), new VillagerTrades.e(Items.DIAMOND_CHESTPLATE, 16, 3, 30, 0.2F)}))); +diff --git a/src/main/java/net/minecraft/server/VoxelShapeMergerList.java b/src/main/java/net/minecraft/server/VoxelShapeMergerList.java +index e8daa74986..71d2ae2a9c 100644 +--- a/src/main/java/net/minecraft/server/VoxelShapeMergerList.java ++++ b/src/main/java/net/minecraft/server/VoxelShapeMergerList.java +@@ -0,0 +0,0 @@ public final class VoxelShapeMergerList implements VoxelShapeMerger { + double d1 = flag4 ? doublelist.getDouble(i++) : doublelist1.getDouble(j++); + + if ((i != 0 && flag2 || flag4 || flag1) && (j != 0 && flag3 || !flag4 || flag)) { +- if (d0 < d1 - 1.0E-7D) { ++ if (!(d0 >= d1 - 1.0E-7D)) { // Paper - decompile error - welcome to hell + this.b.add(i - 1); + this.c.add(j - 1); + this.a.add(d1); diff --git a/src/main/java/net/minecraft/server/WorldGenFeatureStateProviderWeighted.java b/src/main/java/net/minecraft/server/WorldGenFeatureStateProviderWeighted.java -index 555cf6be7..22e14fe1e 100644 +index 555cf6be79..22e14fe1e9 100644 --- a/src/main/java/net/minecraft/server/WorldGenFeatureStateProviderWeighted.java +++ b/src/main/java/net/minecraft/server/WorldGenFeatureStateProviderWeighted.java @@ -0,0 +0,0 @@ public class WorldGenFeatureStateProviderWeighted extends WorldGenFeatureStatePr @@ -603,7 +704,7 @@ index 555cf6be7..22e14fe1e 100644 } } diff --git a/src/main/java/net/minecraft/server/WorldPersistentData.java b/src/main/java/net/minecraft/server/WorldPersistentData.java -index 55fe7625a..19e68a783 100644 +index 55fe7625af..19e68a7831 100644 --- a/src/main/java/net/minecraft/server/WorldPersistentData.java +++ b/src/main/java/net/minecraft/server/WorldPersistentData.java @@ -0,0 +0,0 @@ public class WorldPersistentData { diff --git a/Spigot-Server-Patches/MC-Utils.patch b/Spigot-Server-Patches/MC-Utils.patch index 3dcfb35912..14edd37cf1 100644 --- a/Spigot-Server-Patches/MC-Utils.patch +++ b/Spigot-Server-Patches/MC-Utils.patch @@ -4,8 +4,1613 @@ Date: Mon, 28 Mar 2016 20:55:47 -0400 Subject: [PATCH] MC Utils +diff --git a/src/main/java/com/destroystokyo/paper/util/concurrent/WeakSeqLock.java b/src/main/java/com/destroystokyo/paper/util/concurrent/WeakSeqLock.java +new file mode 100644 +index 0000000000..4029dc68cf +--- /dev/null ++++ b/src/main/java/com/destroystokyo/paper/util/concurrent/WeakSeqLock.java +@@ -0,0 +0,0 @@ ++package com.destroystokyo.paper.util.concurrent; ++ ++import java.util.concurrent.atomic.AtomicLong; ++ ++/** ++ * copied from https://github.com/Spottedleaf/ConcurrentUtil/blob/master/src/main/java/ca/spottedleaf/concurrentutil/lock/WeakSeqLock.java ++ * @author Spottedleaf ++ */ ++public final class WeakSeqLock { ++ // TODO when the switch to J11 is made, nuke this class from orbit ++ ++ protected final AtomicLong lock = new AtomicLong(); ++ ++ public WeakSeqLock() { ++ //VarHandle.storeStoreFence(); // warn: usages must be checked to ensure this behaviour isn't needed ++ } ++ ++ public void acquireWrite() { ++ // must be release-type write ++ this.lock.lazySet(this.lock.get() + 1); ++ } ++ ++ public boolean canRead(final long read) { ++ return (read & 1) == 0; ++ } ++ ++ public boolean tryAcquireWrite() { ++ this.acquireWrite(); ++ return true; ++ } ++ ++ public void releaseWrite() { ++ // must be acquire-type write ++ final long lock = this.lock.get(); // volatile here acts as store-store ++ this.lock.lazySet(lock + 1); ++ } ++ ++ public void abortWrite() { ++ // must be acquire-type write ++ final long lock = this.lock.get(); // volatile here acts as store-store ++ this.lock.lazySet(lock ^ 1); ++ } ++ ++ public long acquireRead() { ++ int failures = 0; ++ long curr; ++ ++ for (curr = this.lock.get(); !this.canRead(curr); curr = this.lock.get()) { ++ // without j11, our only backoff is the yield() call... ++ ++ if (++failures > 5_000) { /* TODO determine a threshold */ ++ Thread.yield(); ++ } ++ /* Better waiting is beyond the scope of this lock; if it is needed the lock is being misused */ ++ } ++ ++ //VarHandle.loadLoadFence(); // volatile acts as the load-load barrier ++ return curr; ++ } ++ ++ public boolean tryReleaseRead(final long read) { ++ return this.lock.get() == read; // volatile acts as the load-load barrier ++ } ++ ++ public long getSequentialCounter() { ++ return this.lock.get(); ++ } ++} +diff --git a/src/main/java/com/destroystokyo/paper/util/map/QueuedChangesMapLong2Int.java b/src/main/java/com/destroystokyo/paper/util/map/QueuedChangesMapLong2Int.java +new file mode 100644 +index 0000000000..968c9ed328 +--- /dev/null ++++ b/src/main/java/com/destroystokyo/paper/util/map/QueuedChangesMapLong2Int.java +@@ -0,0 +0,0 @@ ++package com.destroystokyo.paper.util.map; ++ ++import com.destroystokyo.paper.util.concurrent.WeakSeqLock; ++import it.unimi.dsi.fastutil.longs.Long2IntMap; ++import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap; ++import it.unimi.dsi.fastutil.longs.LongIterator; ++import it.unimi.dsi.fastutil.longs.LongOpenHashSet; ++import it.unimi.dsi.fastutil.objects.ObjectIterator; ++ ++/** ++ * @author Spottedleaf ++ */ ++public class QueuedChangesMapLong2Int { ++ ++ protected final Long2IntOpenHashMap updatingMap; ++ protected final Long2IntOpenHashMap visibleMap; ++ protected final Long2IntOpenHashMap queuedPuts; ++ protected final LongOpenHashSet queuedRemove; ++ ++ protected int queuedDefaultReturnValue; ++ ++ // we use a seqlock as writes are not common. ++ protected final WeakSeqLock updatingMapSeqLock = new WeakSeqLock(); ++ ++ public QueuedChangesMapLong2Int() { ++ this(16, 0.75f); ++ } ++ ++ public QueuedChangesMapLong2Int(final int capacity, final float loadFactor) { ++ this.updatingMap = new Long2IntOpenHashMap(capacity, loadFactor); ++ this.visibleMap = new Long2IntOpenHashMap(capacity, loadFactor); ++ this.queuedPuts = new Long2IntOpenHashMap(); ++ this.queuedRemove = new LongOpenHashSet(); ++ } ++ ++ public void queueDefaultReturnValue(final int dfl) { ++ this.queuedDefaultReturnValue = dfl; ++ this.updatingMap.defaultReturnValue(dfl); ++ } ++ ++ public int queueUpdate(final long k, final int v) { ++ this.queuedRemove.remove(k); ++ this.queuedPuts.put(k, v); ++ ++ return this.updatingMap.put(k, v); ++ } ++ ++ public int queueRemove(final long k) { ++ this.queuedPuts.remove(k); ++ this.queuedRemove.add(k); ++ ++ return this.updatingMap.remove(k); ++ } ++ ++ public int getUpdating(final long k) { ++ return this.updatingMap.get(k); ++ } ++ ++ public int getVisible(final long k) { ++ return this.visibleMap.get(k); ++ } ++ ++ public int getVisibleAsync(final long k) { ++ long readlock; ++ int ret = 0; ++ ++ do { ++ readlock = this.updatingMapSeqLock.acquireRead(); ++ try { ++ ret = this.visibleMap.get(k); ++ } catch (final Throwable thr) { ++ if (thr instanceof ThreadDeath) { ++ throw (ThreadDeath)thr; ++ } ++ // ignore... ++ continue; ++ } ++ ++ } while (!this.updatingMapSeqLock.tryReleaseRead(readlock)); ++ ++ return ret; ++ } ++ ++ public boolean performUpdates() { ++ this.updatingMapSeqLock.acquireWrite(); ++ this.visibleMap.defaultReturnValue(this.queuedDefaultReturnValue); ++ this.updatingMapSeqLock.releaseWrite(); ++ ++ if (this.queuedPuts.isEmpty() && this.queuedRemove.isEmpty()) { ++ return false; ++ } ++ ++ // update puts ++ final ObjectIterator iterator0 = this.queuedPuts.long2IntEntrySet().fastIterator(); ++ while (iterator0.hasNext()) { ++ final Long2IntMap.Entry entry = iterator0.next(); ++ final long key = entry.getLongKey(); ++ final int val = entry.getValue(); ++ ++ this.updatingMapSeqLock.acquireWrite(); ++ try { ++ this.visibleMap.put(key, val); ++ } finally { ++ this.updatingMapSeqLock.releaseWrite(); ++ } ++ } ++ ++ final LongIterator iterator1 = this.queuedRemove.iterator(); ++ while (iterator1.hasNext()) { ++ final long key = iterator1.nextLong(); ++ ++ this.updatingMapSeqLock.acquireWrite(); ++ try { ++ this.visibleMap.remove(key); ++ } finally { ++ this.updatingMapSeqLock.releaseWrite(); ++ } ++ } ++ ++ ++ return true; ++ } ++ ++ public boolean performUpdatesLockMap() { ++ this.updatingMapSeqLock.acquireWrite(); ++ try { ++ this.visibleMap.defaultReturnValue(this.queuedDefaultReturnValue); ++ ++ if (this.queuedPuts.isEmpty() && this.queuedRemove.isEmpty()) { ++ return false; ++ } ++ ++ // update puts ++ final ObjectIterator iterator0 = this.queuedPuts.long2IntEntrySet().fastIterator(); ++ while (iterator0.hasNext()) { ++ final Long2IntMap.Entry entry = iterator0.next(); ++ final long key = entry.getLongKey(); ++ final int val = entry.getValue(); ++ ++ this.visibleMap.put(key, val); ++ } ++ ++ final LongIterator iterator1 = this.queuedRemove.iterator(); ++ while (iterator1.hasNext()) { ++ final long key = iterator1.nextLong(); ++ ++ this.visibleMap.remove(key); ++ } ++ ++ ++ return true; ++ } finally { ++ this.updatingMapSeqLock.releaseWrite(); ++ } ++ } ++} +diff --git a/src/main/java/com/destroystokyo/paper/util/map/QueuedChangesMapLong2Object.java b/src/main/java/com/destroystokyo/paper/util/map/QueuedChangesMapLong2Object.java +new file mode 100644 +index 0000000000..07685b6bd5 +--- /dev/null ++++ b/src/main/java/com/destroystokyo/paper/util/map/QueuedChangesMapLong2Object.java +@@ -0,0 +0,0 @@ ++package com.destroystokyo.paper.util.map; ++ ++import com.destroystokyo.paper.util.concurrent.WeakSeqLock; ++import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap; ++import it.unimi.dsi.fastutil.longs.Long2ObjectMap; ++import it.unimi.dsi.fastutil.objects.ObjectBidirectionalIterator; ++import java.util.ArrayList; ++import java.util.Collection; ++import java.util.List; ++ ++/** ++ * @author Spottedleaf ++ */ ++public class QueuedChangesMapLong2Object { ++ ++ protected static final Object REMOVED = new Object(); ++ ++ protected final Long2ObjectLinkedOpenHashMap updatingMap; ++ protected final Long2ObjectLinkedOpenHashMap visibleMap; ++ protected final Long2ObjectLinkedOpenHashMap queuedChanges; ++ ++ // we use a seqlock as writes are not common. ++ protected final WeakSeqLock updatingMapSeqLock = new WeakSeqLock(); ++ ++ public QueuedChangesMapLong2Object() { ++ this(16, 0.75f); // dfl for fastutil ++ } ++ ++ public QueuedChangesMapLong2Object(final int capacity, final float loadFactor) { ++ this.updatingMap = new Long2ObjectLinkedOpenHashMap<>(capacity, loadFactor); ++ this.visibleMap = new Long2ObjectLinkedOpenHashMap<>(capacity, loadFactor); ++ this.queuedChanges = new Long2ObjectLinkedOpenHashMap<>(); ++ } ++ ++ public V queueUpdate(final long k, final V value) { ++ this.queuedChanges.put(k, value); ++ return this.updatingMap.put(k, value); ++ } ++ ++ public V queueRemove(final long k) { ++ this.queuedChanges.put(k, REMOVED); ++ return this.updatingMap.remove(k); ++ } ++ ++ public V getUpdating(final long k) { ++ return this.updatingMap.get(k); ++ } ++ ++ public V getVisible(final long k) { ++ return this.visibleMap.get(k); ++ } ++ ++ public V getVisibleAsync(final long k) { ++ long readlock; ++ V ret = null; ++ ++ do { ++ readlock = this.updatingMapSeqLock.acquireRead(); ++ ++ try { ++ ret = this.visibleMap.get(k); ++ } catch (final Throwable thr) { ++ if (thr instanceof ThreadDeath) { ++ throw (ThreadDeath)thr; ++ } ++ // ignore... ++ continue; ++ } ++ ++ } while (!this.updatingMapSeqLock.tryReleaseRead(readlock)); ++ ++ return ret; ++ } ++ ++ public Long2ObjectLinkedOpenHashMap getVisibleMap() { ++ return this.visibleMap; ++ } ++ ++ public Long2ObjectLinkedOpenHashMap getUpdatingMap() { ++ return this.updatingMap; ++ } ++ ++ public int getVisibleSize() { ++ return this.visibleMap.size(); ++ } ++ ++ public int getVisibleSizeAsync() { ++ long readlock; ++ int ret; ++ ++ do { ++ readlock = this.updatingMapSeqLock.acquireRead(); ++ ret = this.visibleMap.size(); ++ } while (!this.updatingMapSeqLock.tryReleaseRead(readlock)); ++ ++ return ret; ++ } ++ ++ // unlike mojang's impl this cannot be used async since it's not a view of an immutable map ++ public Collection getUpdatingValues() { ++ return this.updatingMap.values(); ++ } ++ ++ public List getUpdatingValuesCopy() { ++ return new ArrayList<>(this.updatingMap.values()); ++ } ++ ++ // unlike mojang's impl this cannot be used async since it's not a view of an immutable map ++ public Collection getVisibleValues() { ++ return this.visibleMap.values(); ++ } ++ ++ public List getVisibleValuesCopy() { ++ return new ArrayList<>(this.visibleMap.values()); ++ } ++ ++ public boolean performUpdates() { ++ if (this.queuedChanges.isEmpty()) { ++ return false; ++ } ++ ++ final ObjectBidirectionalIterator> iterator = this.queuedChanges.long2ObjectEntrySet().fastIterator(); ++ while (iterator.hasNext()) { ++ final Long2ObjectMap.Entry entry = iterator.next(); ++ final long key = entry.getLongKey(); ++ final Object val = entry.getValue(); ++ ++ this.updatingMapSeqLock.acquireWrite(); ++ try { ++ if (val == REMOVED) { ++ this.visibleMap.remove(key); ++ } else { ++ this.visibleMap.put(key, (V)val); ++ } ++ } finally { ++ this.updatingMapSeqLock.releaseWrite(); ++ } ++ } ++ ++ this.queuedChanges.clear(); ++ return true; ++ } ++ ++ public boolean performUpdatesLockMap() { ++ if (this.queuedChanges.isEmpty()) { ++ return false; ++ } ++ ++ final ObjectBidirectionalIterator> iterator = this.queuedChanges.long2ObjectEntrySet().fastIterator(); ++ ++ try { ++ this.updatingMapSeqLock.acquireWrite(); ++ ++ while (iterator.hasNext()) { ++ final Long2ObjectMap.Entry entry = iterator.next(); ++ final long key = entry.getLongKey(); ++ final Object val = entry.getValue(); ++ ++ if (val == REMOVED) { ++ this.visibleMap.remove(key); ++ } else { ++ this.visibleMap.put(key, (V)val); ++ } ++ } ++ } finally { ++ this.updatingMapSeqLock.releaseWrite(); ++ } ++ ++ this.queuedChanges.clear(); ++ return true; ++ } ++} +diff --git a/src/main/java/com/destroystokyo/paper/util/maplist/ChunkList.java b/src/main/java/com/destroystokyo/paper/util/maplist/ChunkList.java +new file mode 100644 +index 0000000000..4ec248adb6 +--- /dev/null ++++ b/src/main/java/com/destroystokyo/paper/util/maplist/ChunkList.java +@@ -0,0 +0,0 @@ ++package com.destroystokyo.paper.util.maplist; ++ ++import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap; ++import net.minecraft.server.Chunk; ++import net.minecraft.server.MCUtil; ++import java.util.Arrays; ++import java.util.Iterator; ++import java.util.NoSuchElementException; ++ ++// list with O(1) remove & contains ++/** ++ * @author Spottedleaf ++ */ ++public final class ChunkList implements Iterable { ++ ++ protected final Long2IntOpenHashMap chunkToIndex = new Long2IntOpenHashMap(); ++ { ++ this.chunkToIndex.defaultReturnValue(Integer.MIN_VALUE); ++ } ++ ++ protected Chunk[] chunks = new Chunk[16]; ++ protected int count; ++ ++ public int size() { ++ return this.count; ++ } ++ ++ public boolean contains(final Chunk chunk) { ++ return this.chunkToIndex.containsKey(MCUtil.getCoordinateKey(chunk.getPos())); ++ } ++ ++ public boolean remove(final Chunk chunk) { ++ final int index = this.chunkToIndex.remove(MCUtil.getCoordinateKey(chunk.getPos())); ++ if (index == Integer.MIN_VALUE) { ++ return false; ++ } ++ ++ // move the entity at the end to this index ++ final int endIndex = --this.count; ++ final Chunk end = this.chunks[endIndex]; ++ if (index != endIndex) { ++ // not empty after this call ++ this.chunkToIndex.put(MCUtil.getCoordinateKey(end.getPos()), index); // update index ++ } ++ this.chunks[index] = end; ++ this.chunks[endIndex] = null; ++ ++ return true; ++ } ++ ++ public boolean add(final Chunk chunk) { ++ final int count = this.count; ++ final int currIndex = this.chunkToIndex.putIfAbsent(MCUtil.getCoordinateKey(chunk.getPos()), count); ++ ++ if (currIndex != Integer.MIN_VALUE) { ++ return false; // already in this list ++ } ++ ++ Chunk[] list = this.chunks; ++ ++ if (list.length == count) { ++ // resize required ++ list = this.chunks = Arrays.copyOf(list, count * 2); // overflow results in negative ++ } ++ ++ list[count] = chunk; ++ this.count = count + 1; ++ ++ return true; ++ } ++ ++ public Chunk getChecked(final int index) { ++ if (index < 0 || index >= this.count) { ++ throw new IndexOutOfBoundsException("Index: " + index + " is out of bounds, size: " + this.count); ++ } ++ return this.chunks[index]; ++ } ++ ++ public Chunk getUnchecked(final int index) { ++ return this.chunks[index]; ++ } ++ ++ public Chunk[] getRawData() { ++ return this.chunks; ++ } ++ ++ public void clear() { ++ this.chunkToIndex.clear(); ++ Arrays.fill(this.chunks, 0, this.count, null); ++ this.count = 0; ++ } ++ ++ @Override ++ public Iterator iterator() { ++ return new Iterator() { ++ ++ Chunk lastRet; ++ int current; ++ ++ @Override ++ public boolean hasNext() { ++ return this.current < ChunkList.this.count; ++ } ++ ++ @Override ++ public Chunk next() { ++ if (this.current >= ChunkList.this.count) { ++ throw new NoSuchElementException(); ++ } ++ return this.lastRet = ChunkList.this.chunks[this.current++]; ++ } ++ ++ @Override ++ public void remove() { ++ final Chunk lastRet = this.lastRet; ++ ++ if (lastRet == null) { ++ throw new IllegalStateException(); ++ } ++ this.lastRet = null; ++ ++ ChunkList.this.remove(lastRet); ++ --this.current; ++ } ++ }; ++ } ++} +diff --git a/src/main/java/com/destroystokyo/paper/util/maplist/EntityList.java b/src/main/java/com/destroystokyo/paper/util/maplist/EntityList.java +new file mode 100644 +index 0000000000..f3cb346c9d +--- /dev/null ++++ b/src/main/java/com/destroystokyo/paper/util/maplist/EntityList.java +@@ -0,0 +0,0 @@ ++package com.destroystokyo.paper.util.maplist; ++ ++import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; ++import net.minecraft.server.Entity; ++import java.util.Arrays; ++import java.util.Iterator; ++import java.util.NoSuchElementException; ++ ++// list with O(1) remove & contains ++/** ++ * @author Spottedleaf ++ */ ++public final class EntityList implements Iterable { ++ ++ protected final Int2IntOpenHashMap entityToIndex = new Int2IntOpenHashMap(); ++ { ++ this.entityToIndex.defaultReturnValue(Integer.MIN_VALUE); ++ } ++ ++ protected Entity[] entities = new Entity[16]; ++ protected int count; ++ ++ public int size() { ++ return this.count; ++ } ++ ++ public boolean contains(final Entity entity) { ++ return this.entityToIndex.containsKey(entity.getId()); ++ } ++ ++ public boolean remove(final Entity entity) { ++ final int index = this.entityToIndex.remove(entity.getId()); ++ if (index == Integer.MIN_VALUE) { ++ return false; ++ } ++ ++ // move the entity at the end to this index ++ final int endIndex = --this.count; ++ final Entity end = this.entities[endIndex]; ++ if (index != endIndex) { ++ // not empty after this call ++ this.entityToIndex.put(end.getId(), index); // update index ++ } ++ this.entities[index] = end; ++ this.entities[endIndex] = null; ++ ++ return true; ++ } ++ ++ public boolean add(final Entity entity) { ++ final int count = this.count; ++ final int currIndex = this.entityToIndex.putIfAbsent(entity.getId(), count); ++ ++ if (currIndex != Integer.MIN_VALUE) { ++ return false; // already in this list ++ } ++ ++ Entity[] list = this.entities; ++ ++ if (list.length == count) { ++ // resize required ++ list = this.entities = Arrays.copyOf(list, count * 2); // overflow results in negative ++ } ++ ++ list[count] = entity; ++ this.count = count + 1; ++ ++ return true; ++ } ++ ++ public Entity getChecked(final int index) { ++ if (index < 0 || index >= this.count) { ++ throw new IndexOutOfBoundsException("Index: " + index + " is out of bounds, size: " + this.count); ++ } ++ return this.entities[index]; ++ } ++ ++ public Entity getUnchecked(final int index) { ++ return this.entities[index]; ++ } ++ ++ public Entity[] getRawData() { ++ return this.entities; ++ } ++ ++ public void clear() { ++ this.entityToIndex.clear(); ++ Arrays.fill(this.entities, 0, this.count, null); ++ this.count = 0; ++ } ++ ++ @Override ++ public Iterator iterator() { ++ return new Iterator() { ++ ++ Entity lastRet; ++ int current; ++ ++ @Override ++ public boolean hasNext() { ++ return this.current < EntityList.this.count; ++ } ++ ++ @Override ++ public Entity next() { ++ if (this.current >= EntityList.this.count) { ++ throw new NoSuchElementException(); ++ } ++ return this.lastRet = EntityList.this.entities[this.current++]; ++ } ++ ++ @Override ++ public void remove() { ++ final Entity lastRet = this.lastRet; ++ ++ if (lastRet == null) { ++ throw new IllegalStateException(); ++ } ++ this.lastRet = null; ++ ++ EntityList.this.remove(lastRet); ++ --this.current; ++ } ++ }; ++ } ++} +diff --git a/src/main/java/com/destroystokyo/paper/util/maplist/IBlockDataList.java b/src/main/java/com/destroystokyo/paper/util/maplist/IBlockDataList.java +new file mode 100644 +index 0000000000..c2f7e4ca0f +--- /dev/null ++++ b/src/main/java/com/destroystokyo/paper/util/maplist/IBlockDataList.java +@@ -0,0 +0,0 @@ ++package com.destroystokyo.paper.util.maplist; ++ ++import it.unimi.dsi.fastutil.longs.LongIterator; ++import it.unimi.dsi.fastutil.shorts.Short2LongOpenHashMap; ++import net.minecraft.server.ChunkSection; ++import net.minecraft.server.DataPaletteGlobal; ++import net.minecraft.server.IBlockData; ++import java.util.Arrays; ++ ++/** ++ * @author Spottedleaf ++ */ ++public final class IBlockDataList { ++ ++ static final DataPaletteGlobal GLOBAL_PALETTE = (DataPaletteGlobal)ChunkSection.GLOBAL_PALETTE; ++ ++ // map of location -> (index | (location << 16) | (palette id << 32)) ++ private final Short2LongOpenHashMap map = new Short2LongOpenHashMap(16, 0.7f); ++ { ++ this.map.defaultReturnValue(Long.MAX_VALUE); ++ } ++ ++ private long[] byIndex = new long[16]; ++ private int size; ++ ++ public static int getLocationKey(final int x, final int y, final int z) { ++ return (x & 15) | (((z & 15) << 4)) | ((y & 255) << (4 + 4)); ++ } ++ ++ public static IBlockData getBlockDataFromRaw(final long raw) { ++ return GLOBAL_PALETTE.getObject((int)(raw >>> 32)); ++ } ++ ++ public static int getIndexFromRaw(final long raw) { ++ return (int)(raw & 0xFFFF); ++ } ++ ++ public static int getLocationFromRaw(final long raw) { ++ return (int)((raw >>> 16) & 0xFFFF); ++ } ++ ++ public static long getRawFromValues(final int index, final int location, final IBlockData data) { ++ return (long)index | ((long)location << 16) | (((long)GLOBAL_PALETTE.getOrCreateIdFor(data)) << 32); ++ } ++ ++ public static long setIndexRawValues(final long value, final int index) { ++ return value & ~(0xFFFF) | (index); ++ } ++ ++ public long add(final int x, final int y, final int z, final IBlockData data) { ++ return this.add(getLocationKey(x, y, z), data); ++ } ++ ++ public long add(final int location, final IBlockData data) { ++ final long curr = this.map.get((short)location); ++ ++ if (curr == Long.MAX_VALUE) { ++ final int index = this.size++; ++ final long raw = getRawFromValues(index, location, data); ++ this.map.put((short)location, raw); ++ ++ if (index >= this.byIndex.length) { ++ this.byIndex = Arrays.copyOf(this.byIndex, this.byIndex.length * 2); ++ } ++ ++ this.byIndex[index] = raw; ++ return raw; ++ } else { ++ final int index = getIndexFromRaw(curr); ++ final long raw = this.byIndex[index] = getRawFromValues(index, location, data); ++ ++ this.map.put((short)location, raw); ++ ++ return raw; ++ } ++ } ++ ++ public long remove(final int x, final int y, final int z) { ++ return this.remove(getLocationKey(x, y, z)); ++ } ++ ++ public long remove(final int location) { ++ final long ret = this.map.remove((short)location); ++ final int index = getIndexFromRaw(ret); ++ if (ret == Long.MAX_VALUE) { ++ return ret; ++ } ++ ++ // move the entry at the end to this index ++ final int endIndex = --this.size; ++ final long end = this.byIndex[endIndex]; ++ if (index != endIndex) { ++ // not empty after this call ++ this.map.put((short)getLocationFromRaw(end), setIndexRawValues(end, index)); ++ } ++ this.byIndex[index] = end; ++ this.byIndex[endIndex] = 0L; ++ ++ return ret; ++ } ++ ++ public int size() { ++ return this.size; ++ } ++ ++ public long getRaw(final int index) { ++ return this.byIndex[index]; ++ } ++ ++ public int getLocation(final int index) { ++ return getLocationFromRaw(this.getRaw(index)); ++ } ++ ++ public IBlockData getData(final int index) { ++ return getBlockDataFromRaw(this.getRaw(index)); ++ } ++ ++ public void clear() { ++ this.size = 0; ++ this.map.clear(); ++ } ++ ++ public LongIterator getRawIterator() { ++ return this.map.values().iterator(); ++ } ++} +diff --git a/src/main/java/com/destroystokyo/paper/util/misc/AreaMap.java b/src/main/java/com/destroystokyo/paper/util/misc/AreaMap.java +new file mode 100644 +index 0000000000..5a44bc644b +--- /dev/null ++++ b/src/main/java/com/destroystokyo/paper/util/misc/AreaMap.java +@@ -0,0 +0,0 @@ ++package com.destroystokyo.paper.util.misc; ++ ++import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap; ++import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; ++import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; ++import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap; ++import net.minecraft.server.ChunkCoordIntPair; ++import net.minecraft.server.MCUtil; ++import net.minecraft.server.MinecraftServer; ++import javax.annotation.Nullable; ++import java.util.Iterator; ++ ++/** ++ * @author Spottedleaf ++ */ ++public abstract class AreaMap { ++ ++ /* Tested via https://gist.github.com/Spottedleaf/520419c6f41ef348fe9926ce674b7217 */ ++ ++ private final Object2LongOpenHashMap objectToLastCoordinate = new Object2LongOpenHashMap<>(); ++ private final Object2IntOpenHashMap objectToViewDistance = new Object2IntOpenHashMap<>(); ++ ++ { ++ this.objectToViewDistance.defaultReturnValue(-1); ++ this.objectToLastCoordinate.defaultReturnValue(Long.MIN_VALUE); ++ } ++ ++ // we use linked for better iteration. ++ // map of: coordinate to set of objects in coordinate ++ private final Long2ObjectOpenHashMap> areaMap = new Long2ObjectOpenHashMap<>(1024, 0.3f); ++ private final PooledLinkedHashSets pooledHashSets; ++ ++ private final ChangeCallback addCallback; ++ private final ChangeCallback removeCallback; ++ ++ public AreaMap() { ++ this(new PooledLinkedHashSets<>()); ++ } ++ ++ // let users define a "global" or "shared" pooled sets if they wish ++ public AreaMap(final PooledLinkedHashSets pooledHashSets) { ++ this(pooledHashSets, null, null); ++ } ++ ++ public AreaMap(final PooledLinkedHashSets pooledHashSets, final ChangeCallback addCallback, final ChangeCallback removeCallback) { ++ this.pooledHashSets = pooledHashSets; ++ this.addCallback = addCallback; ++ this.removeCallback = removeCallback; ++ } ++ ++ @Nullable ++ public PooledLinkedHashSets.PooledObjectLinkedOpenHashSet getObjectsInRange(final long key) { ++ return this.areaMap.get(key); ++ } ++ ++ @Nullable ++ public PooledLinkedHashSets.PooledObjectLinkedOpenHashSet getObjectsInRange(final ChunkCoordIntPair chunkPos) { ++ return this.getObjectsInRange(chunkPos.x, chunkPos.z); ++ } ++ ++ @Nullable ++ public PooledLinkedHashSets.PooledObjectLinkedOpenHashSet getObjectsInRange(final int chunkX, final int chunkZ) { ++ return this.getObjectsInRange(MCUtil.getCoordinateKey(chunkX, chunkZ)); ++ } ++ ++ // Long.MIN_VALUE indicates the object is not mapped ++ public long getLastCoordinate(final E object) { ++ return this.objectToLastCoordinate.getOrDefault(object, Long.MIN_VALUE); ++ } ++ ++ // -1 indicates the object is not mapped ++ public int getLastViewDistance(final E object) { ++ return this.objectToViewDistance.getOrDefault(object, -1); ++ } ++ ++ // returns the total number of mapped chunks ++ public int size() { ++ return this.areaMap.size(); ++ } ++ ++ public void update(final E object, final int chunkX, final int chunkZ, final int viewDistance) { ++ final int oldDistance = this.objectToViewDistance.put(object, viewDistance); ++ final long newPos = MCUtil.getCoordinateKey(chunkX, chunkZ); ++ if (oldDistance == -1) { ++ this.objectToLastCoordinate.put(object, newPos); ++ this.addObject(object, chunkX, chunkZ, Integer.MIN_VALUE, Integer.MIN_VALUE, viewDistance); ++ } else { ++ this.updateObject(object, this.objectToLastCoordinate.put(object, newPos), newPos, oldDistance, viewDistance); ++ } ++ //this.validate(object, viewDistance); ++ } ++ ++ public boolean remove(final E object) { ++ final long position = this.objectToLastCoordinate.removeLong(object); ++ final int viewDistance = this.objectToViewDistance.removeInt(object); ++ ++ if (viewDistance == -1) { ++ return false; ++ } ++ ++ final int currentX = MCUtil.getCoordinateX(position); ++ final int currentZ = MCUtil.getCoordinateZ(position); ++ ++ this.removeObject(object, currentX, currentZ, currentX, currentZ, viewDistance); ++ //this.validate(object, -1); ++ return true; ++ } ++ ++ protected abstract PooledLinkedHashSets.PooledObjectLinkedOpenHashSet getEmptySetFor(final E object); ++ ++ // expensive op, only for debug ++ private void validate(final E object, final int viewDistance) { ++ int entiesGot = 0; ++ int expectedEntries = (2 * viewDistance + 1); ++ expectedEntries *= expectedEntries; ++ if (viewDistance < 0) { ++ expectedEntries = 0; ++ } ++ ++ final long currPosition = this.objectToLastCoordinate.getLong(object); ++ ++ final int centerX = MCUtil.getCoordinateX(currPosition); ++ final int centerZ = MCUtil.getCoordinateZ(currPosition); ++ ++ for (Iterator>> iterator = this.areaMap.long2ObjectEntrySet().fastIterator(); ++ iterator.hasNext();) { ++ ++ final Long2ObjectLinkedOpenHashMap.Entry> entry = iterator.next(); ++ final long key = entry.getLongKey(); ++ final PooledLinkedHashSets.PooledObjectLinkedOpenHashSet map = entry.getValue(); ++ ++ if (map.referenceCount == 0) { ++ throw new IllegalStateException("Invalid map"); ++ } ++ ++ if (map.contains(object)) { ++ ++entiesGot; ++ ++ final int chunkX = MCUtil.getCoordinateX(key); ++ final int chunkZ = MCUtil.getCoordinateZ(key); ++ ++ final int dist = Math.max(Math.abs(chunkX - centerX), Math.abs(chunkZ - centerZ)); ++ ++ if (dist > viewDistance) { ++ throw new IllegalStateException("Expected view distance " + viewDistance + ", got " + dist); ++ } ++ } ++ } ++ ++ if (entiesGot != expectedEntries) { ++ throw new IllegalStateException("Expected " + expectedEntries + ", got " + entiesGot); ++ } ++ } ++ ++ protected final void addObjectTo(final E object, final int chunkX, final int chunkZ, final int currChunkX, ++ final int currChunkZ, final int prevChunkX, final int prevChunkZ) { ++ final long key = MCUtil.getCoordinateKey(chunkX, chunkZ); ++ ++ PooledLinkedHashSets.PooledObjectLinkedOpenHashSet empty = this.getEmptySetFor(object); ++ PooledLinkedHashSets.PooledObjectLinkedOpenHashSet current = this.areaMap.putIfAbsent(key, empty); ++ ++ if (current != null) { ++ PooledLinkedHashSets.PooledObjectLinkedOpenHashSet next = this.pooledHashSets.findMapWith(current, object); ++ if (next == current) { ++ throw new IllegalStateException("Expected different map: got " + next.toString()); ++ } ++ this.areaMap.put(key, next); ++ ++ current = next; ++ // fall through to callback ++ } else { ++ current = empty; ++ } ++ ++ if (this.addCallback != null) { ++ try { ++ this.addCallback.accept(object, chunkX, chunkZ, currChunkX, currChunkZ, prevChunkX, prevChunkZ, current); ++ } catch (final Throwable ex) { ++ if (ex instanceof ThreadDeath) { ++ throw (ThreadDeath)ex; ++ } ++ MinecraftServer.LOGGER.error("Add callback for map threw exception ", ex); ++ } ++ } ++ } ++ ++ protected final void removeObjectFrom(final E object, final int chunkX, final int chunkZ, final int currChunkX, ++ final int currChunkZ, final int prevChunkX, final int prevChunkZ) { ++ final long key = MCUtil.getCoordinateKey(chunkX, chunkZ); ++ ++ PooledLinkedHashSets.PooledObjectLinkedOpenHashSet current = this.areaMap.get(key); ++ ++ if (current == null) { ++ throw new IllegalStateException("Current map may not be null for " + object + ", (" + chunkX + "," + chunkZ + ")"); ++ } ++ ++ PooledLinkedHashSets.PooledObjectLinkedOpenHashSet next = this.pooledHashSets.findMapWithout(current, object); ++ ++ if (next == current) { ++ throw new IllegalStateException("Current map [" + next.toString() + "] should have contained " + object + ", (" + chunkX + "," + chunkZ + ")"); ++ } ++ ++ if (next != null) { ++ this.areaMap.put(key, next); ++ } else { ++ this.areaMap.remove(key); ++ } ++ ++ if (this.removeCallback != null) { ++ try { ++ this.removeCallback.accept(object, chunkX, chunkZ, currChunkX, currChunkZ, prevChunkX, prevChunkZ, next); ++ } catch (final Throwable ex) { ++ if (ex instanceof ThreadDeath) { ++ throw (ThreadDeath)ex; ++ } ++ MinecraftServer.LOGGER.error("Remove callback for map threw exception ", ex); ++ } ++ } ++ } ++ ++ private void addObject(final E object, final int chunkX, final int chunkZ, final int prevChunkX, final int prevChunkZ, final int viewDistance) { ++ final int maxX = chunkX + viewDistance; ++ final int maxZ = chunkZ + viewDistance; ++ for (int x = chunkX - viewDistance; x <= maxX; ++x) { ++ for (int z = chunkZ - viewDistance; z <= maxZ; ++z) { ++ this.addObjectTo(object, x, z, chunkX, chunkZ, prevChunkX, prevChunkZ); ++ } ++ } ++ } ++ ++ private void removeObject(final E object, final int chunkX, final int chunkZ, final int currentChunkX, final int currentChunkZ, final int viewDistance) { ++ final int maxX = chunkX + viewDistance; ++ final int maxZ = chunkZ + viewDistance; ++ for (int x = chunkX - viewDistance; x <= maxX; ++x) { ++ for (int z = chunkZ - viewDistance; z <= maxZ; ++z) { ++ this.removeObjectFrom(object, x, z, currentChunkX, currentChunkZ, chunkX, chunkZ); ++ } ++ } ++ } ++ ++ /* math sign function except 0 returns 1 */ ++ protected static int sign(int val) { ++ return 1 | (val >> (Integer.SIZE - 1)); ++ } ++ ++ protected final void updateObject(final E object, final long oldPosition, final long newPosition, final int oldViewDistance, final int newViewDistance) { ++ final int toX = MCUtil.getCoordinateX(newPosition); ++ final int toZ = MCUtil.getCoordinateZ(newPosition); ++ final int fromX = MCUtil.getCoordinateX(oldPosition); ++ final int fromZ = MCUtil.getCoordinateZ(oldPosition); ++ ++ final int dx = toX - fromX; ++ final int dz = toZ - fromZ; ++ ++ final int totalX = Math.abs(fromX - toX); ++ final int totalZ = Math.abs(fromZ - toZ); ++ ++ if (Math.max(totalX, totalZ) > (2 * Math.max(newViewDistance, oldViewDistance))) { ++ // teleported? ++ this.removeObject(object, fromX, fromZ, fromX, fromZ, oldViewDistance); ++ this.addObject(object, toX, toZ, fromX, fromZ, newViewDistance); ++ return; ++ } ++ ++ if (oldViewDistance != newViewDistance) { ++ // remove loop ++ ++ final int oldMaxX = fromX + oldViewDistance; ++ final int oldMaxZ = fromZ + oldViewDistance; ++ for (int currX = fromX - oldViewDistance; currX <= oldMaxX; ++currX) { ++ for (int currZ = fromZ - oldViewDistance; currZ <= oldMaxZ; ++currZ) { ++ ++ // only remove if we're outside the new view distance... ++ if (Math.max(Math.abs(currX - toX), Math.abs(currZ - toZ)) > newViewDistance) { ++ this.removeObjectFrom(object, currX, currZ, toX, toZ, fromX, fromZ); ++ } ++ } ++ } ++ ++ // add loop ++ ++ final int newMaxX = toX + newViewDistance; ++ final int newMaxZ = toZ + newViewDistance; ++ for (int currX = toX - newViewDistance; currX <= newMaxX; ++currX) { ++ for (int currZ = toZ - newViewDistance; currZ <= newMaxZ; ++currZ) { ++ ++ // only add if we're outside the old view distance... ++ if (Math.max(Math.abs(currX - fromX), Math.abs(currZ - fromZ)) > oldViewDistance) { ++ this.addObjectTo(object, currX, currZ, toX, toZ, fromX, fromZ); ++ } ++ } ++ } ++ ++ return; ++ } ++ ++ // x axis is width ++ // z axis is height ++ // right refers to the x axis of where we moved ++ // top refers to the z axis of where we moved ++ ++ // same view distance ++ ++ // used for relative positioning ++ final int up = sign(dz); // 1 if dz >= 0, -1 otherwise ++ final int right = sign(dx); // 1 if dx >= 0, -1 otherwise ++ ++ // The area excluded by overlapping the two view distance squares creates four rectangles: ++ // Two on the left, and two on the right. The ones on the left we consider the "removed" section ++ // and on the right the "added" section. ++ // https://i.imgur.com/MrnOBgI.png is a reference image. Note that the outside border is not actually ++ // exclusive to the regions they surround. ++ ++ // 4 points of the rectangle ++ int maxX; // exclusive ++ int minX; // inclusive ++ int maxZ; // exclusive ++ int minZ; // inclusive ++ ++ if (dx != 0) { ++ // handle right addition ++ ++ maxX = toX + (oldViewDistance * right) + right; // exclusive ++ minX = fromX + (oldViewDistance * right) + right; // inclusive ++ maxZ = fromZ + (oldViewDistance * up) + up; // exclusive ++ minZ = toZ - (oldViewDistance * up); // inclusive ++ ++ for (int currX = minX; currX != maxX; currX += right) { ++ for (int currZ = minZ; currZ != maxZ; currZ += up) { ++ this.addObjectTo(object, currX, currZ, toX, toZ, fromX, fromZ); ++ } ++ } ++ } ++ ++ if (dz != 0) { ++ // handle up addition ++ ++ maxX = toX + (oldViewDistance * right) + right; // exclusive ++ minX = toX - (oldViewDistance * right); // inclusive ++ maxZ = toZ + (oldViewDistance * up) + up; // exclusive ++ minZ = fromZ + (oldViewDistance * up) + up; // inclusive ++ ++ for (int currX = minX; currX != maxX; currX += right) { ++ for (int currZ = minZ; currZ != maxZ; currZ += up) { ++ this.addObjectTo(object, currX, currZ, toX, toZ, fromX, fromZ); ++ } ++ } ++ } ++ ++ if (dx != 0) { ++ // handle left removal ++ ++ maxX = toX - (oldViewDistance * right); // exclusive ++ minX = fromX - (oldViewDistance * right); // inclusive ++ maxZ = fromZ + (oldViewDistance * up) + up; // exclusive ++ minZ = toZ - (oldViewDistance * up); // inclusive ++ ++ for (int currX = minX; currX != maxX; currX += right) { ++ for (int currZ = minZ; currZ != maxZ; currZ += up) { ++ this.removeObjectFrom(object, currX, currZ, toX, toZ, fromX, fromZ); ++ } ++ } ++ } ++ ++ if (dz != 0) { ++ // handle down removal ++ ++ maxX = fromX + (oldViewDistance * right) + right; // exclusive ++ minX = fromX - (oldViewDistance * right); // inclusive ++ maxZ = toZ - (oldViewDistance * up); // exclusive ++ minZ = fromZ - (oldViewDistance * up); // inclusive ++ ++ for (int currX = minX; currX != maxX; currX += right) { ++ for (int currZ = minZ; currZ != maxZ; currZ += up) { ++ this.removeObjectFrom(object, currX, currZ, toX, toZ, fromX, fromZ); ++ } ++ } ++ } ++ } ++ ++ @FunctionalInterface ++ public static interface ChangeCallback { ++ ++ // if there is no previous position, then prevPos = Integer.MIN_VALUE ++ void accept(final E object, final int rangeX, final int rangeZ, final int currPosX, final int currPosZ, final int prevPosX, final int prevPosZ, ++ final PooledLinkedHashSets.PooledObjectLinkedOpenHashSet newState); ++ ++ } ++} +diff --git a/src/main/java/com/destroystokyo/paper/util/misc/PlayerAreaMap.java b/src/main/java/com/destroystokyo/paper/util/misc/PlayerAreaMap.java +new file mode 100644 +index 0000000000..8a552a87ab +--- /dev/null ++++ b/src/main/java/com/destroystokyo/paper/util/misc/PlayerAreaMap.java +@@ -0,0 +0,0 @@ ++package com.destroystokyo.paper.util.misc; ++ ++import net.minecraft.server.EntityPlayer; ++ ++/** ++ * @author Spottedleaf ++ */ ++public final class PlayerAreaMap extends AreaMap { ++ ++ public PlayerAreaMap() { ++ super(); ++ } ++ ++ public PlayerAreaMap(final PooledLinkedHashSets pooledHashSets) { ++ super(pooledHashSets); ++ } ++ ++ public PlayerAreaMap(final PooledLinkedHashSets pooledHashSets, final ChangeCallback addCallback, ++ final ChangeCallback removeCallback) { ++ super(pooledHashSets, addCallback, removeCallback); ++ } ++ ++ @Override ++ protected PooledLinkedHashSets.PooledObjectLinkedOpenHashSet getEmptySetFor(final EntityPlayer player) { ++ return player.cachedSingleHashSet; ++ } ++} +diff --git a/src/main/java/com/destroystokyo/paper/util/misc/PooledLinkedHashSets.java b/src/main/java/com/destroystokyo/paper/util/misc/PooledLinkedHashSets.java +new file mode 100644 +index 0000000000..5f2d88797d +--- /dev/null ++++ b/src/main/java/com/destroystokyo/paper/util/misc/PooledLinkedHashSets.java +@@ -0,0 +0,0 @@ ++package com.destroystokyo.paper.util.misc; ++ ++import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; ++import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; ++import java.lang.ref.WeakReference; ++ ++/** ++ * @author Spottedleaf ++ */ ++public class PooledLinkedHashSets { ++ ++ /* Tested via https://gist.github.com/Spottedleaf/a93bb7a8993d6ce142d3efc5932bf573 */ ++ ++ // we really want to avoid that equals() check as much as possible... ++ protected final Object2ObjectOpenHashMap, PooledObjectLinkedOpenHashSet> mapPool = new Object2ObjectOpenHashMap<>(128, 0.25f); ++ ++ protected void decrementReferenceCount(final PooledObjectLinkedOpenHashSet current) { ++ if (current.referenceCount == 0) { ++ throw new IllegalStateException("Cannot decrement reference count for " + current); ++ } ++ if (current.referenceCount == -1 || --current.referenceCount > 0) { ++ return; ++ } ++ ++ this.mapPool.remove(current); ++ return; ++ } ++ ++ public PooledObjectLinkedOpenHashSet findMapWith(final PooledObjectLinkedOpenHashSet current, final E object) { ++ final PooledObjectLinkedOpenHashSet cached = current.getAddCache(object); ++ ++ if (cached != null) { ++ decrementReferenceCount(current); ++ ++ if (cached.referenceCount == 0) { ++ // bring the map back from the dead ++ PooledObjectLinkedOpenHashSet contending = this.mapPool.putIfAbsent(cached, cached); ++ if (contending != null) { ++ // a map already exists with the elements we want ++ if (contending.referenceCount != -1) { ++ ++contending.referenceCount; ++ } ++ current.updateAddCache(object, contending); ++ return contending; ++ } ++ ++ cached.referenceCount = 1; ++ } else if (cached.referenceCount != -1) { ++ ++cached.referenceCount; ++ } ++ ++ return cached; ++ } ++ ++ if (!current.add(object)) { ++ return current; ++ } ++ ++ // we use get/put since we use a different key on put ++ PooledObjectLinkedOpenHashSet ret = this.mapPool.get(current); ++ ++ if (ret == null) { ++ ret = new PooledObjectLinkedOpenHashSet<>(current); ++ current.remove(object); ++ this.mapPool.put(ret, ret); ++ ret.referenceCount = 1; ++ } else { ++ if (ret.referenceCount != -1) { ++ ++ret.referenceCount; ++ } ++ current.remove(object); ++ } ++ ++ current.updateAddCache(object, ret); ++ ++ decrementReferenceCount(current); ++ return ret; ++ } ++ ++ // rets null if current.size() == 1 ++ public PooledObjectLinkedOpenHashSet findMapWithout(final PooledObjectLinkedOpenHashSet current, final E object) { ++ if (current.set.size() == 1) { ++ decrementReferenceCount(current); ++ return null; ++ } ++ ++ final PooledObjectLinkedOpenHashSet cached = current.getRemoveCache(object); ++ ++ if (cached != null) { ++ decrementReferenceCount(current); ++ ++ if (cached.referenceCount == 0) { ++ // bring the map back from the dead ++ PooledObjectLinkedOpenHashSet contending = this.mapPool.putIfAbsent(cached, cached); ++ if (contending != null) { ++ // a map already exists with the elements we want ++ if (contending.referenceCount != -1) { ++ ++contending.referenceCount; ++ } ++ current.updateRemoveCache(object, contending); ++ return contending; ++ } ++ ++ cached.referenceCount = 1; ++ } else if (cached.referenceCount != -1) { ++ ++cached.referenceCount; ++ } ++ ++ return cached; ++ } ++ ++ if (!current.remove(object)) { ++ return current; ++ } ++ ++ // we use get/put since we use a different key on put ++ PooledObjectLinkedOpenHashSet ret = this.mapPool.get(current); ++ ++ if (ret == null) { ++ ret = new PooledObjectLinkedOpenHashSet<>(current); ++ current.add(object); ++ this.mapPool.put(ret, ret); ++ ret.referenceCount = 1; ++ } else { ++ if (ret.referenceCount != -1) { ++ ++ret.referenceCount; ++ } ++ current.add(object); ++ } ++ ++ current.updateRemoveCache(object, ret); ++ ++ decrementReferenceCount(current); ++ return ret; ++ } ++ ++ static final class RawSetObjectLinkedOpenHashSet extends ObjectOpenHashSet { ++ ++ public RawSetObjectLinkedOpenHashSet() { ++ super(); ++ } ++ ++ public RawSetObjectLinkedOpenHashSet(final int capacity) { ++ super(capacity); ++ } ++ ++ public RawSetObjectLinkedOpenHashSet(final int capacity, final float loadFactor) { ++ super(capacity, loadFactor); ++ } ++ ++ @Override ++ public RawSetObjectLinkedOpenHashSet clone() { ++ return (RawSetObjectLinkedOpenHashSet)super.clone(); ++ } ++ ++ public E[] getRawSet() { ++ return this.key; ++ } ++ } ++ ++ public static final class PooledObjectLinkedOpenHashSet { ++ ++ private static final WeakReference NULL_REFERENCE = new WeakReference<>(null); ++ ++ final RawSetObjectLinkedOpenHashSet set; ++ int referenceCount; // -1 if special ++ int hash; // optimize hashcode ++ ++ // add cache ++ WeakReference lastAddObject = NULL_REFERENCE; ++ WeakReference> lastAddMap = NULL_REFERENCE; ++ ++ // remove cache ++ WeakReference lastRemoveObject = NULL_REFERENCE; ++ WeakReference> lastRemoveMap = NULL_REFERENCE; ++ ++ public PooledObjectLinkedOpenHashSet(final PooledLinkedHashSets pooledSets) { ++ this.set = new RawSetObjectLinkedOpenHashSet<>(2, 0.8f); ++ } ++ ++ public PooledObjectLinkedOpenHashSet(final E single) { ++ this((PooledLinkedHashSets)null); ++ this.referenceCount = -1; ++ this.add(single); ++ } ++ ++ public PooledObjectLinkedOpenHashSet(final PooledObjectLinkedOpenHashSet other) { ++ this.set = other.set.clone(); ++ this.hash = other.hash; ++ } ++ ++ // from https://github.com/Spottedleaf/ConcurrentUtil/blob/master/src/main/java/ca/spottedleaf/concurrentutil/util/IntegerUtil.java ++ // generated by https://github.com/skeeto/hash-prospector ++ private static int hash0(int x) { ++ x *= 0x36935555; ++ x ^= x >>> 16; ++ return x; ++ } ++ ++ PooledObjectLinkedOpenHashSet getAddCache(final E element) { ++ final E currentAdd = this.lastAddObject.get(); ++ ++ if (currentAdd == null || !(currentAdd == element || currentAdd.equals(element))) { ++ return null; ++ } ++ ++ return this.lastAddMap.get(); ++ } ++ ++ PooledObjectLinkedOpenHashSet getRemoveCache(final E element) { ++ final E currentRemove = this.lastRemoveObject.get(); ++ ++ if (currentRemove == null || !(currentRemove == element || currentRemove.equals(element))) { ++ return null; ++ } ++ ++ return this.lastRemoveMap.get(); ++ } ++ ++ void updateAddCache(final E element, final PooledObjectLinkedOpenHashSet map) { ++ this.lastAddObject = new WeakReference<>(element); ++ this.lastAddMap = new WeakReference<>(map); ++ } ++ ++ void updateRemoveCache(final E element, final PooledObjectLinkedOpenHashSet map) { ++ this.lastRemoveObject = new WeakReference<>(element); ++ this.lastRemoveMap = new WeakReference<>(map); ++ } ++ ++ boolean add(final E element) { ++ boolean added = this.set.add(element); ++ ++ if (added) { ++ this.hash += hash0(element.hashCode()); ++ } ++ ++ return added; ++ } ++ ++ boolean remove(Object element) { ++ boolean removed = this.set.remove(element); ++ ++ if (removed) { ++ this.hash -= hash0(element.hashCode()); ++ } ++ ++ return removed; ++ } ++ ++ public boolean contains(final Object element) { ++ return this.set.contains(element); ++ } ++ ++ public E[] getBackingSet() { ++ return this.set.getRawSet(); ++ } ++ ++ public int size() { ++ return this.set.size(); ++ } ++ ++ @Override ++ public int hashCode() { ++ return this.hash; ++ } ++ ++ @Override ++ public boolean equals(final Object other) { ++ if (!(other instanceof PooledObjectLinkedOpenHashSet)) { ++ return false; ++ } ++ if (this.referenceCount == 0) { ++ return other == this; ++ } else { ++ if (other == this) { ++ // Unfortunately we are never equal to our own instance while in use! ++ return false; ++ } ++ return this.hash == ((PooledObjectLinkedOpenHashSet)other).hash && this.set.equals(((PooledObjectLinkedOpenHashSet)other).set); ++ } ++ } ++ ++ @Override ++ public String toString() { ++ return "PooledHashSet: size: " + this.set.size() + ", reference count: " + this.referenceCount + ", hash: " + ++ this.hashCode() + ", identity: " + System.identityHashCode(this) + " map: " + this.set.toString(); ++ } ++ } ++} +diff --git a/src/main/java/com/destroystokyo/paper/util/set/OptimizedSmallEnumSet.java b/src/main/java/com/destroystokyo/paper/util/set/OptimizedSmallEnumSet.java +new file mode 100644 +index 0000000000..4d74a7a908 +--- /dev/null ++++ b/src/main/java/com/destroystokyo/paper/util/set/OptimizedSmallEnumSet.java +@@ -0,0 +0,0 @@ ++package com.destroystokyo.paper.util.set; ++ ++import java.util.Collection; ++ ++// containing utils to work on small numbers of enums ++public final class OptimizedSmallEnumSet> { ++ ++ private final Class enumClass; ++ private long backingSet; ++ ++ public OptimizedSmallEnumSet(final Class clazz) { ++ if (clazz == null) { ++ throw new IllegalArgumentException("Null class"); ++ } ++ if (!clazz.isEnum()) { ++ throw new IllegalArgumentException("Class must be enum, not " + clazz.getCanonicalName()); ++ } ++ this.enumClass = clazz; ++ } ++ ++ public boolean addUnchecked(final E element) { ++ final int ordinal = element.ordinal(); ++ final long key = 1L << ordinal; ++ ++ final long prev = this.backingSet; ++ this.backingSet = prev | key; ++ ++ return (prev & key) == 0; ++ } ++ ++ public boolean removeUnchecked(final E element) { ++ final int ordinal = element.ordinal(); ++ final long key = 1L << ordinal; ++ ++ final long prev = this.backingSet; ++ this.backingSet = prev & ~key; ++ ++ return (prev & key) != 0; ++ } ++ ++ public void clear() { ++ this.backingSet = 0L; ++ } ++ ++ public int size() { ++ return Long.bitCount(this.backingSet); ++ } ++ ++ public void addAllUnchecked(final Collection enums) { ++ for (final E element : enums) { ++ if (element == null) { ++ throw new NullPointerException("Null element"); ++ } ++ this.backingSet |= (1L << element.ordinal()); ++ } ++ } ++ ++ public long getBackingSet() { ++ return this.backingSet; ++ } ++ ++ public boolean hasCommonElements(final OptimizedSmallEnumSet other) { ++ return (other.backingSet & this.backingSet) != 0; ++ } ++} diff --git a/src/main/java/net/minecraft/server/BlockAccessAir.java b/src/main/java/net/minecraft/server/BlockAccessAir.java -index eff6ebcd3..30cbfc8ea 100644 +index eff6ebcd30..30cbfc8eac 100644 --- a/src/main/java/net/minecraft/server/BlockAccessAir.java +++ b/src/main/java/net/minecraft/server/BlockAccessAir.java @@ -0,0 +0,0 @@ public enum BlockAccessAir implements IBlockAccess { @@ -28,7 +1633,7 @@ index eff6ebcd3..30cbfc8ea 100644 public IBlockData getType(BlockPosition blockposition) { return Blocks.AIR.getBlockData(); diff --git a/src/main/java/net/minecraft/server/BlockDataAbstract.java b/src/main/java/net/minecraft/server/BlockDataAbstract.java -index 1cf97cefc..2040f1834 100644 +index 1cf97cefc9..2040f18349 100644 --- a/src/main/java/net/minecraft/server/BlockDataAbstract.java +++ b/src/main/java/net/minecraft/server/BlockDataAbstract.java @@ -0,0 +0,0 @@ public abstract class BlockDataAbstract implements IBlockDataHolder { @@ -40,7 +1645,7 @@ index 1cf97cefc..2040f1834 100644 return this.d.containsKey(iblockstate); } diff --git a/src/main/java/net/minecraft/server/BlockPosition.java b/src/main/java/net/minecraft/server/BlockPosition.java -index c88a62f6b..1cdf0346f 100644 +index c88a62f6b7..5dbd3e60fe 100644 --- a/src/main/java/net/minecraft/server/BlockPosition.java +++ b/src/main/java/net/minecraft/server/BlockPosition.java @@ -0,0 +0,0 @@ public class BlockPosition extends BaseBlockPosition implements MinecraftSeriali @@ -76,8 +1681,26 @@ index c88a62f6b..1cdf0346f 100644 public BlockPosition.MutableBlockPosition c(double d0, double d1, double d2) { return this.d(MathHelper.floor(d0), MathHelper.floor(d1), MathHelper.floor(d2)); } +@@ -0,0 +0,0 @@ public class BlockPosition extends BaseBlockPosition implements MinecraftSeriali + return this.d(this.b + i, this.c + j, this.d + k); + } + ++ public final void setX(final int x) { this.o(x); } // Paper - OBFHELPER + public void o(int i) { + this.b = i; + } + ++ public final void setY(final int y) { this.p(y); } // Paper - OBFHELPER + public void p(int i) { + this.c = i; + } + ++ public final void setZ(final int z) { this.q(z); } // Paper - OBFHELPER + public void q(int i) { + this.d = i; + } diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index 55373cae0..cfffbd031 100644 +index 55373cae07..a263f60d49 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java @@ -0,0 +0,0 @@ import org.apache.logging.log4j.Logger; @@ -89,6 +1712,36 @@ index 55373cae0..cfffbd031 100644 private final ChunkSection[] sections; private BiomeStorage d; private final Map e; +@@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess { + private Supplier u; + @Nullable + private Consumer v; +- private final ChunkCoordIntPair loc; ++ private final ChunkCoordIntPair loc; public final long coordinateKey; // Paper - cache coordinate key + private volatile boolean x; + + public Chunk(World world, ChunkCoordIntPair chunkcoordintpair, BiomeStorage biomestorage) { +@@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess { + this.n = new ShortList[16]; + this.entitySlices = (List[]) (new List[16]); // Spigot + this.world = world; +- this.loc = chunkcoordintpair; ++ this.loc = chunkcoordintpair; this.coordinateKey = MCUtil.getCoordinateKey(chunkcoordintpair); // Paper - cache coordinate key + this.i = chunkconverter; + HeightMap.Type[] aheightmap_type = HeightMap.Type.values(); + int j = aheightmap_type.length; +@@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess { + public boolean needsDecoration; + // CraftBukkit end + ++ // Paper start ++ public final com.destroystokyo.paper.util.maplist.EntityList entities = new com.destroystokyo.paper.util.maplist.EntityList(); ++ public PlayerChunk playerChunk; ++ // Paper end ++ + public Chunk(World world, ProtoChunk protochunk) { + this(world, protochunk.getPos(), protochunk.getBiomeIndex(), protochunk.p(), protochunk.n(), protochunk.o(), protochunk.getInhabitedTime(), protochunk.getSections(), (Consumer) null); + Iterator iterator = protochunk.y().iterator(); @@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess { } } @@ -108,6 +1761,14 @@ index 55373cae0..cfffbd031 100644 @Override public Fluid getFluid(BlockPosition blockposition) { return this.a(blockposition.getX(), blockposition.getY(), blockposition.getZ()); +@@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess { + entity.chunkX = this.loc.x; + entity.chunkY = k; + entity.chunkZ = this.loc.z; ++ this.entities.add(entity); // Paper - per chunk entity list + this.entitySlices[k].add(entity); + } + @@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess { return this.a(blockposition, Chunk.EnumTileEntityState.CHECK); } @@ -116,8 +1777,24 @@ index 55373cae0..cfffbd031 100644 @Nullable public TileEntity a(BlockPosition blockposition, Chunk.EnumTileEntityState chunk_enumtileentitystate) { // CraftBukkit start +@@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess { + // CraftBukkit start + public void loadCallback() { + org.bukkit.Server server = this.world.getServer(); ++ ((WorldServer)this.world).getChunkProvider().addLoadedChunk(this); // Paper + if (server != null) { + /* + * If it's a new world, the first few chunks are generated inside +@@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess { + } + + public void unloadCallback() { ++ ((WorldServer)this.world).getChunkProvider().removeLoadedChunk(this); // Paper + org.bukkit.Server server = this.world.getServer(); + org.bukkit.event.world.ChunkUnloadEvent unloadEvent = new org.bukkit.event.world.ChunkUnloadEvent(this.bukkitChunk, this.isNeedsSaving()); + server.getPluginManager().callEvent(unloadEvent); diff --git a/src/main/java/net/minecraft/server/ChunkCache.java b/src/main/java/net/minecraft/server/ChunkCache.java -index 11c4d23ba..53c15c1c0 100644 +index 11c4d23ba9..53c15c1c0b 100644 --- a/src/main/java/net/minecraft/server/ChunkCache.java +++ b/src/main/java/net/minecraft/server/ChunkCache.java @@ -0,0 +0,0 @@ public class ChunkCache implements IBlockAccess, ICollisionAccess { @@ -151,7 +1828,7 @@ index 11c4d23ba..53c15c1c0 100644 @Override public TileEntity getTileEntity(BlockPosition blockposition) { diff --git a/src/main/java/net/minecraft/server/ChunkCoordIntPair.java b/src/main/java/net/minecraft/server/ChunkCoordIntPair.java -index 260644bf0..f2a19acd8 100644 +index 260644bf0b..f2a19acd84 100644 --- a/src/main/java/net/minecraft/server/ChunkCoordIntPair.java +++ b/src/main/java/net/minecraft/server/ChunkCoordIntPair.java @@ -0,0 +0,0 @@ public class ChunkCoordIntPair { @@ -166,9 +1843,107 @@ index 260644bf0..f2a19acd8 100644 } diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java -index e8b7cc06c..9cd21b1ff 100644 +index e8b7cc06c2..d24c8070f4 100644 --- a/src/main/java/net/minecraft/server/ChunkProviderServer.java +++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java +@@ -0,0 +0,0 @@ public class ChunkProviderServer extends IChunkProvider { + private final ChunkMapDistance chunkMapDistance; + public final ChunkGenerator chunkGenerator; + private final WorldServer world; +- private final Thread serverThread; ++ public final Thread serverThread; // Paper - private -> public + private final LightEngineThreaded lightEngine; + private final ChunkProviderServer.a serverThreadQueue; + public final PlayerChunkMap playerChunkMap; +@@ -0,0 +0,0 @@ public class ChunkProviderServer extends IChunkProvider { + private final ChunkStatus[] cacheStatus = new ChunkStatus[4]; + private final IChunkAccess[] cacheChunk = new IChunkAccess[4]; + ++ // Paper start ++ final com.destroystokyo.paper.util.concurrent.WeakSeqLock loadedChunkMapSeqLock = new com.destroystokyo.paper.util.concurrent.WeakSeqLock(); ++ final it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap loadedChunkMap = new it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap<>(8192, 0.5f); ++ ++ private final Chunk[] lastLoadedChunks = new Chunk[4 * 4]; ++ private final long[] lastLoadedChunkKeys = new long[4 * 4]; ++ ++ { ++ java.util.Arrays.fill(this.lastLoadedChunkKeys, MCUtil.INVALID_CHUNK_KEY); ++ } ++ ++ private static int getCacheKey(int x, int z) { ++ return x & 3 | ((z & 3) << 2); ++ } ++ ++ void addLoadedChunk(Chunk chunk) { ++ this.loadedChunkMapSeqLock.acquireWrite(); ++ try { ++ this.loadedChunkMap.put(chunk.coordinateKey, chunk); ++ } finally { ++ this.loadedChunkMapSeqLock.releaseWrite(); ++ } ++ ++ // rewrite cache if we have to ++ // we do this since we also cache null chunks ++ int cacheKey = getCacheKey(chunk.getPos().x, chunk.getPos().z); ++ ++ long cachedKey = this.lastLoadedChunkKeys[cacheKey]; ++ if (cachedKey == chunk.coordinateKey) { ++ this.lastLoadedChunks[cacheKey] = chunk; ++ } ++ } ++ ++ void removeLoadedChunk(Chunk chunk) { ++ this.loadedChunkMapSeqLock.acquireWrite(); ++ try { ++ this.loadedChunkMap.remove(chunk.coordinateKey); ++ } finally { ++ this.loadedChunkMapSeqLock.releaseWrite(); ++ } ++ ++ // rewrite cache if we have to ++ // we do this since we also cache null chunks ++ int cacheKey = getCacheKey(chunk.getPos().x, chunk.getPos().z); ++ ++ long cachedKey = this.lastLoadedChunkKeys[cacheKey]; ++ if (cachedKey == chunk.coordinateKey) { ++ this.lastLoadedChunks[cacheKey] = null; ++ } ++ } ++ ++ public Chunk getChunkAtIfLoadedMainThread(int x, int z) { ++ int cacheKey = getCacheKey(x, z); ++ long chunkKey = MCUtil.getCoordinateKey(x, z); ++ ++ long cachedKey = this.lastLoadedChunkKeys[cacheKey]; ++ if (cachedKey == chunkKey) { ++ return this.lastLoadedChunks[cacheKey]; ++ } ++ ++ Chunk ret = this.loadedChunkMap.get(chunkKey); ++ ++ this.lastLoadedChunkKeys[cacheKey] = chunkKey; ++ this.lastLoadedChunks[cacheKey] = ret; ++ ++ return ret; ++ } ++ ++ public Chunk getChunkAtIfLoadedMainThreadNoCache(int x, int z) { ++ return this.loadedChunkMap.get(MCUtil.getCoordinateKey(x, z)); ++ } ++ ++ public Chunk getChunkAtMainThread(int x, int z) { ++ Chunk ret = this.getChunkAtIfLoadedMainThread(x, z); ++ if (ret != null) { ++ return ret; ++ } ++ return (Chunk)this.getChunkAt(x, z, ChunkStatus.FULL, true); ++ } ++ // Paper ++ ++ + public ChunkProviderServer(WorldServer worldserver, File file, DataFixer datafixer, DefinedStructureManager definedstructuremanager, Executor executor, ChunkGenerator chunkgenerator, int i, WorldLoadListener worldloadlistener, Supplier supplier) { + this.world = worldserver; + this.serverThreadQueue = new ChunkProviderServer.a(worldserver); @@ -0,0 +0,0 @@ public class ChunkProviderServer extends IChunkProvider { this.cacheChunk[0] = ichunkaccess; } @@ -179,14 +1954,28 @@ index e8b7cc06c..9cd21b1ff 100644 + public Chunk getChunkAtIfCachedImmediately(int x, int z) { + long k = ChunkCoordIntPair.pair(x, z); + -+ // Note: Bypass cache to make this MT-Safe -+ -+ PlayerChunk playerChunk = this.getChunk(k); -+ if (playerChunk == null) { -+ return null; ++ // Paper start - Optimize getIfLoaded type calls ++ if (Thread.currentThread() == this.serverThread) { ++ return this.getChunkAtIfLoadedMainThread(x, z); + } + -+ return playerChunk.getFullChunkIfCached(); ++ Chunk ret = null; ++ long readlock; ++ do { ++ readlock = this.loadedChunkMapSeqLock.acquireRead(); ++ try { ++ ret = this.loadedChunkMap.get(k); ++ } catch (Throwable thr) { ++ if (thr instanceof ThreadDeath) { ++ throw (ThreadDeath)thr; ++ } ++ // re-try, this means a CME occurred... ++ continue; ++ } ++ } while (!this.loadedChunkMapSeqLock.tryReleaseRead(readlock)); ++ ++ return ret; ++ // Paper end + } + + @Nullable @@ -208,7 +1997,7 @@ index e8b7cc06c..9cd21b1ff 100644 @Override public IChunkAccess getChunkAt(int i, int j, ChunkStatus chunkstatus, boolean flag) { diff --git a/src/main/java/net/minecraft/server/DataBits.java b/src/main/java/net/minecraft/server/DataBits.java -index 7ca3a1d0c..2edd9b871 100644 +index 7ca3a1d0c5..2edd9b8714 100644 --- a/src/main/java/net/minecraft/server/DataBits.java +++ b/src/main/java/net/minecraft/server/DataBits.java @@ -0,0 +0,0 @@ public class DataBits { @@ -220,7 +2009,7 @@ index 7ca3a1d0c..2edd9b871 100644 return this.a; } diff --git a/src/main/java/net/minecraft/server/DataPalette.java b/src/main/java/net/minecraft/server/DataPalette.java -index 75ba69886..45403fbe3 100644 +index 75ba698868..45403fbe30 100644 --- a/src/main/java/net/minecraft/server/DataPalette.java +++ b/src/main/java/net/minecraft/server/DataPalette.java @@ -0,0 +0,0 @@ import javax.annotation.Nullable; @@ -237,7 +2026,7 @@ index 75ba69886..45403fbe3 100644 T a(int i); diff --git a/src/main/java/net/minecraft/server/DataPaletteBlock.java b/src/main/java/net/minecraft/server/DataPaletteBlock.java -index 774a8f543..d5f5a5187 100644 +index 774a8f5434..d5f5a51872 100644 --- a/src/main/java/net/minecraft/server/DataPaletteBlock.java +++ b/src/main/java/net/minecraft/server/DataPaletteBlock.java @@ -0,0 +0,0 @@ import java.util.stream.Collectors; @@ -279,7 +2068,7 @@ index 774a8f543..d5f5a5187 100644 this.a(); packetdataserializer.writeByte(this.i); diff --git a/src/main/java/net/minecraft/server/EntityCreature.java b/src/main/java/net/minecraft/server/EntityCreature.java -index fe69161e5..b40c8d2f8 100644 +index fe69161e5b..b40c8d2f83 100644 --- a/src/main/java/net/minecraft/server/EntityCreature.java +++ b/src/main/java/net/minecraft/server/EntityCreature.java @@ -0,0 +0,0 @@ import org.bukkit.event.entity.EntityUnleashEvent; @@ -292,7 +2081,7 @@ index fe69161e5..b40c8d2f8 100644 super(entitytypes, world); } diff --git a/src/main/java/net/minecraft/server/EntityInsentient.java b/src/main/java/net/minecraft/server/EntityInsentient.java -index e1398652a..7ee5eb987 100644 +index e1398652a0..7ee5eb987a 100644 --- a/src/main/java/net/minecraft/server/EntityInsentient.java +++ b/src/main/java/net/minecraft/server/EntityInsentient.java @@ -0,0 +0,0 @@ public abstract class EntityInsentient extends EntityLiving { @@ -304,7 +2093,7 @@ index e1398652a..7ee5eb987 100644 // CraftBukkit start - fire event setGoalTarget(entityliving, EntityTargetEvent.TargetReason.UNKNOWN, true); diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java -index 3b1bcf349..1f350e335 100644 +index 3b1bcf3495..1f350e3352 100644 --- a/src/main/java/net/minecraft/server/EntityLiving.java +++ b/src/main/java/net/minecraft/server/EntityLiving.java @@ -0,0 +0,0 @@ public abstract class EntityLiving extends Entity { @@ -316,7 +2105,7 @@ index 3b1bcf349..1f350e335 100644 @Override public float getBukkitYaw() { diff --git a/src/main/java/net/minecraft/server/EntityMonster.java b/src/main/java/net/minecraft/server/EntityMonster.java -index 00c3b666d..e5322fbae 100644 +index 00c3b666d7..e5322fbae5 100644 --- a/src/main/java/net/minecraft/server/EntityMonster.java +++ b/src/main/java/net/minecraft/server/EntityMonster.java @@ -0,0 +0,0 @@ import java.util.function.Predicate; @@ -327,8 +2116,30 @@ index 00c3b666d..e5322fbae 100644 protected EntityMonster(EntityTypes entitytypes, World world) { super(entitytypes, world); this.f = 5; +diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java +index ce48210922..57ce9bde64 100644 +--- a/src/main/java/net/minecraft/server/EntityPlayer.java ++++ b/src/main/java/net/minecraft/server/EntityPlayer.java +@@ -0,0 +0,0 @@ public class EntityPlayer extends EntityHuman implements ICrafting { + public Integer clientViewDistance; + // CraftBukkit end + ++ public final com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet cachedSingleHashSet; // Paper ++ + public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile, PlayerInteractManager playerinteractmanager) { + super((World) worldserver, gameprofile); + playerinteractmanager.player = this; +@@ -0,0 +0,0 @@ public class EntityPlayer extends EntityHuman implements ICrafting { + this.H = 1.0F; + this.a(worldserver); + ++ this.cachedSingleHashSet = new com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<>(this); // Paper ++ + // CraftBukkit start + this.displayName = this.getName(); + this.canPickUpLoot = true; diff --git a/src/main/java/net/minecraft/server/EntityTypes.java b/src/main/java/net/minecraft/server/EntityTypes.java -index f937b7294..cbf0c2f25 100644 +index f937b72945..cbf0c2f25d 100644 --- a/src/main/java/net/minecraft/server/EntityTypes.java +++ b/src/main/java/net/minecraft/server/EntityTypes.java @@ -0,0 +0,0 @@ import com.mojang.datafixers.DataFixUtils; @@ -351,7 +2162,7 @@ index f937b7294..cbf0c2f25 100644 } diff --git a/src/main/java/net/minecraft/server/IAsyncTaskHandler.java b/src/main/java/net/minecraft/server/IAsyncTaskHandler.java -index 1890c760f..7e5ece9d5 100644 +index 1890c760f9..7e5ece9d50 100644 --- a/src/main/java/net/minecraft/server/IAsyncTaskHandler.java +++ b/src/main/java/net/minecraft/server/IAsyncTaskHandler.java @@ -0,0 +0,0 @@ public abstract class IAsyncTaskHandler implements Mailbox h = new CompletableFuture(); diff --git a/src/main/java/net/minecraft/server/IWorldReader.java b/src/main/java/net/minecraft/server/IWorldReader.java -index ba315131e..cbe2aa4c0 100644 +index ba315131e1..cbe2aa4c0a 100644 --- a/src/main/java/net/minecraft/server/IWorldReader.java +++ b/src/main/java/net/minecraft/server/IWorldReader.java @@ -0,0 +0,0 @@ import javax.annotation.Nullable; @@ -425,7 +2236,7 @@ index ba315131e..cbe2aa4c0 100644 IChunkAccess getChunkAt(int i, int j, ChunkStatus chunkstatus, boolean flag); diff --git a/src/main/java/net/minecraft/server/ItemStack.java b/src/main/java/net/minecraft/server/ItemStack.java -index b5d45b43c..766b1fe13 100644 +index b5d45b43ce..766b1fe13c 100644 --- a/src/main/java/net/minecraft/server/ItemStack.java +++ b/src/main/java/net/minecraft/server/ItemStack.java @@ -0,0 +0,0 @@ import org.bukkit.event.world.StructureGrowEvent; @@ -485,7 +2296,7 @@ index b5d45b43c..766b1fe13 100644 // CraftBukkit end diff --git a/src/main/java/net/minecraft/server/MCUtil.java b/src/main/java/net/minecraft/server/MCUtil.java new file mode 100644 -index 000000000..628b73a12 +index 0000000000..9fa88d79d8 --- /dev/null +++ b/src/main/java/net/minecraft/server/MCUtil.java @@ -0,0 +0,0 @@ @@ -513,6 +2324,76 @@ index 000000000..628b73a12 +public final class MCUtil { + private static final Executor asyncExecutor = Executors.newSingleThreadExecutor(new ThreadFactoryBuilder().setNameFormat("Paper Async Task Handler Thread - %1$d").build()); + ++ public static final long INVALID_CHUNK_KEY = getCoordinateKey(Integer.MAX_VALUE, Integer.MAX_VALUE); ++ ++ public static long getCoordinateKey(final BlockPosition blockPos) { ++ return getCoordinateKey(blockPos.getX() >> 4, blockPos.getZ() >> 4); ++ } ++ ++ public static long getCoordinateKey(final Entity entity) { ++ return getCoordinateKey(getChunkCoordinate(entity.locX()), getChunkCoordinate(entity.locZ())); ++ } ++ ++ public static int fastFloor(double x) { ++ int truncated = (int)x; ++ return x < (double)truncated ? truncated - 1 : truncated; ++ } ++ ++ public static int fastFloor(float x) { ++ int truncated = (int)x; ++ return x < (double)truncated ? truncated - 1 : truncated; ++ } ++ ++ public static long getCoordinateKey(final ChunkCoordIntPair pair) { ++ return getCoordinateKey(pair.x, pair.z); ++ } ++ ++ public static long getCoordinateKey(final int x, final int z) { ++ return ((long)z << 32) | (x & 0xFFFFFFFFL); ++ } ++ ++ public static int getCoordinateX(final long key) { ++ return (int)key; ++ } ++ ++ public static int getCoordinateZ(final long key) { ++ return (int)(key >>> 32); ++ } ++ ++ public static int getChunkCoordinate(final double coordinate) { ++ return MCUtil.fastFloor(coordinate) >> 4; ++ } ++ ++ public static int getBlockCoordinate(final double coordinate) { ++ return MCUtil.fastFloor(coordinate); ++ } ++ ++ public static long getBlockKey(final int x, final int y, final int z) { ++ return ((long)x & 0x7FFFFFF) | (((long)z & 0x7FFFFFF) << 27) | ((long)y << 54); ++ } ++ ++ public static long getBlockKey(final BlockPosition pos) { ++ return getBlockKey(pos.getX(), pos.getY(), pos.getZ()); ++ } ++ ++ public static long getBlockKey(final Entity entity) { ++ return getBlockKey(getBlockCoordinate(entity.locX()), getBlockCoordinate(entity.locY()), getBlockCoordinate(entity.locZ())); ++ } ++ ++ // assumes the sets have the same comparator, and if this comparator is null then assume T is Comparable ++ public static void mergeSortedSets(final java.util.function.Consumer consumer, final java.util.SortedSet...sets) { ++ java.util.Comparator comparator = sets[0].comparator(); ++ if (comparator == null) { ++ comparator = (java.util.Comparator)java.util.Comparator.naturalOrder(); ++ } ++ final it.unimi.dsi.fastutil.objects.ObjectRBTreeSet all = new it.unimi.dsi.fastutil.objects.ObjectRBTreeSet<>(comparator); ++ // note: this is done in log(n!) ~ nlogn time. It could be improved if it were to mimic what mergesort does. ++ for (java.util.SortedSet set : sets) { ++ all.addAll(all); ++ } ++ all.forEach(consumer); ++ } ++ + private MCUtil() {} + + @@ -806,7 +2687,7 @@ index 000000000..628b73a12 + } +} diff --git a/src/main/java/net/minecraft/server/NBTTagCompound.java b/src/main/java/net/minecraft/server/NBTTagCompound.java -index e85b24a32..75604dbc6 100644 +index e85b24a327..75604dbc69 100644 --- a/src/main/java/net/minecraft/server/NBTTagCompound.java +++ b/src/main/java/net/minecraft/server/NBTTagCompound.java @@ -0,0 +0,0 @@ public class NBTTagCompound implements NBTBase { @@ -835,7 +2716,7 @@ index e85b24a32..75604dbc6 100644 return new UUID(this.getLong(s + "Most"), this.getLong(s + "Least")); } diff --git a/src/main/java/net/minecraft/server/NetworkManager.java b/src/main/java/net/minecraft/server/NetworkManager.java -index 6700582e3..3ccf16636 100644 +index 6700582e36..3ccf166366 100644 --- a/src/main/java/net/minecraft/server/NetworkManager.java +++ b/src/main/java/net/minecraft/server/NetworkManager.java @@ -0,0 +0,0 @@ public class NetworkManager extends SimpleChannelInboundHandler> { @@ -867,7 +2748,7 @@ index 6700582e3..3ccf16636 100644 public QueuedPacket(Packet packet, @Nullable GenericFutureListener> genericfuturelistener) { this.a = packet; diff --git a/src/main/java/net/minecraft/server/PacketDataSerializer.java b/src/main/java/net/minecraft/server/PacketDataSerializer.java -index 81b6f4581..d9574a9ac 100644 +index 81b6f4581f..d9574a9ace 100644 --- a/src/main/java/net/minecraft/server/PacketDataSerializer.java +++ b/src/main/java/net/minecraft/server/PacketDataSerializer.java @@ -0,0 +0,0 @@ public class PacketDataSerializer extends ByteBuf { @@ -879,7 +2760,7 @@ index 81b6f4581..d9574a9ac 100644 for (int j = 1; j < 5; ++j) { if ((i & -1 << j * 7) == 0) { diff --git a/src/main/java/net/minecraft/server/PacketEncoder.java b/src/main/java/net/minecraft/server/PacketEncoder.java -index 90223deae..63c4dbd32 100644 +index 90223deae3..63c4dbd327 100644 --- a/src/main/java/net/minecraft/server/PacketEncoder.java +++ b/src/main/java/net/minecraft/server/PacketEncoder.java @@ -0,0 +0,0 @@ public class PacketEncoder extends MessageToByteEncoder> { @@ -891,7 +2772,7 @@ index 90223deae..63c4dbd32 100644 throw new SkipEncodeException(throwable); } else { diff --git a/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java b/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java -index 677e3e5f6..3a1d0deb0 100644 +index 677e3e5f68..3a1d0deb0d 100644 --- a/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java +++ b/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java @@ -0,0 +0,0 @@ public class PacketPlayOutMapChunk implements Packet { @@ -912,9 +2793,79 @@ index 677e3e5f6..3a1d0deb0 100644 int j = 0; ChunkSection[] achunksection = chunk.getSections(); diff --git a/src/main/java/net/minecraft/server/PlayerChunk.java b/src/main/java/net/minecraft/server/PlayerChunk.java -index 775359146..3c6fe0596 100644 +index 775359146f..3093154bb7 100644 --- a/src/main/java/net/minecraft/server/PlayerChunk.java +++ b/src/main/java/net/minecraft/server/PlayerChunk.java +@@ -0,0 +0,0 @@ public class PlayerChunk { + private static final List CHUNK_STATUSES = ChunkStatus.a(); + private static final PlayerChunk.State[] CHUNK_STATES = PlayerChunk.State.values(); + private final AtomicReferenceArray>> statusFutures; +- private volatile CompletableFuture> fullChunkFuture; +- private volatile CompletableFuture> tickingFuture; +- private volatile CompletableFuture> entityTickingFuture; ++ private volatile CompletableFuture> fullChunkFuture; private int fullChunkCreateCount; private volatile boolean isFullChunkReady; // Paper - cache chunk ticking stage ++ private volatile CompletableFuture> tickingFuture; private volatile boolean isTickingReady; // Paper - cache chunk ticking stage ++ private volatile CompletableFuture> entityTickingFuture; private volatile boolean isEntityTickingReady; // Paper - cache chunk ticking stage + private CompletableFuture chunkSave; + public int oldTicketLevel; + private int ticketLevel; +@@ -0,0 +0,0 @@ public class PlayerChunk { + public final PlayerChunk.d players; + private boolean hasBeenLoaded; + ++ private final PlayerChunkMap chunkMap; // Paper ++ + public PlayerChunk(ChunkCoordIntPair chunkcoordintpair, int i, LightEngine lightengine, PlayerChunk.c playerchunk_c, PlayerChunk.d playerchunk_d) { + this.statusFutures = new AtomicReferenceArray(PlayerChunk.CHUNK_STATUSES.size()); + this.fullChunkFuture = PlayerChunk.UNLOADED_CHUNK_FUTURE; +@@ -0,0 +0,0 @@ public class PlayerChunk { + this.ticketLevel = this.oldTicketLevel; + this.n = this.oldTicketLevel; + this.a(i); ++ this.chunkMap = (PlayerChunkMap)playerchunk_d; // Paper ++ } ++ ++ // Paper start ++ @Nullable ++ public final Chunk getEntityTickingChunk() { ++ CompletableFuture> completablefuture = this.entityTickingFuture; ++ Either either = completablefuture.getNow(null); ++ ++ return either == null ? null : either.left().orElse(null); ++ } ++ ++ @Nullable ++ public final Chunk getTickingChunk() { ++ CompletableFuture> completablefuture = this.tickingFuture; ++ Either either = completablefuture.getNow(null); ++ ++ return either == null ? null : either.left().orElse(null); ++ } ++ ++ @Nullable ++ public final Chunk getFullReadyChunk() { ++ CompletableFuture> completablefuture = this.fullChunkFuture; ++ Either either = completablefuture.getNow(null); ++ ++ return either == null ? null : either.left().orElse(null); ++ } ++ ++ public final boolean isEntityTickingReady() { ++ return this.isEntityTickingReady; + } + ++ public final boolean isTickingReady() { ++ return this.isTickingReady; ++ } ++ ++ public final boolean isFullChunkReady() { ++ return this.isFullChunkReady; ++ } ++ // Paper end ++ + // CraftBukkit start + public Chunk getFullChunk() { + if (!getChunkState(this.oldTicketLevel).isAtLeast(PlayerChunk.State.BORDER)) return null; // note: using oldTicketLevel for isLoaded checks @@ -0,0 +0,0 @@ public class PlayerChunk { return either == null ? null : (Chunk) either.left().orElse(null); } @@ -930,8 +2881,140 @@ index 775359146..3c6fe0596 100644 public CompletableFuture> getStatusFutureUnchecked(ChunkStatus chunkstatus) { CompletableFuture> completablefuture = (CompletableFuture) this.statusFutures.get(chunkstatus.c()); +@@ -0,0 +0,0 @@ public class PlayerChunk { + + this.hasBeenLoaded |= flag3; + if (!flag2 && flag3) { +- this.fullChunkFuture = playerchunkmap.b(this); ++ // Paper start - cache ticking ready status ++ int expectCreateCount = ++this.fullChunkCreateCount; ++ this.fullChunkFuture = playerchunkmap.b(this); this.fullChunkFuture.thenAccept((either) -> { ++ if (either.left().isPresent() && PlayerChunk.this.fullChunkCreateCount == expectCreateCount) { ++ // note: Here is a very good place to add callbacks to logic waiting on this. ++ Chunk fullChunk = either.left().get(); ++ PlayerChunk.this.isFullChunkReady = true; ++ fullChunk.playerChunk = PlayerChunk.this; ++ ++ ++ } ++ }); ++ // Paper end + this.a(this.fullChunkFuture); + } + + if (flag2 && !flag3) { + completablefuture = this.fullChunkFuture; + this.fullChunkFuture = PlayerChunk.UNLOADED_CHUNK_FUTURE; ++ ++this.fullChunkCreateCount; // Paper - cache ticking ready status ++ this.isFullChunkReady = false; // Paper - cache ticking ready status + this.a(((CompletableFuture>) completablefuture).thenApply((either1) -> { // CraftBukkit - decompile error + playerchunkmap.getClass(); + return either1.ifLeft(playerchunkmap::a); +@@ -0,0 +0,0 @@ public class PlayerChunk { + boolean flag5 = playerchunk_state1.isAtLeast(PlayerChunk.State.TICKING); + + if (!flag4 && flag5) { +- this.tickingFuture = playerchunkmap.a(this); ++ // Paper start - cache ticking ready status ++ this.tickingFuture = playerchunkmap.a(this); this.tickingFuture.thenAccept((either) -> { ++ if (either.left().isPresent()) { ++ // note: Here is a very good place to add callbacks to logic waiting on this. ++ Chunk tickingChunk = either.left().get(); ++ PlayerChunk.this.isTickingReady = true; ++ ++ ++ ++ ++ } ++ }); ++ // Paper end + this.a(this.tickingFuture); + } + + if (flag4 && !flag5) { +- this.tickingFuture.complete(PlayerChunk.UNLOADED_CHUNK); ++ this.tickingFuture.complete(PlayerChunk.UNLOADED_CHUNK); this.isTickingReady = false; // Paper - cache chunk ticking stage + this.tickingFuture = PlayerChunk.UNLOADED_CHUNK_FUTURE; + } + +@@ -0,0 +0,0 @@ public class PlayerChunk { + throw (IllegalStateException) SystemUtils.c(new IllegalStateException()); + } + +- this.entityTickingFuture = playerchunkmap.b(this.location); ++ // Paper start - cache ticking ready status ++ this.entityTickingFuture = playerchunkmap.b(this.location); this.entityTickingFuture.thenAccept((either) -> { ++ if (either.left().isPresent()) { ++ // note: Here is a very good place to add callbacks to logic waiting on this. ++ Chunk entityTickingChunk = either.left().get(); ++ PlayerChunk.this.isEntityTickingReady = true; ++ ++ ++ ++ ++ } ++ }); ++ // Paper end + this.a(this.entityTickingFuture); + } + + if (flag6 && !flag7) { +- this.entityTickingFuture.complete(PlayerChunk.UNLOADED_CHUNK); ++ this.entityTickingFuture.complete(PlayerChunk.UNLOADED_CHUNK); this.isEntityTickingReady = false; // Paper - cache chunk ticking stage + this.entityTickingFuture = PlayerChunk.UNLOADED_CHUNK_FUTURE; + } + +diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java +index b5a3b10012..e248893717 100644 +--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java ++++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java +@@ -0,0 +0,0 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { + }; + // CraftBukkit end + ++ // Paper start - distance maps ++ private final com.destroystokyo.paper.util.misc.PooledLinkedHashSets pooledLinkedPlayerHashSets = new com.destroystokyo.paper.util.misc.PooledLinkedHashSets<>(); ++ ++ void addPlayerToDistanceMaps(EntityPlayer player) { ++ this.updateMaps(player); ++ ++ ++ ++ } ++ ++ void removePlayerFromDistanceMaps(EntityPlayer player) { ++ ++ ++ ++ ++ } ++ ++ void updateMaps(EntityPlayer player) { ++ int chunkX = MCUtil.getChunkCoordinate(player.locX()); ++ int chunkZ = MCUtil.getChunkCoordinate(player.locZ()); ++ ++ ++ ++ ++ } ++ ++ ++ // Paper end ++ + public PlayerChunkMap(WorldServer worldserver, File file, DataFixer datafixer, DefinedStructureManager definedstructuremanager, Executor executor, IAsyncTaskHandler iasynctaskhandler, ILightAccess ilightaccess, ChunkGenerator chunkgenerator, WorldLoadListener worldloadlistener, Supplier supplier, int i) { + super(new File(worldserver.getWorldProvider().getDimensionManager().a(file), "region"), datafixer); + this.visibleChunks = this.updatingChunks.clone(); +@@ -0,0 +0,0 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { + } + } + ++ this.updateMaps(entityplayer); // Paper - distance maps ++ + } + + @Override diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java -index ba0293512..b257e1c4e 100644 +index ba02935128..b257e1c4e9 100644 --- a/src/main/java/net/minecraft/server/PlayerConnection.java +++ b/src/main/java/net/minecraft/server/PlayerConnection.java @@ -0,0 +0,0 @@ public class PlayerConnection implements PacketListenerPlayIn { @@ -948,7 +3031,7 @@ index ba0293512..b257e1c4e 100644 private volatile int chatThrottle; private static final AtomicIntegerFieldUpdater chatSpamField = AtomicIntegerFieldUpdater.newUpdater(PlayerConnection.class, "chatThrottle"); diff --git a/src/main/java/net/minecraft/server/PlayerInventory.java b/src/main/java/net/minecraft/server/PlayerInventory.java -index 08768a3c8..d103cfaac 100644 +index 08768a3c87..d103cfaace 100644 --- a/src/main/java/net/minecraft/server/PlayerInventory.java +++ b/src/main/java/net/minecraft/server/PlayerInventory.java @@ -0,0 +0,0 @@ public class PlayerInventory implements IInventory, INamableTileEntity { @@ -961,7 +3044,7 @@ index 08768a3c8..d103cfaac 100644 public final EntityHuman player; private ItemStack carried; diff --git a/src/main/java/net/minecraft/server/PotionUtil.java b/src/main/java/net/minecraft/server/PotionUtil.java -index b3824898d..bf4172be5 100644 +index b3824898da..bf4172be52 100644 --- a/src/main/java/net/minecraft/server/PotionUtil.java +++ b/src/main/java/net/minecraft/server/PotionUtil.java @@ -0,0 +0,0 @@ public class PotionUtil { @@ -973,7 +3056,7 @@ index b3824898d..bf4172be5 100644 MinecraftKey minecraftkey = IRegistry.POTION.getKey(potionregistry); diff --git a/src/main/java/net/minecraft/server/ProtoChunk.java b/src/main/java/net/minecraft/server/ProtoChunk.java -index 6e65306a2..39339fa27 100644 +index 6e65306a27..39339fa275 100644 --- a/src/main/java/net/minecraft/server/ProtoChunk.java +++ b/src/main/java/net/minecraft/server/ProtoChunk.java @@ -0,0 +0,0 @@ public class ProtoChunk implements IChunkAccess { @@ -996,7 +3079,7 @@ index 6e65306a2..39339fa27 100644 public IBlockData getType(BlockPosition blockposition) { int i = blockposition.getY(); diff --git a/src/main/java/net/minecraft/server/RegionFile.java b/src/main/java/net/minecraft/server/RegionFile.java -index 7b6e0e86b..187c4e0f5 100644 +index 7b6e0e86b0..187c4e0f58 100644 --- a/src/main/java/net/minecraft/server/RegionFile.java +++ b/src/main/java/net/minecraft/server/RegionFile.java @@ -0,0 +0,0 @@ public class RegionFile implements AutoCloseable { @@ -1008,7 +3091,7 @@ index 7b6e0e86b..187c4e0f5 100644 public synchronized DataInputStream a(ChunkCoordIntPair chunkcoordintpair) throws IOException { int i = this.getOffset(chunkcoordintpair); diff --git a/src/main/java/net/minecraft/server/RegionLimitedWorldAccess.java b/src/main/java/net/minecraft/server/RegionLimitedWorldAccess.java -index 8c123f265..9d0e8c2d4 100644 +index 8c123f265e..9d0e8c2d43 100644 --- a/src/main/java/net/minecraft/server/RegionLimitedWorldAccess.java +++ b/src/main/java/net/minecraft/server/RegionLimitedWorldAccess.java @@ -0,0 +0,0 @@ public class RegionLimitedWorldAccess implements GeneratorAccess { @@ -1039,7 +3122,7 @@ index 8c123f265..9d0e8c2d4 100644 public IBlockData getType(BlockPosition blockposition) { return this.getChunkAt(blockposition.getX() >> 4, blockposition.getZ() >> 4).getType(blockposition); diff --git a/src/main/java/net/minecraft/server/RegistryBlockID.java b/src/main/java/net/minecraft/server/RegistryBlockID.java -index 4efcb8b59..60948afa4 100644 +index 4efcb8b595..60948afa4e 100644 --- a/src/main/java/net/minecraft/server/RegistryBlockID.java +++ b/src/main/java/net/minecraft/server/RegistryBlockID.java @@ -0,0 +0,0 @@ public class RegistryBlockID implements Registry { @@ -1051,7 +3134,7 @@ index 4efcb8b59..60948afa4 100644 return this.b.size(); } diff --git a/src/main/java/net/minecraft/server/SystemUtils.java b/src/main/java/net/minecraft/server/SystemUtils.java -index 7b92ecfff..7e224ebef 100644 +index 7b92ecfff9..7e224ebeff 100644 --- a/src/main/java/net/minecraft/server/SystemUtils.java +++ b/src/main/java/net/minecraft/server/SystemUtils.java @@ -0,0 +0,0 @@ public class SystemUtils { @@ -1064,7 +3147,7 @@ index 7b92ecfff..7e224ebef 100644 public static long getTimeMillis() { diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java -index 692f8e4b7..8fc88f162 100644 +index 692f8e4b71..8fc88f162c 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -0,0 +0,0 @@ public abstract class World implements GeneratorAccess, AutoCloseable { @@ -1120,8 +3203,28 @@ index 692f8e4b7..8fc88f162 100644 Fluid fluid = this.getFluid(blockposition); return this.setTypeAndData(blockposition, fluid.getBlockData(), 3 | (flag ? 64 : 0)); +diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java +index 32f8f2aed5..2aaf679df4 100644 +--- a/src/main/java/net/minecraft/server/WorldServer.java ++++ b/src/main/java/net/minecraft/server/WorldServer.java +@@ -0,0 +0,0 @@ public class WorldServer extends World { + } + + this.registerEntity(entityplayer); ++ this.getChunkProvider().playerChunkMap.addPlayerToDistanceMaps(entityplayer); // Paper - distance maps + } + + // CraftBukkit start +@@ -0,0 +0,0 @@ public class WorldServer extends World { + EntityPlayer entityplayer = (EntityPlayer) entity; + + this.players.remove(entityplayer); ++ this.getChunkProvider().playerChunkMap.removePlayerFromDistanceMaps(entityplayer); // Paper - distance maps + } + + this.getScoreboard().a(entity); diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java -index e181df6f4..4a9132c70 100644 +index e181df6f4d..4a9132c701 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java @@ -0,0 +0,0 @@ public final class CraftItemStack extends ItemStack { @@ -1133,7 +3236,7 @@ index e181df6f4..4a9132c70 100644 /** * Mirror diff --git a/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java b/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java -index d8358a0f0..d0b813008 100644 +index d8358a0f03..d0b813008c 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java +++ b/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java @@ -0,0 +0,0 @@ public class DummyGeneratorAccess implements GeneratorAccess { @@ -1159,4 +3262,17 @@ index d8358a0f0..d0b813008 100644 + } + // Paper end } +diff --git a/src/main/java/org/bukkit/craftbukkit/util/UnsafeList.java b/src/main/java/org/bukkit/craftbukkit/util/UnsafeList.java +index 1aec70a1f1..f72c13beda 100644 +--- a/src/main/java/org/bukkit/craftbukkit/util/UnsafeList.java ++++ b/src/main/java/org/bukkit/craftbukkit/util/UnsafeList.java +@@ -0,0 +0,0 @@ import java.util.RandomAccess; + public class UnsafeList extends AbstractList implements List, RandomAccess, Cloneable, Serializable { + private static final long serialVersionUID = 8683452581112892191L; + +- private transient Object[] data; ++ private transient Object[] data; public final Object[] getRawDataArray() { return this.data; } // Paper - expose for raw get + private int size; + private int initialCapacity; + -- \ No newline at end of file diff --git a/Spigot-Server-Patches/Make-targetSize-more-aggressive-in-the-chunk-unload-.patch b/Spigot-Server-Patches/Make-targetSize-more-aggressive-in-the-chunk-unload-.patch index ebd7af5d87..fa576ef899 100644 --- a/Spigot-Server-Patches/Make-targetSize-more-aggressive-in-the-chunk-unload-.patch +++ b/Spigot-Server-Patches/Make-targetSize-more-aggressive-in-the-chunk-unload-.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Make targetSize more aggressive in the chunk unload queue diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java -index 1627aeeef..4fefdb9ce 100644 +index c575ff57dd..86e1b403b2 100644 --- a/src/main/java/net/minecraft/server/PlayerChunkMap.java +++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java @@ -0,0 +0,0 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { diff --git a/Spigot-Server-Patches/Mark-chunk-dirty-anytime-entities-change-to-guarante.patch b/Spigot-Server-Patches/Mark-chunk-dirty-anytime-entities-change-to-guarante.patch index 65ac05603a..f00b9fa8a0 100644 --- a/Spigot-Server-Patches/Mark-chunk-dirty-anytime-entities-change-to-guarante.patch +++ b/Spigot-Server-Patches/Mark-chunk-dirty-anytime-entities-change-to-guarante.patch @@ -6,12 +6,12 @@ Subject: [PATCH] Mark chunk dirty anytime entities change to guarantee it diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index 1efddb533..6774c6480 100644 +index 8fdae388e3..28e5105ffe 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java @@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess { - entity.chunkY = k; entity.chunkZ = this.loc.z; + this.entities.add(entity); // Paper - per chunk entity list this.entitySlices[k].add(entity); + this.markDirty(); // Paper } diff --git a/Spigot-Server-Patches/Mark-entities-as-being-ticked-when-notifying-navigat.patch b/Spigot-Server-Patches/Mark-entities-as-being-ticked-when-notifying-navigat.patch index 15d7335a29..88bf1ae935 100644 --- a/Spigot-Server-Patches/Mark-entities-as-being-ticked-when-notifying-navigat.patch +++ b/Spigot-Server-Patches/Mark-entities-as-being-ticked-when-notifying-navigat.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Mark entities as being ticked when notifying navigation diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index 53172dac2..691ef0048 100644 +index e9d3424103..0f652e58e1 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -0,0 +0,0 @@ public class WorldServer extends World { diff --git a/Spigot-Server-Patches/Optimise-getChunkAt-calls-for-loaded-chunks.patch b/Spigot-Server-Patches/Optimise-getChunkAt-calls-for-loaded-chunks.patch new file mode 100644 index 0000000000..1c9576c787 --- /dev/null +++ b/Spigot-Server-Patches/Optimise-getChunkAt-calls-for-loaded-chunks.patch @@ -0,0 +1,86 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Spottedleaf +Date: Sat, 25 Jan 2020 17:04:35 -0800 +Subject: [PATCH] Optimise getChunkAt calls for loaded chunks + +bypass the need to get a player chunk, then get the either, +then unwrap it... + +diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java +index 72919e4c64..42c559ad4f 100644 +--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java ++++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java +@@ -0,0 +0,0 @@ public class ChunkProviderServer extends IChunkProvider { + return this.getChunkAt(i, j, chunkstatus, flag); + }, this.serverThreadQueue).join(); + } else { ++ // Paper start - optimise for loaded chunks ++ Chunk ifLoaded = this.getChunkAtIfLoadedMainThread(i, j); ++ if (ifLoaded != null) { ++ return ifLoaded; ++ } ++ // Paper end + GameProfilerFiller gameprofilerfiller = this.world.getMethodProfiler(); + + gameprofilerfiller.c("getChunk"); +@@ -0,0 +0,0 @@ public class ChunkProviderServer extends IChunkProvider { + if (Thread.currentThread() != this.serverThread) { + return null; + } else { +- this.world.getMethodProfiler().c("getChunkNow"); +- long k = ChunkCoordIntPair.pair(i, j); +- +- for (int l = 0; l < 4; ++l) { +- if (k == this.cachePos[l] && this.cacheStatus[l] == ChunkStatus.FULL) { +- IChunkAccess ichunkaccess = this.cacheChunk[l]; +- +- return ichunkaccess instanceof Chunk ? (Chunk) ichunkaccess : null; +- } +- } +- +- PlayerChunk playerchunk = this.getChunk(k); +- +- if (playerchunk == null) { +- return null; +- } else { +- Either either = (Either) playerchunk.b(ChunkStatus.FULL).getNow(null); // Craftbukkit - decompile error +- +- if (either == null) { +- return null; +- } else { +- IChunkAccess ichunkaccess1 = (IChunkAccess) either.left().orElse(null); // Craftbukkit - decompile error +- +- if (ichunkaccess1 != null) { +- this.a(k, ichunkaccess1, ChunkStatus.FULL); +- if (ichunkaccess1 instanceof Chunk) { +- return (Chunk) ichunkaccess1; +- } +- } +- +- return null; +- } +- } ++ return this.getChunkAtIfLoadedMainThread(i, j); // Paper - optimise for loaded chunks + } + } + +diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java +index 8a2bb79ad9..abd8b751ba 100644 +--- a/src/main/java/net/minecraft/server/World.java ++++ b/src/main/java/net/minecraft/server/World.java +@@ -0,0 +0,0 @@ public abstract class World implements GeneratorAccess, AutoCloseable { + + @Override + public Chunk getChunkAt(int i, int j) { ++ // Paper start - optimise this for loaded chunks ++ if (Thread.currentThread() == this.serverThread) { ++ Chunk ifLoaded = ((WorldServer) this).getChunkProvider().getChunkAtIfLoadedMainThread(i, j); ++ if (ifLoaded != null) { ++ return ifLoaded; ++ } ++ } ++ // Paper end + return (Chunk) this.getChunkAt(i, j, ChunkStatus.FULL); + } + +-- \ No newline at end of file diff --git a/Spigot-Server-Patches/Optimize-isValidLocation-getType-and-getBlockData-fo.patch b/Spigot-Server-Patches/Optimize-isValidLocation-getType-and-getBlockData-fo.patch index a0f77f9fd6..282601df90 100644 --- a/Spigot-Server-Patches/Optimize-isValidLocation-getType-and-getBlockData-fo.patch +++ b/Spigot-Server-Patches/Optimize-isValidLocation-getType-and-getBlockData-fo.patch @@ -12,7 +12,7 @@ Replace all calls to the new place to the unnecessary forward. Optimize getType and getBlockData to manually inline and optimize the calls diff --git a/src/main/java/net/minecraft/server/BaseBlockPosition.java b/src/main/java/net/minecraft/server/BaseBlockPosition.java -index a3b5793e4..71089442c 100644 +index a3b5793e48..71089442c1 100644 --- a/src/main/java/net/minecraft/server/BaseBlockPosition.java +++ b/src/main/java/net/minecraft/server/BaseBlockPosition.java @@ -0,0 +0,0 @@ public class BaseBlockPosition implements Comparable { @@ -31,7 +31,7 @@ index a3b5793e4..71089442c 100644 public BaseBlockPosition(int i, int j, int k) { this.a = i; diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index be32b31e7..fd9ba8232 100644 +index 6ed23ea6c8..7033c6e839 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java @@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess { @@ -64,7 +64,7 @@ index be32b31e7..fd9ba8232 100644 IBlockData iblockdata = null; diff --git a/src/main/java/net/minecraft/server/ChunkSection.java b/src/main/java/net/minecraft/server/ChunkSection.java -index 652067757..0d5deee36 100644 +index 652067757a..0d5deee365 100644 --- a/src/main/java/net/minecraft/server/ChunkSection.java +++ b/src/main/java/net/minecraft/server/ChunkSection.java @@ -0,0 +0,0 @@ public class ChunkSection { @@ -77,7 +77,7 @@ index 652067757..0d5deee36 100644 public ChunkSection(int i) { this(i, (short) 0, (short) 0, (short) 0); diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java -index 37914c2f5..18ee29e50 100644 +index 37914c2f53..18ee29e507 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -0,0 +0,0 @@ public abstract class World implements GeneratorAccess, AutoCloseable { diff --git a/Spigot-Server-Patches/Option-to-remove-corrupt-tile-entities.patch b/Spigot-Server-Patches/Option-to-remove-corrupt-tile-entities.patch index 0ad9eb9462..6548691a63 100644 --- a/Spigot-Server-Patches/Option-to-remove-corrupt-tile-entities.patch +++ b/Spigot-Server-Patches/Option-to-remove-corrupt-tile-entities.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Option to remove corrupt tile entities diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index 8cf3076f4..721eceeff 100644 +index 8cf3076f4e..721eceeffc 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -0,0 +0,0 @@ public class PaperWorldConfig { @@ -19,7 +19,7 @@ index 8cf3076f4..721eceeff 100644 + } } diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index 034e8684d..1efddb533 100644 +index c6a79644ef..8fdae388e3 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java @@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess { diff --git a/Spigot-Server-Patches/PlayerDeathEvent-getItemsToKeep.patch b/Spigot-Server-Patches/PlayerDeathEvent-getItemsToKeep.patch index 6012bbce70..544585bb99 100644 --- a/Spigot-Server-Patches/PlayerDeathEvent-getItemsToKeep.patch +++ b/Spigot-Server-Patches/PlayerDeathEvent-getItemsToKeep.patch @@ -8,7 +8,7 @@ Exposes a mutable array on items a player should keep on death Example Usage: https://gist.github.com/aikar/5bb202de6057a051a950ce1f29feb0b4 diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java -index 959e2c1c1..6483c4a0b 100644 +index 4d614b9ef1..77ad4774ec 100644 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/EntityPlayer.java @@ -0,0 +0,0 @@ public class EntityPlayer extends EntityHuman implements ICrafting { diff --git a/Spigot-Server-Patches/PlayerDeathEvent-shouldDropExperience.patch b/Spigot-Server-Patches/PlayerDeathEvent-shouldDropExperience.patch index 8e8026553f..b321366230 100644 --- a/Spigot-Server-Patches/PlayerDeathEvent-shouldDropExperience.patch +++ b/Spigot-Server-Patches/PlayerDeathEvent-shouldDropExperience.patch @@ -5,7 +5,7 @@ Subject: [PATCH] PlayerDeathEvent#shouldDropExperience diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java -index 27d529efe..d09afc889 100644 +index 4ca28c8b64..15230a834c 100644 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/EntityPlayer.java @@ -0,0 +0,0 @@ public class EntityPlayer extends EntityHuman implements ICrafting { diff --git a/Spigot-Server-Patches/PlayerNaturallySpawnCreaturesEvent.patch b/Spigot-Server-Patches/PlayerNaturallySpawnCreaturesEvent.patch index 018237309b..521fdbef02 100644 --- a/Spigot-Server-Patches/PlayerNaturallySpawnCreaturesEvent.patch +++ b/Spigot-Server-Patches/PlayerNaturallySpawnCreaturesEvent.patch @@ -9,7 +9,7 @@ from triggering monster spawns on a server. Also a highly more effecient way to blanket block spawns in a world diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java -index 4fefdb9ce..426beb181 100644 +index 86e1b403b2..bf80af2354 100644 --- a/src/main/java/net/minecraft/server/PlayerChunkMap.java +++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java @@ -0,0 +0,0 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { diff --git a/Spigot-Server-Patches/Properly-fix-item-duplication-bug.patch b/Spigot-Server-Patches/Properly-fix-item-duplication-bug.patch index 0186ba30a0..aaa96a5002 100644 --- a/Spigot-Server-Patches/Properly-fix-item-duplication-bug.patch +++ b/Spigot-Server-Patches/Properly-fix-item-duplication-bug.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Properly fix item duplication bug Credit to prplz for figuring out the real issue diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java -index 8aef7e480..68b19a3fc 100644 +index d3bdec7995..1296eb04f0 100644 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/EntityPlayer.java @@ -0,0 +0,0 @@ public class EntityPlayer extends EntityHuman implements ICrafting { @@ -19,7 +19,7 @@ index 8aef7e480..68b19a3fc 100644 @Override diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java -index 16b70221e..cc6a2aaeb 100644 +index 16b70221ea..cc6a2aaeb3 100644 --- a/src/main/java/net/minecraft/server/PlayerConnection.java +++ b/src/main/java/net/minecraft/server/PlayerConnection.java @@ -0,0 +0,0 @@ public class PlayerConnection implements PacketListenerPlayIn { diff --git a/Spigot-Server-Patches/Re-add-vanilla-entity-warnings-for-duplicates.patch b/Spigot-Server-Patches/Re-add-vanilla-entity-warnings-for-duplicates.patch index e572e60440..21f963b4c0 100644 --- a/Spigot-Server-Patches/Re-add-vanilla-entity-warnings-for-duplicates.patch +++ b/Spigot-Server-Patches/Re-add-vanilla-entity-warnings-for-duplicates.patch @@ -8,7 +8,7 @@ These are a critical sign that somethin went wrong, and you've lost some data... We should kind of know about these things you know. diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index ae7df6141..389036405 100644 +index f0c912be43..d46a664bdb 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -0,0 +0,0 @@ public class WorldServer extends World { diff --git a/Spigot-Server-Patches/Re-track-players-that-dismount-from-other-players.patch b/Spigot-Server-Patches/Re-track-players-that-dismount-from-other-players.patch index 9e43b326a5..5c8ad8ef05 100644 --- a/Spigot-Server-Patches/Re-track-players-that-dismount-from-other-players.patch +++ b/Spigot-Server-Patches/Re-track-players-that-dismount-from-other-players.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Re-track players that dismount from other players diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java -index 1f5145d49..b2c070397 100644 +index d4bba876d0..ae1f0d5783 100644 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/EntityPlayer.java @@ -0,0 +0,0 @@ public class EntityPlayer extends EntityHuman implements ICrafting { diff --git a/Spigot-Server-Patches/Reduce-sync-loads.patch b/Spigot-Server-Patches/Reduce-sync-loads.patch index 6dcf852b30..4cc0d24633 100644 --- a/Spigot-Server-Patches/Reduce-sync-loads.patch +++ b/Spigot-Server-Patches/Reduce-sync-loads.patch @@ -11,7 +11,7 @@ it must be enabled by setting the startup flag -Dpaper.debug-sync-loads=true To get a debug log for sync loads, the command is /paper syncloadinfo diff --git a/src/main/java/com/destroystokyo/paper/PaperCommand.java b/src/main/java/com/destroystokyo/paper/PaperCommand.java -index 09efbf725..132397b3f 100644 +index 09efbf7250..132397b3f3 100644 --- a/src/main/java/com/destroystokyo/paper/PaperCommand.java +++ b/src/main/java/com/destroystokyo/paper/PaperCommand.java @@ -0,0 +0,0 @@ @@ -91,7 +91,7 @@ index 09efbf725..132397b3f 100644 if (args.length < 2 || args[1].equals("*")) { diff --git a/src/main/java/com/destroystokyo/paper/io/SyncLoadFinder.java b/src/main/java/com/destroystokyo/paper/io/SyncLoadFinder.java new file mode 100644 -index 000000000..59aec1032 +index 0000000000..59aec10329 --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/io/SyncLoadFinder.java @@ -0,0 +0,0 @@ @@ -268,7 +268,7 @@ index 000000000..59aec1032 + } +} diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java -index 58299562e..3eb867684 100644 +index e10035d461..92b22b9996 100644 --- a/src/main/java/net/minecraft/server/ChunkProviderServer.java +++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java @@ -0,0 +0,0 @@ public class ChunkProviderServer extends IChunkProvider { @@ -280,7 +280,7 @@ index 58299562e..3eb867684 100644 this.serverThreadQueue.awaitTasks(completablefuture::isDone); com.destroystokyo.paper.io.chunk.ChunkTaskManager.popChunkWait(); // Paper - async chunk debug diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java -index 0944ce045..9df079d8a 100644 +index 0944ce0458..9df079d8af 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -0,0 +0,0 @@ public abstract class World implements GeneratorAccess, AutoCloseable { @@ -311,7 +311,7 @@ index 0944ce045..9df079d8a 100644 if (chunk != null) { chunk.a(oclass, axisalignedbb, list, predicate); diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index 541c1535e..4c74a85e0 100644 +index 5eb52817f1..6d362316f7 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -0,0 +0,0 @@ public class WorldServer extends World { diff --git a/Spigot-Server-Patches/Remove-invalid-mob-spawner-tile-entities.patch b/Spigot-Server-Patches/Remove-invalid-mob-spawner-tile-entities.patch index 2701f197ad..cbdd361751 100644 --- a/Spigot-Server-Patches/Remove-invalid-mob-spawner-tile-entities.patch +++ b/Spigot-Server-Patches/Remove-invalid-mob-spawner-tile-entities.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Remove invalid mob spawner tile entities diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index 5f9031257..f62429277 100644 +index 2ebbcc6958..e7268074b4 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java @@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess { diff --git a/Spigot-Server-Patches/Remove-unused-World-Tile-Entity-List.patch b/Spigot-Server-Patches/Remove-unused-World-Tile-Entity-List.patch index 18cc94f5f6..476ebfa6e4 100644 --- a/Spigot-Server-Patches/Remove-unused-World-Tile-Entity-List.patch +++ b/Spigot-Server-Patches/Remove-unused-World-Tile-Entity-List.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Remove unused World Tile Entity List Massive hit to performance and it is completely unnecessary. diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java -index e7d441b22..50c138d06 100644 +index e7d441b22b..50c138d06d 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -0,0 +0,0 @@ public abstract class World implements GeneratorAccess, AutoCloseable { @@ -67,7 +67,7 @@ index e7d441b22..50c138d06 100644 } diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index 2a80fe846..9121aa2e4 100644 +index dac6e10d25..7b3e3487fa 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -0,0 +0,0 @@ public class WorldServer extends World { diff --git a/Spigot-Server-Patches/Reset-players-airTicks-on-respawn.patch b/Spigot-Server-Patches/Reset-players-airTicks-on-respawn.patch index b143264253..1467243a93 100644 --- a/Spigot-Server-Patches/Reset-players-airTicks-on-respawn.patch +++ b/Spigot-Server-Patches/Reset-players-airTicks-on-respawn.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Reset players airTicks on respawn diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index 4619f2c92..03469c965 100644 +index 4619f2c928..03469c9657 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -0,0 +0,0 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke @@ -17,7 +17,7 @@ index 4619f2c92..03469c965 100644 return 300; } diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java -index 8858bea04..f2f34593b 100644 +index 10ca229cb4..f33580f8c5 100644 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/EntityPlayer.java @@ -0,0 +0,0 @@ public class EntityPlayer extends EntityHuman implements ICrafting { diff --git a/Spigot-Server-Patches/Send-absolute-position-the-first-time-an-entity-is-s.patch b/Spigot-Server-Patches/Send-absolute-position-the-first-time-an-entity-is-s.patch index 6dde3cecbf..31f32b2716 100644 --- a/Spigot-Server-Patches/Send-absolute-position-the-first-time-an-entity-is-s.patch +++ b/Spigot-Server-Patches/Send-absolute-position-the-first-time-an-entity-is-s.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Send absolute position the first time an entity is seen diff --git a/src/main/java/net/minecraft/server/EntityTrackerEntry.java b/src/main/java/net/minecraft/server/EntityTrackerEntry.java -index a75e0ec54..a13fd9b34 100644 +index a75e0ec54e..a13fd9b340 100644 --- a/src/main/java/net/minecraft/server/EntityTrackerEntry.java +++ b/src/main/java/net/minecraft/server/EntityTrackerEntry.java @@ -0,0 +0,0 @@ package net.minecraft.server; @@ -77,7 +77,7 @@ index a75e0ec54..a13fd9b34 100644 this.c(); diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java -index dcfb37004..89433004d 100644 +index 1f289047fa..b2260498cb 100644 --- a/src/main/java/net/minecraft/server/PlayerChunkMap.java +++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java @@ -0,0 +0,0 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { diff --git a/Spigot-Server-Patches/Send-nearby-packets-from-world-player-list-not-serve.patch b/Spigot-Server-Patches/Send-nearby-packets-from-world-player-list-not-serve.patch index 081dabd03f..dbeb166f1a 100644 --- a/Spigot-Server-Patches/Send-nearby-packets-from-world-player-list-not-serve.patch +++ b/Spigot-Server-Patches/Send-nearby-packets-from-world-player-list-not-serve.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Send nearby packets from world player list not server list diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java -index fd0f5c6f2..e46436623 100644 +index fd0f5c6f29..e46436623c 100644 --- a/src/main/java/net/minecraft/server/PlayerList.java +++ b/src/main/java/net/minecraft/server/PlayerList.java @@ -0,0 +0,0 @@ public abstract class PlayerList { @@ -46,7 +46,7 @@ index fd0f5c6f2..e46436623 100644 double d5 = d1 - entityplayer.locY(); double d6 = d2 - entityplayer.locZ(); diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index ba0389f2f..1e8079f91 100644 +index 12cdb0cc9a..f12cadc735 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -0,0 +0,0 @@ public class WorldServer extends World { @@ -68,7 +68,7 @@ index ba0389f2f..1e8079f91 100644 } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index 0fb47579f..bc151d8d2 100644 +index 0fb47579f6..bc151d8d25 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -0,0 +0,0 @@ public class CraftWorld implements World { diff --git a/Spigot-Server-Patches/Speedup-BlockPos-by-fixing-inlining.patch b/Spigot-Server-Patches/Speedup-BlockPos-by-fixing-inlining.patch index ebff767024..ed345fbe80 100644 --- a/Spigot-Server-Patches/Speedup-BlockPos-by-fixing-inlining.patch +++ b/Spigot-Server-Patches/Speedup-BlockPos-by-fixing-inlining.patch @@ -21,7 +21,7 @@ This is based upon conclusions drawn from inspecting the assenmbly generated byt They had 'callq' (invoke) instead of 'mov' (get from memory) instructions. diff --git a/src/main/java/net/minecraft/server/BaseBlockPosition.java b/src/main/java/net/minecraft/server/BaseBlockPosition.java -index 71089442c..c439a8d01 100644 +index 71089442c1..c439a8d019 100644 --- a/src/main/java/net/minecraft/server/BaseBlockPosition.java +++ b/src/main/java/net/minecraft/server/BaseBlockPosition.java @@ -0,0 +0,0 @@ import javax.annotation.concurrent.Immutable; @@ -110,7 +110,7 @@ index 71089442c..c439a8d01 100644 return (int) (f + f1 + f2); } diff --git a/src/main/java/net/minecraft/server/BlockPosition.java b/src/main/java/net/minecraft/server/BlockPosition.java -index 1cdf0346f..5a505b753 100644 +index 5dbd3e60fe..e9ea232a78 100644 --- a/src/main/java/net/minecraft/server/BlockPosition.java +++ b/src/main/java/net/minecraft/server/BlockPosition.java @@ -0,0 +0,0 @@ public class BlockPosition extends BaseBlockPosition implements MinecraftSeriali @@ -189,16 +189,19 @@ index 1cdf0346f..5a505b753 100644 + return this.d(this.x + i, this.y + j, this.z + k); } + public final void setX(final int x) { this.o(x); } // Paper - OBFHELPER public void o(int i) { - this.b = i; + this.x = i; // Paper change to x } + public final void setY(final int y) { this.p(y); } // Paper - OBFHELPER public void p(int i) { - this.c = i; + this.y = i; // Paper change to y } + public final void setZ(final int z) { this.q(z); } // Paper - OBFHELPER public void q(int i) { - this.d = i; + this.z = i; // Paper change to z diff --git a/Spigot-Server-Patches/Store-counts-for-each-Entity-Block-Entity-Type.patch b/Spigot-Server-Patches/Store-counts-for-each-Entity-Block-Entity-Type.patch index 30827e0422..ec1108587b 100644 --- a/Spigot-Server-Patches/Store-counts-for-each-Entity-Block-Entity-Type.patch +++ b/Spigot-Server-Patches/Store-counts-for-each-Entity-Block-Entity-Type.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Store counts for each Entity/Block Entity Type Opens door for future patches to optimize performance diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index 125d3acdc..dcaf3a509 100644 +index 8627365923..4110b6fa39 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java @@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess { diff --git a/Spigot-Server-Patches/Store-reference-to-current-Chunk-for-Entity-and-Bloc.patch b/Spigot-Server-Patches/Store-reference-to-current-Chunk-for-Entity-and-Bloc.patch index 12848f4e7f..9450a50915 100644 --- a/Spigot-Server-Patches/Store-reference-to-current-Chunk-for-Entity-and-Bloc.patch +++ b/Spigot-Server-Patches/Store-reference-to-current-Chunk-for-Entity-and-Bloc.patch @@ -8,7 +8,7 @@ This enables us a fast reference to the entities current chunk instead of having to look it up by hashmap lookups. diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index cfffbd031..125d3acdc 100644 +index a263f60d49..8627365923 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java @@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess { @@ -90,7 +90,7 @@ index cfffbd031..125d3acdc 100644 @Override diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index a8ea70b36..3a969d92e 100644 +index a8ea70b36b..3a969d92e0 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -0,0 +0,0 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke @@ -143,7 +143,7 @@ index a8ea70b36..3a969d92e 100644 private String entityKeyString; diff --git a/src/main/java/net/minecraft/server/TileEntity.java b/src/main/java/net/minecraft/server/TileEntity.java -index 9071bb7ec..820180ab3 100644 +index 9071bb7ece..820180ab3f 100644 --- a/src/main/java/net/minecraft/server/TileEntity.java +++ b/src/main/java/net/minecraft/server/TileEntity.java @@ -0,0 +0,0 @@ public abstract class TileEntity implements KeyedObject { // Paper @@ -163,7 +163,7 @@ index 9071bb7ec..820180ab3 100644 @Nullable diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java -index 63ecbcd47..c82c21326 100644 +index 63ecbcd47a..c82c213260 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -0,0 +0,0 @@ import net.minecraft.server.EntityZombieVillager; diff --git a/Spigot-Server-Patches/String-based-Action-Bar-API.patch b/Spigot-Server-Patches/String-based-Action-Bar-API.patch index 994063fc9b..2722f3ce6d 100644 --- a/Spigot-Server-Patches/String-based-Action-Bar-API.patch +++ b/Spigot-Server-Patches/String-based-Action-Bar-API.patch @@ -5,7 +5,7 @@ Subject: [PATCH] String based Action Bar API diff --git a/src/main/java/net/minecraft/server/MCUtil.java b/src/main/java/net/minecraft/server/MCUtil.java -index 628b73a12..2f10dab36 100644 +index 9fa88d79d8..ee2174a9ca 100644 --- a/src/main/java/net/minecraft/server/MCUtil.java +++ b/src/main/java/net/minecraft/server/MCUtil.java @@ -0,0 +0,0 @@ package net.minecraft.server; @@ -42,7 +42,7 @@ index 628b73a12..2f10dab36 100644 public static boolean isMainThread() { return MinecraftServer.getServer().isMainThread(); diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 447ecf636..3a2a88618 100644 +index 447ecf636d..3a2a886180 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player { diff --git a/Spigot-Server-Patches/Timings-v2.patch b/Spigot-Server-Patches/Timings-v2.patch index fc18dfc38b..b0f32fef50 100644 --- a/Spigot-Server-Patches/Timings-v2.patch +++ b/Spigot-Server-Patches/Timings-v2.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Timings v2 diff --git a/src/main/java/co/aikar/timings/MinecraftTimings.java b/src/main/java/co/aikar/timings/MinecraftTimings.java new file mode 100644 -index 000000000..69e26a826 +index 0000000000..69e26a8267 --- /dev/null +++ b/src/main/java/co/aikar/timings/MinecraftTimings.java @@ -0,0 +0,0 @@ @@ -153,7 +153,7 @@ index 000000000..69e26a826 +} diff --git a/src/main/java/co/aikar/timings/WorldTimingsHandler.java b/src/main/java/co/aikar/timings/WorldTimingsHandler.java new file mode 100644 -index 000000000..3a79cde59 +index 0000000000..3a79cde595 --- /dev/null +++ b/src/main/java/co/aikar/timings/WorldTimingsHandler.java @@ -0,0 +0,0 @@ @@ -288,7 +288,7 @@ index 000000000..3a79cde59 + } +} diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java -index b6d470e59..f402a29b0 100644 +index b6d470e594..f402a29b09 100644 --- a/src/main/java/com/destroystokyo/paper/PaperConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java @@ -0,0 +0,0 @@ import java.util.concurrent.TimeUnit; @@ -335,7 +335,7 @@ index b6d470e59..f402a29b0 100644 + } } diff --git a/src/main/java/net/minecraft/server/Block.java b/src/main/java/net/minecraft/server/Block.java -index cd72a9c84..5de881371 100644 +index cd72a9c845..5de881371a 100644 --- a/src/main/java/net/minecraft/server/Block.java +++ b/src/main/java/net/minecraft/server/Block.java @@ -0,0 +0,0 @@ public class Block implements IMaterial { @@ -355,7 +355,7 @@ index cd72a9c84..5de881371 100644 private final float frictionFactor; private final float f; diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index dcaf3a509..5f9031257 100644 +index 4110b6fa39..2ebbcc6958 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java @@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess { @@ -375,7 +375,7 @@ index dcaf3a509..5f9031257 100644 } } diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java -index 9cd21b1ff..99afce39a 100644 +index d24c8070f4..1ba34cfaa9 100644 --- a/src/main/java/net/minecraft/server/ChunkProviderServer.java +++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java @@ -0,0 +0,0 @@ public class ChunkProviderServer extends IChunkProvider { @@ -487,7 +487,7 @@ index 9cd21b1ff..99afce39a 100644 @Override diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java -index e16d30f2c..4af5a230b 100644 +index e16d30f2ca..4af5a230ba 100644 --- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java +++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java @@ -0,0 +0,0 @@ @@ -525,7 +525,7 @@ index e16d30f2c..4af5a230b 100644 } diff --git a/src/main/java/net/minecraft/server/CustomFunction.java b/src/main/java/net/minecraft/server/CustomFunction.java -index 8d7a6d240..707bd2600 100644 +index 8d7a6d2403..707bd2600d 100644 --- a/src/main/java/net/minecraft/server/CustomFunction.java +++ b/src/main/java/net/minecraft/server/CustomFunction.java @@ -0,0 +0,0 @@ public class CustomFunction { @@ -552,7 +552,7 @@ index 8d7a6d240..707bd2600 100644 return this.b; } diff --git a/src/main/java/net/minecraft/server/CustomFunctionData.java b/src/main/java/net/minecraft/server/CustomFunctionData.java -index ba40d5fbb..ee42e1dfa 100644 +index ba40d5fbb5..ee42e1dfa4 100644 --- a/src/main/java/net/minecraft/server/CustomFunctionData.java +++ b/src/main/java/net/minecraft/server/CustomFunctionData.java @@ -0,0 +0,0 @@ public class CustomFunctionData implements IResourcePackListener { @@ -565,7 +565,7 @@ index ba40d5fbb..ee42e1dfa 100644 int k = 0; CustomFunction.c[] acustomfunction_c = customfunction.b(); diff --git a/src/main/java/net/minecraft/server/DedicatedServer.java b/src/main/java/net/minecraft/server/DedicatedServer.java -index 1cde6fc9c..e636433b1 100644 +index 1cde6fc9c1..e636433b11 100644 --- a/src/main/java/net/minecraft/server/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/DedicatedServer.java @@ -0,0 +0,0 @@ import java.util.List; @@ -653,7 +653,7 @@ index 1cde6fc9c..e636433b1 100644 } diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index 3a969d92e..2d8c37d73 100644 +index 3a969d92e0..2d8c37d73b 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -0,0 +0,0 @@ import org.bukkit.command.CommandSender; @@ -692,7 +692,7 @@ index 3a969d92e..2d8c37d73 100644 protected BlockPosition ag() { diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java -index 1f350e335..35e3f1c78 100644 +index 1f350e3352..35e3f1c78d 100644 --- a/src/main/java/net/minecraft/server/EntityLiving.java +++ b/src/main/java/net/minecraft/server/EntityLiving.java @@ -0,0 +0,0 @@ import org.bukkit.event.entity.EntityTeleportEvent; @@ -768,7 +768,7 @@ index 1f350e335..35e3f1c78 100644 } diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index b4a0bd795..4dc691775 100644 +index b4a0bd7951..4dc6917759 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -0,0 +0,0 @@ import org.bukkit.craftbukkit.CraftServer; @@ -944,7 +944,7 @@ index b4a0bd795..4dc691775 100644 this.methodProfiler.exit(); } diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java -index b5a3b1001..dcfb37004 100644 +index e248893717..1f289047fa 100644 --- a/src/main/java/net/minecraft/server/PlayerChunkMap.java +++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java @@ -0,0 +0,0 @@ @@ -1027,7 +1027,7 @@ index b5a3b1001..dcfb37004 100644 protected void broadcast(Entity entity, Packet packet) { diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java -index b257e1c4e..b7beb058d 100644 +index b257e1c4e9..b7beb058d8 100644 --- a/src/main/java/net/minecraft/server/PlayerConnection.java +++ b/src/main/java/net/minecraft/server/PlayerConnection.java @@ -0,0 +0,0 @@ import org.bukkit.inventory.CraftingInventory; @@ -1082,7 +1082,7 @@ index b257e1c4e..b7beb058d 100644 // this.minecraftServer.getCommandDispatcher().a(this.player.getCommandListener(), s); // CraftBukkit end diff --git a/src/main/java/net/minecraft/server/PlayerConnectionUtils.java b/src/main/java/net/minecraft/server/PlayerConnectionUtils.java -index 2c671629a..eb3269e0e 100644 +index 2c671629a4..eb3269e0ea 100644 --- a/src/main/java/net/minecraft/server/PlayerConnectionUtils.java +++ b/src/main/java/net/minecraft/server/PlayerConnectionUtils.java @@ -0,0 +0,0 @@ package net.minecraft.server; @@ -1109,7 +1109,7 @@ index 2c671629a..eb3269e0e 100644 PlayerConnectionUtils.LOGGER.debug("Ignoring packet due to disconnection: " + packet); } diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java -index 0694f4563..1652a57e2 100644 +index 0694f4563e..1652a57e25 100644 --- a/src/main/java/net/minecraft/server/PlayerList.java +++ b/src/main/java/net/minecraft/server/PlayerList.java @@ -0,0 +0,0 @@ @@ -1133,7 +1133,7 @@ index 0694f4563..1652a57e2 100644 public WhiteList getWhitelist() { diff --git a/src/main/java/net/minecraft/server/TickListServer.java b/src/main/java/net/minecraft/server/TickListServer.java -index 00bbd34b6..f533860bb 100644 +index 00bbd34b6a..f533860bbe 100644 --- a/src/main/java/net/minecraft/server/TickListServer.java +++ b/src/main/java/net/minecraft/server/TickListServer.java @@ -0,0 +0,0 @@ public class TickListServer implements TickList { @@ -1183,7 +1183,7 @@ index 00bbd34b6..f533860bb 100644 this.g.clear(); } diff --git a/src/main/java/net/minecraft/server/TileEntity.java b/src/main/java/net/minecraft/server/TileEntity.java -index 820180ab3..fa6400dcc 100644 +index 820180ab3f..fa6400dccd 100644 --- a/src/main/java/net/minecraft/server/TileEntity.java +++ b/src/main/java/net/minecraft/server/TileEntity.java @@ -0,0 +0,0 @@ import org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer; @@ -1202,7 +1202,7 @@ index 820180ab3..fa6400dcc 100644 private static final CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new CraftPersistentDataTypeRegistry(); public CraftPersistentDataContainer persistentDataContainer; diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java -index 8fc88f162..0087bd9b1 100644 +index 8fc88f162c..0087bd9b1c 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -0,0 +0,0 @@ @@ -1257,7 +1257,7 @@ index 8fc88f162..0087bd9b1 100644 CrashReport crashreport = CrashReport.a(throwable, "Ticking entity"); CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being ticked"); diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index 32f8f2aed..bc1ff7d56 100644 +index 2aaf679df4..ebc252a610 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -0,0 +0,0 @@ @@ -1382,7 +1382,7 @@ index 32f8f2aed..bc1ff7d56 100644 // CraftBukkit start - moved from MinecraftServer.saveChunks diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 57ad50403..038928789 100644 +index 57ad50403b..038928789b 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -0,0 +0,0 @@ public final class CraftServer implements Server { @@ -1419,7 +1419,7 @@ index 57ad50403..038928789 100644 org.spigotmc.RestartCommand.restart(); diff --git a/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java b/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java deleted file mode 100644 -index 2bd22a369..000000000 +index 2bd22a3698..0000000000 --- a/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java +++ /dev/null @@ -0,0 +0,0 @@ @@ -1586,7 +1586,7 @@ index 2bd22a369..000000000 - } -} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 9eba8449e..1094190fd 100644 +index 9eba8449e4..1094190fd9 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @@ -1605,7 +1605,7 @@ index 9eba8449e..1094190fd 100644 public Player.Spigot spigot() diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java -index b90979c7b..8823f94f7 100644 +index b90979c7ba..8823f94f7b 100644 --- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java +++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java @@ -0,0 +0,0 @@ @@ -1671,7 +1671,7 @@ index b90979c7b..8823f94f7 100644 private boolean isReady(final int currentTick) { diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java -index 3f55381c1..0d9a46680 100644 +index 3f55381c15..0d9a466809 100644 --- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java +++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java @@ -0,0 +0,0 @@ @@ -1756,7 +1756,7 @@ index 3f55381c1..0d9a46680 100644 - // Spigot end } diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftIconCache.java b/src/main/java/org/bukkit/craftbukkit/util/CraftIconCache.java -index e52ef47b7..3d90b3426 100644 +index e52ef47b78..3d90b34268 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftIconCache.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftIconCache.java @@ -0,0 +0,0 @@ import org.bukkit.util.CachedServerIcon; @@ -1768,7 +1768,7 @@ index e52ef47b7..3d90b3426 100644 this.value = value; } diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -index afe4004ff..1c719ec0e 100644 +index afe4004ff2..1c719ec0e3 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -0,0 +0,0 @@ public final class CraftMagicNumbers implements UnsafeValues { @@ -1786,7 +1786,7 @@ index afe4004ff..1c719ec0e 100644 * This helper class represents the different NBT Tags. *

diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java -index ca7789b5e..442383969 100644 +index ca7789b5e0..4423839697 100644 --- a/src/main/java/org/spigotmc/ActivationRange.java +++ b/src/main/java/org/spigotmc/ActivationRange.java @@ -0,0 +0,0 @@ import net.minecraft.server.EntityWither; diff --git a/Spigot-Server-Patches/Use-ChunkStatus-cache-when-saving-protochunks.patch b/Spigot-Server-Patches/Use-ChunkStatus-cache-when-saving-protochunks.patch index dd34892fe3..f69d799bb0 100644 --- a/Spigot-Server-Patches/Use-ChunkStatus-cache-when-saving-protochunks.patch +++ b/Spigot-Server-Patches/Use-ChunkStatus-cache-when-saving-protochunks.patch @@ -7,7 +7,7 @@ The cache should contain the chunk status when saving. If not it will load it. diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java -index 6257eafe0..4e9edd759 100644 +index 6c4804232a..8bd212388a 100644 --- a/src/main/java/net/minecraft/server/PlayerChunkMap.java +++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java @@ -0,0 +0,0 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { diff --git a/Spigot-Server-Patches/Workaround-for-vehicle-tracking-issue-on-disconnect.patch b/Spigot-Server-Patches/Workaround-for-vehicle-tracking-issue-on-disconnect.patch index dd60f9cdae..31f4be26e7 100644 --- a/Spigot-Server-Patches/Workaround-for-vehicle-tracking-issue-on-disconnect.patch +++ b/Spigot-Server-Patches/Workaround-for-vehicle-tracking-issue-on-disconnect.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Workaround for vehicle tracking issue on disconnect diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java -index f51893892..959e2c1c1 100644 +index d3bfb72e39..4d614b9ef1 100644 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/EntityPlayer.java @@ -0,0 +0,0 @@ public class EntityPlayer extends EntityHuman implements ICrafting { diff --git a/Spigot-Server-Patches/force-entity-dismount-during-teleportation.patch b/Spigot-Server-Patches/force-entity-dismount-during-teleportation.patch index aafc581545..d42d090ccd 100644 --- a/Spigot-Server-Patches/force-entity-dismount-during-teleportation.patch +++ b/Spigot-Server-Patches/force-entity-dismount-during-teleportation.patch @@ -20,7 +20,7 @@ this is going to be the best soultion all around. Improvements/suggestions welcome! diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index 03469c965..db404e4cd 100644 +index 03469c9657..db404e4cd5 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -0,0 +0,0 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke @@ -72,7 +72,7 @@ index 03469c965..db404e4cd 100644 if (event.isCancelled()) { return false; diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java -index d6df01868..2edb99b63 100644 +index 308ac18f7e..584166f225 100644 --- a/src/main/java/net/minecraft/server/EntityHuman.java +++ b/src/main/java/net/minecraft/server/EntityHuman.java @@ -0,0 +0,0 @@ public abstract class EntityHuman extends EntityLiving { @@ -91,7 +91,7 @@ index d6df01868..2edb99b63 100644 } diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java -index eed3e7c58..4e64a80a8 100644 +index eed3e7c58e..4e64a80a8a 100644 --- a/src/main/java/net/minecraft/server/EntityLiving.java +++ b/src/main/java/net/minecraft/server/EntityLiving.java @@ -0,0 +0,0 @@ public abstract class EntityLiving extends Entity { @@ -112,7 +112,7 @@ index eed3e7c58..4e64a80a8 100644 this.a(entity); } diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java -index f2f34593b..83b7ac459 100644 +index f33580f8c5..68e12cf987 100644 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/EntityPlayer.java @@ -0,0 +0,0 @@ public class EntityPlayer extends EntityHuman implements ICrafting { diff --git a/Spigot-Server-Patches/implement-optional-per-player-mob-spawns.patch b/Spigot-Server-Patches/implement-optional-per-player-mob-spawns.patch index f1c16e8967..d66f888059 100644 --- a/Spigot-Server-Patches/implement-optional-per-player-mob-spawns.patch +++ b/Spigot-Server-Patches/implement-optional-per-player-mob-spawns.patch @@ -5,7 +5,7 @@ Subject: [PATCH] implement optional per player mob spawns diff --git a/src/main/java/co/aikar/timings/WorldTimingsHandler.java b/src/main/java/co/aikar/timings/WorldTimingsHandler.java -index 8de6c4816..e25544f11 100644 +index 8de6c4816c..e25544f116 100644 --- a/src/main/java/co/aikar/timings/WorldTimingsHandler.java +++ b/src/main/java/co/aikar/timings/WorldTimingsHandler.java @@ -0,0 +0,0 @@ public class WorldTimingsHandler { @@ -25,7 +25,7 @@ index 8de6c4816..e25544f11 100644 poiUnload = Timings.ofSafe(name + "Chunk unload - POI"); chunkUnload = Timings.ofSafe(name + "Chunk unload - Chunk"); diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index 9d9260ad0..fd3dbea62 100644 +index 9d9260ad07..fd3dbea628 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -0,0 +0,0 @@ public class PaperWorldConfig { @@ -40,7 +40,7 @@ index 9d9260ad0..fd3dbea62 100644 } diff --git a/src/main/java/com/destroystokyo/paper/util/PlayerMobDistanceMap.java b/src/main/java/com/destroystokyo/paper/util/PlayerMobDistanceMap.java new file mode 100644 -index 000000000..9ebd7ecb7 +index 0000000000..9ebd7ecb7a --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/util/PlayerMobDistanceMap.java @@ -0,0 +0,0 @@ @@ -299,7 +299,7 @@ index 000000000..9ebd7ecb7 +} diff --git a/src/main/java/com/destroystokyo/paper/util/PooledHashSets.java b/src/main/java/com/destroystokyo/paper/util/PooledHashSets.java new file mode 100644 -index 000000000..4f13d3ff8 +index 0000000000..4f13d3ff83 --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/util/PooledHashSets.java @@ -0,0 +0,0 @@ @@ -545,7 +545,7 @@ index 000000000..4f13d3ff8 + } +} diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java -index 3eb867684..d1e541ad6 100644 +index 92b22b9996..72919e4c64 100644 --- a/src/main/java/net/minecraft/server/ChunkProviderServer.java +++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java @@ -0,0 +0,0 @@ public class ChunkProviderServer extends IChunkProvider { @@ -599,7 +599,7 @@ index 3eb867684..d1e541ad6 100644 } } diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java -index 6483c4a0b..83405b641 100644 +index 77ad4774ec..22606d894e 100644 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/EntityPlayer.java @@ -0,0 +0,0 @@ public class EntityPlayer extends EntityHuman implements ICrafting { @@ -631,7 +631,7 @@ index 6483c4a0b..83405b641 100644 return this.cs; } diff --git a/src/main/java/net/minecraft/server/EntityTypes.java b/src/main/java/net/minecraft/server/EntityTypes.java -index 79f854966..4100e367a 100644 +index 79f8549660..4100e367a4 100644 --- a/src/main/java/net/minecraft/server/EntityTypes.java +++ b/src/main/java/net/minecraft/server/EntityTypes.java @@ -0,0 +0,0 @@ public class EntityTypes { @@ -643,7 +643,7 @@ index 79f854966..4100e367a 100644 return this.bb; } diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java -index 8ce6cf8ec..1df6a1f19 100644 +index 9fa6d2b526..36657465f2 100644 --- a/src/main/java/net/minecraft/server/PlayerChunkMap.java +++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java @@ -0,0 +0,0 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { @@ -682,7 +682,7 @@ index 8ce6cf8ec..1df6a1f19 100644 private static double a(ChunkCoordIntPair chunkcoordintpair, Entity entity) { diff --git a/src/main/java/net/minecraft/server/SpawnerCreature.java b/src/main/java/net/minecraft/server/SpawnerCreature.java -index fdac5bb3a..58bbf2f9d 100644 +index fdac5bb3a2..58bbf2f9d2 100644 --- a/src/main/java/net/minecraft/server/SpawnerCreature.java +++ b/src/main/java/net/minecraft/server/SpawnerCreature.java @@ -0,0 +0,0 @@ package net.minecraft.server; @@ -755,7 +755,7 @@ index fdac5bb3a..58bbf2f9d 100644 @Nullable diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index b3d23de1b..909af91ca 100644 +index 9055df2ca1..5ec0acc302 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -0,0 +0,0 @@ public class WorldServer extends World { diff --git a/Spigot-Server-Patches/incremental-chunk-saving.patch b/Spigot-Server-Patches/incremental-chunk-saving.patch index ead85acbc4..b7ffe88bb4 100644 --- a/Spigot-Server-Patches/incremental-chunk-saving.patch +++ b/Spigot-Server-Patches/incremental-chunk-saving.patch @@ -5,7 +5,7 @@ Subject: [PATCH] incremental chunk saving diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index 071e5e7f7..486761521 100644 +index 071e5e7f72..4867615215 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -0,0 +0,0 @@ public class PaperWorldConfig { @@ -29,7 +29,7 @@ index 071e5e7f7..486761521 100644 + } } diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index 64c327669..14ec31f0a 100644 +index d9c53cdc4b..76e87c211b 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java @@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess { @@ -42,7 +42,7 @@ index 64c327669..14ec31f0a 100644 private long inhabitedTime; @Nullable diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java -index 0b43e4eb4..99ce73c45 100644 +index 35153af515..191b2759a0 100644 --- a/src/main/java/net/minecraft/server/ChunkProviderServer.java +++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java @@ -0,0 +0,0 @@ public class ChunkProviderServer extends IChunkProvider { @@ -62,7 +62,7 @@ index 0b43e4eb4..99ce73c45 100644 public void close() throws IOException { // CraftBukkit start diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index eaa26e1a5..6fa08c60b 100644 +index eaa26e1a50..6fa08c60bd 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -0,0 +0,0 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant 100) { // Spigot +diff --git a/src/main/java/net/minecraft/server/PlayerChunk.java b/src/main/java/net/minecraft/server/PlayerChunk.java +index 3a0f0314b2..c91312facf 100644 +--- a/src/main/java/net/minecraft/server/PlayerChunk.java ++++ b/src/main/java/net/minecraft/server/PlayerChunk.java +@@ -0,0 +0,0 @@ public class PlayerChunk { + + private final PlayerChunkMap chunkMap; // Paper + ++ long lastAutoSaveTime; // Paper - incremental autosave ++ long inactiveTimeStart; // Paper - incremental autosave ++ + public PlayerChunk(ChunkCoordIntPair chunkcoordintpair, int i, LightEngine lightengine, PlayerChunk.c playerchunk_c, PlayerChunk.d playerchunk_d) { + this.statusFutures = new AtomicReferenceArray(PlayerChunk.CHUNK_STATUSES.size()); + this.fullChunkFuture = PlayerChunk.UNLOADED_CHUNK_FUTURE; +@@ -0,0 +0,0 @@ public class PlayerChunk { + boolean flag2 = playerchunk_state.isAtLeast(PlayerChunk.State.BORDER); + boolean flag3 = playerchunk_state1.isAtLeast(PlayerChunk.State.BORDER); + ++ boolean prevHasBeenLoaded = this.hasBeenLoaded; // Paper + this.hasBeenLoaded |= flag3; ++ // Paper start - incremental autosave ++ if (this.hasBeenLoaded & !prevHasBeenLoaded) { ++ long timeSinceAutoSave = this.inactiveTimeStart - this.lastAutoSaveTime; ++ if (timeSinceAutoSave < 0) { ++ // safest bet is to assume autosave is needed here ++ timeSinceAutoSave = this.chunkMap.world.paperConfig.autoSavePeriod; ++ } ++ this.lastAutoSaveTime = this.chunkMap.world.getTime() - timeSinceAutoSave; ++ this.chunkMap.autoSaveQueue.add(this); ++ } ++ // Paper end + if (!flag2 && flag3) { + // Paper start - cache ticking ready status + int expectCreateCount = ++this.fullChunkCreateCount; +@@ -0,0 +0,0 @@ public class PlayerChunk { + } + + public void m() { ++ boolean prev = this.hasBeenLoaded; // Paper ++ this.hasBeenLoaded = getChunkState(this.ticketLevel).isAtLeast(PlayerChunk.State.BORDER); ++ // Paper start - incremental autosave ++ if (prev != this.hasBeenLoaded) { ++ if (this.hasBeenLoaded) { ++ long timeSinceAutoSave = this.inactiveTimeStart - this.lastAutoSaveTime; ++ if (timeSinceAutoSave < 0) { ++ // safest bet is to assume autosave is needed here ++ timeSinceAutoSave = this.chunkMap.world.paperConfig.autoSavePeriod; ++ } ++ this.lastAutoSaveTime = this.chunkMap.world.getTime() - timeSinceAutoSave; ++ this.chunkMap.autoSaveQueue.add(this); ++ } else { ++ this.inactiveTimeStart = this.chunkMap.world.getTime(); ++ this.chunkMap.autoSaveQueue.remove(this); ++ } ++ } ++ // Paper end ++ } ++ ++ // Paper start - incremental autosave ++ public boolean setHasBeenLoaded() { + this.hasBeenLoaded = getChunkState(this.ticketLevel).isAtLeast(PlayerChunk.State.BORDER); ++ return this.hasBeenLoaded; + } ++ // Paper end + + public void a(ProtoChunkExtension protochunkextension) { + for (int i = 0; i < this.statusFutures.length(); ++i) { diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java -index c17a53915..3a02b6269 100644 +index 803fda511f..40d80f3810 100644 --- a/src/main/java/net/minecraft/server/PlayerChunkMap.java +++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java @@ -0,0 +0,0 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { } -+ // Paper start - derived from below ++ // Paper start - incremental autosave ++ final it.unimi.dsi.fastutil.objects.ObjectRBTreeSet autoSaveQueue = new it.unimi.dsi.fastutil.objects.ObjectRBTreeSet<>((playerchunk1, playerchunk2) -> { ++ int timeCompare = Long.compare(playerchunk1.lastAutoSaveTime, playerchunk2.lastAutoSaveTime); ++ if (timeCompare != 0) { ++ return timeCompare; ++ } ++ ++ return Long.compare(MCUtil.getCoordinateKey(playerchunk1.location), MCUtil.getCoordinateKey(playerchunk2.location)); ++ }); ++ + protected void saveIncrementally() { + int savedThisTick = 0; -+ for (PlayerChunk playerchunk : visibleChunks.values()) { -+ if (playerchunk.hasBeenLoaded()) { ++ // optimized since we search far less chunks to hit ones that need to be saved ++ List reschedule = new ArrayList<>(this.world.paperConfig.maxAutoSaveChunksPerTick); ++ long currentTick = this.world.getTime(); ++ long maxSaveTime = currentTick - this.world.paperConfig.autoSavePeriod; + -+ IChunkAccess ichunkaccess = (IChunkAccess) playerchunk.getChunkSave().getNow(null); // CraftBukkit - decompile error ++ for (Iterator iterator = this.autoSaveQueue.iterator(); iterator.hasNext();) { ++ PlayerChunk playerchunk = iterator.next(); ++ if (playerchunk.lastAutoSaveTime > maxSaveTime) { ++ break; ++ } + ++ iterator.remove(); + -+ if (ichunkaccess instanceof ProtoChunkExtension || ichunkaccess instanceof Chunk) { -+ boolean shouldSave = true; ++ IChunkAccess ichunkaccess = playerchunk.getChunkSave().getNow(null); ++ if (ichunkaccess instanceof Chunk) { ++ boolean shouldSave = ((Chunk)ichunkaccess).lastSaved <= maxSaveTime; + -+ if (ichunkaccess instanceof Chunk) { -+ shouldSave = ((Chunk) ichunkaccess).lastSaved + world.paperConfig.autoSavePeriod <= world.getTime(); ++ if (shouldSave && this.saveChunk(ichunkaccess)) { ++ ++savedThisTick; ++ ++ if (!playerchunk.setHasBeenLoaded()) { ++ // do not fall through to reschedule logic ++ playerchunk.inactiveTimeStart = currentTick; ++ if (savedThisTick >= this.world.paperConfig.maxAutoSaveChunksPerTick) { ++ break; ++ } ++ continue; + } -+ -+ if (shouldSave && this.saveChunk(ichunkaccess)) { -+ ++savedThisTick; -+ playerchunk.m(); -+ } -+ } -+ -+ if (savedThisTick >= world.paperConfig.maxAutoSaveChunksPerTick) { -+ return; + } + } ++ ++ reschedule.add(playerchunk); ++ ++ if (savedThisTick >= this.world.paperConfig.maxAutoSaveChunksPerTick) { ++ break; ++ } ++ } ++ ++ for (int i = 0, len = reschedule.size(); i < len; ++i) { ++ PlayerChunk playerchunk = reschedule.get(i); ++ playerchunk.lastAutoSaveTime = this.world.getTime(); ++ this.autoSaveQueue.add(playerchunk); + } + } -+ // paper end ++ // Paper end + protected void save(boolean flag) { if (flag) { List list = (List) this.visibleChunks.values().stream().filter(PlayerChunk::hasBeenLoaded).peek(PlayerChunk::m).collect(Collectors.toList()); +@@ -0,0 +0,0 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { + + this.world.unloadChunk(chunk); + } ++ this.autoSaveQueue.remove(playerchunk); // Paper + + this.lightEngine.a(ichunkaccess.getPos()); + this.lightEngine.queueUpdate(); +@@ -0,0 +0,0 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { + playerchunk.a(new ProtoChunkExtension(chunk)); + } + ++ chunk.setLastSaved(this.world.getTime() - 1); // Paper - avoid autosaving newly generated/loaded chunks ++ + chunk.a(() -> { + return PlayerChunk.getChunkState(playerchunk.getTicketLevel()); + }); diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index 9be58e785..7bf0b8708 100644 +index 32da4eb4e0..fae30a1c1b 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -0,0 +0,0 @@ public class WorldServer extends World { diff --git a/scripts/importmcdev.sh b/scripts/importmcdev.sh index 227a01eab8..6fd55da94e 100755 --- a/scripts/importmcdev.sh +++ b/scripts/importmcdev.sh @@ -106,6 +106,7 @@ done # dont forget \ at end of each line but last importLibrary com.mojang authlib com/mojang/authlib yggdrasil/YggdrasilGameProfileRepository.java +importLibrary com.mojang datafixerupper com/mojang/datafixers/util Either.java ######################################################## ########################################################