From 3353754726bfcaac7c2ee00ec7bdb2e1874afa9b Mon Sep 17 00:00:00 2001
From: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
Date: Wed, 16 Jun 2021 21:00:32 -0700
Subject: [PATCH] Update Entity load/save limit per chunk

---
 ...647-Entity-load-save-limit-per-chunk.patch | 93 ------------------
 ...647-Entity-load-save-limit-per-chunk.patch | 96 +++++++++++++++++++
 ...block-falling-causing-client-desync.patch} |  0
 ...tch => 0649-Expose-protocol-version.patch} |  0
 ...nt-suggestion-tooltips-in-AsyncTabC.patch} |  0
 ...ab-completions-for-brigadier-comman.patch} |  0
 ...temConsumeEvent-cancelling-properly.patch} |  0
 ...patch => 0653-Add-bypass-host-check.patch} |  0
 ...0654-Set-area-affect-cloud-rotation.patch} |  0
 ...add-isDeeplySleeping-to-HumanEntity.patch} |  0
 ...ting-give-items-on-item-drop-cancel.patch} |  0
 ...add-consumeFuel-to-FurnaceBurnEvent.patch} |  0
 ...-set-drop-chance-to-EntityEquipment.patch} |  0
 ...ix-PigZombieAngerEvent-cancellation.patch} |  0
 ...-checkReach-check-for-Shulker-boxes.patch} |  0
 ...ix-PlayerItemHeldEvent-firing-twice.patch} |  0
 ... => 0662-Added-PlayerDeepSleepEvent.patch} |  0
 ...ld-API.patch => 0663-More-World-API.patch} |  0
 ... 0664-Added-PlayerBedFailEnterEvent.patch} |  0
 ...-to-convert-between-Component-and-B.patch} |  0
 ...n-acting-as-a-bed-respawn-from-the-.patch} |  0
 ...acon-activation-deactivation-events.patch} |  0
 ...-RespawnFlags-to-PlayerRespawnEvent.patch} |  0
 ...dd-Channel-initialization-listeners.patch} |  0
 ...mands-if-tab-completion-is-disabled.patch} |  0
 ...> 0671-Add-more-WanderingTrader-API.patch} |  0
 ...dd-EntityBlockStorage-clearEntities.patch} |  0
 ...ssage-to-PlayerAdvancementDoneEvent.patch} |  0
 ...address-to-AsyncPlayerPreLoginEvent.patch} |  0
 ...close.patch => 0675-Inventory-close.patch} |  0
 ...reateEvent-players-and-end-platform.patch} |  4 +-
 ...-in-sunlight-API-for-Phantoms-and-S.patch} |  2 +-
 ...=> 0678-Fix-CraftPotionBrewer-cache.patch} |  0
 ...atch => 0679-Add-basic-Datapack-API.patch} |  0
 ...ment-variable-to-disable-server-gui.patch} |  0
 ...itions-to-PlayerGameModeChangeEvent.patch} |  4 +-
 ...fo.patch => 0682-Clear-SyncLoadInfo.patch} |  0
 ... => 0683-ItemStack-repair-check-API.patch} |  0
 ....patch => 0684-More-Enchantment-API.patch} |  0
 ...option-to-load-extra-plugin-jars-no.patch} |  0
 ...-and-optimise-world-force-upgrading.patch} |  4 +-
 ...PI.patch => 0687-Add-Mob-lookAt-API.patch} |  0
 ...0688-Add-Unix-domain-socket-support.patch} |  0
 ... => 0689-Add-EntityInsideBlockEvent.patch} |  0
 ...90-Attributes-API-for-item-defaults.patch} |  0
 ...hantCustom-emit-PlayerPurchaseEvent.patch} |  0
 ...ause-to-Weather-ThunderChangeEvents.patch} |  0
 ...patch => 0693-More-Lidded-Block-API.patch} |  0
 ...94-Limit-item-frame-cursors-on-maps.patch} |  6 +-
 ...0695-Add-PufferFishStateChangeEvent.patch} |  0
 ... => 0696-Add-PlayerKickEvent-causes.patch} |  4 +-
 ...erBucketEmptyEvent-result-itemstack.patch} |  0
 ...tedContainer-instead-of-ReentrantLo.patch} |  2 +-
 ...-to-fix-items-merging-through-walls.patch} |  4 +-
 ...h => 0700-Add-BellRevealRaiderEvent.patch} |  0
 ... 0701-Fix-invulnerable-end-crystals.patch} |  4 +-
 ...02-Add-ElderGuardianAppearanceEvent.patch} |  0
 ...inventory-on-cancelled-pickup-event.patch} |  0
 ...0704-Fix-dangerous-end-portal-logic.patch} |  2 +-
 ...-Biome-Mob-Lookups-for-Mob-Spawning.patch} |  0
 ...-Make-item-validations-configurable.patch} |  0
 ...0707-Add-more-line-of-sight-methods.patch} |  0
 ... => 0708-add-per-world-spawn-limits.patch} |  4 +-
 ...plashEvent-for-water-splash-potions.patch} |  0
 ...tus-dataconverter-for-pre-1.13-chun.patch} |  2 -
 65 files changed, 116 insertions(+), 115 deletions(-)
 delete mode 100644 patches/removed/1.17/0647-Entity-load-save-limit-per-chunk.patch
 create mode 100644 patches/server/0647-Entity-load-save-limit-per-chunk.patch
 rename patches/server/{0647-fix-cancelling-block-falling-causing-client-desync.patch => 0648-fix-cancelling-block-falling-causing-client-desync.patch} (100%)
 rename patches/server/{0648-Expose-protocol-version.patch => 0649-Expose-protocol-version.patch} (100%)
 rename patches/server/{0649-Allow-for-Component-suggestion-tooltips-in-AsyncTabC.patch => 0650-Allow-for-Component-suggestion-tooltips-in-AsyncTabC.patch} (100%)
 rename patches/server/{0650-Enhance-console-tab-completions-for-brigadier-comman.patch => 0651-Enhance-console-tab-completions-for-brigadier-comman.patch} (100%)
 rename patches/server/{0651-Fix-PlayerItemConsumeEvent-cancelling-properly.patch => 0652-Fix-PlayerItemConsumeEvent-cancelling-properly.patch} (100%)
 rename patches/server/{0652-Add-bypass-host-check.patch => 0653-Add-bypass-host-check.patch} (100%)
 rename patches/server/{0653-Set-area-affect-cloud-rotation.patch => 0654-Set-area-affect-cloud-rotation.patch} (100%)
 rename patches/server/{0654-add-isDeeplySleeping-to-HumanEntity.patch => 0655-add-isDeeplySleeping-to-HumanEntity.patch} (100%)
 rename patches/server/{0655-Fix-duplicating-give-items-on-item-drop-cancel.patch => 0656-Fix-duplicating-give-items-on-item-drop-cancel.patch} (100%)
 rename patches/server/{0656-add-consumeFuel-to-FurnaceBurnEvent.patch => 0657-add-consumeFuel-to-FurnaceBurnEvent.patch} (100%)
 rename patches/server/{0657-add-get-set-drop-chance-to-EntityEquipment.patch => 0658-add-get-set-drop-chance-to-EntityEquipment.patch} (100%)
 rename patches/server/{0658-fix-PigZombieAngerEvent-cancellation.patch => 0659-fix-PigZombieAngerEvent-cancellation.patch} (100%)
 rename patches/server/{0659-Fix-checkReach-check-for-Shulker-boxes.patch => 0660-Fix-checkReach-check-for-Shulker-boxes.patch} (100%)
 rename patches/server/{0660-fix-PlayerItemHeldEvent-firing-twice.patch => 0661-fix-PlayerItemHeldEvent-firing-twice.patch} (100%)
 rename patches/server/{0661-Added-PlayerDeepSleepEvent.patch => 0662-Added-PlayerDeepSleepEvent.patch} (100%)
 rename patches/server/{0662-More-World-API.patch => 0663-More-World-API.patch} (100%)
 rename patches/server/{0663-Added-PlayerBedFailEnterEvent.patch => 0664-Added-PlayerBedFailEnterEvent.patch} (100%)
 rename patches/server/{0664-Implement-methods-to-convert-between-Component-and-B.patch => 0665-Implement-methods-to-convert-between-Component-and-B.patch} (100%)
 rename patches/server/{0665-Fix-anchor-respawn-acting-as-a-bed-respawn-from-the-.patch => 0666-Fix-anchor-respawn-acting-as-a-bed-respawn-from-the-.patch} (100%)
 rename patches/server/{0666-Introduce-beacon-activation-deactivation-events.patch => 0667-Introduce-beacon-activation-deactivation-events.patch} (100%)
 rename patches/server/{0667-add-RespawnFlags-to-PlayerRespawnEvent.patch => 0668-add-RespawnFlags-to-PlayerRespawnEvent.patch} (100%)
 rename patches/server/{0668-Add-Channel-initialization-listeners.patch => 0669-Add-Channel-initialization-listeners.patch} (100%)
 rename patches/server/{0669-Send-empty-commands-if-tab-completion-is-disabled.patch => 0670-Send-empty-commands-if-tab-completion-is-disabled.patch} (100%)
 rename patches/server/{0670-Add-more-WanderingTrader-API.patch => 0671-Add-more-WanderingTrader-API.patch} (100%)
 rename patches/server/{0671-Add-EntityBlockStorage-clearEntities.patch => 0672-Add-EntityBlockStorage-clearEntities.patch} (100%)
 rename patches/server/{0672-Add-Adventure-message-to-PlayerAdvancementDoneEvent.patch => 0673-Add-Adventure-message-to-PlayerAdvancementDoneEvent.patch} (100%)
 rename patches/server/{0673-Add-raw-address-to-AsyncPlayerPreLoginEvent.patch => 0674-Add-raw-address-to-AsyncPlayerPreLoginEvent.patch} (100%)
 rename patches/server/{0674-Inventory-close.patch => 0675-Inventory-close.patch} (100%)
 rename patches/server/{0675-call-PortalCreateEvent-players-and-end-platform.patch => 0676-call-PortalCreateEvent-players-and-end-platform.patch} (92%)
 rename patches/server/{0676-Add-a-should-burn-in-sunlight-API-for-Phantoms-and-S.patch => 0677-Add-a-should-burn-in-sunlight-API-for-Phantoms-and-S.patch} (98%)
 rename patches/server/{0677-Fix-CraftPotionBrewer-cache.patch => 0678-Fix-CraftPotionBrewer-cache.patch} (100%)
 rename patches/server/{0678-Add-basic-Datapack-API.patch => 0679-Add-basic-Datapack-API.patch} (100%)
 rename patches/server/{0679-Add-environment-variable-to-disable-server-gui.patch => 0680-Add-environment-variable-to-disable-server-gui.patch} (100%)
 rename patches/server/{0680-additions-to-PlayerGameModeChangeEvent.patch => 0681-additions-to-PlayerGameModeChangeEvent.patch} (97%)
 rename patches/server/{0681-Clear-SyncLoadInfo.patch => 0682-Clear-SyncLoadInfo.patch} (100%)
 rename patches/server/{0682-ItemStack-repair-check-API.patch => 0683-ItemStack-repair-check-API.patch} (100%)
 rename patches/server/{0683-More-Enchantment-API.patch => 0684-More-Enchantment-API.patch} (100%)
 rename patches/server/{0684-Add-command-line-option-to-load-extra-plugin-jars-no.patch => 0685-Add-command-line-option-to-load-extra-plugin-jars-no.patch} (100%)
 rename patches/server/{0685-Fix-and-optimise-world-force-upgrading.patch => 0686-Fix-and-optimise-world-force-upgrading.patch} (99%)
 rename patches/server/{0686-Add-Mob-lookAt-API.patch => 0687-Add-Mob-lookAt-API.patch} (100%)
 rename patches/server/{0687-Add-Unix-domain-socket-support.patch => 0688-Add-Unix-domain-socket-support.patch} (100%)
 rename patches/server/{0688-Add-EntityInsideBlockEvent.patch => 0689-Add-EntityInsideBlockEvent.patch} (100%)
 rename patches/server/{0689-Attributes-API-for-item-defaults.patch => 0690-Attributes-API-for-item-defaults.patch} (100%)
 rename patches/server/{0690-Have-CraftMerchantCustom-emit-PlayerPurchaseEvent.patch => 0691-Have-CraftMerchantCustom-emit-PlayerPurchaseEvent.patch} (100%)
 rename patches/server/{0691-Add-cause-to-Weather-ThunderChangeEvents.patch => 0692-Add-cause-to-Weather-ThunderChangeEvents.patch} (100%)
 rename patches/server/{0692-More-Lidded-Block-API.patch => 0693-More-Lidded-Block-API.patch} (100%)
 rename patches/server/{0693-Limit-item-frame-cursors-on-maps.patch => 0694-Limit-item-frame-cursors-on-maps.patch} (89%)
 rename patches/server/{0694-Add-PufferFishStateChangeEvent.patch => 0695-Add-PufferFishStateChangeEvent.patch} (100%)
 rename patches/server/{0695-Add-PlayerKickEvent-causes.patch => 0696-Add-PlayerKickEvent-causes.patch} (99%)
 rename patches/server/{0696-Fix-PlayerBucketEmptyEvent-result-itemstack.patch => 0697-Fix-PlayerBucketEmptyEvent-result-itemstack.patch} (100%)
 rename patches/server/{0697-Synchronize-PalettedContainer-instead-of-ReentrantLo.patch => 0698-Synchronize-PalettedContainer-instead-of-ReentrantLo.patch} (97%)
 rename patches/server/{0698-Add-option-to-fix-items-merging-through-walls.patch => 0699-Add-option-to-fix-items-merging-through-walls.patch} (93%)
 rename patches/server/{0699-Add-BellRevealRaiderEvent.patch => 0700-Add-BellRevealRaiderEvent.patch} (100%)
 rename patches/server/{0700-Fix-invulnerable-end-crystals.patch => 0701-Fix-invulnerable-end-crystals.patch} (96%)
 rename patches/server/{0701-Add-ElderGuardianAppearanceEvent.patch => 0702-Add-ElderGuardianAppearanceEvent.patch} (100%)
 rename patches/server/{0702-Reset-villager-inventory-on-cancelled-pickup-event.patch => 0703-Reset-villager-inventory-on-cancelled-pickup-event.patch} (100%)
 rename patches/server/{0703-Fix-dangerous-end-portal-logic.patch => 0704-Fix-dangerous-end-portal-logic.patch} (97%)
 rename patches/server/{0704-Optimize-Biome-Mob-Lookups-for-Mob-Spawning.patch => 0705-Optimize-Biome-Mob-Lookups-for-Mob-Spawning.patch} (100%)
 rename patches/server/{0705-Make-item-validations-configurable.patch => 0706-Make-item-validations-configurable.patch} (100%)
 rename patches/server/{0706-Add-more-line-of-sight-methods.patch => 0707-Add-more-line-of-sight-methods.patch} (100%)
 rename patches/server/{0707-add-per-world-spawn-limits.patch => 0708-add-per-world-spawn-limits.patch} (94%)
 rename patches/server/{0708-Fix-PotionSplashEvent-for-water-splash-potions.patch => 0709-Fix-PotionSplashEvent-for-water-splash-potions.patch} (100%)
 rename patches/server/{0709-Fix-incorrect-status-dataconverter-for-pre-1.13-chun.patch => 0710-Fix-incorrect-status-dataconverter-for-pre-1.13-chun.patch} (99%)

diff --git a/patches/removed/1.17/0647-Entity-load-save-limit-per-chunk.patch b/patches/removed/1.17/0647-Entity-load-save-limit-per-chunk.patch
deleted file mode 100644
index 784088ba5d..0000000000
--- a/patches/removed/1.17/0647-Entity-load-save-limit-per-chunk.patch
+++ /dev/null
@@ -1,93 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: jmp <jasonpenilla2@me.com>
-Date: Wed, 18 Nov 2020 20:52:25 -0800
-Subject: [PATCH] Entity load/save limit per chunk
-
-Adds a config option to limit the number of entities saved and loaded
-to a chunk. The default values of -1 disable the limit. Although
-defaults are only included for certain entites, this allows setting
-limits for any entity type.
-
-1.17: looks like tracking the count on loading should work fine just putting it in the EntityType#loadEntitiesRecursive, but
-the tracking count on save needs some more work to implement.
-
-diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
-index 7ebc85264a2cbfb601dfe5472b561cac1a7cf8bf..486e5438254348db68017228af131cba7defd637 100644
---- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
-+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
-@@ -7,6 +7,7 @@ import java.util.List;
- import java.util.Map;
- import java.util.stream.Collectors;
- import net.minecraft.world.Difficulty;
-+import net.minecraft.world.entity.EntityType;
- import net.minecraft.world.entity.monster.Vindicator;
- import net.minecraft.world.entity.monster.Zombie;
- import com.destroystokyo.paper.antixray.ChunkPacketBlockControllerAntiXray.EngineMode;
-@@ -762,4 +763,18 @@ public class PaperWorldConfig {
-             Difficulty.class
-         );
-     }
-+
-+    public Map<EntityType<?>, Integer> entityPerChunkSaveLimits = new HashMap<>();
-+    private void entityPerChunkSaveLimits() {
-+        getInt("entity-per-chunk-save-limit.experience_orb", -1);
-+        getInt("entity-per-chunk-save-limit.snowball", -1);
-+        getInt("entity-per-chunk-save-limit.ender_pearl", -1);
-+        getInt("entity-per-chunk-save-limit.arrow", -1);
-+        EntityType.getEntityNameList().forEach(name -> {
-+            final EntityType<?> type = EntityType.getByName(name.getPath()).orElseThrow(() -> new IllegalStateException("Unknown Entity Type: " + name.toString()));
-+            final String path = ".entity-per-chunk-save-limit." + name.getPath();
-+            final int value = config.getInt("world-settings." + worldName + path, config.getInt("world-settings.default" + path, -1)); // get without setting defaults
-+            if (value != -1) entityPerChunkSaveLimits.put(type, value);
-+        });
-+    }
- }
-diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java
-index f6a814f9305813eaafa56baa0327e0111cd4e38c..30f80f8549c3236d6bfe594e323e4ca6e702005d 100644
---- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java
-+++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java
-@@ -539,11 +539,22 @@ public class ChunkSerializer {
- 
-             chunk.setLastSaveHadEntities(false);
- 
-+            // Paper start
-+            final Map<EntityType<?>, Integer> savedEntityCounts = Maps.newHashMap();
-             for (int j = 0; j < chunk.getEntitySlices().length; ++j) {
-                 Iterator iterator1 = chunk.getEntitySlices()[j].iterator();
- 
-                 while (iterator1.hasNext()) {
-                     Entity entity = (Entity) iterator1.next();
-+                    final EntityType<?> entityType = entity.getType();
-+                    final int saveLimit = worldserver.paperConfig.entityPerChunkSaveLimits.getOrDefault(entityType, -1);
-+                    if (saveLimit > -1) {
-+                        if (savedEntityCounts.getOrDefault(entityType, 0) >= saveLimit) {
-+                            continue;
-+                        }
-+                        savedEntityCounts.merge(entityType, 1, Integer::sum);
-+                    }
-+                    // Paper end
-                     CompoundTag nbttagcompound4 = new CompoundTag();
-                     // Paper start
-                     if (asyncsavedata == null && !entity.removed && (int) Math.floor(entity.getX()) >> 4 != chunk.getPos().x || (int) Math.floor(entity.getZ()) >> 4 != chunk.getPos().z) {
-@@ -674,10 +685,21 @@ public class ChunkSerializer {
-         ListTag nbttaglist = tag.getList("Entities", 10);
-         Level world = chunk.getLevel();
- 
-+        // Paper start
-+        final Map<EntityType<?>, Integer> loadedEntityCounts = Maps.newHashMap();
-         for (int i = 0; i < nbttaglist.size(); ++i) {
-             CompoundTag nbttagcompound1 = nbttaglist.getCompound(i);
- 
-             EntityType.loadEntityRecursive(nbttagcompound1, world, (entity) -> {
-+                final EntityType<?> entityType = entity.getType();
-+                final int saveLimit = world.paperConfig.entityPerChunkSaveLimits.getOrDefault(entityType, -1);
-+                if (saveLimit > -1) {
-+                    if (loadedEntityCounts.getOrDefault(entityType, 0) >= saveLimit) {
-+                        return null;
-+                    }
-+                    loadedEntityCounts.merge(entityType, 1, Integer::sum);
-+                }
-+                // Paper end
-                 chunk.addEntity(entity);
-                 return entity;
-             });
diff --git a/patches/server/0647-Entity-load-save-limit-per-chunk.patch b/patches/server/0647-Entity-load-save-limit-per-chunk.patch
new file mode 100644
index 0000000000..5fe41929a7
--- /dev/null
+++ b/patches/server/0647-Entity-load-save-limit-per-chunk.patch
@@ -0,0 +1,96 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: jmp <jasonpenilla2@me.com>
+Date: Wed, 18 Nov 2020 20:52:25 -0800
+Subject: [PATCH] Entity load/save limit per chunk
+
+Adds a config option to limit the number of entities saved and loaded
+to a chunk. The default values of -1 disable the limit. Although
+defaults are only included for certain entites, this allows setting
+limits for any entity type.
+
+diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+index 79687b8add9e4768d2c9aa1efdad7cc9736ef22c..54c74b8d3056e512b4a8c1760c45a33ab7a6f4a9 100644
+--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
++++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+@@ -1,9 +1,12 @@
+ package com.destroystokyo.paper;
+ 
+ import java.util.Arrays;
++import java.util.HashMap;
+ import java.util.List;
++import java.util.Map;
+ import java.util.stream.Collectors;
+ import net.minecraft.world.Difficulty;
++import net.minecraft.world.entity.EntityType;
+ import net.minecraft.world.entity.monster.Vindicator;
+ import net.minecraft.world.entity.monster.Zombie;
+ import com.destroystokyo.paper.antixray.ChunkPacketBlockControllerAntiXray.EngineMode;
+@@ -123,6 +126,20 @@ public class PaperWorldConfig {
+         );
+     }
+ 
++    public Map<EntityType<?>, Integer> entityPerChunkSaveLimits = new HashMap<>();
++    private void entityPerChunkSaveLimits() {
++        getInt("entity-per-chunk-save-limit.experience_orb", -1);
++        getInt("entity-per-chunk-save-limit.snowball", -1);
++        getInt("entity-per-chunk-save-limit.ender_pearl", -1);
++        getInt("entity-per-chunk-save-limit.arrow", -1);
++        EntityType.getEntityNameList().forEach(name -> {
++            final EntityType<?> type = EntityType.getByName(name.getPath()).orElseThrow(() -> new IllegalStateException("Unknown Entity Type: " + name.toString()));
++            final String path = ".entity-per-chunk-save-limit." + name.getPath();
++            final int value = config.getInt("world-settings." + worldName + path, config.getInt("world-settings.default" + path, -1)); // get without setting defaults
++            if (value != -1) entityPerChunkSaveLimits.put(type, value);
++        });
++    }
++
+     public short keepLoadedRange;
+     private void keepLoadedRange() {
+         keepLoadedRange = (short) (getInt("keep-spawn-loaded-range", Math.min(spigotConfig.viewDistance, 10)) * 16);
+diff --git a/src/main/java/net/minecraft/world/entity/EntityType.java b/src/main/java/net/minecraft/world/entity/EntityType.java
+index 536d979139326191d1199e93e9fc885164766aec..c7f50d45b3a0a238e41e5a024cd4dec08e07c8b4 100644
+--- a/src/main/java/net/minecraft/world/entity/EntityType.java
++++ b/src/main/java/net/minecraft/world/entity/EntityType.java
+@@ -561,9 +561,20 @@ public class EntityType<T extends Entity> implements EntityTypeTest<Entity, T> {
+         final Spliterator<? extends net.minecraft.nbt.Tag> spliterator = entityNbtList.spliterator();
+ 
+         return StreamSupport.stream(new Spliterator<Entity>() {
++            final Map<EntityType<?>, Integer> loadedEntityCounts = new java.util.HashMap<>(); // Paper
+             public boolean tryAdvance(Consumer<? super Entity> consumer) {
+                 return spliterator.tryAdvance((nbtbase) -> {
+                     EntityType.loadEntityRecursive((CompoundTag) nbtbase, world, (entity) -> {
++                        // Paper start
++                        final EntityType<?> entityType = entity.getType();
++                        final int saveLimit = world.paperConfig.entityPerChunkSaveLimits.getOrDefault(entityType, -1);
++                        if (saveLimit > -1) {
++                            if (this.loadedEntityCounts.getOrDefault(entityType, 0) >= saveLimit) {
++                                return null;
++                            }
++                            this.loadedEntityCounts.merge(entityType, 1, Integer::sum);
++                        }
++                        // Paper end
+                         consumer.accept(entity);
+                         return entity;
+                     });
+diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/EntityStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/EntityStorage.java
+index 6204c6c9cf2cb620e41105889807f85438bd006c..572a013445bd83d366cce27d0e015ba8271df7e0 100644
+--- a/src/main/java/net/minecraft/world/level/chunk/storage/EntityStorage.java
++++ b/src/main/java/net/minecraft/world/level/chunk/storage/EntityStorage.java
+@@ -89,7 +89,18 @@ public class EntityStorage implements EntityPersistentStorage<Entity> {
+ 
+         } else {
+             ListTag listTag = new ListTag();
++            final java.util.Map<net.minecraft.world.entity.EntityType<?>, Integer> savedEntityCounts = new java.util.HashMap<>(); // Paper
+             dataList.getEntities().forEach((entity) -> {
++                // Paper start
++                final EntityType<?> entityType = entity.getType();
++                final int saveLimit = this.level.paperConfig.entityPerChunkSaveLimits.getOrDefault(entityType, -1);
++                if (saveLimit > -1) {
++                    if (savedEntityCounts.getOrDefault(entityType, 0) >= saveLimit) {
++                        return;
++                    }
++                    savedEntityCounts.merge(entityType, 1, Integer::sum);
++                }
++                // Paper end
+                 CompoundTag compoundTag = new CompoundTag();
+                 if (entity.save(compoundTag)) {
+                     listTag.add(compoundTag);
diff --git a/patches/server/0647-fix-cancelling-block-falling-causing-client-desync.patch b/patches/server/0648-fix-cancelling-block-falling-causing-client-desync.patch
similarity index 100%
rename from patches/server/0647-fix-cancelling-block-falling-causing-client-desync.patch
rename to patches/server/0648-fix-cancelling-block-falling-causing-client-desync.patch
diff --git a/patches/server/0648-Expose-protocol-version.patch b/patches/server/0649-Expose-protocol-version.patch
similarity index 100%
rename from patches/server/0648-Expose-protocol-version.patch
rename to patches/server/0649-Expose-protocol-version.patch
diff --git a/patches/server/0649-Allow-for-Component-suggestion-tooltips-in-AsyncTabC.patch b/patches/server/0650-Allow-for-Component-suggestion-tooltips-in-AsyncTabC.patch
similarity index 100%
rename from patches/server/0649-Allow-for-Component-suggestion-tooltips-in-AsyncTabC.patch
rename to patches/server/0650-Allow-for-Component-suggestion-tooltips-in-AsyncTabC.patch
diff --git a/patches/server/0650-Enhance-console-tab-completions-for-brigadier-comman.patch b/patches/server/0651-Enhance-console-tab-completions-for-brigadier-comman.patch
similarity index 100%
rename from patches/server/0650-Enhance-console-tab-completions-for-brigadier-comman.patch
rename to patches/server/0651-Enhance-console-tab-completions-for-brigadier-comman.patch
diff --git a/patches/server/0651-Fix-PlayerItemConsumeEvent-cancelling-properly.patch b/patches/server/0652-Fix-PlayerItemConsumeEvent-cancelling-properly.patch
similarity index 100%
rename from patches/server/0651-Fix-PlayerItemConsumeEvent-cancelling-properly.patch
rename to patches/server/0652-Fix-PlayerItemConsumeEvent-cancelling-properly.patch
diff --git a/patches/server/0652-Add-bypass-host-check.patch b/patches/server/0653-Add-bypass-host-check.patch
similarity index 100%
rename from patches/server/0652-Add-bypass-host-check.patch
rename to patches/server/0653-Add-bypass-host-check.patch
diff --git a/patches/server/0653-Set-area-affect-cloud-rotation.patch b/patches/server/0654-Set-area-affect-cloud-rotation.patch
similarity index 100%
rename from patches/server/0653-Set-area-affect-cloud-rotation.patch
rename to patches/server/0654-Set-area-affect-cloud-rotation.patch
diff --git a/patches/server/0654-add-isDeeplySleeping-to-HumanEntity.patch b/patches/server/0655-add-isDeeplySleeping-to-HumanEntity.patch
similarity index 100%
rename from patches/server/0654-add-isDeeplySleeping-to-HumanEntity.patch
rename to patches/server/0655-add-isDeeplySleeping-to-HumanEntity.patch
diff --git a/patches/server/0655-Fix-duplicating-give-items-on-item-drop-cancel.patch b/patches/server/0656-Fix-duplicating-give-items-on-item-drop-cancel.patch
similarity index 100%
rename from patches/server/0655-Fix-duplicating-give-items-on-item-drop-cancel.patch
rename to patches/server/0656-Fix-duplicating-give-items-on-item-drop-cancel.patch
diff --git a/patches/server/0656-add-consumeFuel-to-FurnaceBurnEvent.patch b/patches/server/0657-add-consumeFuel-to-FurnaceBurnEvent.patch
similarity index 100%
rename from patches/server/0656-add-consumeFuel-to-FurnaceBurnEvent.patch
rename to patches/server/0657-add-consumeFuel-to-FurnaceBurnEvent.patch
diff --git a/patches/server/0657-add-get-set-drop-chance-to-EntityEquipment.patch b/patches/server/0658-add-get-set-drop-chance-to-EntityEquipment.patch
similarity index 100%
rename from patches/server/0657-add-get-set-drop-chance-to-EntityEquipment.patch
rename to patches/server/0658-add-get-set-drop-chance-to-EntityEquipment.patch
diff --git a/patches/server/0658-fix-PigZombieAngerEvent-cancellation.patch b/patches/server/0659-fix-PigZombieAngerEvent-cancellation.patch
similarity index 100%
rename from patches/server/0658-fix-PigZombieAngerEvent-cancellation.patch
rename to patches/server/0659-fix-PigZombieAngerEvent-cancellation.patch
diff --git a/patches/server/0659-Fix-checkReach-check-for-Shulker-boxes.patch b/patches/server/0660-Fix-checkReach-check-for-Shulker-boxes.patch
similarity index 100%
rename from patches/server/0659-Fix-checkReach-check-for-Shulker-boxes.patch
rename to patches/server/0660-Fix-checkReach-check-for-Shulker-boxes.patch
diff --git a/patches/server/0660-fix-PlayerItemHeldEvent-firing-twice.patch b/patches/server/0661-fix-PlayerItemHeldEvent-firing-twice.patch
similarity index 100%
rename from patches/server/0660-fix-PlayerItemHeldEvent-firing-twice.patch
rename to patches/server/0661-fix-PlayerItemHeldEvent-firing-twice.patch
diff --git a/patches/server/0661-Added-PlayerDeepSleepEvent.patch b/patches/server/0662-Added-PlayerDeepSleepEvent.patch
similarity index 100%
rename from patches/server/0661-Added-PlayerDeepSleepEvent.patch
rename to patches/server/0662-Added-PlayerDeepSleepEvent.patch
diff --git a/patches/server/0662-More-World-API.patch b/patches/server/0663-More-World-API.patch
similarity index 100%
rename from patches/server/0662-More-World-API.patch
rename to patches/server/0663-More-World-API.patch
diff --git a/patches/server/0663-Added-PlayerBedFailEnterEvent.patch b/patches/server/0664-Added-PlayerBedFailEnterEvent.patch
similarity index 100%
rename from patches/server/0663-Added-PlayerBedFailEnterEvent.patch
rename to patches/server/0664-Added-PlayerBedFailEnterEvent.patch
diff --git a/patches/server/0664-Implement-methods-to-convert-between-Component-and-B.patch b/patches/server/0665-Implement-methods-to-convert-between-Component-and-B.patch
similarity index 100%
rename from patches/server/0664-Implement-methods-to-convert-between-Component-and-B.patch
rename to patches/server/0665-Implement-methods-to-convert-between-Component-and-B.patch
diff --git a/patches/server/0665-Fix-anchor-respawn-acting-as-a-bed-respawn-from-the-.patch b/patches/server/0666-Fix-anchor-respawn-acting-as-a-bed-respawn-from-the-.patch
similarity index 100%
rename from patches/server/0665-Fix-anchor-respawn-acting-as-a-bed-respawn-from-the-.patch
rename to patches/server/0666-Fix-anchor-respawn-acting-as-a-bed-respawn-from-the-.patch
diff --git a/patches/server/0666-Introduce-beacon-activation-deactivation-events.patch b/patches/server/0667-Introduce-beacon-activation-deactivation-events.patch
similarity index 100%
rename from patches/server/0666-Introduce-beacon-activation-deactivation-events.patch
rename to patches/server/0667-Introduce-beacon-activation-deactivation-events.patch
diff --git a/patches/server/0667-add-RespawnFlags-to-PlayerRespawnEvent.patch b/patches/server/0668-add-RespawnFlags-to-PlayerRespawnEvent.patch
similarity index 100%
rename from patches/server/0667-add-RespawnFlags-to-PlayerRespawnEvent.patch
rename to patches/server/0668-add-RespawnFlags-to-PlayerRespawnEvent.patch
diff --git a/patches/server/0668-Add-Channel-initialization-listeners.patch b/patches/server/0669-Add-Channel-initialization-listeners.patch
similarity index 100%
rename from patches/server/0668-Add-Channel-initialization-listeners.patch
rename to patches/server/0669-Add-Channel-initialization-listeners.patch
diff --git a/patches/server/0669-Send-empty-commands-if-tab-completion-is-disabled.patch b/patches/server/0670-Send-empty-commands-if-tab-completion-is-disabled.patch
similarity index 100%
rename from patches/server/0669-Send-empty-commands-if-tab-completion-is-disabled.patch
rename to patches/server/0670-Send-empty-commands-if-tab-completion-is-disabled.patch
diff --git a/patches/server/0670-Add-more-WanderingTrader-API.patch b/patches/server/0671-Add-more-WanderingTrader-API.patch
similarity index 100%
rename from patches/server/0670-Add-more-WanderingTrader-API.patch
rename to patches/server/0671-Add-more-WanderingTrader-API.patch
diff --git a/patches/server/0671-Add-EntityBlockStorage-clearEntities.patch b/patches/server/0672-Add-EntityBlockStorage-clearEntities.patch
similarity index 100%
rename from patches/server/0671-Add-EntityBlockStorage-clearEntities.patch
rename to patches/server/0672-Add-EntityBlockStorage-clearEntities.patch
diff --git a/patches/server/0672-Add-Adventure-message-to-PlayerAdvancementDoneEvent.patch b/patches/server/0673-Add-Adventure-message-to-PlayerAdvancementDoneEvent.patch
similarity index 100%
rename from patches/server/0672-Add-Adventure-message-to-PlayerAdvancementDoneEvent.patch
rename to patches/server/0673-Add-Adventure-message-to-PlayerAdvancementDoneEvent.patch
diff --git a/patches/server/0673-Add-raw-address-to-AsyncPlayerPreLoginEvent.patch b/patches/server/0674-Add-raw-address-to-AsyncPlayerPreLoginEvent.patch
similarity index 100%
rename from patches/server/0673-Add-raw-address-to-AsyncPlayerPreLoginEvent.patch
rename to patches/server/0674-Add-raw-address-to-AsyncPlayerPreLoginEvent.patch
diff --git a/patches/server/0674-Inventory-close.patch b/patches/server/0675-Inventory-close.patch
similarity index 100%
rename from patches/server/0674-Inventory-close.patch
rename to patches/server/0675-Inventory-close.patch
diff --git a/patches/server/0675-call-PortalCreateEvent-players-and-end-platform.patch b/patches/server/0676-call-PortalCreateEvent-players-and-end-platform.patch
similarity index 92%
rename from patches/server/0675-call-PortalCreateEvent-players-and-end-platform.patch
rename to patches/server/0676-call-PortalCreateEvent-players-and-end-platform.patch
index eb541c0ee2..1e9b5dd549 100644
--- a/patches/server/0675-call-PortalCreateEvent-players-and-end-platform.patch
+++ b/patches/server/0676-call-PortalCreateEvent-players-and-end-platform.patch
@@ -5,7 +5,7 @@ Subject: [PATCH] call PortalCreateEvent players and end platform
 
 
 diff --git a/src/main/java/net/minecraft/core/BlockPos.java b/src/main/java/net/minecraft/core/BlockPos.java
-index 8f0cf4297015f3cbe709e2eb82280cac72489925..22ea0da3836b61bb018ae974d2b8c7546b9528d6 100644
+index b98316165c6d10945ccc9e5e0c3f0be9cfc3e889..84eca485a09c6d147f3baa277e398de58a9dc147 100644
 --- a/src/main/java/net/minecraft/core/BlockPos.java
 +++ b/src/main/java/net/minecraft/core/BlockPos.java
 @@ -523,6 +523,7 @@ public class BlockPos extends Vec3i {
@@ -17,7 +17,7 @@ index 8f0cf4297015f3cbe709e2eb82280cac72489925..22ea0da3836b61bb018ae974d2b8c754
              return this.set(this.getX() + dx, this.getY() + dy, this.getZ() + dz);
          }
 diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
-index 2fa2ba45fa1d79d9c78d80cca2aeebedad5a9ba0..b131e307056f04be14917ab92b1688b4fa2832cd 100644
+index 654befb6433647c701ef7966fd37baea3c2ba39b..57e2a6af2bc9e08797e3d06262d4af4bd156f34b 100644
 --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
 +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
 @@ -1167,15 +1167,21 @@ public class ServerPlayer extends Player {
diff --git a/patches/server/0676-Add-a-should-burn-in-sunlight-API-for-Phantoms-and-S.patch b/patches/server/0677-Add-a-should-burn-in-sunlight-API-for-Phantoms-and-S.patch
similarity index 98%
rename from patches/server/0676-Add-a-should-burn-in-sunlight-API-for-Phantoms-and-S.patch
rename to patches/server/0677-Add-a-should-burn-in-sunlight-API-for-Phantoms-and-S.patch
index 4330fb3781..7a0c9f8eb4 100644
--- a/patches/server/0676-Add-a-should-burn-in-sunlight-API-for-Phantoms-and-S.patch
+++ b/patches/server/0677-Add-a-should-burn-in-sunlight-API-for-Phantoms-and-S.patch
@@ -44,7 +44,7 @@ index 6b4163f5601a0961055c8451ec7ef2204938cf69..c54a37516ef1d8a76f7161917bf44812
      @Override
      public void setItemSlot(EquipmentSlot slot, ItemStack stack) {
 diff --git a/src/main/java/net/minecraft/world/entity/monster/Phantom.java b/src/main/java/net/minecraft/world/entity/monster/Phantom.java
-index 2257391ad42219efda0b6a11f1ca0f66e377e412..1ffe939bb66358391d92d3e5378865b1cc8690fd 100644
+index 6dbf806b5984ae16e747dce350c7cffcf0b190ad..f17ed24cee2ac9a9ba5d9a02c1cf8c92ee7fe8db 100644
 --- a/src/main/java/net/minecraft/world/entity/monster/Phantom.java
 +++ b/src/main/java/net/minecraft/world/entity/monster/Phantom.java
 @@ -145,7 +145,7 @@ public class Phantom extends FlyingMob implements Enemy {
diff --git a/patches/server/0677-Fix-CraftPotionBrewer-cache.patch b/patches/server/0678-Fix-CraftPotionBrewer-cache.patch
similarity index 100%
rename from patches/server/0677-Fix-CraftPotionBrewer-cache.patch
rename to patches/server/0678-Fix-CraftPotionBrewer-cache.patch
diff --git a/patches/server/0678-Add-basic-Datapack-API.patch b/patches/server/0679-Add-basic-Datapack-API.patch
similarity index 100%
rename from patches/server/0678-Add-basic-Datapack-API.patch
rename to patches/server/0679-Add-basic-Datapack-API.patch
diff --git a/patches/server/0679-Add-environment-variable-to-disable-server-gui.patch b/patches/server/0680-Add-environment-variable-to-disable-server-gui.patch
similarity index 100%
rename from patches/server/0679-Add-environment-variable-to-disable-server-gui.patch
rename to patches/server/0680-Add-environment-variable-to-disable-server-gui.patch
diff --git a/patches/server/0680-additions-to-PlayerGameModeChangeEvent.patch b/patches/server/0681-additions-to-PlayerGameModeChangeEvent.patch
similarity index 97%
rename from patches/server/0680-additions-to-PlayerGameModeChangeEvent.patch
rename to patches/server/0681-additions-to-PlayerGameModeChangeEvent.patch
index ace243298e..d46dddee41 100644
--- a/patches/server/0680-additions-to-PlayerGameModeChangeEvent.patch
+++ b/patches/server/0681-additions-to-PlayerGameModeChangeEvent.patch
@@ -45,7 +45,7 @@ index d75f78d2e3fb1376e8f6a8668c98a04a693c99e1..79f6089b934124c3309c6bee2e48b36b
          }
  
 diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
-index b131e307056f04be14917ab92b1688b4fa2832cd..b4055c6de62c22ba8ee8384884f9b3fd62eddeb8 100644
+index 57e2a6af2bc9e08797e3d06262d4af4bd156f34b..5d3269c6912a23aef26d5b155c04c2cd567cefba 100644
 --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
 +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
 @@ -1784,8 +1784,15 @@ public class ServerPlayer extends Player {
@@ -136,7 +136,7 @@ index 0b2cb820b912ddb6366f7ffb79c71047d03f2001..52294f5cfce86faf301c835bf1a9c2a5
                      }
                  }
 diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
-index ee40e03704bb8c6b3aa990542fc852058d00f081..0329a727b71e56195a55c69edfd3502fb322e572 100644
+index e5a2fcd390ab5b41d7e482d486cef42a9eef94f5..6e3bebdb7667bfd39c608412b55f7ec7732e1f7d 100644
 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
 +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
 @@ -1249,7 +1249,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
diff --git a/patches/server/0681-Clear-SyncLoadInfo.patch b/patches/server/0682-Clear-SyncLoadInfo.patch
similarity index 100%
rename from patches/server/0681-Clear-SyncLoadInfo.patch
rename to patches/server/0682-Clear-SyncLoadInfo.patch
diff --git a/patches/server/0682-ItemStack-repair-check-API.patch b/patches/server/0683-ItemStack-repair-check-API.patch
similarity index 100%
rename from patches/server/0682-ItemStack-repair-check-API.patch
rename to patches/server/0683-ItemStack-repair-check-API.patch
diff --git a/patches/server/0683-More-Enchantment-API.patch b/patches/server/0684-More-Enchantment-API.patch
similarity index 100%
rename from patches/server/0683-More-Enchantment-API.patch
rename to patches/server/0684-More-Enchantment-API.patch
diff --git a/patches/server/0684-Add-command-line-option-to-load-extra-plugin-jars-no.patch b/patches/server/0685-Add-command-line-option-to-load-extra-plugin-jars-no.patch
similarity index 100%
rename from patches/server/0684-Add-command-line-option-to-load-extra-plugin-jars-no.patch
rename to patches/server/0685-Add-command-line-option-to-load-extra-plugin-jars-no.patch
diff --git a/patches/server/0685-Fix-and-optimise-world-force-upgrading.patch b/patches/server/0686-Fix-and-optimise-world-force-upgrading.patch
similarity index 99%
rename from patches/server/0685-Fix-and-optimise-world-force-upgrading.patch
rename to patches/server/0686-Fix-and-optimise-world-force-upgrading.patch
index de71eaee1b..5c60318d59 100644
--- a/patches/server/0685-Fix-and-optimise-world-force-upgrading.patch
+++ b/patches/server/0686-Fix-and-optimise-world-force-upgrading.patch
@@ -263,7 +263,7 @@ index cf0a74b8a1c31d4bc493eb09a69ee2bd94cb6485..6fa1a7da70896d0ff34d38698769195a
          Main.LOGGER.info("Forcing world upgrade! {}", session.getLevelId()); // CraftBukkit
          WorldUpgrader worldupgrader = new WorldUpgrader(session, dataFixer, worlds, eraseCache);
 diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
-index 8ab99b04ef3e85b64ea78680aa85df1a0894399f..43f9143e892111aa9901454b3de7b57945ecb707 100644
+index c567d8a80fb9caca186bd4c4a7f5199a3eb6f494..c582610142e9f8568c330c7c804926b9ccdaec09 100644
 --- a/src/main/java/net/minecraft/server/MinecraftServer.java
 +++ b/src/main/java/net/minecraft/server/MinecraftServer.java
 @@ -562,13 +562,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -297,7 +297,7 @@ index 8ab99b04ef3e85b64ea78680aa85df1a0894399f..43f9143e892111aa9901454b3de7b579
  
              if (dimensionKey == LevelStem.OVERWORLD) {
 diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
-index 11b454836610f07fffc0efcb60ac5960757a0644..5635b1049f950b8520f527b015c9404c80f5d86c 100644
+index 54cac6167796360ddaeb0b968f17a3533c4b9775..aa4969ea486c8654228d96e48a2192500ee78a63 100644
 --- a/src/main/java/net/minecraft/world/level/Level.java
 +++ b/src/main/java/net/minecraft/world/level/Level.java
 @@ -174,6 +174,15 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
diff --git a/patches/server/0686-Add-Mob-lookAt-API.patch b/patches/server/0687-Add-Mob-lookAt-API.patch
similarity index 100%
rename from patches/server/0686-Add-Mob-lookAt-API.patch
rename to patches/server/0687-Add-Mob-lookAt-API.patch
diff --git a/patches/server/0687-Add-Unix-domain-socket-support.patch b/patches/server/0688-Add-Unix-domain-socket-support.patch
similarity index 100%
rename from patches/server/0687-Add-Unix-domain-socket-support.patch
rename to patches/server/0688-Add-Unix-domain-socket-support.patch
diff --git a/patches/server/0688-Add-EntityInsideBlockEvent.patch b/patches/server/0689-Add-EntityInsideBlockEvent.patch
similarity index 100%
rename from patches/server/0688-Add-EntityInsideBlockEvent.patch
rename to patches/server/0689-Add-EntityInsideBlockEvent.patch
diff --git a/patches/server/0689-Attributes-API-for-item-defaults.patch b/patches/server/0690-Attributes-API-for-item-defaults.patch
similarity index 100%
rename from patches/server/0689-Attributes-API-for-item-defaults.patch
rename to patches/server/0690-Attributes-API-for-item-defaults.patch
diff --git a/patches/server/0690-Have-CraftMerchantCustom-emit-PlayerPurchaseEvent.patch b/patches/server/0691-Have-CraftMerchantCustom-emit-PlayerPurchaseEvent.patch
similarity index 100%
rename from patches/server/0690-Have-CraftMerchantCustom-emit-PlayerPurchaseEvent.patch
rename to patches/server/0691-Have-CraftMerchantCustom-emit-PlayerPurchaseEvent.patch
diff --git a/patches/server/0691-Add-cause-to-Weather-ThunderChangeEvents.patch b/patches/server/0692-Add-cause-to-Weather-ThunderChangeEvents.patch
similarity index 100%
rename from patches/server/0691-Add-cause-to-Weather-ThunderChangeEvents.patch
rename to patches/server/0692-Add-cause-to-Weather-ThunderChangeEvents.patch
diff --git a/patches/server/0692-More-Lidded-Block-API.patch b/patches/server/0693-More-Lidded-Block-API.patch
similarity index 100%
rename from patches/server/0692-More-Lidded-Block-API.patch
rename to patches/server/0693-More-Lidded-Block-API.patch
diff --git a/patches/server/0693-Limit-item-frame-cursors-on-maps.patch b/patches/server/0694-Limit-item-frame-cursors-on-maps.patch
similarity index 89%
rename from patches/server/0693-Limit-item-frame-cursors-on-maps.patch
rename to patches/server/0694-Limit-item-frame-cursors-on-maps.patch
index 017e766ba3..8b1c81646c 100644
--- a/patches/server/0693-Limit-item-frame-cursors-on-maps.patch
+++ b/patches/server/0694-Limit-item-frame-cursors-on-maps.patch
@@ -5,10 +5,10 @@ Subject: [PATCH] Limit item frame cursors on maps
 
 
 diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
-index fcae27a0149e2d135faefcdb135e817190ceb44b..4a5dd2527fce021e7d69d7509c3abfe39deab235 100644
+index 54c74b8d3056e512b4a8c1760c45a33ab7a6f4a9..cc0946050383d00f1f46f16a5bc9236606bee638 100644
 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
 +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
-@@ -760,5 +760,10 @@ public class PaperWorldConfig {
+@@ -777,5 +777,10 @@ public class PaperWorldConfig {
      private void allowUsingSignsInsideSpawnProtection() {
          allowUsingSignsInsideSpawnProtection = getBoolean("allow-using-signs-inside-spawn-protection", allowUsingSignsInsideSpawnProtection);
      }
@@ -20,7 +20,7 @@ index fcae27a0149e2d135faefcdb135e817190ceb44b..4a5dd2527fce021e7d69d7509c3abfe3
  }
  
 diff --git a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
-index e90cb274ae07a259b90ec2badf35980ba684c5b1..ec4c0ebc1067fea9833f93bbbada69446aeee670 100644
+index 2e5155fe541ed7040a6be9fdec98b23e8c45bfb0..60d7496966b22e0553372a93e3c0e7ed9e166cba 100644
 --- a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
 +++ b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
 @@ -296,8 +296,12 @@ public class MapItemSavedData extends SavedData {
diff --git a/patches/server/0694-Add-PufferFishStateChangeEvent.patch b/patches/server/0695-Add-PufferFishStateChangeEvent.patch
similarity index 100%
rename from patches/server/0694-Add-PufferFishStateChangeEvent.patch
rename to patches/server/0695-Add-PufferFishStateChangeEvent.patch
diff --git a/patches/server/0695-Add-PlayerKickEvent-causes.patch b/patches/server/0696-Add-PlayerKickEvent-causes.patch
similarity index 99%
rename from patches/server/0695-Add-PlayerKickEvent-causes.patch
rename to patches/server/0696-Add-PlayerKickEvent-causes.patch
index 33c1fca820..5746fc5519 100644
--- a/patches/server/0695-Add-PlayerKickEvent-causes.patch
+++ b/patches/server/0696-Add-PlayerKickEvent-causes.patch
@@ -5,7 +5,7 @@ Subject: [PATCH] Add PlayerKickEvent causes
 
 
 diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
-index 43f9143e892111aa9901454b3de7b57945ecb707..1f29c92776aea8dbba52d4cb197addce5b3e4d5e 100644
+index c582610142e9f8568c330c7c804926b9ccdaec09..4c78ccd54d3780ea1ed7636a233dc6d3451ed0d9 100644
 --- a/src/main/java/net/minecraft/server/MinecraftServer.java
 +++ b/src/main/java/net/minecraft/server/MinecraftServer.java
 @@ -2110,7 +2110,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -351,7 +351,7 @@ index a9d6154cb9cd347306f745e752cabdf94ed61744..d6ecf7671663957b27ee0cadbfc57ce3
          // CraftBukkit end
  
 diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
-index 0329a727b71e56195a55c69edfd3502fb322e572..05007190441117fe8b2f8b54fc37e589ffc213dc 100644
+index 6e3bebdb7667bfd39c608412b55f7ec7732e1f7d..3f0096423ba5db02c1007a8547d8a0497597055f 100644
 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
 +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
 @@ -498,16 +498,21 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
diff --git a/patches/server/0696-Fix-PlayerBucketEmptyEvent-result-itemstack.patch b/patches/server/0697-Fix-PlayerBucketEmptyEvent-result-itemstack.patch
similarity index 100%
rename from patches/server/0696-Fix-PlayerBucketEmptyEvent-result-itemstack.patch
rename to patches/server/0697-Fix-PlayerBucketEmptyEvent-result-itemstack.patch
diff --git a/patches/server/0697-Synchronize-PalettedContainer-instead-of-ReentrantLo.patch b/patches/server/0698-Synchronize-PalettedContainer-instead-of-ReentrantLo.patch
similarity index 97%
rename from patches/server/0697-Synchronize-PalettedContainer-instead-of-ReentrantLo.patch
rename to patches/server/0698-Synchronize-PalettedContainer-instead-of-ReentrantLo.patch
index 2a6493c294..65c6717bb4 100644
--- a/patches/server/0697-Synchronize-PalettedContainer-instead-of-ReentrantLo.patch
+++ b/patches/server/0698-Synchronize-PalettedContainer-instead-of-ReentrantLo.patch
@@ -13,7 +13,7 @@ contention situations.
 And this is extremely a low contention situation.
 
 diff --git a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
-index b5b0dbbb21f15a61017d8fc936feed30c2b193dc..418eb1ec7dd407ec751b22aa6c7c96069c7eb2ff 100644
+index 66175691af9417275dee33bbc07c6826e807d571..79a6f43f6aa37362990b403695fcdd13f1a2a3ec 100644
 --- a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
 +++ b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
 @@ -37,16 +37,18 @@ public class PalettedContainer<T> implements PaletteResize<T> {
diff --git a/patches/server/0698-Add-option-to-fix-items-merging-through-walls.patch b/patches/server/0699-Add-option-to-fix-items-merging-through-walls.patch
similarity index 93%
rename from patches/server/0698-Add-option-to-fix-items-merging-through-walls.patch
rename to patches/server/0699-Add-option-to-fix-items-merging-through-walls.patch
index ea7f105268..36c4605de8 100644
--- a/patches/server/0698-Add-option-to-fix-items-merging-through-walls.patch
+++ b/patches/server/0699-Add-option-to-fix-items-merging-through-walls.patch
@@ -5,10 +5,10 @@ Subject: [PATCH] Add option to fix items merging through walls
 
 
 diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
-index 4a5dd2527fce021e7d69d7509c3abfe39deab235..1ee76ca0df91a7d23882d8647539c5135593410c 100644
+index cc0946050383d00f1f46f16a5bc9236606bee638..a132f4a5dddf2c895712e5393dfe3d6d1656b6d1 100644
 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
 +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
-@@ -765,5 +765,10 @@ public class PaperWorldConfig {
+@@ -782,5 +782,10 @@ public class PaperWorldConfig {
      private void mapItemFrameCursorLimit() {
          mapItemFrameCursorLimit = getInt("map-item-frame-cursor-limit", mapItemFrameCursorLimit);
      }
diff --git a/patches/server/0699-Add-BellRevealRaiderEvent.patch b/patches/server/0700-Add-BellRevealRaiderEvent.patch
similarity index 100%
rename from patches/server/0699-Add-BellRevealRaiderEvent.patch
rename to patches/server/0700-Add-BellRevealRaiderEvent.patch
diff --git a/patches/server/0700-Fix-invulnerable-end-crystals.patch b/patches/server/0701-Fix-invulnerable-end-crystals.patch
similarity index 96%
rename from patches/server/0700-Fix-invulnerable-end-crystals.patch
rename to patches/server/0701-Fix-invulnerable-end-crystals.patch
index 3d27ccc916..299094a5fc 100644
--- a/patches/server/0700-Fix-invulnerable-end-crystals.patch
+++ b/patches/server/0701-Fix-invulnerable-end-crystals.patch
@@ -6,10 +6,10 @@ Subject: [PATCH] Fix invulnerable end crystals
 MC-108513
 
 diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
-index 1ee76ca0df91a7d23882d8647539c5135593410c..9974151e3bcc7db9acf3f6adacb68331f6085824 100644
+index a132f4a5dddf2c895712e5393dfe3d6d1656b6d1..37d438d131bd66c46a650a48c70af1fde5665fc7 100644
 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
 +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
-@@ -770,5 +770,10 @@ public class PaperWorldConfig {
+@@ -787,5 +787,10 @@ public class PaperWorldConfig {
      private void fixItemsMergingThroughWalls() {
          fixItemsMergingThroughWalls = getBoolean("fix-items-merging-through-walls", fixItemsMergingThroughWalls);
      }
diff --git a/patches/server/0701-Add-ElderGuardianAppearanceEvent.patch b/patches/server/0702-Add-ElderGuardianAppearanceEvent.patch
similarity index 100%
rename from patches/server/0701-Add-ElderGuardianAppearanceEvent.patch
rename to patches/server/0702-Add-ElderGuardianAppearanceEvent.patch
diff --git a/patches/server/0702-Reset-villager-inventory-on-cancelled-pickup-event.patch b/patches/server/0703-Reset-villager-inventory-on-cancelled-pickup-event.patch
similarity index 100%
rename from patches/server/0702-Reset-villager-inventory-on-cancelled-pickup-event.patch
rename to patches/server/0703-Reset-villager-inventory-on-cancelled-pickup-event.patch
diff --git a/patches/server/0703-Fix-dangerous-end-portal-logic.patch b/patches/server/0704-Fix-dangerous-end-portal-logic.patch
similarity index 97%
rename from patches/server/0703-Fix-dangerous-end-portal-logic.patch
rename to patches/server/0704-Fix-dangerous-end-portal-logic.patch
index 3bdefebafa..72f9d5461b 100644
--- a/patches/server/0703-Fix-dangerous-end-portal-logic.patch
+++ b/patches/server/0704-Fix-dangerous-end-portal-logic.patch
@@ -11,7 +11,7 @@ Move the tick logic into the post tick, where portaling was
 designed to happen in the first place.
 
 diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
-index 8c5bf69b89822c8211d472ba3b4b809fa436948a..aaaf5d49972ab608473637dc884dd0c802deaae0 100644
+index 2c25e5ca42a700e1be52781f605a1583df249b85..cfab75b70b4cf4c95f3a7971c78f6dc42c0d23d0 100644
 --- a/src/main/java/net/minecraft/world/entity/Entity.java
 +++ b/src/main/java/net/minecraft/world/entity/Entity.java
 @@ -361,6 +361,37 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n
diff --git a/patches/server/0704-Optimize-Biome-Mob-Lookups-for-Mob-Spawning.patch b/patches/server/0705-Optimize-Biome-Mob-Lookups-for-Mob-Spawning.patch
similarity index 100%
rename from patches/server/0704-Optimize-Biome-Mob-Lookups-for-Mob-Spawning.patch
rename to patches/server/0705-Optimize-Biome-Mob-Lookups-for-Mob-Spawning.patch
diff --git a/patches/server/0705-Make-item-validations-configurable.patch b/patches/server/0706-Make-item-validations-configurable.patch
similarity index 100%
rename from patches/server/0705-Make-item-validations-configurable.patch
rename to patches/server/0706-Make-item-validations-configurable.patch
diff --git a/patches/server/0706-Add-more-line-of-sight-methods.patch b/patches/server/0707-Add-more-line-of-sight-methods.patch
similarity index 100%
rename from patches/server/0706-Add-more-line-of-sight-methods.patch
rename to patches/server/0707-Add-more-line-of-sight-methods.patch
diff --git a/patches/server/0707-add-per-world-spawn-limits.patch b/patches/server/0708-add-per-world-spawn-limits.patch
similarity index 94%
rename from patches/server/0707-add-per-world-spawn-limits.patch
rename to patches/server/0708-add-per-world-spawn-limits.patch
index 0f1dd93b1b..a258214674 100644
--- a/patches/server/0707-add-per-world-spawn-limits.patch
+++ b/patches/server/0708-add-per-world-spawn-limits.patch
@@ -6,10 +6,10 @@ Subject: [PATCH] add per world spawn limits
 Taken from #2982. Credit to Chasewhip8
 
 diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
-index 9974151e3bcc7db9acf3f6adacb68331f6085824..913b0a9b5a31aba4e28e1fe15d5d58b4c8edfc3c 100644
+index 37d438d131bd66c46a650a48c70af1fde5665fc7..b252fc8b88d380feede31f7bc3cca24b4452478b 100644
 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
 +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
-@@ -626,6 +626,19 @@ public class PaperWorldConfig {
+@@ -643,6 +643,19 @@ public class PaperWorldConfig {
          zombieVillagerInfectionChance = getDouble("zombie-villager-infection-chance", zombieVillagerInfectionChance);
      }
  
diff --git a/patches/server/0708-Fix-PotionSplashEvent-for-water-splash-potions.patch b/patches/server/0709-Fix-PotionSplashEvent-for-water-splash-potions.patch
similarity index 100%
rename from patches/server/0708-Fix-PotionSplashEvent-for-water-splash-potions.patch
rename to patches/server/0709-Fix-PotionSplashEvent-for-water-splash-potions.patch
diff --git a/patches/server/0709-Fix-incorrect-status-dataconverter-for-pre-1.13-chun.patch b/patches/server/0710-Fix-incorrect-status-dataconverter-for-pre-1.13-chun.patch
similarity index 99%
rename from patches/server/0709-Fix-incorrect-status-dataconverter-for-pre-1.13-chun.patch
rename to patches/server/0710-Fix-incorrect-status-dataconverter-for-pre-1.13-chun.patch
index a09b97be3d..096c6fb001 100644
--- a/patches/server/0709-Fix-incorrect-status-dataconverter-for-pre-1.13-chun.patch
+++ b/patches/server/0710-Fix-incorrect-status-dataconverter-for-pre-1.13-chun.patch
@@ -34,8 +34,6 @@ This should fix some problems converting old data, as the
 changes here are going to prevent the chunk from being regenerated
 incorrectly.
 
-SPOTTEDLEAF!!!!!!!!!!!
-
 diff --git a/src/main/java/net/minecraft/util/datafix/fixes/ChunkToProtochunkFix.java b/src/main/java/net/minecraft/util/datafix/fixes/ChunkToProtochunkFix.java
 index 081bcae48ae34d8354635ea57952f09f14f7fa7a..a4305f58f793e1577de5e13132381ce81304cae4 100644
 --- a/src/main/java/net/minecraft/util/datafix/fixes/ChunkToProtochunkFix.java