diff --git a/patches/server/0463-Optimize-NibbleArray-to-use-pooled-buffers.patch b/patches/removed/1.18/0463-Optimize-NibbleArray-to-use-pooled-buffers.patch similarity index 100% rename from patches/server/0463-Optimize-NibbleArray-to-use-pooled-buffers.patch rename to patches/removed/1.18/0463-Optimize-NibbleArray-to-use-pooled-buffers.patch diff --git a/patches/server/0334-Fix-World-isChunkGenerated-calls.patch b/patches/server/0334-Fix-World-isChunkGenerated-calls.patch index 7a613ff013..890bba394c 100644 --- a/patches/server/0334-Fix-World-isChunkGenerated-calls.patch +++ b/patches/server/0334-Fix-World-isChunkGenerated-calls.patch @@ -103,7 +103,7 @@ index 328f482a0bae8d2f8013ae9a90f0500ef889ffb5..6c72854aa975800bd6160d104936a5ba return (ChunkStatus) Registry.CHUNK_STATUS.get(ResourceLocation.tryParse(id)); } 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 9168bc15f8fbc8719e6c83428b8241053505441e..384ee6fbc65baff381d875665fd2462dbc99683e 100644 +index 9168bc15f8fbc8719e6c83428b8241053505441e..b44d621fc8a5194622775b7903de083cca999022 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 @@ -597,6 +597,17 @@ public class ChunkSerializer { @@ -117,7 +117,7 @@ index 9168bc15f8fbc8719e6c83428b8241053505441e..384ee6fbc65baff381d875665fd2462d + } + + // Note: Copied from below -+ return ChunkStatus.getStatus(compound.getCompound("Level").getString("Status")); ++ return ChunkStatus.getStatus(compound.getString("Status")); + } + // Paper end + diff --git a/patches/server/0464-Support-components-in-ItemMeta.patch b/patches/server/0463-Support-components-in-ItemMeta.patch similarity index 100% rename from patches/server/0464-Support-components-in-ItemMeta.patch rename to patches/server/0463-Support-components-in-ItemMeta.patch diff --git a/patches/server/0465-Improve-EntityTargetLivingEntityEvent-for-1.16-mobs.patch b/patches/server/0464-Improve-EntityTargetLivingEntityEvent-for-1.16-mobs.patch similarity index 100% rename from patches/server/0465-Improve-EntityTargetLivingEntityEvent-for-1.16-mobs.patch rename to patches/server/0464-Improve-EntityTargetLivingEntityEvent-for-1.16-mobs.patch diff --git a/patches/server/0466-Add-entity-liquid-API.patch b/patches/server/0465-Add-entity-liquid-API.patch similarity index 100% rename from patches/server/0466-Add-entity-liquid-API.patch rename to patches/server/0465-Add-entity-liquid-API.patch diff --git a/patches/server/0467-Update-itemstack-legacy-name-and-lore.patch b/patches/server/0466-Update-itemstack-legacy-name-and-lore.patch similarity index 100% rename from patches/server/0467-Update-itemstack-legacy-name-and-lore.patch rename to patches/server/0466-Update-itemstack-legacy-name-and-lore.patch diff --git a/patches/server/0468-Spawn-player-in-correct-world-on-login.patch b/patches/server/0467-Spawn-player-in-correct-world-on-login.patch similarity index 100% rename from patches/server/0468-Spawn-player-in-correct-world-on-login.patch rename to patches/server/0467-Spawn-player-in-correct-world-on-login.patch diff --git a/patches/server/0469-Add-PrepareResultEvent.patch b/patches/server/0468-Add-PrepareResultEvent.patch similarity index 100% rename from patches/server/0469-Add-PrepareResultEvent.patch rename to patches/server/0468-Add-PrepareResultEvent.patch diff --git a/patches/server/0470-Don-t-check-chunk-for-portal-on-world-gen-entity-add.patch b/patches/server/0469-Don-t-check-chunk-for-portal-on-world-gen-entity-add.patch similarity index 100% rename from patches/server/0470-Don-t-check-chunk-for-portal-on-world-gen-entity-add.patch rename to patches/server/0469-Don-t-check-chunk-for-portal-on-world-gen-entity-add.patch diff --git a/patches/server/0471-Implement-Chunk-Priority-Urgency-System-for-Chunks.patch b/patches/server/0470-Implement-Chunk-Priority-Urgency-System-for-Chunks.patch similarity index 100% rename from patches/server/0471-Implement-Chunk-Priority-Urgency-System-for-Chunks.patch rename to patches/server/0470-Implement-Chunk-Priority-Urgency-System-for-Chunks.patch diff --git a/patches/server/0472-Optimize-NetworkManager-Exception-Handling.patch b/patches/server/0471-Optimize-NetworkManager-Exception-Handling.patch similarity index 100% rename from patches/server/0472-Optimize-NetworkManager-Exception-Handling.patch rename to patches/server/0471-Optimize-NetworkManager-Exception-Handling.patch diff --git a/patches/server/0473-Optimize-the-advancement-data-player-iteration-to-be.patch b/patches/server/0472-Optimize-the-advancement-data-player-iteration-to-be.patch similarity index 100% rename from patches/server/0473-Optimize-the-advancement-data-player-iteration-to-be.patch rename to patches/server/0472-Optimize-the-advancement-data-player-iteration-to-be.patch diff --git a/patches/server/0474-Fix-arrows-never-despawning-MC-125757.patch b/patches/server/0473-Fix-arrows-never-despawning-MC-125757.patch similarity index 100% rename from patches/server/0474-Fix-arrows-never-despawning-MC-125757.patch rename to patches/server/0473-Fix-arrows-never-despawning-MC-125757.patch diff --git a/patches/server/0475-Thread-Safe-Vanilla-Command-permission-checking.patch b/patches/server/0474-Thread-Safe-Vanilla-Command-permission-checking.patch similarity index 100% rename from patches/server/0475-Thread-Safe-Vanilla-Command-permission-checking.patch rename to patches/server/0474-Thread-Safe-Vanilla-Command-permission-checking.patch diff --git a/patches/server/0476-Move-range-check-for-block-placing-up.patch b/patches/server/0475-Move-range-check-for-block-placing-up.patch similarity index 100% rename from patches/server/0476-Move-range-check-for-block-placing-up.patch rename to patches/server/0475-Move-range-check-for-block-placing-up.patch diff --git a/patches/server/0477-Fix-SPIGOT-5989.patch b/patches/server/0476-Fix-SPIGOT-5989.patch similarity index 100% rename from patches/server/0477-Fix-SPIGOT-5989.patch rename to patches/server/0476-Fix-SPIGOT-5989.patch diff --git a/patches/server/0478-Fix-SPIGOT-5824-Bukkit-world-container-is-not-used.patch b/patches/server/0477-Fix-SPIGOT-5824-Bukkit-world-container-is-not-used.patch similarity index 100% rename from patches/server/0478-Fix-SPIGOT-5824-Bukkit-world-container-is-not-used.patch rename to patches/server/0477-Fix-SPIGOT-5824-Bukkit-world-container-is-not-used.patch diff --git a/patches/server/0479-Fix-SPIGOT-5885-Unable-to-disable-advancements.patch b/patches/server/0478-Fix-SPIGOT-5885-Unable-to-disable-advancements.patch similarity index 100% rename from patches/server/0479-Fix-SPIGOT-5885-Unable-to-disable-advancements.patch rename to patches/server/0478-Fix-SPIGOT-5885-Unable-to-disable-advancements.patch diff --git a/patches/server/0480-Fix-AdvancementDataPlayer-leak-due-from-quitting-ear.patch b/patches/server/0479-Fix-AdvancementDataPlayer-leak-due-from-quitting-ear.patch similarity index 100% rename from patches/server/0480-Fix-AdvancementDataPlayer-leak-due-from-quitting-ear.patch rename to patches/server/0479-Fix-AdvancementDataPlayer-leak-due-from-quitting-ear.patch diff --git a/patches/server/0481-Add-missing-strikeLighting-call-to-World-spigot-stri.patch b/patches/server/0480-Add-missing-strikeLighting-call-to-World-spigot-stri.patch similarity index 100% rename from patches/server/0481-Add-missing-strikeLighting-call-to-World-spigot-stri.patch rename to patches/server/0480-Add-missing-strikeLighting-call-to-World-spigot-stri.patch diff --git a/patches/server/0482-Fix-some-rails-connecting-improperly.patch b/patches/server/0481-Fix-some-rails-connecting-improperly.patch similarity index 100% rename from patches/server/0482-Fix-some-rails-connecting-improperly.patch rename to patches/server/0481-Fix-some-rails-connecting-improperly.patch diff --git a/patches/server/0483-Fix-regex-mistake-in-CB-NBT-int-deserialization.patch b/patches/server/0482-Fix-regex-mistake-in-CB-NBT-int-deserialization.patch similarity index 100% rename from patches/server/0483-Fix-regex-mistake-in-CB-NBT-int-deserialization.patch rename to patches/server/0482-Fix-regex-mistake-in-CB-NBT-int-deserialization.patch diff --git a/patches/server/0484-Do-not-let-the-server-load-chunks-from-newer-version.patch b/patches/server/0483-Do-not-let-the-server-load-chunks-from-newer-version.patch similarity index 95% rename from patches/server/0484-Do-not-let-the-server-load-chunks-from-newer-version.patch rename to patches/server/0483-Do-not-let-the-server-load-chunks-from-newer-version.patch index 2fa64e3aff..40d3676085 100644 --- a/patches/server/0484-Do-not-let-the-server-load-chunks-from-newer-version.patch +++ b/patches/server/0483-Do-not-let-the-server-load-chunks-from-newer-version.patch @@ -9,7 +9,7 @@ the game, immediately stop the server to prevent data corruption. You can override this functionality at your own peril. 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 46beea026eec707c69194da6d1d51dc66b61f54e..a5bd7d9a7440887d8997a96efebaf3db155263be 100644 +index 9a6f4c0bcfe8ce331ba7f6c92e527addcf65c911..03439b92297d8a2d73f21ddb57b3b2087f70907c 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 @@ -109,9 +109,22 @@ public class ChunkSerializer { diff --git a/patches/server/0485-Brand-support.patch b/patches/server/0484-Brand-support.patch similarity index 100% rename from patches/server/0485-Brand-support.patch rename to patches/server/0484-Brand-support.patch diff --git a/patches/server/0486-Add-setMaxPlayers-API.patch b/patches/server/0485-Add-setMaxPlayers-API.patch similarity index 100% rename from patches/server/0486-Add-setMaxPlayers-API.patch rename to patches/server/0485-Add-setMaxPlayers-API.patch diff --git a/patches/server/0487-Add-playPickupItemAnimation-to-LivingEntity.patch b/patches/server/0486-Add-playPickupItemAnimation-to-LivingEntity.patch similarity index 100% rename from patches/server/0487-Add-playPickupItemAnimation-to-LivingEntity.patch rename to patches/server/0486-Add-playPickupItemAnimation-to-LivingEntity.patch diff --git a/patches/server/0488-Don-t-require-FACING-data.patch b/patches/server/0487-Don-t-require-FACING-data.patch similarity index 100% rename from patches/server/0488-Don-t-require-FACING-data.patch rename to patches/server/0487-Don-t-require-FACING-data.patch diff --git a/patches/server/0489-Fix-SpawnChangeEvent-not-firing-for-all-use-cases.patch b/patches/server/0488-Fix-SpawnChangeEvent-not-firing-for-all-use-cases.patch similarity index 100% rename from patches/server/0489-Fix-SpawnChangeEvent-not-firing-for-all-use-cases.patch rename to patches/server/0488-Fix-SpawnChangeEvent-not-firing-for-all-use-cases.patch diff --git a/patches/server/0490-Add-moon-phase-API.patch b/patches/server/0489-Add-moon-phase-API.patch similarity index 100% rename from patches/server/0490-Add-moon-phase-API.patch rename to patches/server/0489-Add-moon-phase-API.patch diff --git a/patches/server/0491-Improve-Chunk-Status-Transition-Speed.patch b/patches/server/0490-Improve-Chunk-Status-Transition-Speed.patch similarity index 100% rename from patches/server/0491-Improve-Chunk-Status-Transition-Speed.patch rename to patches/server/0490-Improve-Chunk-Status-Transition-Speed.patch diff --git a/patches/server/0492-Prevent-headless-pistons-from-being-created.patch b/patches/server/0491-Prevent-headless-pistons-from-being-created.patch similarity index 100% rename from patches/server/0492-Prevent-headless-pistons-from-being-created.patch rename to patches/server/0491-Prevent-headless-pistons-from-being-created.patch diff --git a/patches/server/0493-Add-BellRingEvent.patch b/patches/server/0492-Add-BellRingEvent.patch similarity index 100% rename from patches/server/0493-Add-BellRingEvent.patch rename to patches/server/0492-Add-BellRingEvent.patch diff --git a/patches/server/0494-Add-zombie-targets-turtle-egg-config.patch b/patches/server/0493-Add-zombie-targets-turtle-egg-config.patch similarity index 100% rename from patches/server/0494-Add-zombie-targets-turtle-egg-config.patch rename to patches/server/0493-Add-zombie-targets-turtle-egg-config.patch diff --git a/patches/server/0495-Buffer-joins-to-world.patch b/patches/server/0494-Buffer-joins-to-world.patch similarity index 100% rename from patches/server/0495-Buffer-joins-to-world.patch rename to patches/server/0494-Buffer-joins-to-world.patch diff --git a/patches/server/0496-Optimize-redstone-algorithm.patch b/patches/server/0495-Optimize-redstone-algorithm.patch similarity index 100% rename from patches/server/0496-Optimize-redstone-algorithm.patch rename to patches/server/0495-Optimize-redstone-algorithm.patch diff --git a/patches/server/0497-Fix-hex-colors-not-working-in-some-kick-messages.patch b/patches/server/0496-Fix-hex-colors-not-working-in-some-kick-messages.patch similarity index 100% rename from patches/server/0497-Fix-hex-colors-not-working-in-some-kick-messages.patch rename to patches/server/0496-Fix-hex-colors-not-working-in-some-kick-messages.patch diff --git a/patches/server/0498-PortalCreateEvent-needs-to-know-its-entity.patch b/patches/server/0497-PortalCreateEvent-needs-to-know-its-entity.patch similarity index 100% rename from patches/server/0498-PortalCreateEvent-needs-to-know-its-entity.patch rename to patches/server/0497-PortalCreateEvent-needs-to-know-its-entity.patch diff --git a/patches/server/0499-Fix-CraftTeam-null-check.patch b/patches/server/0498-Fix-CraftTeam-null-check.patch similarity index 100% rename from patches/server/0499-Fix-CraftTeam-null-check.patch rename to patches/server/0498-Fix-CraftTeam-null-check.patch diff --git a/patches/server/0500-Add-more-Evoker-API.patch b/patches/server/0499-Add-more-Evoker-API.patch similarity index 100% rename from patches/server/0500-Add-more-Evoker-API.patch rename to patches/server/0499-Add-more-Evoker-API.patch diff --git a/patches/server/0501-Add-methods-to-get-translation-keys.patch b/patches/server/0500-Add-methods-to-get-translation-keys.patch similarity index 98% rename from patches/server/0501-Add-methods-to-get-translation-keys.patch rename to patches/server/0500-Add-methods-to-get-translation-keys.patch index fe6531e508..ed27a602e0 100644 --- a/patches/server/0501-Add-methods-to-get-translation-keys.patch +++ b/patches/server/0500-Add-methods-to-get-translation-keys.patch @@ -42,7 +42,7 @@ index eb99e0c2462a2d1ab4508a5c3f1580b6e31d7465..c536eceef3365a7b726cd970df345ba1 public net.minecraft.world.item.enchantment.Enchantment getHandle() { diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -index a849724a9fb642bcd4de3c6438937adc882c610e..1380df5f70f9284b47b9e6426672d82df384b2c0 100644 +index 19401098850f3fecaaea1f27ff4febd7bda1f7c9..dd9433f014c974bbee6f00a9677403ddbbcee416 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -442,6 +442,30 @@ public final class CraftMagicNumbers implements UnsafeValues { diff --git a/patches/server/0502-Create-HoverEvent-from-ItemStack-Entity.patch b/patches/server/0501-Create-HoverEvent-from-ItemStack-Entity.patch similarity index 100% rename from patches/server/0502-Create-HoverEvent-from-ItemStack-Entity.patch rename to patches/server/0501-Create-HoverEvent-from-ItemStack-Entity.patch diff --git a/patches/server/0503-Cache-block-data-strings.patch b/patches/server/0502-Cache-block-data-strings.patch similarity index 100% rename from patches/server/0503-Cache-block-data-strings.patch rename to patches/server/0502-Cache-block-data-strings.patch diff --git a/patches/server/0504-Fix-Entity-Teleportation-and-cancel-velocity-if-tele.patch b/patches/server/0503-Fix-Entity-Teleportation-and-cancel-velocity-if-tele.patch similarity index 100% rename from patches/server/0504-Fix-Entity-Teleportation-and-cancel-velocity-if-tele.patch rename to patches/server/0503-Fix-Entity-Teleportation-and-cancel-velocity-if-tele.patch diff --git a/patches/server/0505-Add-additional-open-container-api-to-HumanEntity.patch b/patches/server/0504-Add-additional-open-container-api-to-HumanEntity.patch similarity index 100% rename from patches/server/0505-Add-additional-open-container-api-to-HumanEntity.patch rename to patches/server/0504-Add-additional-open-container-api-to-HumanEntity.patch diff --git a/patches/server/0506-Cache-DataFixerUpper-Rewrite-Rules-on-demand.patch b/patches/server/0505-Cache-DataFixerUpper-Rewrite-Rules-on-demand.patch similarity index 100% rename from patches/server/0506-Cache-DataFixerUpper-Rewrite-Rules-on-demand.patch rename to patches/server/0505-Cache-DataFixerUpper-Rewrite-Rules-on-demand.patch diff --git a/patches/server/0507-Extend-block-drop-capture-to-capture-all-items-added.patch b/patches/server/0506-Extend-block-drop-capture-to-capture-all-items-added.patch similarity index 100% rename from patches/server/0507-Extend-block-drop-capture-to-capture-all-items-added.patch rename to patches/server/0506-Extend-block-drop-capture-to-capture-all-items-added.patch diff --git a/patches/server/0508-Don-t-mark-dirty-in-invalid-locations-SPIGOT-6086.patch b/patches/server/0507-Don-t-mark-dirty-in-invalid-locations-SPIGOT-6086.patch similarity index 89% rename from patches/server/0508-Don-t-mark-dirty-in-invalid-locations-SPIGOT-6086.patch rename to patches/server/0507-Don-t-mark-dirty-in-invalid-locations-SPIGOT-6086.patch index 7d017eb965..be798e12cb 100644 --- a/patches/server/0508-Don-t-mark-dirty-in-invalid-locations-SPIGOT-6086.patch +++ b/patches/server/0507-Don-t-mark-dirty-in-invalid-locations-SPIGOT-6086.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Don't mark dirty in invalid locations (SPIGOT-6086) diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java -index 8950470bbaa57ac0ef6ca4d6e3796a712e0b6cd6..b493769dd420f0dd93fdf8184c452c53cb63e95b 100644 +index 5b9abfb7b8edd686f416a46851f12bd52bea7000..874c99cdb8ea57c7ba986dd1cbd43bedbff30260 100644 --- a/src/main/java/net/minecraft/server/level/ChunkHolder.java +++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java @@ -229,6 +229,7 @@ public class ChunkHolder { diff --git a/patches/server/0509-Expose-the-Entity-Counter-to-allow-plugins-to-use-va.patch b/patches/server/0508-Expose-the-Entity-Counter-to-allow-plugins-to-use-va.patch similarity index 94% rename from patches/server/0509-Expose-the-Entity-Counter-to-allow-plugins-to-use-va.patch rename to patches/server/0508-Expose-the-Entity-Counter-to-allow-plugins-to-use-va.patch index a57ddd84c7..624bc44802 100644 --- a/patches/server/0509-Expose-the-Entity-Counter-to-allow-plugins-to-use-va.patch +++ b/patches/server/0508-Expose-the-Entity-Counter-to-allow-plugins-to-use-va.patch @@ -21,7 +21,7 @@ index d5455fda54047ad3723772a352d35a371727f0cd..f5198f23e6147adb69aa95d5da816eae + // Paper end } diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -index 1380df5f70f9284b47b9e6426672d82df384b2c0..33b85d2cd6be32d70a9621c02666e297fc78ff97 100644 +index dd9433f014c974bbee6f00a9677403ddbbcee416..92e3717b217448398c4d07d8331ed8c57cd68c8f 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -466,6 +466,10 @@ public final class CraftMagicNumbers implements UnsafeValues { diff --git a/patches/server/0510-Lazily-track-plugin-scoreboards-by-default.patch b/patches/server/0509-Lazily-track-plugin-scoreboards-by-default.patch similarity index 98% rename from patches/server/0510-Lazily-track-plugin-scoreboards-by-default.patch rename to patches/server/0509-Lazily-track-plugin-scoreboards-by-default.patch index 8d8a011b26..e2d6b40548 100644 --- a/patches/server/0510-Lazily-track-plugin-scoreboards-by-default.patch +++ b/patches/server/0509-Lazily-track-plugin-scoreboards-by-default.patch @@ -14,7 +14,7 @@ this breaks your workflow you can always force all scoreboards to be tracked wit settings.track-plugin-scoreboards in paper.yml. diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java -index b6c7aec1516a4db4fde8c9ec2772cd982ed5e304..dbfd840f2f64fa7eec5523aa2ba9e1018f4bb19d 100644 +index 16d6ce24031590ff9dfba5c938aeb9755704798d..bd7926fa89621e8cdd0b5fdd8ed3b8c6dbfbc3ec 100644 --- a/src/main/java/com/destroystokyo/paper/PaperConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java @@ -96,6 +96,11 @@ public class PaperConfig { diff --git a/patches/server/0511-Entity-isTicking.patch b/patches/server/0510-Entity-isTicking.patch similarity index 100% rename from patches/server/0511-Entity-isTicking.patch rename to patches/server/0510-Entity-isTicking.patch diff --git a/patches/server/0512-Fix-deop-kicking-non-whitelisted-player-when-white-l.patch b/patches/server/0511-Fix-deop-kicking-non-whitelisted-player-when-white-l.patch similarity index 100% rename from patches/server/0512-Fix-deop-kicking-non-whitelisted-player-when-white-l.patch rename to patches/server/0511-Fix-deop-kicking-non-whitelisted-player-when-white-l.patch diff --git a/patches/server/0513-Fix-Concurrency-issue-in-WeightedList.patch b/patches/server/0512-Fix-Concurrency-issue-in-WeightedList.patch similarity index 100% rename from patches/server/0513-Fix-Concurrency-issue-in-WeightedList.patch rename to patches/server/0512-Fix-Concurrency-issue-in-WeightedList.patch diff --git a/patches/server/0514-Reset-Ender-Crystals-on-Dragon-Spawn.patch b/patches/server/0513-Reset-Ender-Crystals-on-Dragon-Spawn.patch similarity index 100% rename from patches/server/0514-Reset-Ender-Crystals-on-Dragon-Spawn.patch rename to patches/server/0513-Reset-Ender-Crystals-on-Dragon-Spawn.patch diff --git a/patches/server/0515-Fix-for-large-move-vectors-crashing-server.patch b/patches/server/0514-Fix-for-large-move-vectors-crashing-server.patch similarity index 100% rename from patches/server/0515-Fix-for-large-move-vectors-crashing-server.patch rename to patches/server/0514-Fix-for-large-move-vectors-crashing-server.patch diff --git a/patches/server/0516-Optimise-getType-calls.patch b/patches/server/0515-Optimise-getType-calls.patch similarity index 100% rename from patches/server/0516-Optimise-getType-calls.patch rename to patches/server/0515-Optimise-getType-calls.patch diff --git a/patches/server/0517-Villager-resetOffers.patch b/patches/server/0516-Villager-resetOffers.patch similarity index 100% rename from patches/server/0517-Villager-resetOffers.patch rename to patches/server/0516-Villager-resetOffers.patch diff --git a/patches/server/0518-Improve-inlinig-for-some-hot-IBlockData-methods.patch b/patches/server/0517-Improve-inlinig-for-some-hot-IBlockData-methods.patch similarity index 100% rename from patches/server/0518-Improve-inlinig-for-some-hot-IBlockData-methods.patch rename to patches/server/0517-Improve-inlinig-for-some-hot-IBlockData-methods.patch diff --git a/patches/server/0519-Retain-block-place-order-when-capturing-blockstates.patch b/patches/server/0518-Retain-block-place-order-when-capturing-blockstates.patch similarity index 100% rename from patches/server/0519-Retain-block-place-order-when-capturing-blockstates.patch rename to patches/server/0518-Retain-block-place-order-when-capturing-blockstates.patch diff --git a/patches/server/0520-Reduce-blockpos-allocation-from-pathfinding.patch b/patches/server/0519-Reduce-blockpos-allocation-from-pathfinding.patch similarity index 100% rename from patches/server/0520-Reduce-blockpos-allocation-from-pathfinding.patch rename to patches/server/0519-Reduce-blockpos-allocation-from-pathfinding.patch diff --git a/patches/server/0521-Fix-item-locations-dropped-from-campfires.patch b/patches/server/0520-Fix-item-locations-dropped-from-campfires.patch similarity index 100% rename from patches/server/0521-Fix-item-locations-dropped-from-campfires.patch rename to patches/server/0520-Fix-item-locations-dropped-from-campfires.patch diff --git a/patches/server/0522-Player-elytra-boost-API.patch b/patches/server/0521-Player-elytra-boost-API.patch similarity index 100% rename from patches/server/0522-Player-elytra-boost-API.patch rename to patches/server/0521-Player-elytra-boost-API.patch diff --git a/patches/server/0523-Fixed-TileEntityBell-memory-leak.patch b/patches/server/0522-Fixed-TileEntityBell-memory-leak.patch similarity index 100% rename from patches/server/0523-Fixed-TileEntityBell-memory-leak.patch rename to patches/server/0522-Fixed-TileEntityBell-memory-leak.patch diff --git a/patches/server/0524-Avoid-error-bubbling-up-when-item-stack-is-empty-in-.patch b/patches/server/0523-Avoid-error-bubbling-up-when-item-stack-is-empty-in-.patch similarity index 100% rename from patches/server/0524-Avoid-error-bubbling-up-when-item-stack-is-empty-in-.patch rename to patches/server/0523-Avoid-error-bubbling-up-when-item-stack-is-empty-in-.patch diff --git a/patches/server/0525-Add-getOfflinePlayerIfCached-String.patch b/patches/server/0524-Add-getOfflinePlayerIfCached-String.patch similarity index 100% rename from patches/server/0525-Add-getOfflinePlayerIfCached-String.patch rename to patches/server/0524-Add-getOfflinePlayerIfCached-String.patch diff --git a/patches/server/0526-Add-ignore-discounts-API.patch b/patches/server/0525-Add-ignore-discounts-API.patch similarity index 100% rename from patches/server/0526-Add-ignore-discounts-API.patch rename to patches/server/0525-Add-ignore-discounts-API.patch diff --git a/patches/server/0527-Toggle-for-removing-existing-dragon.patch b/patches/server/0526-Toggle-for-removing-existing-dragon.patch similarity index 95% rename from patches/server/0527-Toggle-for-removing-existing-dragon.patch rename to patches/server/0526-Toggle-for-removing-existing-dragon.patch index 5ee6302027..7961333334 100644 --- a/patches/server/0527-Toggle-for-removing-existing-dragon.patch +++ b/patches/server/0526-Toggle-for-removing-existing-dragon.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Toggle for removing existing dragon diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index bc93318246eab1da5462aa3fa0cde4c100622f4e..62e60057a362ad7c3e96b3167f78ba154cfefdc3 100644 +index aee981e967bfb32a531d5d79213c5d165bb64ad0..ffcfa631a519079f355cddb7bf10dbceb2496882 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -71,6 +71,14 @@ public class PaperWorldConfig { diff --git a/patches/server/0528-Fix-client-lag-on-advancement-loading.patch b/patches/server/0527-Fix-client-lag-on-advancement-loading.patch similarity index 95% rename from patches/server/0528-Fix-client-lag-on-advancement-loading.patch rename to patches/server/0527-Fix-client-lag-on-advancement-loading.patch index 4abc66ce71..ba1add3c37 100644 --- a/patches/server/0528-Fix-client-lag-on-advancement-loading.patch +++ b/patches/server/0527-Fix-client-lag-on-advancement-loading.patch @@ -15,7 +15,7 @@ manually reload the advancement data for all players, which normally takes place as a part of the datapack reloading. diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -index 33b85d2cd6be32d70a9621c02666e297fc78ff97..463cabee7f4f40f2f8d4f4502296d1abfff18229 100644 +index 92e3717b217448398c4d07d8331ed8c57cd68c8f..de6343455ce92835f3e5bc2646f64c03dab8aba2 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -323,7 +323,13 @@ public final class CraftMagicNumbers implements UnsafeValues { diff --git a/patches/server/0529-Item-no-age-no-player-pickup.patch b/patches/server/0528-Item-no-age-no-player-pickup.patch similarity index 100% rename from patches/server/0529-Item-no-age-no-player-pickup.patch rename to patches/server/0528-Item-no-age-no-player-pickup.patch diff --git a/patches/server/0530-Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch b/patches/server/0529-Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch similarity index 100% rename from patches/server/0530-Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch rename to patches/server/0529-Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch diff --git a/patches/server/0531-Beacon-API-custom-effect-ranges.patch b/patches/server/0530-Beacon-API-custom-effect-ranges.patch similarity index 100% rename from patches/server/0531-Beacon-API-custom-effect-ranges.patch rename to patches/server/0530-Beacon-API-custom-effect-ranges.patch diff --git a/patches/server/0532-Add-API-for-quit-reason.patch b/patches/server/0531-Add-API-for-quit-reason.patch similarity index 98% rename from patches/server/0532-Add-API-for-quit-reason.patch rename to patches/server/0531-Add-API-for-quit-reason.patch index 31b097e487..1c17061042 100644 --- a/patches/server/0532-Add-API-for-quit-reason.patch +++ b/patches/server/0531-Add-API-for-quit-reason.patch @@ -49,7 +49,7 @@ index 2dd47eab63cf9322a5844e748709e220272a8cfe..c0a685cfe62aeda3583763ecc1e4fa12 this.connection.disconnect(ichatbasecomponent); }); diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index b1f93551ce3e4d12e5cbe424c1ceaf3da20d0ffd..5bbf5c83a5052df07392cd17236469b2d3ddecdc 100644 +index 5c829538a008f1a737380627f7b88c7a0914050f..d414a3abae7dea5b813e41758eccf98cd35bddc2 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java @@ -596,7 +596,7 @@ public abstract class PlayerList { diff --git a/patches/server/0533-Add-Wandering-Trader-spawn-rate-config-options.patch b/patches/server/0532-Add-Wandering-Trader-spawn-rate-config-options.patch similarity index 98% rename from patches/server/0533-Add-Wandering-Trader-spawn-rate-config-options.patch rename to patches/server/0532-Add-Wandering-Trader-spawn-rate-config-options.patch index ab3e9e7ec0..b2b1e86170 100644 --- a/patches/server/0533-Add-Wandering-Trader-spawn-rate-config-options.patch +++ b/patches/server/0532-Add-Wandering-Trader-spawn-rate-config-options.patch @@ -11,7 +11,7 @@ in IWorldServerData are removed as they were only used in certain places, with h values used in other places. diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index 62e60057a362ad7c3e96b3167f78ba154cfefdc3..ab6ade77a7be2b0d67effcacbf74ed64a1beccff 100644 +index ffcfa631a519079f355cddb7bf10dbceb2496882..7f4e963c1bb37f929321e0a862f76f42ab72b4c4 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -79,6 +79,19 @@ public class PaperWorldConfig { diff --git a/patches/server/0534-Significantly-improve-performance-of-the-end-generat.patch b/patches/server/0533-Significantly-improve-performance-of-the-end-generat.patch similarity index 100% rename from patches/server/0534-Significantly-improve-performance-of-the-end-generat.patch rename to patches/server/0533-Significantly-improve-performance-of-the-end-generat.patch diff --git a/patches/server/0535-Expose-world-spawn-angle.patch b/patches/server/0534-Expose-world-spawn-angle.patch similarity index 95% rename from patches/server/0535-Expose-world-spawn-angle.patch rename to patches/server/0534-Expose-world-spawn-angle.patch index 8a4fd893fa..0995290bac 100644 --- a/patches/server/0535-Expose-world-spawn-angle.patch +++ b/patches/server/0534-Expose-world-spawn-angle.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Expose world spawn angle diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index 5bbf5c83a5052df07392cd17236469b2d3ddecdc..d0c824290c08f825956ec1396381ec1657a6476d 100644 +index d414a3abae7dea5b813e41758eccf98cd35bddc2..e7834772e38e61df405be406fe320a646778175a 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java @@ -874,7 +874,7 @@ public abstract class PlayerList { diff --git a/patches/server/0536-Add-Destroy-Speed-API.patch b/patches/server/0535-Add-Destroy-Speed-API.patch similarity index 100% rename from patches/server/0536-Add-Destroy-Speed-API.patch rename to patches/server/0535-Add-Destroy-Speed-API.patch diff --git a/patches/server/0537-Fix-Player-spawnParticle-x-y-z-precision-loss.patch b/patches/server/0536-Fix-Player-spawnParticle-x-y-z-precision-loss.patch similarity index 100% rename from patches/server/0537-Fix-Player-spawnParticle-x-y-z-precision-loss.patch rename to patches/server/0536-Fix-Player-spawnParticle-x-y-z-precision-loss.patch diff --git a/patches/server/0538-Add-LivingEntity-clearActiveItem.patch b/patches/server/0537-Add-LivingEntity-clearActiveItem.patch similarity index 100% rename from patches/server/0538-Add-LivingEntity-clearActiveItem.patch rename to patches/server/0537-Add-LivingEntity-clearActiveItem.patch diff --git a/patches/server/0539-Add-PlayerItemCooldownEvent.patch b/patches/server/0538-Add-PlayerItemCooldownEvent.patch similarity index 100% rename from patches/server/0539-Add-PlayerItemCooldownEvent.patch rename to patches/server/0538-Add-PlayerItemCooldownEvent.patch diff --git a/patches/server/0540-More-lightning-API.patch b/patches/server/0539-More-lightning-API.patch similarity index 100% rename from patches/server/0540-More-lightning-API.patch rename to patches/server/0539-More-lightning-API.patch diff --git a/patches/server/0541-Climbing-should-not-bypass-cramming-gamerule.patch b/patches/server/0540-Climbing-should-not-bypass-cramming-gamerule.patch similarity index 98% rename from patches/server/0541-Climbing-should-not-bypass-cramming-gamerule.patch rename to patches/server/0540-Climbing-should-not-bypass-cramming-gamerule.patch index 25859f642d..f5f3eba660 100644 --- a/patches/server/0541-Climbing-should-not-bypass-cramming-gamerule.patch +++ b/patches/server/0540-Climbing-should-not-bypass-cramming-gamerule.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Climbing should not bypass cramming gamerule diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index ab6ade77a7be2b0d67effcacbf74ed64a1beccff..cf9d0877d842b7821ea7f8981aaddcf5fa604e80 100644 +index 7f4e963c1bb37f929321e0a862f76f42ab72b4c4..9bc44cbe06bc7055c4fafff899c999b5929f468b 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -92,6 +92,11 @@ public class PaperWorldConfig { diff --git a/patches/server/0542-Added-missing-default-perms-for-commands.patch b/patches/server/0541-Added-missing-default-perms-for-commands.patch similarity index 100% rename from patches/server/0542-Added-missing-default-perms-for-commands.patch rename to patches/server/0541-Added-missing-default-perms-for-commands.patch diff --git a/patches/server/0543-Add-PlayerShearBlockEvent.patch b/patches/server/0542-Add-PlayerShearBlockEvent.patch similarity index 100% rename from patches/server/0543-Add-PlayerShearBlockEvent.patch rename to patches/server/0542-Add-PlayerShearBlockEvent.patch diff --git a/patches/server/0544-Fix-curing-zombie-villager-discount-exploit.patch b/patches/server/0543-Fix-curing-zombie-villager-discount-exploit.patch similarity index 96% rename from patches/server/0544-Fix-curing-zombie-villager-discount-exploit.patch rename to patches/server/0543-Fix-curing-zombie-villager-discount-exploit.patch index 1d9ca254e3..03542bbe10 100644 --- a/patches/server/0544-Fix-curing-zombie-villager-discount-exploit.patch +++ b/patches/server/0543-Fix-curing-zombie-villager-discount-exploit.patch @@ -8,7 +8,7 @@ and curing a villager on repeat by simply resetting the relevant part of the reputation when it is cured. diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index cf9d0877d842b7821ea7f8981aaddcf5fa604e80..1c9958d8c989add9ef062c54d5348373ddeea4cd 100644 +index 9bc44cbe06bc7055c4fafff899c999b5929f468b..fb03c7c1c2f0e090f22964973c1499271ad3dad9 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -97,6 +97,11 @@ public class PaperWorldConfig { diff --git a/patches/server/0545-Limit-recipe-packets.patch b/patches/server/0544-Limit-recipe-packets.patch similarity index 97% rename from patches/server/0545-Limit-recipe-packets.patch rename to patches/server/0544-Limit-recipe-packets.patch index f11df1c178..b845097946 100644 --- a/patches/server/0545-Limit-recipe-packets.patch +++ b/patches/server/0544-Limit-recipe-packets.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Limit recipe packets diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java -index dbfd840f2f64fa7eec5523aa2ba9e1018f4bb19d..1100f44ec9dcd7183b220028c87c79a07d3f2ff7 100644 +index bd7926fa89621e8cdd0b5fdd8ed3b8c6dbfbc3ec..f20497eb1202e3e4c256f6cf04f8644a2413fe27 100644 --- a/src/main/java/com/destroystokyo/paper/PaperConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java @@ -365,6 +365,13 @@ public class PaperConfig { diff --git a/patches/server/0546-Fix-CraftSound-backwards-compatibility.patch b/patches/server/0545-Fix-CraftSound-backwards-compatibility.patch similarity index 100% rename from patches/server/0546-Fix-CraftSound-backwards-compatibility.patch rename to patches/server/0545-Fix-CraftSound-backwards-compatibility.patch diff --git a/patches/server/0547-MC-4-Fix-item-position-desync.patch b/patches/server/0546-MC-4-Fix-item-position-desync.patch similarity index 97% rename from patches/server/0547-MC-4-Fix-item-position-desync.patch rename to patches/server/0546-MC-4-Fix-item-position-desync.patch index b81fcf460f..4f2105a4c4 100644 --- a/patches/server/0547-MC-4-Fix-item-position-desync.patch +++ b/patches/server/0546-MC-4-Fix-item-position-desync.patch @@ -9,7 +9,7 @@ loss, which forces the server to lose the same precision as the client keeping them in sync. diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java -index 1100f44ec9dcd7183b220028c87c79a07d3f2ff7..c8a49e7131d0722e4c57cc889933a43569059ba6 100644 +index f20497eb1202e3e4c256f6cf04f8644a2413fe27..d48c8e3408510cacc148e8071af95994610869a6 100644 --- a/src/main/java/com/destroystokyo/paper/PaperConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java @@ -101,6 +101,11 @@ public class PaperConfig { diff --git a/patches/server/0548-Player-Chunk-Load-Unload-Events.patch b/patches/server/0547-Player-Chunk-Load-Unload-Events.patch similarity index 100% rename from patches/server/0548-Player-Chunk-Load-Unload-Events.patch rename to patches/server/0547-Player-Chunk-Load-Unload-Events.patch diff --git a/patches/server/0549-Optimize-Dynamic-get-Missing-Keys.patch b/patches/server/0548-Optimize-Dynamic-get-Missing-Keys.patch similarity index 100% rename from patches/server/0549-Optimize-Dynamic-get-Missing-Keys.patch rename to patches/server/0548-Optimize-Dynamic-get-Missing-Keys.patch diff --git a/patches/server/0550-Expose-LivingEntity-hurt-direction.patch b/patches/server/0549-Expose-LivingEntity-hurt-direction.patch similarity index 100% rename from patches/server/0550-Expose-LivingEntity-hurt-direction.patch rename to patches/server/0549-Expose-LivingEntity-hurt-direction.patch diff --git a/patches/server/0551-Add-OBSTRUCTED-reason-to-BedEnterResult.patch b/patches/server/0550-Add-OBSTRUCTED-reason-to-BedEnterResult.patch similarity index 100% rename from patches/server/0551-Add-OBSTRUCTED-reason-to-BedEnterResult.patch rename to patches/server/0550-Add-OBSTRUCTED-reason-to-BedEnterResult.patch diff --git a/patches/server/0552-Do-not-crash-from-invalid-ingredient-lists-in-Villag.patch b/patches/server/0551-Do-not-crash-from-invalid-ingredient-lists-in-Villag.patch similarity index 100% rename from patches/server/0552-Do-not-crash-from-invalid-ingredient-lists-in-Villag.patch rename to patches/server/0551-Do-not-crash-from-invalid-ingredient-lists-in-Villag.patch diff --git a/patches/server/0553-Add-PlayerTradeEvent-and-PlayerPurchaseEvent.patch b/patches/server/0552-Add-PlayerTradeEvent-and-PlayerPurchaseEvent.patch similarity index 100% rename from patches/server/0553-Add-PlayerTradeEvent-and-PlayerPurchaseEvent.patch rename to patches/server/0552-Add-PlayerTradeEvent-and-PlayerPurchaseEvent.patch diff --git a/patches/server/0554-Implement-TargetHitEvent.patch b/patches/server/0553-Implement-TargetHitEvent.patch similarity index 100% rename from patches/server/0554-Implement-TargetHitEvent.patch rename to patches/server/0553-Implement-TargetHitEvent.patch diff --git a/patches/server/0555-Additional-Block-Material-API-s.patch b/patches/server/0554-Additional-Block-Material-API-s.patch similarity index 100% rename from patches/server/0555-Additional-Block-Material-API-s.patch rename to patches/server/0554-Additional-Block-Material-API-s.patch diff --git a/patches/server/0556-Fix-harming-potion-dupe.patch b/patches/server/0555-Fix-harming-potion-dupe.patch similarity index 100% rename from patches/server/0556-Fix-harming-potion-dupe.patch rename to patches/server/0555-Fix-harming-potion-dupe.patch diff --git a/patches/server/0557-Implement-API-to-get-Material-from-Boats-and-Minecar.patch b/patches/server/0556-Implement-API-to-get-Material-from-Boats-and-Minecar.patch similarity index 100% rename from patches/server/0557-Implement-API-to-get-Material-from-Boats-and-Minecar.patch rename to patches/server/0556-Implement-API-to-get-Material-from-Boats-and-Minecar.patch diff --git a/patches/server/0558-Cache-burn-durations.patch b/patches/server/0557-Cache-burn-durations.patch similarity index 100% rename from patches/server/0558-Cache-burn-durations.patch rename to patches/server/0557-Cache-burn-durations.patch diff --git a/patches/server/0559-Allow-disabling-mob-spawner-spawn-egg-transformation.patch b/patches/server/0558-Allow-disabling-mob-spawner-spawn-egg-transformation.patch similarity index 95% rename from patches/server/0559-Allow-disabling-mob-spawner-spawn-egg-transformation.patch rename to patches/server/0558-Allow-disabling-mob-spawner-spawn-egg-transformation.patch index 204a15a905..5109435f95 100644 --- a/patches/server/0559-Allow-disabling-mob-spawner-spawn-egg-transformation.patch +++ b/patches/server/0558-Allow-disabling-mob-spawner-spawn-egg-transformation.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Allow disabling mob spawner spawn egg transformation diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index 1c9958d8c989add9ef062c54d5348373ddeea4cd..98e7bd4c85ed9f6bb063dfc3b0e4b80150a86835 100644 +index fb03c7c1c2f0e090f22964973c1499271ad3dad9..3ad93abb830d307a0d2cf8cb4554bf3fa37cb91d 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -102,6 +102,11 @@ public class PaperWorldConfig { diff --git a/patches/server/0560-Fix-Not-a-string-Map-Conversion-spam.patch b/patches/server/0559-Fix-Not-a-string-Map-Conversion-spam.patch similarity index 100% rename from patches/server/0560-Fix-Not-a-string-Map-Conversion-spam.patch rename to patches/server/0559-Fix-Not-a-string-Map-Conversion-spam.patch diff --git a/patches/server/0561-Implement-PlayerFlowerPotManipulateEvent.patch b/patches/server/0560-Implement-PlayerFlowerPotManipulateEvent.patch similarity index 100% rename from patches/server/0561-Implement-PlayerFlowerPotManipulateEvent.patch rename to patches/server/0560-Implement-PlayerFlowerPotManipulateEvent.patch diff --git a/patches/server/0562-Fix-interact-event-not-being-called-in-adventure.patch b/patches/server/0561-Fix-interact-event-not-being-called-in-adventure.patch similarity index 100% rename from patches/server/0562-Fix-interact-event-not-being-called-in-adventure.patch rename to patches/server/0561-Fix-interact-event-not-being-called-in-adventure.patch diff --git a/patches/server/0563-Zombie-API-breaking-doors.patch b/patches/server/0562-Zombie-API-breaking-doors.patch similarity index 100% rename from patches/server/0563-Zombie-API-breaking-doors.patch rename to patches/server/0562-Zombie-API-breaking-doors.patch diff --git a/patches/server/0564-Fix-nerfed-slime-when-splitting.patch b/patches/server/0563-Fix-nerfed-slime-when-splitting.patch similarity index 100% rename from patches/server/0564-Fix-nerfed-slime-when-splitting.patch rename to patches/server/0563-Fix-nerfed-slime-when-splitting.patch diff --git a/patches/server/0565-Add-EntityLoadCrossbowEvent.patch b/patches/server/0564-Add-EntityLoadCrossbowEvent.patch similarity index 100% rename from patches/server/0565-Add-EntityLoadCrossbowEvent.patch rename to patches/server/0564-Add-EntityLoadCrossbowEvent.patch diff --git a/patches/server/0566-Guardian-beam-workaround.patch b/patches/server/0565-Guardian-beam-workaround.patch similarity index 100% rename from patches/server/0566-Guardian-beam-workaround.patch rename to patches/server/0565-Guardian-beam-workaround.patch diff --git a/patches/server/0567-Added-WorldGameRuleChangeEvent.patch b/patches/server/0566-Added-WorldGameRuleChangeEvent.patch similarity index 100% rename from patches/server/0567-Added-WorldGameRuleChangeEvent.patch rename to patches/server/0566-Added-WorldGameRuleChangeEvent.patch diff --git a/patches/server/0568-Added-ServerResourcesReloadedEvent.patch b/patches/server/0567-Added-ServerResourcesReloadedEvent.patch similarity index 100% rename from patches/server/0568-Added-ServerResourcesReloadedEvent.patch rename to patches/server/0567-Added-ServerResourcesReloadedEvent.patch diff --git a/patches/server/0569-Added-world-settings-for-mobs-picking-up-loot.patch b/patches/server/0568-Added-world-settings-for-mobs-picking-up-loot.patch similarity index 100% rename from patches/server/0569-Added-world-settings-for-mobs-picking-up-loot.patch rename to patches/server/0568-Added-world-settings-for-mobs-picking-up-loot.patch diff --git a/patches/server/0570-Implemented-BlockFailedDispenseEvent.patch b/patches/server/0569-Implemented-BlockFailedDispenseEvent.patch similarity index 100% rename from patches/server/0570-Implemented-BlockFailedDispenseEvent.patch rename to patches/server/0569-Implemented-BlockFailedDispenseEvent.patch diff --git a/patches/server/0571-Added-PlayerLecternPageChangeEvent.patch b/patches/server/0570-Added-PlayerLecternPageChangeEvent.patch similarity index 100% rename from patches/server/0571-Added-PlayerLecternPageChangeEvent.patch rename to patches/server/0570-Added-PlayerLecternPageChangeEvent.patch diff --git a/patches/server/0572-Added-PlayerLoomPatternSelectEvent.patch b/patches/server/0571-Added-PlayerLoomPatternSelectEvent.patch similarity index 100% rename from patches/server/0572-Added-PlayerLoomPatternSelectEvent.patch rename to patches/server/0571-Added-PlayerLoomPatternSelectEvent.patch diff --git a/patches/server/0573-Configurable-door-breaking-difficulty.patch b/patches/server/0572-Configurable-door-breaking-difficulty.patch similarity index 97% rename from patches/server/0573-Configurable-door-breaking-difficulty.patch rename to patches/server/0572-Configurable-door-breaking-difficulty.patch index 82f9d6d017..4131ea9ff1 100644 --- a/patches/server/0573-Configurable-door-breaking-difficulty.patch +++ b/patches/server/0572-Configurable-door-breaking-difficulty.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Configurable door breaking difficulty diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index 53681d342935feb4d0f0428df751a4f8004e783e..ad355eaf5e597be9c35fbf0a635944b16603bdc2 100644 +index 556bf08491466a061119338a05d6165d041e6668..79c8618eb1300239d457013c44d47277e2962904 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -6,6 +6,9 @@ import java.util.stream.Collectors; diff --git a/patches/server/0574-Empty-commands-shall-not-be-dispatched.patch b/patches/server/0573-Empty-commands-shall-not-be-dispatched.patch similarity index 100% rename from patches/server/0574-Empty-commands-shall-not-be-dispatched.patch rename to patches/server/0573-Empty-commands-shall-not-be-dispatched.patch diff --git a/patches/server/0575-Implement-API-to-expose-exact-interaction-point.patch b/patches/server/0574-Implement-API-to-expose-exact-interaction-point.patch similarity index 100% rename from patches/server/0575-Implement-API-to-expose-exact-interaction-point.patch rename to patches/server/0574-Implement-API-to-expose-exact-interaction-point.patch diff --git a/patches/server/0576-Remove-stale-POIs.patch b/patches/server/0575-Remove-stale-POIs.patch similarity index 100% rename from patches/server/0576-Remove-stale-POIs.patch rename to patches/server/0575-Remove-stale-POIs.patch diff --git a/patches/server/0577-Fix-villager-boat-exploit.patch b/patches/server/0576-Fix-villager-boat-exploit.patch similarity index 93% rename from patches/server/0577-Fix-villager-boat-exploit.patch rename to patches/server/0576-Fix-villager-boat-exploit.patch index 9ba01c2257..12ae3a8b80 100644 --- a/patches/server/0577-Fix-villager-boat-exploit.patch +++ b/patches/server/0576-Fix-villager-boat-exploit.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Fix villager boat exploit diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index d0c824290c08f825956ec1396381ec1657a6476d..ef1b4c290a9dee365a353a9ab26159ef399f0425 100644 +index e7834772e38e61df405be406fe320a646778175a..236641fa4c325e455de0a5ad83541143f5bc18d1 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java @@ -621,6 +621,14 @@ public abstract class PlayerList { diff --git a/patches/server/0578-Add-sendOpLevel-API.patch b/patches/server/0577-Add-sendOpLevel-API.patch similarity index 100% rename from patches/server/0578-Add-sendOpLevel-API.patch rename to patches/server/0577-Add-sendOpLevel-API.patch diff --git a/patches/server/0579-Add-StructureLocateEvent.patch b/patches/server/0578-Add-StructureLocateEvent.patch similarity index 100% rename from patches/server/0579-Add-StructureLocateEvent.patch rename to patches/server/0578-Add-StructureLocateEvent.patch diff --git a/patches/server/0580-Collision-option-for-requiring-a-player-participant.patch b/patches/server/0579-Collision-option-for-requiring-a-player-participant.patch similarity index 97% rename from patches/server/0580-Collision-option-for-requiring-a-player-participant.patch rename to patches/server/0579-Collision-option-for-requiring-a-player-participant.patch index fce3f00ef1..ad984fbd2a 100644 --- a/patches/server/0580-Collision-option-for-requiring-a-player-participant.patch +++ b/patches/server/0579-Collision-option-for-requiring-a-player-participant.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Collision option for requiring a player participant diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index ad355eaf5e597be9c35fbf0a635944b16603bdc2..44319f7ebd5e97435b4a4068d638946b74159cf1 100644 +index 79c8618eb1300239d457013c44d47277e2962904..a1c0b9770f4f9b84778db9b42c097af146485420 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -82,6 +82,18 @@ public class PaperWorldConfig { diff --git a/patches/server/0581-Remove-ProjectileHitEvent-call-when-fireballs-dead.patch b/patches/server/0580-Remove-ProjectileHitEvent-call-when-fireballs-dead.patch similarity index 100% rename from patches/server/0581-Remove-ProjectileHitEvent-call-when-fireballs-dead.patch rename to patches/server/0580-Remove-ProjectileHitEvent-call-when-fireballs-dead.patch diff --git a/patches/server/0582-Return-chat-component-with-empty-text-instead-of-thr.patch b/patches/server/0581-Return-chat-component-with-empty-text-instead-of-thr.patch similarity index 100% rename from patches/server/0582-Return-chat-component-with-empty-text-instead-of-thr.patch rename to patches/server/0581-Return-chat-component-with-empty-text-instead-of-thr.patch diff --git a/patches/server/0583-Make-schedule-command-per-world.patch b/patches/server/0582-Make-schedule-command-per-world.patch similarity index 100% rename from patches/server/0583-Make-schedule-command-per-world.patch rename to patches/server/0582-Make-schedule-command-per-world.patch diff --git a/patches/server/0584-Configurable-max-leash-distance.patch b/patches/server/0583-Configurable-max-leash-distance.patch similarity index 100% rename from patches/server/0584-Configurable-max-leash-distance.patch rename to patches/server/0583-Configurable-max-leash-distance.patch diff --git a/patches/server/0585-Implement-BlockPreDispenseEvent.patch b/patches/server/0584-Implement-BlockPreDispenseEvent.patch similarity index 100% rename from patches/server/0585-Implement-BlockPreDispenseEvent.patch rename to patches/server/0584-Implement-BlockPreDispenseEvent.patch diff --git a/patches/server/0586-added-Wither-API.patch b/patches/server/0585-added-Wither-API.patch similarity index 100% rename from patches/server/0586-added-Wither-API.patch rename to patches/server/0585-added-Wither-API.patch diff --git a/patches/server/0587-Added-firing-of-PlayerChangeBeaconEffectEvent.patch b/patches/server/0586-Added-firing-of-PlayerChangeBeaconEffectEvent.patch similarity index 100% rename from patches/server/0587-Added-firing-of-PlayerChangeBeaconEffectEvent.patch rename to patches/server/0586-Added-firing-of-PlayerChangeBeaconEffectEvent.patch diff --git a/patches/server/0588-Add-toggle-for-always-placing-the-dragon-egg.patch b/patches/server/0587-Add-toggle-for-always-placing-the-dragon-egg.patch similarity index 100% rename from patches/server/0588-Add-toggle-for-always-placing-the-dragon-egg.patch rename to patches/server/0587-Add-toggle-for-always-placing-the-dragon-egg.patch diff --git a/patches/server/0589-Added-PlayerStonecutterRecipeSelectEvent.patch b/patches/server/0588-Added-PlayerStonecutterRecipeSelectEvent.patch similarity index 100% rename from patches/server/0589-Added-PlayerStonecutterRecipeSelectEvent.patch rename to patches/server/0588-Added-PlayerStonecutterRecipeSelectEvent.patch diff --git a/patches/server/0590-Add-dropLeash-variable-to-EntityUnleashEvent.patch b/patches/server/0589-Add-dropLeash-variable-to-EntityUnleashEvent.patch similarity index 100% rename from patches/server/0590-Add-dropLeash-variable-to-EntityUnleashEvent.patch rename to patches/server/0589-Add-dropLeash-variable-to-EntityUnleashEvent.patch diff --git a/patches/server/0591-Skip-distance-map-update-when-spawning-disabled.patch b/patches/server/0590-Skip-distance-map-update-when-spawning-disabled.patch similarity index 100% rename from patches/server/0591-Skip-distance-map-update-when-spawning-disabled.patch rename to patches/server/0590-Skip-distance-map-update-when-spawning-disabled.patch diff --git a/patches/server/0592-Reset-shield-blocking-on-dimension-change.patch b/patches/server/0591-Reset-shield-blocking-on-dimension-change.patch similarity index 100% rename from patches/server/0592-Reset-shield-blocking-on-dimension-change.patch rename to patches/server/0591-Reset-shield-blocking-on-dimension-change.patch diff --git a/patches/server/0593-add-DragonEggFormEvent.patch b/patches/server/0592-add-DragonEggFormEvent.patch similarity index 100% rename from patches/server/0593-add-DragonEggFormEvent.patch rename to patches/server/0592-add-DragonEggFormEvent.patch diff --git a/patches/server/0594-EntityMoveEvent.patch b/patches/server/0593-EntityMoveEvent.patch similarity index 100% rename from patches/server/0594-EntityMoveEvent.patch rename to patches/server/0593-EntityMoveEvent.patch diff --git a/patches/server/0595-added-option-to-disable-pathfinding-updates-on-block.patch b/patches/server/0594-added-option-to-disable-pathfinding-updates-on-block.patch similarity index 100% rename from patches/server/0595-added-option-to-disable-pathfinding-updates-on-block.patch rename to patches/server/0594-added-option-to-disable-pathfinding-updates-on-block.patch diff --git a/patches/server/0596-Inline-shift-direction-fields.patch b/patches/server/0595-Inline-shift-direction-fields.patch similarity index 100% rename from patches/server/0596-Inline-shift-direction-fields.patch rename to patches/server/0595-Inline-shift-direction-fields.patch diff --git a/patches/server/0597-Allow-adding-items-to-BlockDropItemEvent.patch b/patches/server/0596-Allow-adding-items-to-BlockDropItemEvent.patch similarity index 100% rename from patches/server/0597-Allow-adding-items-to-BlockDropItemEvent.patch rename to patches/server/0596-Allow-adding-items-to-BlockDropItemEvent.patch diff --git a/patches/server/0598-Add-getMainThreadExecutor-to-BukkitScheduler.patch b/patches/server/0597-Add-getMainThreadExecutor-to-BukkitScheduler.patch similarity index 100% rename from patches/server/0598-Add-getMainThreadExecutor-to-BukkitScheduler.patch rename to patches/server/0597-Add-getMainThreadExecutor-to-BukkitScheduler.patch diff --git a/patches/server/0599-living-entity-allow-attribute-registration.patch b/patches/server/0598-living-entity-allow-attribute-registration.patch similarity index 100% rename from patches/server/0599-living-entity-allow-attribute-registration.patch rename to patches/server/0598-living-entity-allow-attribute-registration.patch diff --git a/patches/server/0600-fix-dead-slime-setSize-invincibility.patch b/patches/server/0599-fix-dead-slime-setSize-invincibility.patch similarity index 100% rename from patches/server/0600-fix-dead-slime-setSize-invincibility.patch rename to patches/server/0599-fix-dead-slime-setSize-invincibility.patch diff --git a/patches/server/0601-Merchant-getRecipes-should-return-an-immutable-list.patch b/patches/server/0600-Merchant-getRecipes-should-return-an-immutable-list.patch similarity index 100% rename from patches/server/0601-Merchant-getRecipes-should-return-an-immutable-list.patch rename to patches/server/0600-Merchant-getRecipes-should-return-an-immutable-list.patch diff --git a/patches/server/0602-Add-support-for-hex-color-codes-in-console.patch b/patches/server/0601-Add-support-for-hex-color-codes-in-console.patch similarity index 100% rename from patches/server/0602-Add-support-for-hex-color-codes-in-console.patch rename to patches/server/0601-Add-support-for-hex-color-codes-in-console.patch diff --git a/patches/server/0603-Expose-Tracked-Players.patch b/patches/server/0602-Expose-Tracked-Players.patch similarity index 100% rename from patches/server/0603-Expose-Tracked-Players.patch rename to patches/server/0602-Expose-Tracked-Players.patch diff --git a/patches/server/0604-Remove-streams-from-SensorNearest.patch b/patches/server/0603-Remove-streams-from-SensorNearest.patch similarity index 100% rename from patches/server/0604-Remove-streams-from-SensorNearest.patch rename to patches/server/0603-Remove-streams-from-SensorNearest.patch diff --git a/patches/server/0605-Throw-proper-exception-on-empty-JsonList-file.patch b/patches/server/0604-Throw-proper-exception-on-empty-JsonList-file.patch similarity index 100% rename from patches/server/0605-Throw-proper-exception-on-empty-JsonList-file.patch rename to patches/server/0604-Throw-proper-exception-on-empty-JsonList-file.patch diff --git a/patches/server/0606-Improve-ServerGUI.patch b/patches/server/0605-Improve-ServerGUI.patch similarity index 100% rename from patches/server/0606-Improve-ServerGUI.patch rename to patches/server/0605-Improve-ServerGUI.patch diff --git a/patches/server/0607-stop-firing-pressure-plate-EntityInteractEvent-for-i.patch b/patches/server/0606-stop-firing-pressure-plate-EntityInteractEvent-for-i.patch similarity index 100% rename from patches/server/0607-stop-firing-pressure-plate-EntityInteractEvent-for-i.patch rename to patches/server/0606-stop-firing-pressure-plate-EntityInteractEvent-for-i.patch diff --git a/patches/server/0608-fix-converting-txt-to-json-file.patch b/patches/server/0607-fix-converting-txt-to-json-file.patch similarity index 97% rename from patches/server/0608-fix-converting-txt-to-json-file.patch rename to patches/server/0607-fix-converting-txt-to-json-file.patch index 3bc971a05d..2f1dd0a239 100644 --- a/patches/server/0608-fix-converting-txt-to-json-file.patch +++ b/patches/server/0607-fix-converting-txt-to-json-file.patch @@ -48,7 +48,7 @@ index e968b880e435b8753314d85b919a0abc4f35be25..02d7b16f81ebf9f902a36d4f31802b20 if (!OldUsersConverter.serverReadyAfterUserconversion(this)) { return false; diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index a841435338d6c242be35441d902ef2749ea6d406..c6f98a9fbfc058ca22b54eee9ac73ade697a5e9f 100644 +index e04e4cf62d2a7dcf95ffee452dc2ee2e2a4fdf6f..5077991ca54f848a2e1a3e2f375f0957f68113bd 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java @@ -174,6 +174,7 @@ public abstract class PlayerList { diff --git a/patches/server/0609-Add-worldborder-events.patch b/patches/server/0608-Add-worldborder-events.patch similarity index 100% rename from patches/server/0609-Add-worldborder-events.patch rename to patches/server/0608-Add-worldborder-events.patch diff --git a/patches/server/0610-added-PlayerNameEntityEvent.patch b/patches/server/0609-added-PlayerNameEntityEvent.patch similarity index 100% rename from patches/server/0610-added-PlayerNameEntityEvent.patch rename to patches/server/0609-added-PlayerNameEntityEvent.patch diff --git a/patches/server/0611-Prevent-grindstones-from-overstacking-items.patch b/patches/server/0610-Prevent-grindstones-from-overstacking-items.patch similarity index 100% rename from patches/server/0611-Prevent-grindstones-from-overstacking-items.patch rename to patches/server/0610-Prevent-grindstones-from-overstacking-items.patch diff --git a/patches/server/0612-Add-recipe-to-cook-events.patch b/patches/server/0611-Add-recipe-to-cook-events.patch similarity index 100% rename from patches/server/0612-Add-recipe-to-cook-events.patch rename to patches/server/0611-Add-recipe-to-cook-events.patch diff --git a/patches/server/0613-Add-Block-isValidTool.patch b/patches/server/0612-Add-Block-isValidTool.patch similarity index 100% rename from patches/server/0613-Add-Block-isValidTool.patch rename to patches/server/0612-Add-Block-isValidTool.patch diff --git a/patches/server/0614-Allow-using-signs-inside-spawn-protection.patch b/patches/server/0613-Allow-using-signs-inside-spawn-protection.patch similarity index 100% rename from patches/server/0614-Allow-using-signs-inside-spawn-protection.patch rename to patches/server/0613-Allow-using-signs-inside-spawn-protection.patch diff --git a/patches/server/0615-Implement-Keyed-on-World.patch b/patches/server/0614-Implement-Keyed-on-World.patch similarity index 100% rename from patches/server/0615-Implement-Keyed-on-World.patch rename to patches/server/0614-Implement-Keyed-on-World.patch diff --git a/patches/server/0616-Add-fast-alternative-constructor-for-Rotations.patch b/patches/server/0615-Add-fast-alternative-constructor-for-Rotations.patch similarity index 100% rename from patches/server/0616-Add-fast-alternative-constructor-for-Rotations.patch rename to patches/server/0615-Add-fast-alternative-constructor-for-Rotations.patch diff --git a/patches/server/0617-Item-Rarity-API.patch b/patches/server/0616-Item-Rarity-API.patch similarity index 96% rename from patches/server/0617-Item-Rarity-API.patch rename to patches/server/0616-Item-Rarity-API.patch index a87f26bb6e..4deefe1dde 100644 --- a/patches/server/0617-Item-Rarity-API.patch +++ b/patches/server/0616-Item-Rarity-API.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Item Rarity API diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -index 463cabee7f4f40f2f8d4f4502296d1abfff18229..6ef091d64a2b7a61fabc7c325c90754f4b500bff 100644 +index de6343455ce92835f3e5bc2646f64c03dab8aba2..a76516003fe2c2c713658837de992bf237fec9ad 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -476,6 +476,20 @@ public final class CraftMagicNumbers implements UnsafeValues { diff --git a/patches/server/0618-Only-set-despawnTimer-for-Wandering-Traders-spawned-.patch b/patches/server/0617-Only-set-despawnTimer-for-Wandering-Traders-spawned-.patch similarity index 100% rename from patches/server/0618-Only-set-despawnTimer-for-Wandering-Traders-spawned-.patch rename to patches/server/0617-Only-set-despawnTimer-for-Wandering-Traders-spawned-.patch diff --git a/patches/server/0619-copy-TESign-isEditable-from-snapshots.patch b/patches/server/0618-copy-TESign-isEditable-from-snapshots.patch similarity index 100% rename from patches/server/0619-copy-TESign-isEditable-from-snapshots.patch rename to patches/server/0618-copy-TESign-isEditable-from-snapshots.patch diff --git a/patches/server/0620-Drop-carried-item-when-player-has-disconnected.patch b/patches/server/0619-Drop-carried-item-when-player-has-disconnected.patch similarity index 92% rename from patches/server/0620-Drop-carried-item-when-player-has-disconnected.patch rename to patches/server/0619-Drop-carried-item-when-player-has-disconnected.patch index c4fdb55289..c4ba936379 100644 --- a/patches/server/0620-Drop-carried-item-when-player-has-disconnected.patch +++ b/patches/server/0619-Drop-carried-item-when-player-has-disconnected.patch @@ -7,7 +7,7 @@ Fixes disappearance of held items, when a player gets disconnected and PlayerDro Closes #5036 diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index c6f98a9fbfc058ca22b54eee9ac73ade697a5e9f..b0b3775a706a52fd02eff745ff8f0a9b97de4cf8 100644 +index 5077991ca54f848a2e1a3e2f375f0957f68113bd..29864d3c25cea7bbb84a431a82e7b80f4af2966d 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java @@ -614,6 +614,14 @@ public abstract class PlayerList { diff --git a/patches/server/0621-forced-whitelist-use-configurable-kick-message.patch b/patches/server/0620-forced-whitelist-use-configurable-kick-message.patch similarity index 100% rename from patches/server/0621-forced-whitelist-use-configurable-kick-message.patch rename to patches/server/0620-forced-whitelist-use-configurable-kick-message.patch diff --git a/patches/server/0622-Don-t-ignore-result-of-PlayerEditBookEvent.patch b/patches/server/0621-Don-t-ignore-result-of-PlayerEditBookEvent.patch similarity index 100% rename from patches/server/0622-Don-t-ignore-result-of-PlayerEditBookEvent.patch rename to patches/server/0621-Don-t-ignore-result-of-PlayerEditBookEvent.patch diff --git a/patches/server/0623-Entity-load-save-limit-per-chunk.patch b/patches/server/0622-Entity-load-save-limit-per-chunk.patch similarity index 98% rename from patches/server/0623-Entity-load-save-limit-per-chunk.patch rename to patches/server/0622-Entity-load-save-limit-per-chunk.patch index 6deab2675e..2bdf1a9c3b 100644 --- a/patches/server/0623-Entity-load-save-limit-per-chunk.patch +++ b/patches/server/0622-Entity-load-save-limit-per-chunk.patch @@ -9,7 +9,7 @@ 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 85203627790204cf899f955781b4e876e23e0809..f754ca5e10cc7709fc2a67eb48861da01300292f 100644 +index 9fc14f3102e2ceb10b80974fabb5c4513e17e63f..cc4c067ad70375f76ddede403b88e76f3c8f37da 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -6,7 +6,10 @@ import java.util.stream.Collectors; diff --git a/patches/server/0624-fix-cancelling-block-falling-causing-client-desync.patch b/patches/server/0623-fix-cancelling-block-falling-causing-client-desync.patch similarity index 100% rename from patches/server/0624-fix-cancelling-block-falling-causing-client-desync.patch rename to patches/server/0623-fix-cancelling-block-falling-causing-client-desync.patch diff --git a/patches/server/0625-Expose-protocol-version.patch b/patches/server/0624-Expose-protocol-version.patch similarity index 91% rename from patches/server/0625-Expose-protocol-version.patch rename to patches/server/0624-Expose-protocol-version.patch index 84f610e670..5e797761af 100644 --- a/patches/server/0625-Expose-protocol-version.patch +++ b/patches/server/0624-Expose-protocol-version.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Expose protocol version diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -index 6ef091d64a2b7a61fabc7c325c90754f4b500bff..80dc84864755bf46b9be46d69cd23f588628f9bd 100644 +index a76516003fe2c2c713658837de992bf237fec9ad..3a7b7a0766075e8a7d359138ca01dbcc88c609a3 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -490,6 +490,11 @@ public final class CraftMagicNumbers implements UnsafeValues { diff --git a/patches/server/0626-Allow-for-Component-suggestion-tooltips-in-AsyncTabC.patch b/patches/server/0625-Allow-for-Component-suggestion-tooltips-in-AsyncTabC.patch similarity index 100% rename from patches/server/0626-Allow-for-Component-suggestion-tooltips-in-AsyncTabC.patch rename to patches/server/0625-Allow-for-Component-suggestion-tooltips-in-AsyncTabC.patch diff --git a/patches/server/0627-Enhance-console-tab-completions-for-brigadier-comman.patch b/patches/server/0626-Enhance-console-tab-completions-for-brigadier-comman.patch similarity index 99% rename from patches/server/0627-Enhance-console-tab-completions-for-brigadier-comman.patch rename to patches/server/0626-Enhance-console-tab-completions-for-brigadier-comman.patch index 0f242b9384..139325cbeb 100644 --- a/patches/server/0627-Enhance-console-tab-completions-for-brigadier-comman.patch +++ b/patches/server/0626-Enhance-console-tab-completions-for-brigadier-comman.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Enhance console tab completions for brigadier commands diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java -index c8a49e7131d0722e4c57cc889933a43569059ba6..bf256ffaf9311d04712fdba38d529283a5330b09 100644 +index d48c8e3408510cacc148e8071af95994610869a6..ae7ca7fbed3a1a4532a78bb8a029bb7fc642bcb3 100644 --- a/src/main/java/com/destroystokyo/paper/PaperConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java @@ -106,6 +106,13 @@ public class PaperConfig { diff --git a/patches/server/0628-Fix-PlayerItemConsumeEvent-cancelling-properly.patch b/patches/server/0627-Fix-PlayerItemConsumeEvent-cancelling-properly.patch similarity index 100% rename from patches/server/0628-Fix-PlayerItemConsumeEvent-cancelling-properly.patch rename to patches/server/0627-Fix-PlayerItemConsumeEvent-cancelling-properly.patch diff --git a/patches/server/0629-Add-bypass-host-check.patch b/patches/server/0628-Add-bypass-host-check.patch similarity index 100% rename from patches/server/0629-Add-bypass-host-check.patch rename to patches/server/0628-Add-bypass-host-check.patch diff --git a/patches/server/0630-Set-area-affect-cloud-rotation.patch b/patches/server/0629-Set-area-affect-cloud-rotation.patch similarity index 92% rename from patches/server/0630-Set-area-affect-cloud-rotation.patch rename to patches/server/0629-Set-area-affect-cloud-rotation.patch index 44fd4f57d2..b7cb1837b3 100644 --- a/patches/server/0630-Set-area-affect-cloud-rotation.patch +++ b/patches/server/0629-Set-area-affect-cloud-rotation.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Set area affect cloud rotation diff --git a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java -index 8eb7a4579d8296b0090f9cfa215562a52fa51d75..9653604f05eb3170f4b5dca60e05f3d55db9f508 100644 +index e9d6df8339dec597e646ab3e55fb7e032664908e..15341c07f9e07ba1d875ef9de16476c07751cab6 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java @@ -885,6 +885,7 @@ public abstract class CraftRegionAccessor implements RegionAccessor { diff --git a/patches/server/0631-add-isDeeplySleeping-to-HumanEntity.patch b/patches/server/0630-add-isDeeplySleeping-to-HumanEntity.patch similarity index 100% rename from patches/server/0631-add-isDeeplySleeping-to-HumanEntity.patch rename to patches/server/0630-add-isDeeplySleeping-to-HumanEntity.patch diff --git a/patches/server/0632-Fix-duplicating-give-items-on-item-drop-cancel.patch b/patches/server/0631-Fix-duplicating-give-items-on-item-drop-cancel.patch similarity index 100% rename from patches/server/0632-Fix-duplicating-give-items-on-item-drop-cancel.patch rename to patches/server/0631-Fix-duplicating-give-items-on-item-drop-cancel.patch diff --git a/patches/server/0633-add-consumeFuel-to-FurnaceBurnEvent.patch b/patches/server/0632-add-consumeFuel-to-FurnaceBurnEvent.patch similarity index 100% rename from patches/server/0633-add-consumeFuel-to-FurnaceBurnEvent.patch rename to patches/server/0632-add-consumeFuel-to-FurnaceBurnEvent.patch diff --git a/patches/server/0634-add-get-set-drop-chance-to-EntityEquipment.patch b/patches/server/0633-add-get-set-drop-chance-to-EntityEquipment.patch similarity index 100% rename from patches/server/0634-add-get-set-drop-chance-to-EntityEquipment.patch rename to patches/server/0633-add-get-set-drop-chance-to-EntityEquipment.patch diff --git a/patches/server/0635-fix-PigZombieAngerEvent-cancellation.patch b/patches/server/0634-fix-PigZombieAngerEvent-cancellation.patch similarity index 100% rename from patches/server/0635-fix-PigZombieAngerEvent-cancellation.patch rename to patches/server/0634-fix-PigZombieAngerEvent-cancellation.patch diff --git a/patches/server/0636-Fix-checkReach-check-for-Shulker-boxes.patch b/patches/server/0635-Fix-checkReach-check-for-Shulker-boxes.patch similarity index 100% rename from patches/server/0636-Fix-checkReach-check-for-Shulker-boxes.patch rename to patches/server/0635-Fix-checkReach-check-for-Shulker-boxes.patch diff --git a/patches/server/0637-fix-PlayerItemHeldEvent-firing-twice.patch b/patches/server/0636-fix-PlayerItemHeldEvent-firing-twice.patch similarity index 100% rename from patches/server/0637-fix-PlayerItemHeldEvent-firing-twice.patch rename to patches/server/0636-fix-PlayerItemHeldEvent-firing-twice.patch diff --git a/patches/server/0638-Added-PlayerDeepSleepEvent.patch b/patches/server/0637-Added-PlayerDeepSleepEvent.patch similarity index 100% rename from patches/server/0638-Added-PlayerDeepSleepEvent.patch rename to patches/server/0637-Added-PlayerDeepSleepEvent.patch diff --git a/patches/server/0639-More-World-API.patch b/patches/server/0638-More-World-API.patch similarity index 100% rename from patches/server/0639-More-World-API.patch rename to patches/server/0638-More-World-API.patch diff --git a/patches/server/0640-Added-PlayerBedFailEnterEvent.patch b/patches/server/0639-Added-PlayerBedFailEnterEvent.patch similarity index 100% rename from patches/server/0640-Added-PlayerBedFailEnterEvent.patch rename to patches/server/0639-Added-PlayerBedFailEnterEvent.patch diff --git a/patches/server/0641-Implement-methods-to-convert-between-Component-and-B.patch b/patches/server/0640-Implement-methods-to-convert-between-Component-and-B.patch similarity index 100% rename from patches/server/0641-Implement-methods-to-convert-between-Component-and-B.patch rename to patches/server/0640-Implement-methods-to-convert-between-Component-and-B.patch diff --git a/patches/server/0642-Fix-anchor-respawn-acting-as-a-bed-respawn-from-the-.patch b/patches/server/0641-Fix-anchor-respawn-acting-as-a-bed-respawn-from-the-.patch similarity index 95% rename from patches/server/0642-Fix-anchor-respawn-acting-as-a-bed-respawn-from-the-.patch rename to patches/server/0641-Fix-anchor-respawn-acting-as-a-bed-respawn-from-the-.patch index 5ea281a039..5046cc4ab7 100644 --- a/patches/server/0642-Fix-anchor-respawn-acting-as-a-bed-respawn-from-the-.patch +++ b/patches/server/0641-Fix-anchor-respawn-acting-as-a-bed-respawn-from-the-.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Fix anchor respawn acting as a bed respawn from the end diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index b0b3775a706a52fd02eff745ff8f0a9b97de4cf8..0ccbe77e8ca58dbe8cbbe04d99a3e6181fee1e9d 100644 +index 29864d3c25cea7bbb84a431a82e7b80f4af2966d..5f099d45203f155abb23c9241b55d34e04f2aa7e 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java @@ -847,6 +847,7 @@ public abstract class PlayerList { diff --git a/patches/server/0643-Introduce-beacon-activation-deactivation-events.patch b/patches/server/0642-Introduce-beacon-activation-deactivation-events.patch similarity index 100% rename from patches/server/0643-Introduce-beacon-activation-deactivation-events.patch rename to patches/server/0642-Introduce-beacon-activation-deactivation-events.patch diff --git a/patches/server/0644-add-RespawnFlags-to-PlayerRespawnEvent.patch b/patches/server/0643-add-RespawnFlags-to-PlayerRespawnEvent.patch similarity index 97% rename from patches/server/0644-add-RespawnFlags-to-PlayerRespawnEvent.patch rename to patches/server/0643-add-RespawnFlags-to-PlayerRespawnEvent.patch index 9a184cebbf..187ae5be21 100644 --- a/patches/server/0644-add-RespawnFlags-to-PlayerRespawnEvent.patch +++ b/patches/server/0643-add-RespawnFlags-to-PlayerRespawnEvent.patch @@ -18,7 +18,7 @@ index eb811f9fcaf84edce3b59fc5f53cd72ffaf1506c..9daad376b7c837ac5dcda5f54d520e2a } else { if (this.player.getHealth() > 0.0F) { diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index 0ccbe77e8ca58dbe8cbbe04d99a3e6181fee1e9d..53fa2fbaeacc333ab28392df4613819719a55d2e 100644 +index 5f099d45203f155abb23c9241b55d34e04f2aa7e..f61c31a028c286399f0921c516b5d94ad52f88b5 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java @@ -806,6 +806,12 @@ public abstract class PlayerList { diff --git a/patches/server/0645-Add-Channel-initialization-listeners.patch b/patches/server/0644-Add-Channel-initialization-listeners.patch similarity index 100% rename from patches/server/0645-Add-Channel-initialization-listeners.patch rename to patches/server/0644-Add-Channel-initialization-listeners.patch diff --git a/patches/server/0646-Send-empty-commands-if-tab-completion-is-disabled.patch b/patches/server/0645-Send-empty-commands-if-tab-completion-is-disabled.patch similarity index 100% rename from patches/server/0646-Send-empty-commands-if-tab-completion-is-disabled.patch rename to patches/server/0645-Send-empty-commands-if-tab-completion-is-disabled.patch diff --git a/patches/server/0647-Add-more-WanderingTrader-API.patch b/patches/server/0646-Add-more-WanderingTrader-API.patch similarity index 100% rename from patches/server/0647-Add-more-WanderingTrader-API.patch rename to patches/server/0646-Add-more-WanderingTrader-API.patch diff --git a/patches/server/0648-Add-EntityBlockStorage-clearEntities.patch b/patches/server/0647-Add-EntityBlockStorage-clearEntities.patch similarity index 100% rename from patches/server/0648-Add-EntityBlockStorage-clearEntities.patch rename to patches/server/0647-Add-EntityBlockStorage-clearEntities.patch diff --git a/patches/server/0649-Add-Adventure-message-to-PlayerAdvancementDoneEvent.patch b/patches/server/0648-Add-Adventure-message-to-PlayerAdvancementDoneEvent.patch similarity index 100% rename from patches/server/0649-Add-Adventure-message-to-PlayerAdvancementDoneEvent.patch rename to patches/server/0648-Add-Adventure-message-to-PlayerAdvancementDoneEvent.patch diff --git a/patches/server/0650-Add-raw-address-to-AsyncPlayerPreLoginEvent.patch b/patches/server/0649-Add-raw-address-to-AsyncPlayerPreLoginEvent.patch similarity index 100% rename from patches/server/0650-Add-raw-address-to-AsyncPlayerPreLoginEvent.patch rename to patches/server/0649-Add-raw-address-to-AsyncPlayerPreLoginEvent.patch diff --git a/patches/server/0651-Inventory-close.patch b/patches/server/0650-Inventory-close.patch similarity index 100% rename from patches/server/0651-Inventory-close.patch rename to patches/server/0650-Inventory-close.patch diff --git a/patches/server/0652-call-PortalCreateEvent-players-and-end-platform.patch b/patches/server/0651-call-PortalCreateEvent-players-and-end-platform.patch similarity index 100% rename from patches/server/0652-call-PortalCreateEvent-players-and-end-platform.patch rename to patches/server/0651-call-PortalCreateEvent-players-and-end-platform.patch diff --git a/patches/server/0653-Add-a-should-burn-in-sunlight-API-for-Phantoms-and-S.patch b/patches/server/0652-Add-a-should-burn-in-sunlight-API-for-Phantoms-and-S.patch similarity index 100% rename from patches/server/0653-Add-a-should-burn-in-sunlight-API-for-Phantoms-and-S.patch rename to patches/server/0652-Add-a-should-burn-in-sunlight-API-for-Phantoms-and-S.patch diff --git a/patches/server/0654-Fix-CraftPotionBrewer-cache.patch b/patches/server/0653-Fix-CraftPotionBrewer-cache.patch similarity index 100% rename from patches/server/0654-Fix-CraftPotionBrewer-cache.patch rename to patches/server/0653-Fix-CraftPotionBrewer-cache.patch diff --git a/patches/server/0655-Add-basic-Datapack-API.patch b/patches/server/0654-Add-basic-Datapack-API.patch similarity index 100% rename from patches/server/0655-Add-basic-Datapack-API.patch rename to patches/server/0654-Add-basic-Datapack-API.patch diff --git a/patches/server/0656-Add-environment-variable-to-disable-server-gui.patch b/patches/server/0655-Add-environment-variable-to-disable-server-gui.patch similarity index 100% rename from patches/server/0656-Add-environment-variable-to-disable-server-gui.patch rename to patches/server/0655-Add-environment-variable-to-disable-server-gui.patch diff --git a/patches/server/0657-additions-to-PlayerGameModeChangeEvent.patch b/patches/server/0656-additions-to-PlayerGameModeChangeEvent.patch similarity index 100% rename from patches/server/0657-additions-to-PlayerGameModeChangeEvent.patch rename to patches/server/0656-additions-to-PlayerGameModeChangeEvent.patch diff --git a/patches/server/0658-ItemStack-repair-check-API.patch b/patches/server/0657-ItemStack-repair-check-API.patch similarity index 97% rename from patches/server/0658-ItemStack-repair-check-API.patch rename to patches/server/0657-ItemStack-repair-check-API.patch index 3fa1f719a3..518bb79325 100644 --- a/patches/server/0658-ItemStack-repair-check-API.patch +++ b/patches/server/0657-ItemStack-repair-check-API.patch @@ -5,7 +5,7 @@ Subject: [PATCH] ItemStack repair check API diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -index 80dc84864755bf46b9be46d69cd23f588628f9bd..e3f55036f44a92adb268880a458518bcccca34be 100644 +index 3a7b7a0766075e8a7d359138ca01dbcc88c609a3..d9eb0f7c38118014b8dd22c42f3330977c6af228 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -491,6 +491,14 @@ public final class CraftMagicNumbers implements UnsafeValues { diff --git a/patches/server/0659-More-Enchantment-API.patch b/patches/server/0658-More-Enchantment-API.patch similarity index 100% rename from patches/server/0659-More-Enchantment-API.patch rename to patches/server/0658-More-Enchantment-API.patch diff --git a/patches/server/0660-Fix-and-optimise-world-force-upgrading.patch b/patches/server/0659-Fix-and-optimise-world-force-upgrading.patch similarity index 99% rename from patches/server/0660-Fix-and-optimise-world-force-upgrading.patch rename to patches/server/0659-Fix-and-optimise-world-force-upgrading.patch index 6fa8f71735..83dd9f896d 100644 --- a/patches/server/0660-Fix-and-optimise-world-force-upgrading.patch +++ b/patches/server/0659-Fix-and-optimise-world-force-upgrading.patch @@ -274,7 +274,7 @@ index f685ab3cc6e4fd76e8dec3d2d3627a13715cda44..36a1d58dd238c835ce3cc9c2376a86a0 Main.LOGGER.info("Forcing world upgrade! {}", session.getLevelId()); // CraftBukkit WorldUpgrader worldupgrader = new WorldUpgrader(session, dataFixer, generatorOptions, eraseCache); diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index f1713ceace84ecbe2e4a0dcde050c43a636e3595..fcdae82ecaaa86854a5cddcb652ed3bc388e33c3 100644 +index 80e101301f148520a04dfc914caa58ea3a6653d2..6715920dcbc7cd895f8662d9c7b9dbb8b8790323 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -556,11 +556,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 4096 -+ final byte[] visibleBytes = this.storageVisible; -+ if (visibleBytes == null) { -+ return 0; -+ } -+ final byte value = visibleBytes[index >>> 1]; -+ -+ // if we are an even index, we want lower 4 bits -+ // if we are an odd index, we want upper 4 bits -+ return ((value >>> ((index & 1) << 2)) & 0xF); ++ // indices range from 0 -> 4096 ++ final byte[] visibleBytes = this.storageVisible; ++ if (visibleBytes == null) { ++ return 0; + } ++ final byte value = visibleBytes[index >>> 1]; ++ ++ // if we are an even index, we want lower 4 bits ++ // if we are an odd index, we want upper 4 bits ++ return ((value >>> ((index & 1) << 2)) & 0xF); + } + + // operation type: updating @@ -770,15 +772,15 @@ index 0000000000000000000000000000000000000000..174dc7ffa66258da0b867fba5c54880e + } + } +} -diff --git a/src/main/java/ca/spottedleaf/starlight/light/SkyStarLightEngine.java b/src/main/java/ca/spottedleaf/starlight/light/SkyStarLightEngine.java +diff --git a/src/main/java/ca/spottedleaf/starlight/common/light/SkyStarLightEngine.java b/src/main/java/ca/spottedleaf/starlight/common/light/SkyStarLightEngine.java new file mode 100644 -index 0000000000000000000000000000000000000000..e843ceb27bce134f7785e8c45fac25d5ec747233 +index 0000000000000000000000000000000000000000..5f771962afb44175d446f138c8e7453230f48c6c --- /dev/null -+++ b/src/main/java/ca/spottedleaf/starlight/light/SkyStarLightEngine.java -@@ -0,0 +1,715 @@ -+package ca.spottedleaf.starlight.light; ++++ b/src/main/java/ca/spottedleaf/starlight/common/light/SkyStarLightEngine.java +@@ -0,0 +1,709 @@ ++package ca.spottedleaf.starlight.common.light; + -+import io.papermc.paper.util.WorldUtil; ++import ca.spottedleaf.starlight.common.util.WorldUtil; +import it.unimi.dsi.fastutil.shorts.ShortCollection; +import it.unimi.dsi.fastutil.shorts.ShortIterator; +import net.minecraft.core.BlockPos; @@ -871,7 +873,7 @@ index 0000000000000000000000000000000000000000..e843ceb27bce134f7785e8c45fac25d5 + if (emptinessMap == null) { + // cannot delay nibble init for lit chunks, as we need to init to propagate into them. + final LevelChunkSection current = this.getChunkSection(chunkX, currY, chunkZ); -+ if (current == null || current == EMPTY_CHUNK_SECTION) { ++ if (current == null || current.hasOnlyAir()) { + continue; + } + } else { @@ -1080,7 +1082,7 @@ index 0000000000000000000000000000000000000000..e843ceb27bce134f7785e8c45fac25d5 + final BlockState centerState = this.getBlockState(worldX, worldY, worldZ); + int opacity = centerState.getOpacityIfCached(); + -+ BlockState conditionallyOpaqueState; ++ final BlockState conditionallyOpaqueState; + if (opacity < 0) { + this.recalcCenterPos.set(worldX, worldY, worldZ); + opacity = Math.max(1, centerState.getLightBlock(lightAccess.getLevel(), this.recalcCenterPos)); @@ -1243,7 +1245,7 @@ index 0000000000000000000000000000000000000000..e843ceb27bce134f7785e8c45fac25d5 + + int highestNonEmptySection = this.maxSection; + while (highestNonEmptySection == (this.minSection - 1) || -+ sections[highestNonEmptySection - this.minSection] == null || sections[highestNonEmptySection - this.minSection].isEmpty()) { ++ sections[highestNonEmptySection - this.minSection] == null || sections[highestNonEmptySection - this.minSection].hasOnlyAir()) { + this.checkNullSection(chunkX, highestNonEmptySection, chunkZ, false); + // try propagate FULL to neighbours + @@ -1398,19 +1400,13 @@ index 0000000000000000000000000000000000000000..e843ceb27bce134f7785e8c45fac25d5 + this.checkNullSection(worldX >> 4, startY >> 4, worldZ >> 4, extrudeInitialised); + + BlockState above = this.getBlockState(worldX, startY + 1, worldZ); -+ if (above == null) { -+ above = AIR_BLOCK_STATE; -+ } + + for (;startY >= (this.minLightSection << 4); --startY) { + if ((startY & 15) == 15) { + // ensure this section is always checked + this.checkNullSection(worldX >> 4, startY >> 4, worldZ >> 4, extrudeInitialised); + } -+ BlockState current = this.getBlockState(worldX, startY, worldZ); -+ if (current == null) { -+ current = AIR_BLOCK_STATE; -+ } ++ final BlockState current = this.getBlockState(worldX, startY, worldZ); + + final VoxelShape fromShape; + if (above.isConditionallyFullOpaque()) { @@ -1491,24 +1487,28 @@ index 0000000000000000000000000000000000000000..e843ceb27bce134f7785e8c45fac25d5 + return startY; + } +} -diff --git a/src/main/java/ca/spottedleaf/starlight/light/StarLightEngine.java b/src/main/java/ca/spottedleaf/starlight/light/StarLightEngine.java +diff --git a/src/main/java/ca/spottedleaf/starlight/common/light/StarLightEngine.java b/src/main/java/ca/spottedleaf/starlight/common/light/StarLightEngine.java new file mode 100644 -index 0000000000000000000000000000000000000000..319e5c674f027e2e06322bb75b38acd46b51cc7a +index 0000000000000000000000000000000000000000..f0ef2192df6ef7f9decceaa790a054ecd99794cc --- /dev/null -+++ b/src/main/java/ca/spottedleaf/starlight/light/StarLightEngine.java -@@ -0,0 +1,1577 @@ -+package ca.spottedleaf.starlight.light; ++++ b/src/main/java/ca/spottedleaf/starlight/common/light/StarLightEngine.java +@@ -0,0 +1,1571 @@ ++package ca.spottedleaf.starlight.common.light; + -+import io.papermc.paper.util.CoordinateUtils; -+import io.papermc.paper.util.IntegerUtil; -+import io.papermc.paper.util.WorldUtil; ++import ca.spottedleaf.starlight.common.util.CoordinateUtils; ++import ca.spottedleaf.starlight.common.util.IntegerUtil; ++import ca.spottedleaf.starlight.common.util.WorldUtil; +import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; +import it.unimi.dsi.fastutil.shorts.ShortCollection; +import it.unimi.dsi.fastutil.shorts.ShortIterator; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.SectionPos; -+import net.minecraft.world.level.*; ++import net.minecraft.world.level.BlockGetter; ++import net.minecraft.world.level.ChunkPos; ++import net.minecraft.world.level.Level; ++import net.minecraft.world.level.LevelHeightAccessor; ++import net.minecraft.world.level.LightLayer; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.chunk.ChunkAccess; @@ -1527,8 +1527,6 @@ index 0000000000000000000000000000000000000000..319e5c674f027e2e06322bb75b38acd4 + + protected static final BlockState AIR_BLOCK_STATE = Blocks.AIR.defaultBlockState(); + -+ protected static final LevelChunkSection EMPTY_CHUNK_SECTION = new LevelChunkSection(0); -+ + protected static final AxisDirection[] DIRECTIONS = AxisDirection.values(); + protected static final AxisDirection[] AXIS_DIRECTIONS = DIRECTIONS; + protected static final AxisDirection[] ONLY_HORIZONTAL_DIRECTIONS = new AxisDirection[] { @@ -1722,7 +1720,7 @@ index 0000000000000000000000000000000000000000..319e5c674f027e2e06322bb75b38acd4 + protected final void setBlocksForChunkInCache(final int chunkX, final int chunkZ, final LevelChunkSection[] sections) { + for (int cy = this.minLightSection; cy <= this.maxLightSection; ++cy) { + this.setChunkSectionInCache(chunkX, cy, chunkZ, -+ sections == null ? null : (cy >= this.minSection && cy <= this.maxSection ? (sections[cy - this.minSection] == null || sections[cy - this.minSection].isEmpty() ? EMPTY_CHUNK_SECTION : sections[cy - this.minSection]) : EMPTY_CHUNK_SECTION)); ++ sections == null ? null : (cy >= this.minSection && cy <= this.maxSection ? sections[cy - this.minSection] : null)); + } + } + @@ -1780,20 +1778,20 @@ index 0000000000000000000000000000000000000000..319e5c674f027e2e06322bb75b38acd4 + final LevelChunkSection section = this.sectionCache[(worldX >> 4) + 5 * (worldZ >> 4) + (5 * 5) * (worldY >> 4) + this.chunkSectionIndexOffset]; + + if (section != null) { -+ return section == EMPTY_CHUNK_SECTION ? AIR_BLOCK_STATE : section.getBlockState(worldX & 15, worldY & 15, worldZ & 15); ++ return section.hasOnlyAir() ? AIR_BLOCK_STATE : section.getBlockState(worldX & 15, worldY & 15, worldZ & 15); + } + -+ return null; ++ return AIR_BLOCK_STATE; + } + + protected final BlockState getBlockState(final int sectionIndex, final int localIndex) { + final LevelChunkSection section = this.sectionCache[sectionIndex]; + + if (section != null) { -+ return section == EMPTY_CHUNK_SECTION ? AIR_BLOCK_STATE : section.states.get(localIndex); ++ return section.hasOnlyAir() ? AIR_BLOCK_STATE : section.states.get(localIndex); + } + -+ return null; ++ return AIR_BLOCK_STATE; + } + + protected final int getLightLevel(final int worldX, final int worldY, final int worldZ) { @@ -1881,15 +1879,6 @@ index 0000000000000000000000000000000000000000..319e5c674f027e2e06322bb75b38acd4 + this.emptinessMapCache[chunkX + 5*chunkZ + this.chunkIndexOffset] = emptinessMap; + } + -+ protected final long getKnownTransparency(final int worldX, final int worldY, final int worldZ) { -+ throw new UnsupportedOperationException(); // :( -+ } -+ -+ // warn: localIndex = y | (x << 4) | (z << 8) -+ protected final long getKnownTransparency(final int sectionIndex, final int localIndex) { -+ throw new UnsupportedOperationException(); // :( -+ } -+ + public static SWMRNibbleArray[] getFilledEmptyLight(final LevelHeightAccessor world) { + return getFilledEmptyLight(WorldUtil.getTotalLightSections(world)); + } @@ -2180,7 +2169,7 @@ index 0000000000000000000000000000000000000000..319e5c674f027e2e06322bb75b38acd4 + final Boolean[] ret = new Boolean[sections.length]; + + for (int i = 0; i < sections.length; ++i) { -+ if (sections[i] == null || sections[i].isEmpty()) { ++ if (sections[i] == null || sections[i].hasOnlyAir()) { + ret[i] = Boolean.TRUE; + } else { + ret[i] = Boolean.FALSE; @@ -2253,12 +2242,13 @@ index 0000000000000000000000000000000000000000..319e5c674f027e2e06322bb75b38acd4 + + // update emptiness map + for (int sectionIndex = (emptinessChanges.length - 1); sectionIndex >= 0; --sectionIndex) { -+ final Boolean valueBoxed = emptinessChanges[sectionIndex]; ++ Boolean valueBoxed = emptinessChanges[sectionIndex]; + if (valueBoxed == null) { -+ if (needsInit) { -+ throw new IllegalStateException("Current chunk has not initialised emptiness map yet supplied emptiness map isn't filled?"); ++ if (!needsInit) { ++ continue; + } -+ continue; ++ final LevelChunkSection section = this.getChunkSection(chunkX, sectionIndex + this.minSection, chunkZ); ++ emptinessChanges[sectionIndex] = valueBoxed = section == null || section.hasOnlyAir() ? Boolean.TRUE : Boolean.FALSE; + } + chunkEmptinessMap[sectionIndex] = valueBoxed.booleanValue(); + } @@ -2326,7 +2316,7 @@ index 0000000000000000000000000000000000000000..319e5c674f027e2e06322bb75b38acd4 + } + } else { + final LevelChunkSection section = this.getChunkSection(dx + dx2 + chunkX, y, dz + dz2 + chunkZ); -+ if (section != null && section != EMPTY_CHUNK_SECTION) { ++ if (section != null && !section.hasOnlyAir()) { + allEmpty = false; + break neighbour_search; + } @@ -2949,7 +2939,7 @@ index 0000000000000000000000000000000000000000..319e5c674f027e2e06322bb75b38acd4 + final int sectionIndex = (offX >> 4) + 5 * (offZ >> 4) + (5 * 5) * (offY >> 4) + sectionOffset; + final int localIndex = (offX & 15) | ((offZ & 15) << 4) | ((offY & 15) << 8); + -+ final VoxelShape fromShape = fromBlock.isConditionallyFullOpaque() ? fromBlock.getFaceOcclusionShape(world, this.mutablePos2, propagate.nms) : Shapes.empty(); ++ final VoxelShape fromShape = (fromBlock.isConditionallyFullOpaque()) ? fromBlock.getFaceOcclusionShape(world, this.mutablePos2, propagate.nms) : Shapes.empty(); + + if (fromShape != Shapes.empty() && Shapes.faceShapeOccludes(Shapes.empty(), fromShape)) { + continue; @@ -3074,21 +3064,22 @@ index 0000000000000000000000000000000000000000..319e5c674f027e2e06322bb75b38acd4 + this.performLightIncrease(lightAccess); + } +} -diff --git a/src/main/java/ca/spottedleaf/starlight/light/StarLightInterface.java b/src/main/java/ca/spottedleaf/starlight/light/StarLightInterface.java +diff --git a/src/main/java/ca/spottedleaf/starlight/common/light/StarLightInterface.java b/src/main/java/ca/spottedleaf/starlight/common/light/StarLightInterface.java new file mode 100644 -index 0000000000000000000000000000000000000000..9b8412f50d161471166cdf5c9effc2d58915faa1 +index 0000000000000000000000000000000000000000..d857dfe72550378375ce288be028d4fe51669209 --- /dev/null -+++ b/src/main/java/ca/spottedleaf/starlight/light/StarLightInterface.java -@@ -0,0 +1,635 @@ -+package ca.spottedleaf.starlight.light; ++++ b/src/main/java/ca/spottedleaf/starlight/common/light/StarLightInterface.java +@@ -0,0 +1,652 @@ ++package ca.spottedleaf.starlight.common.light; + -+import io.papermc.paper.util.CoordinateUtils; -+import io.papermc.paper.util.WorldUtil; ++import ca.spottedleaf.starlight.common.util.CoordinateUtils; ++import ca.spottedleaf.starlight.common.util.WorldUtil; +import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap; +import it.unimi.dsi.fastutil.shorts.ShortCollection; +import it.unimi.dsi.fastutil.shorts.ShortOpenHashSet; +import net.minecraft.core.BlockPos; +import net.minecraft.core.SectionPos; ++import net.minecraft.server.level.ServerChunkCache; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.TicketType; +import net.minecraft.world.level.ChunkPos; @@ -3096,10 +3087,15 @@ index 0000000000000000000000000000000000000000..9b8412f50d161471166cdf5c9effc2d5 +import net.minecraft.world.level.chunk.ChunkAccess; +import net.minecraft.world.level.chunk.ChunkStatus; +import net.minecraft.world.level.chunk.DataLayer; ++import net.minecraft.world.level.chunk.LevelChunk; +import net.minecraft.world.level.chunk.LightChunkGetter; +import net.minecraft.world.level.lighting.LayerLightEventListener; +import net.minecraft.world.level.lighting.LevelLightEngine; -+import java.util.*; ++import java.util.ArrayDeque; ++import java.util.ArrayList; ++import java.util.HashSet; ++import java.util.List; ++import java.util.Set; +import java.util.concurrent.CompletableFuture; +import java.util.function.Consumer; +import java.util.function.IntConsumer; @@ -3137,10 +3133,10 @@ index 0000000000000000000000000000000000000000..9b8412f50d161471166cdf5c9effc2d5 + this.cachedBlockPropagators = hasBlockLight && lightAccess != null ? new ArrayDeque<>() : null; + this.isClientSide = !(this.world instanceof ServerLevel); + if (this.world == null) { -+ this.minSection = 0; -+ this.maxSection = 15; -+ this.minLightSection = -1; -+ this.maxLightSection = 16; ++ this.minSection = -4; ++ this.maxSection = 19; ++ this.minLightSection = -5; ++ this.maxLightSection = 20; + } else { + this.minSection = WorldUtil.getMinSection(this.world); + this.maxSection = WorldUtil.getMaxSection(this.world); @@ -3197,78 +3193,7 @@ index 0000000000000000000000000000000000000000..9b8412f50d161471166cdf5c9effc2d5 + + @Override + public int getLightValue(final BlockPos blockPos) { -+ final int x = blockPos.getX(); -+ int y = blockPos.getY(); -+ final int z = blockPos.getZ(); -+ -+ final ChunkAccess chunk = StarLightInterface.this.getAnyChunkNow(x >> 4, z >> 4); -+ if (chunk == null || (!StarLightInterface.this.isClientSide && !chunk.isLightCorrect()) || !chunk.getStatus().isOrAfter(ChunkStatus.LIGHT)) { -+ return 15; -+ } -+ -+ int sectionY = y >> 4; -+ -+ if (sectionY > StarLightInterface.this.maxLightSection) { -+ return 15; -+ } -+ -+ if (sectionY < StarLightInterface.this.minLightSection) { -+ sectionY = StarLightInterface.this.minLightSection; -+ y = sectionY << 4; -+ } -+ -+ final SWMRNibbleArray[] nibbles = chunk.getSkyNibbles(); -+ final SWMRNibbleArray immediate = nibbles[sectionY - StarLightInterface.this.minLightSection]; -+ -+ if (StarLightInterface.this.isClientSide) { -+ if (!immediate.isNullNibbleUpdating()) { -+ return immediate.getUpdating(x, y, z); -+ } -+ } else { -+ if (!immediate.isNullNibbleVisible()) { -+ return immediate.getVisible(x, y, z); -+ } -+ } -+ -+ final boolean[] emptinessMap = chunk.getSkyEmptinessMap(); -+ -+ if (emptinessMap == null) { -+ return 15; -+ } -+ -+ // are we above this chunk's lowest empty section? -+ int lowestY = StarLightInterface.this.minLightSection - 1; -+ for (int currY = StarLightInterface.this.maxSection; currY >= StarLightInterface.this.minSection; --currY) { -+ if (emptinessMap[currY - StarLightInterface.this.minSection]) { -+ continue; -+ } -+ -+ // should always be full lit here -+ lowestY = currY; -+ break; -+ } -+ -+ if (sectionY > lowestY) { -+ return 15; -+ } -+ -+ // this nibble is going to depend solely on the skylight data above it -+ // find first non-null data above (there does exist one, as we just found it above) -+ for (int currY = sectionY + 1; currY <= StarLightInterface.this.maxLightSection; ++currY) { -+ final SWMRNibbleArray nibble = nibbles[currY - StarLightInterface.this.minLightSection]; -+ if (StarLightInterface.this.isClientSide) { -+ if (!nibble.isNullNibbleUpdating()) { -+ return nibble.getUpdating(x, 0, z); -+ } -+ } else { -+ if (!nibble.isNullNibbleVisible()) { -+ return nibble.getVisible(x, 0, z); -+ } -+ } -+ } -+ -+ // should never reach here -+ return 15; ++ return StarLightInterface.this.getSkyLightValue(blockPos, StarLightInterface.this.getAnyChunkNow(blockPos.getX() >> 4, blockPos.getZ() >> 4)); + } + + @Override @@ -3316,26 +3241,7 @@ index 0000000000000000000000000000000000000000..9b8412f50d161471166cdf5c9effc2d5 + + @Override + public int getLightValue(final BlockPos blockPos) { -+ final int cx = blockPos.getX() >> 4; -+ final int cy = blockPos.getY() >> 4; -+ final int cz = blockPos.getZ() >> 4; -+ -+ if (cy < StarLightInterface.this.minLightSection || cy > StarLightInterface.this.maxLightSection) { -+ return 0; -+ } -+ -+ final ChunkAccess chunk = StarLightInterface.this.getAnyChunkNow(cx, cz); -+ -+ if (chunk == null) { -+ return 0; -+ } -+ -+ final SWMRNibbleArray nibble = chunk.getBlockNibbles()[cy - StarLightInterface.this.minLightSection]; -+ if (StarLightInterface.this.isClientSide) { -+ return nibble.getUpdating(blockPos.getX(), blockPos.getY(), blockPos.getZ()); -+ } else { -+ return nibble.getVisible(blockPos.getX(), blockPos.getY(), blockPos.getZ()); -+ } ++ return StarLightInterface.this.getBlockLightValue(blockPos, StarLightInterface.this.getAnyChunkNow(blockPos.getX() >> 4, blockPos.getZ() >> 4)); + } + + @Override @@ -3345,6 +3251,100 @@ index 0000000000000000000000000000000000000000..9b8412f50d161471166cdf5c9effc2d5 + }; + } + ++ protected int getSkyLightValue(final BlockPos blockPos, final ChunkAccess chunk) { ++ final int x = blockPos.getX(); ++ int y = blockPos.getY(); ++ final int z = blockPos.getZ(); ++ ++ final int minSection = this.minSection; ++ final int maxSection = this.maxSection; ++ final int minLightSection = this.minLightSection; ++ final int maxLightSection = this.maxLightSection; ++ ++ if (chunk == null || (!this.isClientSide && !chunk.isLightCorrect()) || !chunk.getStatus().isOrAfter(ChunkStatus.LIGHT)) { ++ return 15; ++ } ++ ++ int sectionY = y >> 4; ++ ++ if (sectionY > maxLightSection) { ++ return 15; ++ } ++ ++ if (sectionY < minLightSection) { ++ sectionY = minLightSection; ++ y = sectionY << 4; ++ } ++ ++ final SWMRNibbleArray[] nibbles = chunk.getSkyNibbles(); ++ final SWMRNibbleArray immediate = nibbles[sectionY - minLightSection]; ++ ++ if (!immediate.isNullNibbleVisible()) { ++ return immediate.getVisible(x, y, z); ++ } ++ ++ final boolean[] emptinessMap = chunk.getSkyEmptinessMap(); ++ ++ if (emptinessMap == null) { ++ return 15; ++ } ++ ++ // are we above this chunk's lowest empty section? ++ int lowestY = minLightSection - 1; ++ for (int currY = maxSection; currY >= minSection; --currY) { ++ if (emptinessMap[currY - minSection]) { ++ continue; ++ } ++ ++ // should always be full lit here ++ lowestY = currY; ++ break; ++ } ++ ++ if (sectionY > lowestY) { ++ return 15; ++ } ++ ++ // this nibble is going to depend solely on the skylight data above it ++ // find first non-null data above (there does exist one, as we just found it above) ++ for (int currY = sectionY + 1; currY <= maxLightSection; ++currY) { ++ final SWMRNibbleArray nibble = nibbles[currY - minLightSection]; ++ if (!nibble.isNullNibbleVisible()) { ++ return nibble.getVisible(x, 0, z); ++ } ++ } ++ ++ // should never reach here ++ return 15; ++ } ++ ++ protected int getBlockLightValue(final BlockPos blockPos, final ChunkAccess chunk) { ++ final int y = blockPos.getY(); ++ final int cy = y >> 4; ++ ++ final int minLightSection = this.minLightSection; ++ final int maxLightSection = this.maxLightSection; ++ ++ if (cy < minLightSection || cy > maxLightSection) { ++ return 0; ++ } ++ ++ if (chunk == null) { ++ return 0; ++ } ++ ++ final SWMRNibbleArray nibble = chunk.getBlockNibbles()[cy - minLightSection]; ++ return nibble.getVisible(blockPos.getX(), y, blockPos.getZ()); ++ } ++ ++ public int getRawBrightness(final BlockPos pos, final int ambientDarkness) { ++ final ChunkAccess chunk = this.getAnyChunkNow(pos.getX() >> 4, pos.getZ() >> 4); ++ ++ final int sky = this.getSkyLightValue(pos, chunk) - ambientDarkness; ++ final int block = this.getBlockLightValue(pos, chunk); ++ return Math.max(sky, block); ++ } ++ + public LayerLightEventListener getSkyReader() { + return this.skyReader; + } @@ -3362,7 +3362,14 @@ index 0000000000000000000000000000000000000000..9b8412f50d161471166cdf5c9effc2d5 + // empty world + return null; + } -+ return ((ServerLevel)this.world).getChunkSource().getChunkAtImmediately(chunkX, chunkZ); ++ ++ final ServerChunkCache chunkProvider = ((ServerLevel)this.world).getChunkSource(); ++ final LevelChunk fullLoaded = chunkProvider.getChunkAtIfLoadedImmediately(chunkX, chunkZ); ++ if (fullLoaded != null) { ++ return fullLoaded; ++ } ++ ++ return chunkProvider.getChunkAtImmediately(chunkX, chunkZ); + } + + public boolean hasUpdates() { @@ -3715,8 +3722,618 @@ index 0000000000000000000000000000000000000000..9b8412f50d161471166cdf5c9effc2d5 + } + } +} +diff --git a/src/main/java/ca/spottedleaf/starlight/common/util/CoordinateUtils.java b/src/main/java/ca/spottedleaf/starlight/common/util/CoordinateUtils.java +new file mode 100644 +index 0000000000000000000000000000000000000000..16a4a14e7ccf9e4d7fdf1166674fe8f529c06d39 +--- /dev/null ++++ b/src/main/java/ca/spottedleaf/starlight/common/util/CoordinateUtils.java +@@ -0,0 +1,128 @@ ++package ca.spottedleaf.starlight.common.util; ++ ++import net.minecraft.core.BlockPos; ++import net.minecraft.core.SectionPos; ++import net.minecraft.util.Mth; ++import net.minecraft.world.entity.Entity; ++import net.minecraft.world.level.ChunkPos; ++ ++public final class CoordinateUtils { ++ ++ // dx, dz are relative to the target chunk ++ // dx, dz in [-radius, radius] ++ public static int getNeighbourMappedIndex(final int dx, final int dz, final int radius) { ++ return (dx + radius) + (2 * radius + 1)*(dz + radius); ++ } ++ ++ // the chunk keys are compatible with vanilla ++ ++ public static long getChunkKey(final BlockPos pos) { ++ return ((long)(pos.getZ() >> 4) << 32) | ((pos.getX() >> 4) & 0xFFFFFFFFL); ++ } ++ ++ public static long getChunkKey(final Entity entity) { ++ return ((long)(Mth.floor(entity.getZ()) >> 4) << 32) | ((Mth.floor(entity.getX()) >> 4) & 0xFFFFFFFFL); ++ } ++ ++ public static long getChunkKey(final ChunkPos pos) { ++ return ((long)pos.z << 32) | (pos.x & 0xFFFFFFFFL); ++ } ++ ++ public static long getChunkKey(final SectionPos pos) { ++ return ((long)pos.getZ() << 32) | (pos.getX() & 0xFFFFFFFFL); ++ } ++ ++ public static long getChunkKey(final int x, final int z) { ++ return ((long)z << 32) | (x & 0xFFFFFFFFL); ++ } ++ ++ public static int getChunkX(final long chunkKey) { ++ return (int)chunkKey; ++ } ++ ++ public static int getChunkZ(final long chunkKey) { ++ return (int)(chunkKey >>> 32); ++ } ++ ++ public static int getChunkCoordinate(final double blockCoordinate) { ++ return Mth.floor(blockCoordinate) >> 4; ++ } ++ ++ // the section keys are compatible with vanilla's ++ ++ static final int SECTION_X_BITS = 22; ++ static final long SECTION_X_MASK = (1L << SECTION_X_BITS) - 1; ++ static final int SECTION_Y_BITS = 20; ++ static final long SECTION_Y_MASK = (1L << SECTION_Y_BITS) - 1; ++ static final int SECTION_Z_BITS = 22; ++ static final long SECTION_Z_MASK = (1L << SECTION_Z_BITS) - 1; ++ // format is y,z,x (in order of LSB to MSB) ++ static final int SECTION_Y_SHIFT = 0; ++ static final int SECTION_Z_SHIFT = SECTION_Y_SHIFT + SECTION_Y_BITS; ++ static final int SECTION_X_SHIFT = SECTION_Z_SHIFT + SECTION_X_BITS; ++ static final int SECTION_TO_BLOCK_SHIFT = 4; ++ ++ public static long getChunkSectionKey(final int x, final int y, final int z) { ++ return ((x & SECTION_X_MASK) << SECTION_X_SHIFT) ++ | ((y & SECTION_Y_MASK) << SECTION_Y_SHIFT) ++ | ((z & SECTION_Z_MASK) << SECTION_Z_SHIFT); ++ } ++ ++ public static long getChunkSectionKey(final SectionPos pos) { ++ return ((pos.getX() & SECTION_X_MASK) << SECTION_X_SHIFT) ++ | ((pos.getY() & SECTION_Y_MASK) << SECTION_Y_SHIFT) ++ | ((pos.getZ() & SECTION_Z_MASK) << SECTION_Z_SHIFT); ++ } ++ ++ public static long getChunkSectionKey(final ChunkPos pos, final int y) { ++ return ((pos.x & SECTION_X_MASK) << SECTION_X_SHIFT) ++ | ((y & SECTION_Y_MASK) << SECTION_Y_SHIFT) ++ | ((pos.z & SECTION_Z_MASK) << SECTION_Z_SHIFT); ++ } ++ ++ public static long getChunkSectionKey(final BlockPos pos) { ++ return (((long)pos.getX() << (SECTION_X_SHIFT - SECTION_TO_BLOCK_SHIFT)) & (SECTION_X_MASK << SECTION_X_SHIFT)) | ++ ((pos.getY() >> SECTION_TO_BLOCK_SHIFT) & (SECTION_Y_MASK << SECTION_Y_SHIFT)) | ++ (((long)pos.getZ() << (SECTION_Z_SHIFT - SECTION_TO_BLOCK_SHIFT)) & (SECTION_Z_MASK << SECTION_Z_SHIFT)); ++ } ++ ++ public static long getChunkSectionKey(final Entity entity) { ++ return ((Mth.lfloor(entity.getX()) << (SECTION_X_SHIFT - SECTION_TO_BLOCK_SHIFT)) & (SECTION_X_MASK << SECTION_X_SHIFT)) | ++ ((Mth.lfloor(entity.getY()) >> SECTION_TO_BLOCK_SHIFT) & (SECTION_Y_MASK << SECTION_Y_SHIFT)) | ++ ((Mth.lfloor(entity.getZ()) << (SECTION_Z_SHIFT - SECTION_TO_BLOCK_SHIFT)) & (SECTION_Z_MASK << SECTION_Z_SHIFT)); ++ } ++ ++ public static int getChunkSectionX(final long key) { ++ return (int)(key << (Long.SIZE - (SECTION_X_SHIFT + SECTION_X_BITS)) >> (Long.SIZE - SECTION_X_BITS)); ++ } ++ ++ public static int getChunkSectionY(final long key) { ++ return (int)(key << (Long.SIZE - (SECTION_Y_SHIFT + SECTION_Y_BITS)) >> (Long.SIZE - SECTION_Y_BITS)); ++ } ++ ++ public static int getChunkSectionZ(final long key) { ++ return (int)(key << (Long.SIZE - (SECTION_Z_SHIFT + SECTION_Z_BITS)) >> (Long.SIZE - SECTION_Z_BITS)); ++ } ++ ++ // the block coordinates are not necessarily compatible with vanilla's ++ ++ public static int getBlockCoordinate(final double blockCoordinate) { ++ return Mth.floor(blockCoordinate); ++ } ++ ++ 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 BlockPos pos) { ++ return ((long)pos.getX() & 0x7FFFFFF) | (((long)pos.getZ() & 0x7FFFFFF) << 27) | ((long)pos.getY() << 54); ++ } ++ ++ public static long getBlockKey(final Entity entity) { ++ return ((long)entity.getX() & 0x7FFFFFF) | (((long)entity.getZ() & 0x7FFFFFF) << 27) | ((long)entity.getY() << 54); ++ } ++ ++ private CoordinateUtils() { ++ throw new RuntimeException(); ++ } ++} +diff --git a/src/main/java/ca/spottedleaf/starlight/common/util/IntegerUtil.java b/src/main/java/ca/spottedleaf/starlight/common/util/IntegerUtil.java +new file mode 100644 +index 0000000000000000000000000000000000000000..177d0a969f3d72a34e773e8309c3719a235ee06d +--- /dev/null ++++ b/src/main/java/ca/spottedleaf/starlight/common/util/IntegerUtil.java +@@ -0,0 +1,226 @@ ++package ca.spottedleaf.starlight.common.util; ++ ++public final class IntegerUtil { ++ ++ public static final int HIGH_BIT_U32 = Integer.MIN_VALUE; ++ public static final long HIGH_BIT_U64 = Long.MIN_VALUE; ++ ++ public static int ceilLog2(final int value) { ++ return Integer.SIZE - Integer.numberOfLeadingZeros(value - 1); // see doc of numberOfLeadingZeros ++ } ++ ++ public static long ceilLog2(final long value) { ++ return Long.SIZE - Long.numberOfLeadingZeros(value - 1); // see doc of numberOfLeadingZeros ++ } ++ ++ public static int floorLog2(final int value) { ++ // xor is optimized subtract for 2^n -1 ++ // note that (2^n -1) - k = (2^n -1) ^ k for k <= (2^n - 1) ++ return (Integer.SIZE - 1) ^ Integer.numberOfLeadingZeros(value); // see doc of numberOfLeadingZeros ++ } ++ ++ public static int floorLog2(final long value) { ++ // xor is optimized subtract for 2^n -1 ++ // note that (2^n -1) - k = (2^n -1) ^ k for k <= (2^n - 1) ++ return (Long.SIZE - 1) ^ Long.numberOfLeadingZeros(value); // see doc of numberOfLeadingZeros ++ } ++ ++ public static int roundCeilLog2(final int value) { ++ // optimized variant of 1 << (32 - leading(val - 1)) ++ // given ++ // 1 << n = HIGH_BIT_32 >>> (31 - n) for n [0, 32) ++ // 1 << (32 - leading(val - 1)) = HIGH_BIT_32 >>> (31 - (32 - leading(val - 1))) ++ // HIGH_BIT_32 >>> (31 - (32 - leading(val - 1))) ++ // HIGH_BIT_32 >>> (31 - 32 + leading(val - 1)) ++ // HIGH_BIT_32 >>> (-1 + leading(val - 1)) ++ return HIGH_BIT_U32 >>> (Integer.numberOfLeadingZeros(value - 1) - 1); ++ } ++ ++ public static long roundCeilLog2(final long value) { ++ // see logic documented above ++ return HIGH_BIT_U64 >>> (Long.numberOfLeadingZeros(value - 1) - 1); ++ } ++ ++ public static int roundFloorLog2(final int value) { ++ // optimized variant of 1 << (31 - leading(val)) ++ // given ++ // 1 << n = HIGH_BIT_32 >>> (31 - n) for n [0, 32) ++ // 1 << (31 - leading(val)) = HIGH_BIT_32 >> (31 - (31 - leading(val))) ++ // HIGH_BIT_32 >> (31 - (31 - leading(val))) ++ // HIGH_BIT_32 >> (31 - 31 + leading(val)) ++ return HIGH_BIT_U32 >>> Integer.numberOfLeadingZeros(value); ++ } ++ ++ public static long roundFloorLog2(final long value) { ++ // see logic documented above ++ return HIGH_BIT_U64 >>> Long.numberOfLeadingZeros(value); ++ } ++ ++ public static boolean isPowerOfTwo(final int n) { ++ // 2^n has one bit ++ // note: this rets true for 0 still ++ return IntegerUtil.getTrailingBit(n) == n; ++ } ++ ++ public static boolean isPowerOfTwo(final long n) { ++ // 2^n has one bit ++ // note: this rets true for 0 still ++ return IntegerUtil.getTrailingBit(n) == n; ++ } ++ ++ public static int getTrailingBit(final int n) { ++ return -n & n; ++ } ++ ++ public static long getTrailingBit(final long n) { ++ return -n & n; ++ } ++ ++ public static int trailingZeros(final int n) { ++ return Integer.numberOfTrailingZeros(n); ++ } ++ ++ public static int trailingZeros(final long n) { ++ return Long.numberOfTrailingZeros(n); ++ } ++ ++ // from hacker's delight (signed division magic value) ++ public static int getDivisorMultiple(final long numbers) { ++ return (int)(numbers >>> 32); ++ } ++ ++ // from hacker's delight (signed division magic value) ++ public static int getDivisorShift(final long numbers) { ++ return (int)numbers; ++ } ++ ++ // copied from hacker's delight (signed division magic value) ++ // http://www.hackersdelight.org/hdcodetxt/magic.c.txt ++ public static long getDivisorNumbers(final int d) { ++ final int ad = IntegerUtil.branchlessAbs(d); ++ ++ if (ad < 2) { ++ throw new IllegalArgumentException("|number| must be in [2, 2^31 -1], not: " + d); ++ } ++ ++ final int two31 = 0x80000000; ++ final long mask = 0xFFFFFFFFL; // mask for enforcing unsigned behaviour ++ ++ int p = 31; ++ ++ // all these variables are UNSIGNED! ++ int t = two31 + (d >>> 31); ++ int anc = t - 1 - t%ad; ++ int q1 = (int)((two31 & mask)/(anc & mask)); ++ int r1 = two31 - q1*anc; ++ int q2 = (int)((two31 & mask)/(ad & mask)); ++ int r2 = two31 - q2*ad; ++ int delta; ++ ++ do { ++ p = p + 1; ++ q1 = 2*q1; // Update q1 = 2**p/|nc|. ++ r1 = 2*r1; // Update r1 = rem(2**p, |nc|). ++ if ((r1 & mask) >= (anc & mask)) {// (Must be an unsigned comparison here) ++ q1 = q1 + 1; ++ r1 = r1 - anc; ++ } ++ q2 = 2*q2; // Update q2 = 2**p/|d|. ++ r2 = 2*r2; // Update r2 = rem(2**p, |d|). ++ if ((r2 & mask) >= (ad & mask)) {// (Must be an unsigned comparison here) ++ q2 = q2 + 1; ++ r2 = r2 - ad; ++ } ++ delta = ad - r2; ++ } while ((q1 & mask) < (delta & mask) || (q1 == delta && r1 == 0)); ++ ++ int magicNum = q2 + 1; ++ if (d < 0) { ++ magicNum = -magicNum; ++ } ++ int shift = p - 32; ++ return ((long)magicNum << 32) | shift; ++ } ++ ++ public static int branchlessAbs(final int val) { ++ // -n = -1 ^ n + 1 ++ final int mask = val >> (Integer.SIZE - 1); // -1 if < 0, 0 if >= 0 ++ return (mask ^ val) - mask; // if val < 0, then (0 ^ val) - 0 else (-1 ^ val) + 1 ++ } ++ ++ public static long branchlessAbs(final long val) { ++ // -n = -1 ^ n + 1 ++ final long mask = val >> (Long.SIZE - 1); // -1 if < 0, 0 if >= 0 ++ return (mask ^ val) - mask; // if val < 0, then (0 ^ val) - 0 else (-1 ^ val) + 1 ++ } ++ ++ //https://github.com/skeeto/hash-prospector for hash functions ++ ++ //score = ~590.47984224483832 ++ public static int hash0(int x) { ++ x *= 0x36935555; ++ x ^= x >>> 16; ++ return x; ++ } ++ ++ //score = ~310.01596637036749 ++ public static int hash1(int x) { ++ x ^= x >>> 15; ++ x *= 0x356aaaad; ++ x ^= x >>> 17; ++ return x; ++ } ++ ++ public static int hash2(int x) { ++ x ^= x >>> 16; ++ x *= 0x7feb352d; ++ x ^= x >>> 15; ++ x *= 0x846ca68b; ++ x ^= x >>> 16; ++ return x; ++ } ++ ++ public static int hash3(int x) { ++ x ^= x >>> 17; ++ x *= 0xed5ad4bb; ++ x ^= x >>> 11; ++ x *= 0xac4c1b51; ++ x ^= x >>> 15; ++ x *= 0x31848bab; ++ x ^= x >>> 14; ++ return x; ++ } ++ ++ //score = ~365.79959673201887 ++ public static long hash1(long x) { ++ x ^= x >>> 27; ++ x *= 0xb24924b71d2d354bL; ++ x ^= x >>> 28; ++ return x; ++ } ++ ++ //h2 hash ++ public static long hash2(long x) { ++ x ^= x >>> 32; ++ x *= 0xd6e8feb86659fd93L; ++ x ^= x >>> 32; ++ x *= 0xd6e8feb86659fd93L; ++ x ^= x >>> 32; ++ return x; ++ } ++ ++ public static long hash3(long x) { ++ x ^= x >>> 45; ++ x *= 0xc161abe5704b6c79L; ++ x ^= x >>> 41; ++ x *= 0xe3e5389aedbc90f7L; ++ x ^= x >>> 56; ++ x *= 0x1f9aba75a52db073L; ++ x ^= x >>> 53; ++ return x; ++ } ++ ++ private IntegerUtil() { ++ throw new RuntimeException(); ++ } ++} +diff --git a/src/main/java/ca/spottedleaf/starlight/common/util/SaveUtil.java b/src/main/java/ca/spottedleaf/starlight/common/util/SaveUtil.java +new file mode 100644 +index 0000000000000000000000000000000000000000..0cfb9c213e7970e98895cafdc9dd4b66cf557d72 +--- /dev/null ++++ b/src/main/java/ca/spottedleaf/starlight/common/util/SaveUtil.java +@@ -0,0 +1,185 @@ ++package ca.spottedleaf.starlight.common.util; ++ ++import ca.spottedleaf.starlight.common.light.SWMRNibbleArray; ++import ca.spottedleaf.starlight.common.light.StarLightEngine; ++import net.minecraft.nbt.CompoundTag; ++import net.minecraft.nbt.ListTag; ++import net.minecraft.server.level.ServerLevel; ++import net.minecraft.world.level.ChunkPos; ++import net.minecraft.world.level.Level; ++import net.minecraft.world.level.chunk.ChunkAccess; ++import net.minecraft.world.level.chunk.ChunkStatus; ++import org.apache.logging.log4j.LogManager; ++import org.apache.logging.log4j.Logger; ++ ++public final class SaveUtil { ++ ++ private static final Logger LOGGER = LogManager.getLogger(); ++ ++ private static final int STARLIGHT_LIGHT_VERSION = 6; ++ ++ private static final String BLOCKLIGHT_STATE_TAG = "starlight.blocklight_state"; ++ private static final String SKYLIGHT_STATE_TAG = "starlight.skylight_state"; ++ private static final String STARLIGHT_VERSION_TAG = "starlight.light_version"; ++ ++ public static void saveLightHook(final Level world, final ChunkAccess chunk, final CompoundTag nbt) { ++ try { ++ saveLightHookReal(world, chunk, nbt); ++ } catch (final Exception ex) { ++ // failing to inject is not fatal so we catch anything here. if it fails, it will have correctly set lit to false ++ // for Vanilla to relight on load and it will not set our lit tag so we will relight on load ++ LOGGER.warn("Failed to inject light data into save data for chunk " + chunk.getPos() + ", chunk light will be recalculated on its next load", ex); ++ } ++ } ++ ++ private static void saveLightHookReal(final Level world, final ChunkAccess chunk, final CompoundTag nbt) { ++ if (nbt == null) { ++ return; ++ } ++ ++ final int minSection = WorldUtil.getMinLightSection(world); ++ final int maxSection = WorldUtil.getMaxLightSection(world); ++ ++ SWMRNibbleArray[] blockNibbles = chunk.getBlockNibbles(); ++ SWMRNibbleArray[] skyNibbles = chunk.getSkyNibbles(); ++ ++ CompoundTag level = nbt.getCompound("Level"); ++ boolean lit = chunk.isLightCorrect() || !(world instanceof ServerLevel); ++ // diff start - store our tag for whether light data is init'd ++ if (lit) { ++ level.putBoolean("isLightOn", false); ++ } ++ // diff end - store our tag for whether light data is init'd ++ ChunkStatus status = ChunkStatus.byName(level.getString("Status")); ++ ++ CompoundTag[] sections = new CompoundTag[maxSection - minSection + 1]; ++ ++ ListTag sectionsStored = level.getList("Sections", 10); ++ ++ for (int i = 0; i < sectionsStored.size(); ++i) { ++ CompoundTag sectionStored = sectionsStored.getCompound(i); ++ int k = sectionStored.getByte("Y"); ++ ++ // strip light data ++ sectionStored.remove("BlockLight"); ++ sectionStored.remove("SkyLight"); ++ ++ if (!sectionStored.isEmpty()) { ++ sections[k - minSection] = sectionStored; ++ } ++ } ++ ++ if (lit && status.isOrAfter(ChunkStatus.LIGHT)) { ++ for (int i = minSection; i <= maxSection; ++i) { ++ SWMRNibbleArray.SaveState blockNibble = blockNibbles[i - minSection].getSaveState(); ++ SWMRNibbleArray.SaveState skyNibble = skyNibbles[i - minSection].getSaveState(); ++ if (blockNibble != null || skyNibble != null) { ++ CompoundTag section = sections[i - minSection]; ++ if (section == null) { ++ section = new CompoundTag(); ++ section.putByte("Y", (byte)i); ++ sections[i - minSection] = section; ++ } ++ ++ // we store under the same key so mod programs editing nbt ++ // can still read the data, hopefully. ++ // however, for compatibility we store chunks as unlit so vanilla ++ // is forced to re-light them if it encounters our data. It's too much of a burden ++ // to try and maintain compatibility with a broken and inferior skylight management system. ++ ++ if (blockNibble != null) { ++ if (blockNibble.data != null) { ++ section.putByteArray("BlockLight", blockNibble.data); ++ } ++ section.putInt(BLOCKLIGHT_STATE_TAG, blockNibble.state); ++ } ++ ++ if (skyNibble != null) { ++ if (skyNibble.data != null) { ++ section.putByteArray("SkyLight", skyNibble.data); ++ } ++ section.putInt(SKYLIGHT_STATE_TAG, skyNibble.state); ++ } ++ } ++ } ++ } ++ ++ // rewrite section list ++ sectionsStored.clear(); ++ for (CompoundTag section : sections) { ++ if (section != null) { ++ sectionsStored.add(section); ++ } ++ } ++ level.put("Sections", sectionsStored); ++ if (lit) { ++ level.putInt(STARLIGHT_VERSION_TAG, STARLIGHT_LIGHT_VERSION); // only mark as fully lit after we have successfully injected our data ++ } ++ } ++ ++ public static void loadLightHook(final Level world, final ChunkPos pos, final CompoundTag tag, final ChunkAccess into) { ++ try { ++ loadLightHookReal(world, pos, tag, into); ++ } catch (final Exception ex) { ++ // failing to inject is not fatal so we catch anything here. if it fails, then we simply relight. Not a problem, we get correct ++ // lighting in both cases. ++ LOGGER.warn("Failed to load light for chunk " + pos + ", light will be recalculated", ex); ++ } ++ } ++ ++ private static void loadLightHookReal(final Level world, final ChunkPos pos, final CompoundTag tag, final ChunkAccess into) { ++ if (into == null) { ++ return; ++ } ++ final int minSection = WorldUtil.getMinLightSection(world); ++ final int maxSection = WorldUtil.getMaxLightSection(world); ++ ++ into.setLightCorrect(false); // mark as unlit in case we fail parsing ++ ++ SWMRNibbleArray[] blockNibbles = StarLightEngine.getFilledEmptyLight(world); ++ SWMRNibbleArray[] skyNibbles = StarLightEngine.getFilledEmptyLight(world); ++ ++ ++ // start copy from from the original method ++ CompoundTag levelTag = tag.getCompound("Level"); ++ boolean lit = levelTag.get("isLightOn") != null && levelTag.getInt(STARLIGHT_VERSION_TAG) == STARLIGHT_LIGHT_VERSION; ++ boolean canReadSky = world.dimensionType().hasSkyLight(); ++ ChunkStatus status = ChunkStatus.byName(tag.getCompound("Level").getString("Status")); ++ if (lit && status.isOrAfter(ChunkStatus.LIGHT)) { // diff - we add the status check here ++ ListTag sections = levelTag.getList("Sections", 10); ++ ++ for (int i = 0; i < sections.size(); ++i) { ++ CompoundTag sectionData = sections.getCompound(i); ++ int y = sectionData.getByte("Y"); ++ ++ if (sectionData.contains("BlockLight", 7)) { ++ // this is where our diff is ++ blockNibbles[y - minSection] = new SWMRNibbleArray(sectionData.getByteArray("BlockLight").clone(), sectionData.getInt(BLOCKLIGHT_STATE_TAG)); // clone for data safety ++ } else { ++ blockNibbles[y - minSection] = new SWMRNibbleArray(null, sectionData.getInt(BLOCKLIGHT_STATE_TAG)); ++ } ++ ++ if (canReadSky) { ++ if (sectionData.contains("SkyLight", 7)) { ++ // we store under the same key so mod programs editing nbt ++ // can still read the data, hopefully. ++ // however, for compatibility we store chunks as unlit so vanilla ++ // is forced to re-light them if it encounters our data. It's too much of a burden ++ // to try and maintain compatibility with a broken and inferior skylight management system. ++ skyNibbles[y - minSection] = new SWMRNibbleArray(sectionData.getByteArray("SkyLight").clone(), sectionData.getInt(SKYLIGHT_STATE_TAG)); // clone for data safety ++ } else { ++ skyNibbles[y - minSection] = new SWMRNibbleArray(null, sectionData.getInt(SKYLIGHT_STATE_TAG)); ++ } ++ } ++ } ++ } ++ // end copy from vanilla ++ ++ into.setBlockNibbles(blockNibbles); ++ into.setSkyNibbles(skyNibbles); ++ into.setLightCorrect(lit); // now we set lit here, only after we've correctly parsed data ++ } ++ ++ private SaveUtil() {} ++ ++} +diff --git a/src/main/java/ca/spottedleaf/starlight/common/util/WorldUtil.java b/src/main/java/ca/spottedleaf/starlight/common/util/WorldUtil.java +new file mode 100644 +index 0000000000000000000000000000000000000000..dd995e25ae620ae36cd5eecb2fe10ad034ba50d2 +--- /dev/null ++++ b/src/main/java/ca/spottedleaf/starlight/common/util/WorldUtil.java +@@ -0,0 +1,47 @@ ++package ca.spottedleaf.starlight.common.util; ++ ++import net.minecraft.world.level.LevelHeightAccessor; ++ ++public final class WorldUtil { ++ ++ // min, max are inclusive ++ ++ public static int getMaxSection(final LevelHeightAccessor world) { ++ return world.getMaxSection() - 1; // getMaxSection() is exclusive ++ } ++ ++ public static int getMinSection(final LevelHeightAccessor world) { ++ return world.getMinSection(); ++ } ++ ++ public static int getMaxLightSection(final LevelHeightAccessor world) { ++ return getMaxSection(world) + 1; ++ } ++ ++ public static int getMinLightSection(final LevelHeightAccessor world) { ++ return getMinSection(world) - 1; ++ } ++ ++ ++ ++ public static int getTotalSections(final LevelHeightAccessor world) { ++ return getMaxSection(world) - getMinSection(world) + 1; ++ } ++ ++ public static int getTotalLightSections(final LevelHeightAccessor world) { ++ return getMaxLightSection(world) - getMinLightSection(world) + 1; ++ } ++ ++ public static int getMinBlockY(final LevelHeightAccessor world) { ++ return getMinSection(world) << 4; ++ } ++ ++ public static int getMaxBlockY(final LevelHeightAccessor world) { ++ return (getMaxSection(world) << 4) | 15; ++ } ++ ++ private WorldUtil() { ++ throw new RuntimeException(); ++ } ++ ++} diff --git a/src/main/java/com/destroystokyo/paper/PaperCommand.java b/src/main/java/com/destroystokyo/paper/PaperCommand.java -index f436ab35798c9b6e6cb2eb60d2c02cbf9b742e69..807bbe54f6516f794bdcb735bb7b8d6812e3ef01 100644 +index 85beb460aa59313cf2ace2d6a6bf24938e3e2b80..2ef4b4c2ff81d0fa33d4630593266066d8e6a6f3 100644 --- a/src/main/java/com/destroystokyo/paper/PaperCommand.java +++ b/src/main/java/com/destroystokyo/paper/PaperCommand.java @@ -501,6 +501,46 @@ public class PaperCommand extends Command { @@ -3789,87 +4406,34 @@ index f436ab35798c9b6e6cb2eb60d2c02cbf9b742e69..807bbe54f6516f794bdcb735bb7b8d68 net.minecraft.core.BlockPos center = MCUtil.toBlockPosition(player.getLocation()); Deque queue = new ArrayDeque<>(MCUtil.getSpiralOutChunks(center, radius)); updateLight(sender, world, lightengine, queue); -diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundLightUpdatePacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundLightUpdatePacket.java -index d8be2ad889f46491e50404916fb4ae0de5f42098..29ba097a7b230ef67d4d1b5f4ebe20cd5228d214 100644 ---- a/src/main/java/net/minecraft/network/protocol/game/ClientboundLightUpdatePacket.java -+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundLightUpdatePacket.java -@@ -32,25 +32,17 @@ public class ClientboundLightUpdatePacket implements Packet { -- if (remainingSends.get() == 0) { -- cleaner1.run(); -- cleaner2.run(); -- } -- }, "Light Packet Release"); -- } -+ // Paper - rewrite light engine - } - - @Override - public boolean hasFinishListener() { -- return true; -+ return false; // Paper - rewrite light engine - } - - // Paper end -@@ -63,8 +55,8 @@ public class ClientboundLightUpdatePacket implements Packet> fullChunkFuture; private int fullChunkCreateCount; private volatile boolean isFullChunkReady; // Paper - cache chunk ticking stage private volatile CompletableFuture> tickingChunkFuture; private volatile boolean isTickingReady; // Paper - cache chunk ticking stage private volatile CompletableFuture> entityTickingChunkFuture; private volatile boolean isEntityTickingReady; // Paper - cache chunk ticking stage - private CompletableFuture chunkToSave; -+ public CompletableFuture chunkToSave; // Paper - public ++ public CompletableFuture chunkToSave; // Paper - public @Nullable private final DebugBuffer chunkToSaveHistory; public int oldTicketLevel; diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java -index efaab00b73f48e267a033a4ef466dcbaf2af2044..aae8dca773686bec3f867b79aa11d668032b9244 100644 +index 7c4154b1b5ccc53af5f5fb186c2a5d1ff88c7af1..cf6f5388e171035a22e9c35c9dd5d75d147562a4 100644 --- a/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java -@@ -121,7 +121,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -130,7 +130,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider public final LongSet entitiesInLevel; public final ServerLevel level; private final ThreadedLevelLightEngine lightEngine; - private final BlockableEventLoop mainThreadExecutor; + public final BlockableEventLoop mainThreadExecutor; // Paper - public final java.util.concurrent.Executor mainInvokingExecutor; // Paper - public final ChunkGenerator generator; + public ChunkGenerator generator; public final Supplier overworldDataStorage; diff --git a/src/main/java/net/minecraft/server/level/ThreadedLevelLightEngine.java b/src/main/java/net/minecraft/server/level/ThreadedLevelLightEngine.java -index 833b6b2193cf08e123aabb344f2283730aed1bcd..136ca55ac38b709e086f8e2e68dc1d0db2670ae4 100644 +index fec2a2a9f958492eefbbffcaf8179a2fac5a4d99..731001489eb6d2562e4685af79efa8116941638d 100644 --- a/src/main/java/net/minecraft/server/level/ThreadedLevelLightEngine.java +++ b/src/main/java/net/minecraft/server/level/ThreadedLevelLightEngine.java @@ -25,6 +25,17 @@ import net.minecraft.world.level.lighting.LevelLightEngine; @@ -3877,7 +4441,7 @@ index 833b6b2193cf08e123aabb344f2283730aed1bcd..136ca55ac38b709e086f8e2e68dc1d0d import org.apache.logging.log4j.Logger; +// Paper start -+import ca.spottedleaf.starlight.light.StarLightEngine; ++import ca.spottedleaf.starlight.common.light.StarLightEngine; +import io.papermc.paper.util.CoordinateUtils; +import java.util.function.Supplier; +import net.minecraft.world.level.lighting.LayerLightEventListener; @@ -3895,7 +4459,7 @@ index 833b6b2193cf08e123aabb344f2283730aed1bcd..136ca55ac38b709e086f8e2e68dc1d0d private final AtomicBoolean scheduled = new AtomicBoolean(); + // Paper start - replace light engine impl -+ protected final ca.spottedleaf.starlight.light.StarLightInterface theLightEngine; ++ protected final ca.spottedleaf.starlight.common.light.StarLightInterface theLightEngine; + public final boolean hasBlockLight; + public final boolean hasSkyLight; + // Paper end - replace light engine impl @@ -3909,11 +4473,11 @@ index 833b6b2193cf08e123aabb344f2283730aed1bcd..136ca55ac38b709e086f8e2e68dc1d0d + // Paper start - replace light engine impl + this.hasBlockLight = true; + this.hasSkyLight = hasBlockLight; // Nice variable name. -+ this.theLightEngine = new ca.spottedleaf.starlight.light.StarLightInterface(chunkProvider, this.hasSkyLight, this.hasBlockLight, this); ++ this.theLightEngine = new ca.spottedleaf.starlight.common.light.StarLightInterface(chunkProvider, this.hasSkyLight, this.hasBlockLight, this); + // Paper end - replace light engine impl + } + -+ // Paper start - replace light engine impl ++// Paper start - replace light engine impl + protected final ChunkAccess getChunk(final int chunkX, final int chunkZ) { + return ((ServerLevel)this.theLightEngine.getWorld()).getChunkSource().getChunkAtImmediately(chunkX, chunkZ); + } @@ -4002,7 +4566,7 @@ index 833b6b2193cf08e123aabb344f2283730aed1bcd..136ca55ac38b709e086f8e2e68dc1d0d + final int references = this.chunksBeingWorkedOn.addTo(key, 1); + if (references == 0) { + final ChunkPos pos = new ChunkPos(chunkX, chunkZ); -+ world.getChunkSource().addRegionTicket(ca.spottedleaf.starlight.light.StarLightInterface.CHUNK_WORK_TICKET, pos, 0, pos); ++ world.getChunkSource().addRegionTicket(ca.spottedleaf.starlight.common.light.StarLightInterface.CHUNK_WORK_TICKET, pos, 0, pos); + } + + // append future to this chunk and 1 radius neighbours chunk save futures @@ -4024,7 +4588,7 @@ index 833b6b2193cf08e123aabb344f2283730aed1bcd..136ca55ac38b709e086f8e2e68dc1d0d + if (newReferences == 1) { + this.chunksBeingWorkedOn.remove(key); + final ChunkPos pos = new ChunkPos(chunkX, chunkZ); -+ world.getChunkSource().removeRegionTicket(ca.spottedleaf.starlight.light.StarLightInterface.CHUNK_WORK_TICKET, pos, 0, pos); ++ world.getChunkSource().removeRegionTicket(ca.spottedleaf.starlight.common.light.StarLightInterface.CHUNK_WORK_TICKET, pos, 0, pos); + } else { + this.chunksBeingWorkedOn.put(key, newReferences - 1); + } @@ -4053,7 +4617,7 @@ index 833b6b2193cf08e123aabb344f2283730aed1bcd..136ca55ac38b709e086f8e2e68dc1d0d + final int block = this.theLightEngine.getBlockReader().getLightValue(pos); + return Math.max(sky, block); + } -+ // Paper end - replace light engine impl ++ // Paper end - replace light engine imp + @Override public void close() { @@ -4100,15 +4664,15 @@ index 833b6b2193cf08e123aabb344f2283730aed1bcd..136ca55ac38b709e086f8e2e68dc1d0d } @Override - public void enableLightSources(ChunkPos chunkPos, boolean bl) { + public void enableLightSources(ChunkPos pos, boolean retainData) { + if (true) return; // Paper - replace light engine impl - this.addTask(chunkPos.x, chunkPos.z, ThreadedLevelLightEngine.TaskType.PRE_UPDATE, Util.name(() -> { - super.enableLightSources(chunkPos, bl); + this.addTask(pos.x, pos.z, ThreadedLevelLightEngine.TaskType.PRE_UPDATE, Util.name(() -> { + super.enableLightSources(pos, retainData); }, () -> { @@ -233,6 +397,7 @@ public class ThreadedLevelLightEngine extends LevelLightEngine implements AutoCl @Override - public void queueSectionData(LightLayer lightType, SectionPos pos, @Nullable DataLayer nibbles, boolean bl) { + public void queueSectionData(LightLayer lightType, SectionPos pos, @Nullable DataLayer nibbles, boolean nonEdge) { + if (true) return; // Paper - replace light engine impl this.addTask(pos.x(), pos.z(), () -> { return 0; @@ -4164,7 +4728,7 @@ index 833b6b2193cf08e123aabb344f2283730aed1bcd..136ca55ac38b709e086f8e2e68dc1d0d public void tryScheduleUpdate() { - if ((!this.queue.isEmpty() || super.hasLightWork()) && this.scheduled.compareAndSet(false, true)) { // Paper -+ if (this.hasLightWork() && this.scheduled.compareAndSet(false, true)) { // Paper // Paper - rewrite light engine ++ if (this.hasLightWork() && this.scheduled.compareAndSet(false, true)) { // Paper // Paper - rewrite light engine this.taskMailbox.tell(() -> { this.runUpdate(); this.scheduled.set(false); @@ -4184,22 +4748,22 @@ index 833b6b2193cf08e123aabb344f2283730aed1bcd..136ca55ac38b709e086f8e2e68dc1d0d // Paper end } diff --git a/src/main/java/net/minecraft/server/level/TicketType.java b/src/main/java/net/minecraft/server/level/TicketType.java -index 41ddcf6775f99c56cf4b13b284420061e5dd6bdc..ae46429264e6a7e5c88b6b6a41a6df4db7b3e70d 100644 +index 3c1698ba0d3bc412ab957777d9b5211dbc555208..858e94f07b675f4aed2930491633fb6e3a7d168e 100644 --- a/src/main/java/net/minecraft/server/level/TicketType.java +++ b/src/main/java/net/minecraft/server/level/TicketType.java -@@ -32,6 +32,7 @@ public class TicketType { +@@ -31,6 +31,7 @@ public class TicketType { + public static final TicketType PLUGIN = TicketType.create("plugin", (a, b) -> 0); // CraftBukkit public static final TicketType PLUGIN_TICKET = TicketType.create("plugin_ticket", (plugin1, plugin2) -> plugin1.getClass().getName().compareTo(plugin2.getClass().getName())); // CraftBukkit public static final TicketType DELAY_UNLOAD = create("delay_unload", Long::compareTo, 300); // Paper - public static final TicketType REQUIRED_LOAD = create("required_load", Long::compareTo); // Paper - make sure getChunkAt does not fail + public static final TicketType CHUNK_RELIGHT = create("light_update", Long::compareTo); // Paper - ensure chunks stay loaded for lighting public static TicketType create(String name, Comparator argumentComparator) { return new TicketType<>(name, argumentComparator, 0L); diff --git a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java -index b534fd9e5d2a17926282cf40c9d66a2143a37bfe..4a7fdea6a5f966db444dc41f7215faa99e3820b3 100644 +index ce4848bdd00c091b9eb5fa2d47b03378d43c91b2..1831588b275f11aff37573fead835f6ddabfece1 100644 --- a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java +++ b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java -@@ -643,6 +643,7 @@ public abstract class BlockBehaviour { +@@ -684,6 +684,7 @@ public abstract class BlockBehaviour { this.isViewBlocking = blockbase_info.isViewBlocking; this.hasPostProcess = blockbase_info.hasPostProcess; this.emissiveRendering = blockbase_info.emissiveRendering; @@ -4207,7 +4771,7 @@ index b534fd9e5d2a17926282cf40c9d66a2143a37bfe..4a7fdea6a5f966db444dc41f7215faa9 } // Paper start - impl cached craft block data, lazy load to fix issue with loading at the wrong time private org.bukkit.craftbukkit.block.data.CraftBlockData cachedCraftBlockData; -@@ -663,6 +664,18 @@ public abstract class BlockBehaviour { +@@ -704,6 +705,18 @@ public abstract class BlockBehaviour { protected boolean isTicking; protected FluidState fluid; // Paper end @@ -4226,7 +4790,7 @@ index b534fd9e5d2a17926282cf40c9d66a2143a37bfe..4a7fdea6a5f966db444dc41f7215faa9 public void initCache() { this.fluid = this.getBlock().getFluidState(this.asState()); // Paper - moved from getFluid() -@@ -671,6 +684,7 @@ public abstract class BlockBehaviour { +@@ -712,6 +725,7 @@ public abstract class BlockBehaviour { this.cache = new BlockBehaviour.BlockStateBase.Cache(this.asState()); } this.shapeExceedsCube = this.cache == null || this.cache.largeCollisionShape; // Paper - moved from actual method to here @@ -4235,395 +4799,246 @@ index b534fd9e5d2a17926282cf40c9d66a2143a37bfe..4a7fdea6a5f966db444dc41f7215faa9 } diff --git a/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java b/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java -index 8393950a0b38ec7897d7643803d5accdb1f983f3..ae2050da03ea2ed82b5b0dadbe4e9d37162e8fdb 100644 +index a44901edc49259ebbbb4367b0d10b8daa76b07cd..4a04e742ffa090046341974cf8ec9c1b97dc382d 100644 --- a/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java +++ b/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java -@@ -41,6 +41,36 @@ public interface ChunkAccess extends BlockGetter, FeatureAccess { - net.minecraft.world.level.Level getLevel(); - // Paper end - -+ // Paper start -+ default ca.spottedleaf.starlight.light.SWMRNibbleArray[] getBlockNibbles() { -+ throw new UnsupportedOperationException(this.getClass().getName()); -+ } -+ default void setBlockNibbles(ca.spottedleaf.starlight.light.SWMRNibbleArray[] nibbles) { -+ throw new UnsupportedOperationException(this.getClass().getName()); -+ } -+ -+ default ca.spottedleaf.starlight.light.SWMRNibbleArray[] getSkyNibbles() { -+ throw new UnsupportedOperationException(this.getClass().getName()); -+ } -+ default void setSkyNibbles(ca.spottedleaf.starlight.light.SWMRNibbleArray[] nibbles) { -+ throw new UnsupportedOperationException(this.getClass().getName()); -+ } -+ public default boolean[] getSkyEmptinessMap() { -+ throw new UnsupportedOperationException(this.getClass().getName()); -+ } -+ public default void setSkyEmptinessMap(final boolean[] emptinessMap) { -+ throw new UnsupportedOperationException(this.getClass().getName()); -+ } -+ -+ public default boolean[] getBlockEmptinessMap() { -+ throw new UnsupportedOperationException(this.getClass().getName()); -+ } -+ -+ public default void setBlockEmptinessMap(final boolean[] emptinessMap) { -+ throw new UnsupportedOperationException(this.getClass().getName()); -+ } -+ // Paper end -+ - BlockState getType(final int x, final int y, final int z); // Paper - @Nullable - BlockState setBlockState(BlockPos pos, BlockState state, boolean moved); -diff --git a/src/main/java/net/minecraft/world/level/chunk/DataLayer.java b/src/main/java/net/minecraft/world/level/chunk/DataLayer.java -index 68a6c4db5980e733d81ef9a34cf32950f0983de6..0ed00b98e2e183aa6a8a2dfeaabea6b3c8ab97a9 100644 ---- a/src/main/java/net/minecraft/world/level/chunk/DataLayer.java -+++ b/src/main/java/net/minecraft/world/level/chunk/DataLayer.java -@@ -12,7 +12,7 @@ public final class DataLayer { - public static final int SIZE = 2048; - private static final int NIBBLE_SIZE = 4; - @Nullable -- protected byte[] data; -+ protected byte[] data; public final byte[] getDataRaw() { return this.data; } // Paper - provide accessor - // Paper start - public static byte[] EMPTY_NIBBLE = new byte[2048]; - private static final int nibbleBucketSizeMultiplier = Integer.getInteger("Paper.nibbleBucketSize", 3072); -@@ -55,6 +55,7 @@ public final class DataLayer { - boolean poolSafe = false; - public java.lang.Runnable cleaner; - private void registerCleaner() { -+ if (true) return; // Paper - purge cleaner usage - if (!poolSafe) { - cleaner = net.minecraft.server.MCUtil.registerCleaner(this, this.data, DataLayer::releaseBytes); - } else { -@@ -69,7 +70,7 @@ public final class DataLayer { - } - public DataLayer(byte[] bytes, boolean isSafe) { - this.data = bytes; -- if (!isSafe) this.data = getCloneIfSet(); // Paper - clone for safety -+ // Paper - purge cleaner usage - registerCleaner(); - // Paper end - if (bytes.length != 2048) { -@@ -155,7 +156,7 @@ public final class DataLayer { - } - // Paper end - public DataLayer copy() { -- return this.data == null ? new DataLayer() : new DataLayer(this.data); // Paper - clone in ctor -+ return this.data == null ? new DataLayer() : new DataLayer(this.data.clone()); // Paper - clone in ctor // Paper - no longer clone in constructor - } - - public String toString() { -diff --git a/src/main/java/net/minecraft/world/level/chunk/ImposterProtoChunk.java b/src/main/java/net/minecraft/world/level/chunk/ImposterProtoChunk.java -index 8245c5834ec69beb8e3b95fb3900601009a9273f..5f6b611dc99cc04cd553b9e01dba19ec6d8b250e 100644 ---- a/src/main/java/net/minecraft/world/level/chunk/ImposterProtoChunk.java -+++ b/src/main/java/net/minecraft/world/level/chunk/ImposterProtoChunk.java -@@ -1,5 +1,6 @@ - package net.minecraft.world.level.chunk; - -+import ca.spottedleaf.starlight.light.SWMRNibbleArray; - import it.unimi.dsi.fastutil.longs.LongSet; - import java.util.BitSet; - import java.util.Map; -@@ -29,6 +30,48 @@ public class ImposterProtoChunk extends ProtoChunk { - this.wrapped = wrapped; - } +@@ -77,6 +77,48 @@ public abstract class ChunkAccess implements BlockGetter, BiomeManager.NoiseBiom + protected final LevelHeightAccessor levelHeightAccessor; + protected final LevelChunkSection[] sections; + // Paper start - rewrite light engine -+ @Override -+ public SWMRNibbleArray[] getBlockNibbles() { -+ return this.getWrapped().getBlockNibbles(); -+ } ++ private volatile ca.spottedleaf.starlight.common.light.SWMRNibbleArray[] blockNibbles; + -+ @Override -+ public void setBlockNibbles(SWMRNibbleArray[] nibbles) { -+ this.getWrapped().setBlockNibbles(nibbles); -+ } ++ private volatile ca.spottedleaf.starlight.common.light.SWMRNibbleArray[] skyNibbles; + -+ @Override -+ public SWMRNibbleArray[] getSkyNibbles() { -+ return this.getWrapped().getSkyNibbles(); -+ } ++ private volatile boolean[] skyEmptinessMap; + -+ @Override -+ public void setSkyNibbles(SWMRNibbleArray[] nibbles) { -+ this.getWrapped().setSkyNibbles(nibbles); -+ } ++ private volatile boolean[] blockEmptinessMap; + -+ @Override -+ public boolean[] getSkyEmptinessMap() { -+ return this.getWrapped().getSkyEmptinessMap(); -+ } -+ -+ @Override -+ public void setSkyEmptinessMap(boolean[] emptinessMap) { -+ this.getWrapped().setSkyEmptinessMap(emptinessMap); -+ } -+ -+ @Override -+ public boolean[] getBlockEmptinessMap() { -+ return this.getWrapped().getBlockEmptinessMap(); -+ } -+ -+ @Override -+ public void setBlockEmptinessMap(boolean[] emptinessMap) { -+ this.getWrapped().setBlockEmptinessMap(emptinessMap); -+ } -+ // Paper end - rewrite light engine -+ - @Nullable - @Override - public BlockEntity getBlockEntity(BlockPos pos) { -diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java -index d580f0375cce5e995c024f1b0cd4843b5718121c..f0c43f9f636a5dd1f0dfbae604dfa1f4ff9ebd4e 100644 ---- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java -+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java -@@ -1,5 +1,7 @@ - package net.minecraft.world.level.chunk; - -+import ca.spottedleaf.starlight.light.SWMRNibbleArray; -+import ca.spottedleaf.starlight.light.StarLightEngine; - import com.google.common.collect.ImmutableList; - import com.destroystokyo.paper.exception.ServerInternalException; - import com.google.common.collect.Maps; -@@ -17,7 +19,6 @@ import java.util.Collections; - import java.util.Iterator; - import java.util.Map; - import java.util.Map.Entry; --import java.util.Objects; - import java.util.Set; - import java.util.function.Consumer; - import java.util.function.Supplier; -@@ -28,7 +29,6 @@ import net.minecraft.CrashReport; - import net.minecraft.CrashReportCategory; - import net.minecraft.ReportedException; - import net.minecraft.core.BlockPos; --import net.minecraft.core.DefaultedRegistry; - import net.minecraft.core.Registry; - import net.minecraft.core.SectionPos; - import net.minecraft.nbt.CompoundTag; -@@ -125,11 +125,62 @@ public class LevelChunk implements ChunkAccess { - private volatile boolean isLightCorrect; - private final Int2ObjectMap gameEventDispatcherSections; - -+ // Paper start - rewrite light engine -+ protected volatile SWMRNibbleArray[] blockNibbles; -+ protected volatile SWMRNibbleArray[] skyNibbles; -+ protected volatile boolean[] skyEmptinessMap; -+ protected volatile boolean[] blockEmptinessMap; -+ -+ @Override -+ public SWMRNibbleArray[] getBlockNibbles() { ++ public ca.spottedleaf.starlight.common.light.SWMRNibbleArray[] getBlockNibbles() { + return this.blockNibbles; + } + -+ @Override -+ public void setBlockNibbles(SWMRNibbleArray[] nibbles) { ++ public void setBlockNibbles(final ca.spottedleaf.starlight.common.light.SWMRNibbleArray[] nibbles) { + this.blockNibbles = nibbles; + } + -+ @Override -+ public SWMRNibbleArray[] getSkyNibbles() { ++ public ca.spottedleaf.starlight.common.light.SWMRNibbleArray[] getSkyNibbles() { + return this.skyNibbles; + } + -+ @Override -+ public void setSkyNibbles(SWMRNibbleArray[] nibbles) { ++ public void setSkyNibbles(final ca.spottedleaf.starlight.common.light.SWMRNibbleArray[] nibbles) { + this.skyNibbles = nibbles; + } + -+ @Override + public boolean[] getSkyEmptinessMap() { + return this.skyEmptinessMap; + } + -+ @Override -+ public void setSkyEmptinessMap(boolean[] emptinessMap) { ++ public void setSkyEmptinessMap(final boolean[] emptinessMap) { + this.skyEmptinessMap = emptinessMap; + } + -+ @Override + public boolean[] getBlockEmptinessMap() { + return this.blockEmptinessMap; + } + -+ @Override -+ public void setBlockEmptinessMap(boolean[] emptinessMap) { ++ public void setBlockEmptinessMap(final boolean[] emptinessMap) { + this.blockEmptinessMap = emptinessMap; + } + // Paper end - rewrite light engine + - public LevelChunk(Level world, ChunkPos pos, ChunkBiomeContainer biomes) { - this(world, pos, biomes, UpgradeData.EMPTY, EmptyTickList.empty(), EmptyTickList.empty(), 0L, (LevelChunkSection[]) null, (Consumer) null); + public ChunkAccess(ChunkPos pos, UpgradeData upgradeData, LevelHeightAccessor heightLimitView, Registry biome, long inhabitedTime, @Nullable LevelChunkSection[] sectionArrayInitializer, @Nullable BlendingData blendingData) { + this.locX = pos.x; this.locZ = pos.z; // Paper - reduce need for field lookups + this.chunkPos = pos; this.coordinateKey = ChunkPos.asLong(locX, locZ); // Paper - cache long key +diff --git a/src/main/java/net/minecraft/world/level/chunk/EmptyLevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/EmptyLevelChunk.java +index 25e9cc39d748dfd99d38f504c14f40f9ec7bdd2d..d14416f186292f2dda5f6539d285705226b7c699 100644 +--- a/src/main/java/net/minecraft/world/level/chunk/EmptyLevelChunk.java ++++ b/src/main/java/net/minecraft/world/level/chunk/EmptyLevelChunk.java +@@ -18,6 +18,38 @@ public class EmptyLevelChunk extends LevelChunk { + super(world, pos); } - public LevelChunk(Level world, ChunkPos pos, ChunkBiomeContainer biomes, UpgradeData upgradeData, TickList blockTickScheduler, TickList fluidTickScheduler, long inhabitedTime, @Nullable LevelChunkSection[] sections, @Nullable Consumer loadToWorldConsumer) { -+ // Paper start -+ this.blockNibbles = StarLightEngine.getFilledEmptyLight(world); -+ this.skyNibbles = StarLightEngine.getFilledEmptyLight(world); -+ // Paper end - this.pendingBlockEntities = Maps.newHashMap(); - this.tickersInLevel = Maps.newHashMap(); - this.heightmaps = Maps.newEnumMap(Heightmap.Types.class); -@@ -333,6 +384,12 @@ public class LevelChunk implements ChunkAccess { ++ @Override ++ public ca.spottedleaf.starlight.common.light.SWMRNibbleArray[] getBlockNibbles() { ++ return ca.spottedleaf.starlight.common.light.StarLightEngine.getFilledEmptyLight(this.getLevel()); ++ } ++ ++ @Override ++ public void setBlockNibbles(final ca.spottedleaf.starlight.common.light.SWMRNibbleArray[] nibbles) {} ++ ++ @Override ++ public ca.spottedleaf.starlight.common.light.SWMRNibbleArray[] getSkyNibbles() { ++ return ca.spottedleaf.starlight.common.light.StarLightEngine.getFilledEmptyLight(this.getLevel()); ++ } ++ ++ @Override ++ public void setSkyNibbles(final ca.spottedleaf.starlight.common.light.SWMRNibbleArray[] nibbles) {} ++ ++ @Override ++ public boolean[] getSkyEmptinessMap() { ++ return null; ++ } ++ ++ @Override ++ public void setSkyEmptinessMap(final boolean[] emptinessMap) {} ++ ++ @Override ++ public boolean[] getBlockEmptinessMap() { ++ return null; ++ } ++ ++ @Override ++ public void setBlockEmptinessMap(final boolean[] emptinessMap) {} ++ + // Paper start + @Override public BlockState getType(int x, int y, int z) { + return Blocks.VOID_AIR.defaultBlockState(); +diff --git a/src/main/java/net/minecraft/world/level/chunk/ImposterProtoChunk.java b/src/main/java/net/minecraft/world/level/chunk/ImposterProtoChunk.java +index 7c5b3acd299c5b021bd20f17ff0b89c8208a6623..d29739c3a67e60741a06fb25bcaf7705329804a4 100644 +--- a/src/main/java/net/minecraft/world/level/chunk/ImposterProtoChunk.java ++++ b/src/main/java/net/minecraft/world/level/chunk/ImposterProtoChunk.java +@@ -30,6 +30,48 @@ public class ImposterProtoChunk extends ProtoChunk { + private final LevelChunk wrapped; + private final boolean allowWrites; - public LevelChunk(ServerLevel worldserver, ProtoChunk protoChunk, @Nullable Consumer consumer) { - this(worldserver, protoChunk.getPos(), protoChunk.getBiomes(), protoChunk.getUpgradeData(), protoChunk.getBlockTicks(), protoChunk.getLiquidTicks(), protoChunk.getInhabitedTime(), protoChunk.getSections(), consumer); -+ // Paper start - copy over protochunk light ++ // Paper start - rewrite light engine ++ @Override ++ public ca.spottedleaf.starlight.common.light.SWMRNibbleArray[] getBlockNibbles() { ++ return this.wrapped.getBlockNibbles(); ++ } ++ ++ @Override ++ public void setBlockNibbles(final ca.spottedleaf.starlight.common.light.SWMRNibbleArray[] nibbles) { ++ this.wrapped.setBlockNibbles(nibbles); ++ } ++ ++ @Override ++ public ca.spottedleaf.starlight.common.light.SWMRNibbleArray[] getSkyNibbles() { ++ return this.wrapped.getSkyNibbles(); ++ } ++ ++ @Override ++ public void setSkyNibbles(final ca.spottedleaf.starlight.common.light.SWMRNibbleArray[] nibbles) { ++ this.wrapped.setSkyNibbles(nibbles); ++ } ++ ++ @Override ++ public boolean[] getSkyEmptinessMap() { ++ return this.wrapped.getSkyEmptinessMap(); ++ } ++ ++ @Override ++ public void setSkyEmptinessMap(final boolean[] emptinessMap) { ++ this.wrapped.setSkyEmptinessMap(emptinessMap); ++ } ++ ++ @Override ++ public boolean[] getBlockEmptinessMap() { ++ return this.wrapped.getBlockEmptinessMap(); ++ } ++ ++ @Override ++ public void setBlockEmptinessMap(final boolean[] emptinessMap) { ++ this.wrapped.setBlockEmptinessMap(emptinessMap); ++ } ++ // Paper end - rewrite light engine ++ + public ImposterProtoChunk(LevelChunk wrapped, boolean bl) { + super(wrapped.getPos(), UpgradeData.EMPTY, wrapped.levelHeightAccessor, wrapped.getLevel().registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), wrapped.getBlendingData()); + this.wrapped = wrapped; +diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java +index 0435c750ec03f65bad3f904070960d56c2ed4832..0a0f6efe5687f35bff31e39746636738c1248533 100644 +--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java ++++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java +@@ -100,6 +100,10 @@ public class LevelChunk extends ChunkAccess { + + public LevelChunk(Level world, ChunkPos pos, UpgradeData upgradeData, LevelChunkTicks blockTickScheduler, LevelChunkTicks fluidTickScheduler, long inhabitedTime, @Nullable LevelChunkSection[] sectionArrayInitializer, @Nullable LevelChunk.PostLoadProcessor entityLoader, @Nullable BlendingData blendingData) { + super(pos, upgradeData, world, world.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), inhabitedTime, sectionArrayInitializer, blendingData); ++ // Paper start - rewrite light engine ++ this.setBlockNibbles(ca.spottedleaf.starlight.common.light.StarLightEngine.getFilledEmptyLight(world)); ++ this.setSkyNibbles(ca.spottedleaf.starlight.common.light.StarLightEngine.getFilledEmptyLight(world)); ++ // Paper end - rewrite light engine + this.tickersInLevel = Maps.newHashMap(); + this.clientLightReady = false; + this.level = (ServerLevel) world; // CraftBukkit - type +@@ -327,6 +331,12 @@ public class LevelChunk extends ChunkAccess { + + public LevelChunk(ServerLevel world, ProtoChunk protoChunk, @Nullable LevelChunk.PostLoadProcessor chunk_c) { + this(world, protoChunk.getPos(), protoChunk.getUpgradeData(), protoChunk.unpackBlockTicks(), protoChunk.unpackFluidTicks(), protoChunk.getInhabitedTime(), protoChunk.getSections(), chunk_c, protoChunk.getBlendingData()); ++ // Paper start - rewrite light engine + this.setBlockNibbles(protoChunk.getBlockNibbles()); + this.setSkyNibbles(protoChunk.getSkyNibbles()); + this.setSkyEmptinessMap(protoChunk.getSkyEmptinessMap()); + this.setBlockEmptinessMap(protoChunk.getBlockEmptinessMap()); -+ // Paper end - copy over protochunk light ++ // Paper end - rewrite light engine Iterator iterator = protoChunk.getBlockEntities().values().iterator(); while (iterator.hasNext()) { -diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java -index cdac1f7b30e4c043dcb12ac9e29af926df8170bd..c1c95ac9deb134a0cf5c7763090ac5f3cddf24cc 100644 ---- a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java -+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java -@@ -18,7 +18,7 @@ public class LevelChunkSection { - short nonEmptyBlockCount; // Paper - package-private - private short tickingBlockCount; - private short tickingFluidCount; -- final PalettedContainer states; // Paper - package-private -+ public final PalettedContainer states; // Paper - package-private // Paper - public - - // Paper start - Anti-Xray - Add parameters - @Deprecated public LevelChunkSection(int yOffset) { this(yOffset, null, null, true); } // Notice for updates: Please make sure this constructor isn't used anywhere 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 554474d4b2e57d8a005b3c3b9b23f32a62243058..79fd7a6e8a6eb1f699d03801910d97066677311c 100644 +index dea80ddba894453a0229888adfa235638cc9f659..8005df9339d3dca5bd4ec72e502a9cb516d161a4 100644 --- a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java +++ b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java -@@ -174,7 +174,7 @@ public class PalettedContainer implements PaletteResize { - return this.get(y << 8 | z << 4 | x); // Paper - inline +@@ -127,7 +127,7 @@ public class PalettedContainer implements PaletteResize { + return this.get(this.strategy.getIndex(x, y, z)); } - protected T get(int index) { + public T get(int index) { // Paper - public - T object = this.palette.valueFor(this.storage.get(index)); - return (T)(object == null ? this.defaultValue : object); + PalettedContainer.Data data = this.data; + return data.palette.valueFor(data.storage.get(index)); } diff --git a/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java b/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java -index 7dc3d806a680150c6a2fffa1436fd63bbdc31eb3..e1b32b644bc976ff66258ed706f4d1e8de99420d 100644 +index 568dc3c9cbf009a3892766cacdd00667556e27c5..e7676e86c08affa8e730c13f11d4b269ca896ee8 100644 --- a/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java +++ b/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java -@@ -1,5 +1,7 @@ - package net.minecraft.world.level.chunk; +@@ -54,6 +54,12 @@ public class ProtoChunk extends ChunkAccess { -+import ca.spottedleaf.starlight.light.SWMRNibbleArray; -+import ca.spottedleaf.starlight.light.StarLightEngine; - import com.google.common.collect.Lists; - import com.google.common.collect.Maps; - import com.google.common.collect.Sets; -@@ -72,6 +74,53 @@ public class ProtoChunk implements ChunkAccess { - // Paper end - private static boolean PRINTED_OUTDATED_CTOR_MSG = false; // Paper - Add level - -+ // Paper start - rewrite light engine -+ protected volatile SWMRNibbleArray[] blockNibbles; -+ protected volatile SWMRNibbleArray[] skyNibbles; -+ protected volatile boolean[] skyEmptinessMap; -+ protected volatile boolean[] blockEmptinessMap; -+ -+ @Override -+ public SWMRNibbleArray[] getBlockNibbles() { -+ return this.blockNibbles; -+ } -+ -+ @Override -+ public void setBlockNibbles(SWMRNibbleArray[] nibbles) { -+ this.blockNibbles = nibbles; -+ } -+ -+ @Override -+ public SWMRNibbleArray[] getSkyNibbles() { -+ return this.skyNibbles; -+ } -+ -+ @Override -+ public void setSkyNibbles(SWMRNibbleArray[] nibbles) { -+ this.skyNibbles = nibbles; -+ } -+ -+ @Override -+ public boolean[] getSkyEmptinessMap() { -+ return this.skyEmptinessMap; -+ } -+ -+ @Override -+ public void setSkyEmptinessMap(boolean[] emptinessMap) { -+ this.skyEmptinessMap = emptinessMap; -+ } -+ -+ @Override -+ public boolean[] getBlockEmptinessMap() { -+ return this.blockEmptinessMap; -+ } -+ -+ @Override -+ public void setBlockEmptinessMap(boolean[] emptinessMap) { -+ this.blockEmptinessMap = emptinessMap; -+ } -+ // Paper end - rewrite light engine -+ - @Deprecated // Paper start - add level - public ProtoChunk(ChunkPos pos, UpgradeData upgradeData, LevelHeightAccessor world) { - // Paper start -@@ -100,6 +149,10 @@ public class ProtoChunk implements ChunkAccess { - } + public ProtoChunk(ChunkPos pos, UpgradeData upgradeData, @Nullable LevelChunkSection[] sections, ProtoChunkTicks blockTickScheduler, ProtoChunkTicks fluidTickScheduler, LevelHeightAccessor world, Registry biomeRegistry, @Nullable BlendingData blendingData) { + super(pos, upgradeData, world, biomeRegistry, 0L, sections, blendingData); ++ // Paper start - rewrite light engine ++ if (!(this instanceof ImposterProtoChunk)) { ++ this.setBlockNibbles(ca.spottedleaf.starlight.common.light.StarLightEngine.getFilledEmptyLight(world)); ++ this.setSkyNibbles(ca.spottedleaf.starlight.common.light.StarLightEngine.getFilledEmptyLight(world)); ++ } ++ // Paper end - rewrite light engine + this.blockTicks = blockTickScheduler; + this.fluidTicks = fluidTickScheduler; } - public ProtoChunk(ChunkPos pos, UpgradeData upgradeData, @Nullable LevelChunkSection[] levelChunkSections, ProtoTickList blockTickScheduler, ProtoTickList fluidTickScheduler, LevelHeightAccessor world, net.minecraft.server.level.ServerLevel level) { -+ // Paper start -+ this.blockNibbles = StarLightEngine.getFilledEmptyLight(world); -+ this.skyNibbles = StarLightEngine.getFilledEmptyLight(world); -+ // Paper end - this.level = level; - // Paper end - this.chunkPos = pos; -@@ -197,7 +250,7 @@ public class ProtoChunk implements ChunkAccess { - - LevelChunkSection levelChunkSection = this.getOrCreateSection(l); - BlockState blockState = levelChunkSection.setBlockState(i & 15, j & 15, k & 15, state); -- if (this.status.isOrAfter(ChunkStatus.FEATURES) && state != blockState && (state.getLightBlock(this, pos) != blockState.getLightBlock(this, pos) || state.getLightEmission() != blockState.getLightEmission() || state.useShapeForLightOcclusion() || blockState.useShapeForLightOcclusion())) { -+ if (this.status.isOrAfter(ChunkStatus.LIGHT) && state != blockState && (state.getLightBlock(this, pos) != blockState.getLightBlock(this, pos) || state.getLightEmission() != blockState.getLightEmission() || state.useShapeForLightOcclusion() || blockState.useShapeForLightOcclusion())) { // Paper - move block updates to only happen after lighting occurs (or during, thanks chunk system) - this.lightEngine.checkBlock(pos); - } - 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 80b9f3547bc30cb470d272132e96fcce188efd91..c81392f5b4a6dcef9c1864c1b2c268914b904561 100644 +index 45930793e7fffe6ce243c7637cb9c0e948c6a83d..e072a895ed71bb2e98a3a0c4aef37418c7c39f41 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 -@@ -63,6 +63,14 @@ import org.apache.logging.log4j.Logger; - - public class ChunkSerializer { +@@ -79,6 +79,14 @@ public class ChunkSerializer { + private static final String BLOCK_TICKS_TAG = "block_ticks"; + private static final String FLUID_TICKS_TAG = "fluid_ticks"; + // Paper start - replace light engine impl -+ private static final int STARLIGHT_LIGHT_VERSION = 5; ++ private static final int STARLIGHT_LIGHT_VERSION = 6; + + private static final String BLOCKLIGHT_STATE_TAG = "starlight.blocklight_state"; + private static final String SKYLIGHT_STATE_TAG = "starlight.skylight_state"; + private static final String STARLIGHT_VERSION_TAG = "starlight.light_version"; + // Paper end - replace light engine impl + - private static final Logger LOGGER = LogManager.getLogger(); - public static final String TAG_UPGRADE_DATA = "UpgradeData"; + public ChunkSerializer() {} -@@ -131,13 +139,20 @@ public class ChunkSerializer { - ProtoTickList protochunkticklist1 = new ProtoTickList<>((fluidtype) -> { - return fluidtype == null || fluidtype == Fluids.EMPTY; - }, pos, nbttagcompound1.getList("LiquidsToBeTicked", 9), world); -- boolean flag = nbttagcompound1.getBoolean("isLightOn"); -+ boolean flag = getStatus(nbt).isOrAfter(ChunkStatus.LIGHT) && nbttagcompound1.get("isLightOn") != null && nbttagcompound1.getInt(STARLIGHT_VERSION_TAG) == STARLIGHT_LIGHT_VERSION; // Paper - ListTag nbttaglist = nbttagcompound1.getList("Sections", 10); + // Paper start - guard against serializing mismatching coordinates +@@ -138,13 +146,20 @@ public class ChunkSerializer { + } + + UpgradeData chunkconverter = nbt.contains("UpgradeData", 10) ? new UpgradeData(nbt.getCompound("UpgradeData"), world) : UpgradeData.EMPTY; +- boolean flag = nbt.getBoolean("isLightOn"); ++ boolean flag = getStatus(nbt).isOrAfter(ChunkStatus.LIGHT) && nbt.get("isLightOn") != null && nbt.getInt(STARLIGHT_VERSION_TAG) == STARLIGHT_LIGHT_VERSION; // Paper + ListTag nbttaglist = nbt.getList("sections", 10); int i = world.getSectionsCount(); LevelChunkSection[] achunksection = new LevelChunkSection[i]; boolean flag1 = world.dimensionType().hasSkyLight(); ServerChunkCache chunkproviderserver = world.getChunkSource(); LevelLightEngine lightengine = chunkproviderserver.getLightEngine(); + // Paper start -+ ca.spottedleaf.starlight.light.SWMRNibbleArray[] blockNibbles = ca.spottedleaf.starlight.light.StarLightEngine.getFilledEmptyLight(world); // Paper - replace light impl -+ ca.spottedleaf.starlight.light.SWMRNibbleArray[] skyNibbles = ca.spottedleaf.starlight.light.StarLightEngine.getFilledEmptyLight(world); // Paper - replace light impl ++ ca.spottedleaf.starlight.common.light.SWMRNibbleArray[] blockNibbles = ca.spottedleaf.starlight.common.light.StarLightEngine.getFilledEmptyLight(world); // Paper - replace light impl ++ ca.spottedleaf.starlight.common.light.SWMRNibbleArray[] skyNibbles = ca.spottedleaf.starlight.common.light.StarLightEngine.getFilledEmptyLight(world); // Paper - replace light impl + final int minSection = io.papermc.paper.util.WorldUtil.getMinLightSection(world); + final int maxSection = io.papermc.paper.util.WorldUtil.getMaxLightSection(world); + boolean canReadSky = world.dimensionType().hasSkyLight(); @@ -4631,22 +5046,22 @@ index 80b9f3547bc30cb470d272132e96fcce188efd91..c81392f5b4a6dcef9c1864c1b2c26891 if (flag) { tasksToExecuteOnMain.add(() -> { // Paper - delay this task since we're executing off-main -@@ -146,7 +161,7 @@ public class ChunkSerializer { - } +@@ -158,7 +173,7 @@ public class ChunkSerializer { + DataResult dataresult; for (int j = 0; j < nbttaglist.size(); ++j) { -- CompoundTag nbttagcompound2 = nbttaglist.getCompound(j); -+ CompoundTag nbttagcompound2 = nbttaglist.getCompound(j); CompoundTag sectionData = nbttagcompound2; // Paper - byte b0 = nbttagcompound2.getByte("Y"); +- CompoundTag nbttagcompound1 = nbttaglist.getCompound(j); ++ CompoundTag nbttagcompound1 = nbttaglist.getCompound(j); CompoundTag sectionData = nbttagcompound1; // Paper + byte b0 = nbttagcompound1.getByte("Y"); + int k = world.getSectionIndexFromSectionY(b0); - if (nbttagcompound2.contains("Palette", 9) && nbttagcompound2.contains("BlockStates", 12)) { -@@ -164,23 +179,29 @@ public class ChunkSerializer { +@@ -199,23 +214,29 @@ public class ChunkSerializer { } if (flag) { -- if (nbttagcompound2.contains("BlockLight", 7)) { +- if (nbttagcompound1.contains("BlockLight", 7)) { - // Paper start - delay this task since we're executing off-main -- DataLayer blockLight = new DataLayer(nbttagcompound2.getByteArray("BlockLight")); +- DataLayer blockLight = new DataLayer(nbttagcompound1.getByteArray("BlockLight")); - tasksToExecuteOnMain.add(() -> { - lightengine.queueSectionData(LightLayer.BLOCK, SectionPos.of(chunkcoordintpair1, b0), blockLight, true); - }); @@ -4656,18 +5071,18 @@ index 80b9f3547bc30cb470d272132e96fcce188efd91..c81392f5b4a6dcef9c1864c1b2c26891 + + if (sectionData.contains("BlockLight", 7)) { + // this is where our diff is -+ blockNibbles[y - minSection] = new ca.spottedleaf.starlight.light.SWMRNibbleArray(sectionData.getByteArray("BlockLight").clone(), sectionData.getInt(BLOCKLIGHT_STATE_TAG)); // clone for data safety ++ blockNibbles[y - minSection] = new ca.spottedleaf.starlight.common.light.SWMRNibbleArray(sectionData.getByteArray("BlockLight").clone(), sectionData.getInt(BLOCKLIGHT_STATE_TAG)); // clone for data safety + } else { -+ blockNibbles[y - minSection] = new ca.spottedleaf.starlight.light.SWMRNibbleArray(null, sectionData.getInt(BLOCKLIGHT_STATE_TAG)); ++ blockNibbles[y - minSection] = new ca.spottedleaf.starlight.common.light.SWMRNibbleArray(null, sectionData.getInt(BLOCKLIGHT_STATE_TAG)); } -- if (flag1 && nbttagcompound2.contains("SkyLight", 7)) { +- if (flag1 && nbttagcompound1.contains("SkyLight", 7)) { - // Paper start - delay this task since we're executing off-main -- DataLayer skyLight = new DataLayer(nbttagcompound2.getByteArray("SkyLight")); +- DataLayer skyLight = new DataLayer(nbttagcompound1.getByteArray("SkyLight")); - tasksToExecuteOnMain.add(() -> { - lightengine.queueSectionData(LightLayer.SKY, SectionPos.of(chunkcoordintpair1, b0), skyLight, true); - }); -- // Paper end - delay this task since we're executing off-main +- // Paper end - delay this task since we're executing off-mai + if (canReadSky) { + if (sectionData.contains("SkyLight", 7)) { + // we store under the same key so mod programs editing nbt @@ -4675,29 +5090,34 @@ index 80b9f3547bc30cb470d272132e96fcce188efd91..c81392f5b4a6dcef9c1864c1b2c26891 + // however, for compatibility we store chunks as unlit so vanilla + // is forced to re-light them if it encounters our data. It's too much of a burden + // to try and maintain compatibility with a broken and inferior skylight management system. -+ skyNibbles[y - minSection] = new ca.spottedleaf.starlight.light.SWMRNibbleArray(sectionData.getByteArray("SkyLight").clone(), sectionData.getInt(SKYLIGHT_STATE_TAG)); // clone for data safety ++ skyNibbles[y - minSection] = new ca.spottedleaf.starlight.common.light.SWMRNibbleArray(sectionData.getByteArray("SkyLight").clone(), sectionData.getInt(SKYLIGHT_STATE_TAG)); // clone for data safety + } else { -+ skyNibbles[y - minSection] = new ca.spottedleaf.starlight.light.SWMRNibbleArray(null, sectionData.getInt(SKYLIGHT_STATE_TAG)); ++ skyNibbles[y - minSection] = new ca.spottedleaf.starlight.common.light.SWMRNibbleArray(null, sectionData.getInt(SKYLIGHT_STATE_TAG)); + } } + // Paper end - rewrite light engine } } -@@ -224,8 +245,12 @@ public class ChunkSerializer { - object = new LevelChunk(world.getLevel(), pos, biomestorage, chunkconverter, (TickList) object1, (TickList) object2, k, achunksection, // Paper start - fix massive nbt memory leak due to lambda. move lambda into a container method to not leak scope. Only clone needed NBT keys. - createLoadEntitiesConsumer(new SafeNBTCopy(nbttagcompound1, "TileEntities", "Entities", "ChunkBukkitValues")) // Paper - move CB Chunk PDC into here - );// Paper end +@@ -244,6 +265,8 @@ public class ChunkSerializer { + }, chunkPos); + + object = new LevelChunk(world.getLevel(), chunkPos, chunkconverter, levelchunkticks, levelchunkticks1, l, achunksection, ChunkSerializer.postLoadChunk(world, nbt), blendingdata); + ((LevelChunk)object).setBlockNibbles(blockNibbles); // Paper - replace light impl + ((LevelChunk)object).setSkyNibbles(skyNibbles); // Paper - replace light impl } else { - ProtoChunk protochunk = new ProtoChunk(pos, chunkconverter, achunksection, protochunkticklist, protochunkticklist1, world, world); // Paper - add level + ProtoChunkTicks protochunkticklist = ProtoChunkTicks.load(nbt.getList("block_ticks", 10), (s) -> { + return Registry.BLOCK.getOptional(ResourceLocation.tryParse(s)); +@@ -252,6 +275,8 @@ public class ChunkSerializer { + return Registry.FLUID.getOptional(ResourceLocation.tryParse(s)); + }, chunkPos); + ProtoChunk protochunk = new ProtoChunk(chunkPos, chunkconverter, achunksection, protochunkticklist, protochunkticklist1, world, iregistry, blendingdata); + protochunk.setBlockNibbles(blockNibbles); // Paper - replace light impl + protochunk.setSkyNibbles(skyNibbles); // Paper - replace light impl - protochunk.setBiomes(biomestorage); object = protochunk; -@@ -406,7 +431,7 @@ public class ChunkSerializer { + protochunk.setInhabitedTime(l); +@@ -390,7 +415,7 @@ public class ChunkSerializer { DataLayer[] blockLight = new DataLayer[lightenginethreaded.getMaxLightSection() - lightenginethreaded.getMinLightSection()]; DataLayer[] skyLight = new DataLayer[lightenginethreaded.getMaxLightSection() - lightenginethreaded.getMinLightSection()]; @@ -4706,23 +5126,23 @@ index 80b9f3547bc30cb470d272132e96fcce188efd91..c81392f5b4a6dcef9c1864c1b2c26891 DataLayer blockArray = lightenginethreaded.getLayerListener(LightLayer.BLOCK).getDataLayerData(SectionPos.of(chunkPos, i)); DataLayer skyArray = lightenginethreaded.getLayerListener(LightLayer.SKY).getDataLayerData(SectionPos.of(chunkPos, i)); -@@ -455,6 +480,12 @@ public class ChunkSerializer { - return saveChunk(world, chunk, null); +@@ -442,6 +467,12 @@ public class ChunkSerializer { } - public static CompoundTag saveChunk(ServerLevel world, ChunkAccess chunk, AsyncSaveData asyncsavedata) { + public static CompoundTag saveChunk(ServerLevel world, ChunkAccess chunk, @org.checkerframework.checker.nullness.qual.Nullable AsyncSaveData asyncsavedata) { + // Paper end + // Paper start - rewrite light impl + final int minSection = io.papermc.paper.util.WorldUtil.getMinLightSection(world); + final int maxSection = io.papermc.paper.util.WorldUtil.getMaxLightSection(world); -+ ca.spottedleaf.starlight.light.SWMRNibbleArray[] blockNibbles = chunk.getBlockNibbles(); -+ ca.spottedleaf.starlight.light.SWMRNibbleArray[] skyNibbles = chunk.getSkyNibbles(); ++ ca.spottedleaf.starlight.common.light.SWMRNibbleArray[] blockNibbles = chunk.getBlockNibbles(); ++ ca.spottedleaf.starlight.common.light.SWMRNibbleArray[] skyNibbles = chunk.getSkyNibbles(); + // Paper end - rewrite light impl - // Paper end ChunkPos chunkcoordintpair = chunk.getPos(); CompoundTag nbttagcompound = new CompoundTag(); -@@ -483,32 +514,33 @@ public class ChunkSerializer { - LevelChunkSection chunksection = (LevelChunkSection) Arrays.stream(achunksection).filter((chunksection1) -> { - return chunksection1 != null && SectionPos.blockToSectionCoord(chunksection1.bottomBlockY()) == finalI; // CraftBukkit - decompile errors - }).findFirst().orElse(LevelChunk.EMPTY_SECTION); + +@@ -492,20 +523,14 @@ public class ChunkSerializer { + for (int i = lightenginethreaded.getMinLightSection(); i < lightenginethreaded.getMaxLightSection(); ++i) { + int j = chunk.getSectionIndexFromSectionY(i); + boolean flag1 = j >= 0 && j < achunksection.length; - // Paper start - async chunk save for unload - DataLayer nibblearray; // block light - DataLayer nibblearray1; // sky light @@ -4734,23 +5154,32 @@ index 80b9f3547bc30cb470d272132e96fcce188efd91..c81392f5b4a6dcef9c1864c1b2c26891 - nibblearray1 = asyncsavedata.skyLight[i - lightenginethreaded.getMinLightSection()]; - } - // Paper end -- if (chunksection != LevelChunk.EMPTY_SECTION || nibblearray != null || nibblearray1 != null) { -- CompoundTag nbttagcompound2 = new CompoundTag(); -+ // Paper start - replace light engine -+ ca.spottedleaf.starlight.light.SWMRNibbleArray.SaveState blockNibble = blockNibbles[i - minSection].getSaveState(); -+ ca.spottedleaf.starlight.light.SWMRNibbleArray.SaveState skyNibble = skyNibbles[i - minSection].getSaveState(); -+ if (chunksection != LevelChunk.EMPTY_SECTION || blockNibble != null || skyNibble != null) { -+ // Paper end - replace light engine -+ CompoundTag nbttagcompound2 = new CompoundTag(); CompoundTag section = nbttagcompound2; // Paper ++ // Paper - replace light engine - nbttagcompound2.putByte("Y", (byte) (i & 255)); - if (chunksection != LevelChunk.EMPTY_SECTION) { - chunksection.getStates().write(nbttagcompound2, "Palette", "BlockStates"); +- if (flag1 || nibblearray != null || nibblearray1 != null) { +- CompoundTag nbttagcompound1 = new CompoundTag(); ++ // Paper start - replace light engine ++ ca.spottedleaf.starlight.common.light.SWMRNibbleArray.SaveState blockNibble = blockNibbles[i - minSection].getSaveState(); ++ ca.spottedleaf.starlight.common.light.SWMRNibbleArray.SaveState skyNibble = skyNibbles[i - minSection].getSaveState(); ++ if (flag1 || blockNibble != null || skyNibble != null) { ++ // Paper end - replace light engine ++ CompoundTag nbttagcompound1 = new CompoundTag(); CompoundTag section = nbttagcompound1; // Paper + + if (flag1) { + LevelChunkSection chunksection = achunksection[j]; +@@ -520,13 +545,27 @@ public class ChunkSerializer { + nbttagcompound1.put("biomes", (Tag) dataresult1.getOrThrow(false, logger1::error)); } - if (nibblearray != null && !nibblearray.isEmpty()) { -- nbttagcompound2.putByteArray("BlockLight", nibblearray.asBytesPoolSafe().clone()); // Paper -+ // Paper start - replace light engine +- nbttagcompound1.putByteArray("BlockLight", nibblearray.getData()); ++ // Paper start ++ // we store under the same key so mod programs editing nbt ++ // can still read the data, hopefully. ++ // however, for compatibility we store chunks as unlit so vanilla ++ // is forced to re-light them if it encounters our data. It's too much of a burden ++ // to try and maintain compatibility with a broken and inferior skylight management system. ++ + if (blockNibble != null) { + if (blockNibble.data != null) { + section.putByteArray("BlockLight", blockNibble.data); @@ -4759,24 +5188,24 @@ index 80b9f3547bc30cb470d272132e96fcce188efd91..c81392f5b4a6dcef9c1864c1b2c26891 } - if (nibblearray1 != null && !nibblearray1.isEmpty()) { -- nbttagcompound2.putByteArray("SkyLight", nibblearray1.asBytesPoolSafe().clone()); // Paper +- nbttagcompound1.putByteArray("SkyLight", nibblearray1.getData()); + if (skyNibble != null) { + if (skyNibble.data != null) { + section.putByteArray("SkyLight", skyNibble.data); + } + section.putInt(SKYLIGHT_STATE_TAG, skyNibble.state); } -+ // Paper end - replace light engine ++ // Paper end - nbttaglist.add(nbttagcompound2); - } -@@ -516,7 +548,8 @@ public class ChunkSerializer { + if (!nbttagcompound1.isEmpty()) { + nbttagcompound1.putByte("Y", (byte) i); +@@ -537,7 +576,8 @@ public class ChunkSerializer { - nbttagcompound1.put("Sections", nbttaglist); + nbttagcompound.put("sections", nbttaglist); if (flag) { -- nbttagcompound1.putBoolean("isLightOn", true); -+ nbttagcompound1.putInt(STARLIGHT_VERSION_TAG, STARLIGHT_LIGHT_VERSION); // Paper -+ nbttagcompound1.putBoolean("isLightOn", false); // Paper - set to false but still store, this allows us to detect --eraseCache (as eraseCache _removes_) +- nbttagcompound.putBoolean("isLightOn", true); ++ nbttagcompound.putInt(STARLIGHT_VERSION_TAG, STARLIGHT_LIGHT_VERSION); // Paper ++ nbttagcompound.putBoolean("isLightOn", false); // Paper - set to false but still store, this allows us to detect --eraseCache (as eraseCache _removes_) } - ChunkBiomeContainer biomestorage = chunk.getBiomes(); + // Paper start