diff --git a/leaf-server/minecraft-patches/features/0101-Collect-then-startEachNonRunningBehavior-in-Brain.patch b/leaf-archived-patches/removed/hardfork/server/0101-Collect-then-startEachNonRunningBehavior-in-Brain.patch similarity index 96% rename from leaf-server/minecraft-patches/features/0101-Collect-then-startEachNonRunningBehavior-in-Brain.patch rename to leaf-archived-patches/removed/hardfork/server/0101-Collect-then-startEachNonRunningBehavior-in-Brain.patch index c4960779..5909a99d 100644 --- a/leaf-server/minecraft-patches/features/0101-Collect-then-startEachNonRunningBehavior-in-Brain.patch +++ b/leaf-archived-patches/removed/hardfork/server/0101-Collect-then-startEachNonRunningBehavior-in-Brain.patch @@ -3,6 +3,7 @@ From: Taiyou06 Date: Tue, 9 Nov 2077 00:00:00 +0800 Subject: [PATCH] Collect then startEachNonRunningBehavior in Brain +Removed since Leaf 1.21.4, replaced by Cache potential behaviors in Brain patch diff --git a/net/minecraft/world/entity/ai/Brain.java b/net/minecraft/world/entity/ai/Brain.java index c561b749fb9b76ba9b1e9689089b743248c65d50..ea6c8e85ccff67b1c24109732f74f1e8199cad07 100644 diff --git a/leaf-server/minecraft-patches/features/0102-Lithium-equipment-tracking.patch b/leaf-server/minecraft-patches/features/0101-Lithium-equipment-tracking.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0102-Lithium-equipment-tracking.patch rename to leaf-server/minecraft-patches/features/0101-Lithium-equipment-tracking.patch diff --git a/leaf-server/minecraft-patches/features/0103-C2ME-Optimize-world-gen-math.patch b/leaf-server/minecraft-patches/features/0102-C2ME-Optimize-world-gen-math.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0103-C2ME-Optimize-world-gen-math.patch rename to leaf-server/minecraft-patches/features/0102-C2ME-Optimize-world-gen-math.patch diff --git a/leaf-server/minecraft-patches/features/0104-Cache-chunk-key.patch b/leaf-server/minecraft-patches/features/0103-Cache-chunk-key.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0104-Cache-chunk-key.patch rename to leaf-server/minecraft-patches/features/0103-Cache-chunk-key.patch diff --git a/leaf-server/minecraft-patches/features/0105-Cache-random-tick-block-status.patch b/leaf-server/minecraft-patches/features/0104-Cache-random-tick-block-status.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0105-Cache-random-tick-block-status.patch rename to leaf-server/minecraft-patches/features/0104-Cache-random-tick-block-status.patch diff --git a/leaf-server/minecraft-patches/features/0106-Cache-part-of-canHoldFluid-result.patch b/leaf-server/minecraft-patches/features/0105-Cache-part-of-canHoldFluid-result.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0106-Cache-part-of-canHoldFluid-result.patch rename to leaf-server/minecraft-patches/features/0105-Cache-part-of-canHoldFluid-result.patch diff --git a/leaf-server/minecraft-patches/features/0107-Configurable-tripwire-dupe.patch b/leaf-server/minecraft-patches/features/0106-Configurable-tripwire-dupe.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0107-Configurable-tripwire-dupe.patch rename to leaf-server/minecraft-patches/features/0106-Configurable-tripwire-dupe.patch diff --git a/leaf-server/minecraft-patches/features/0108-PaperPR-Fix-MC-117075-Block-Entities-Unload-Lag-Spik.patch b/leaf-server/minecraft-patches/features/0107-PaperPR-Fix-MC-117075-Block-Entities-Unload-Lag-Spik.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0108-PaperPR-Fix-MC-117075-Block-Entities-Unload-Lag-Spik.patch rename to leaf-server/minecraft-patches/features/0107-PaperPR-Fix-MC-117075-Block-Entities-Unload-Lag-Spik.patch diff --git a/leaf-server/minecraft-patches/features/0109-Sepals-Rearrange-the-attackable-conditions.patch b/leaf-server/minecraft-patches/features/0108-Sepals-Rearrange-the-attackable-conditions.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0109-Sepals-Rearrange-the-attackable-conditions.patch rename to leaf-server/minecraft-patches/features/0108-Sepals-Rearrange-the-attackable-conditions.patch diff --git a/leaf-server/minecraft-patches/features/0110-SparklyPaper-Skip-dirty-stats-copy-when-requesting-p.patch b/leaf-server/minecraft-patches/features/0109-SparklyPaper-Skip-dirty-stats-copy-when-requesting-p.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0110-SparklyPaper-Skip-dirty-stats-copy-when-requesting-p.patch rename to leaf-server/minecraft-patches/features/0109-SparklyPaper-Skip-dirty-stats-copy-when-requesting-p.patch diff --git a/leaf-server/minecraft-patches/features/0111-SparklyPaper-Reset-dirty-flag-when-loading-maps-from.patch b/leaf-server/minecraft-patches/features/0110-SparklyPaper-Reset-dirty-flag-when-loading-maps-from.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0111-SparklyPaper-Reset-dirty-flag-when-loading-maps-from.patch rename to leaf-server/minecraft-patches/features/0110-SparklyPaper-Reset-dirty-flag-when-loading-maps-from.patch diff --git a/leaf-server/minecraft-patches/features/0112-Optimize-checking-nearby-players-for-spawning.patch b/leaf-server/minecraft-patches/features/0111-Optimize-checking-nearby-players-for-spawning.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0112-Optimize-checking-nearby-players-for-spawning.patch rename to leaf-server/minecraft-patches/features/0111-Optimize-checking-nearby-players-for-spawning.patch diff --git a/leaf-server/minecraft-patches/features/0113-Cache-supporting-block-check.patch b/leaf-server/minecraft-patches/features/0112-Cache-supporting-block-check.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0113-Cache-supporting-block-check.patch rename to leaf-server/minecraft-patches/features/0112-Cache-supporting-block-check.patch diff --git a/leaf-server/minecraft-patches/features/0114-Avoid-useless-deque-clear-on-LevelTicks-cleanupAfter.patch b/leaf-server/minecraft-patches/features/0113-Avoid-useless-deque-clear-on-LevelTicks-cleanupAfter.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0114-Avoid-useless-deque-clear-on-LevelTicks-cleanupAfter.patch rename to leaf-server/minecraft-patches/features/0113-Avoid-useless-deque-clear-on-LevelTicks-cleanupAfter.patch diff --git a/leaf-server/minecraft-patches/features/0115-Replace-brain-activity-maps-with-optimized-collectio.patch b/leaf-server/minecraft-patches/features/0114-Replace-brain-activity-maps-with-optimized-collectio.patch similarity index 92% rename from leaf-server/minecraft-patches/features/0115-Replace-brain-activity-maps-with-optimized-collectio.patch rename to leaf-server/minecraft-patches/features/0114-Replace-brain-activity-maps-with-optimized-collectio.patch index dbdcd2c0..880b8ae0 100644 --- a/leaf-server/minecraft-patches/features/0115-Replace-brain-activity-maps-with-optimized-collectio.patch +++ b/leaf-server/minecraft-patches/features/0114-Replace-brain-activity-maps-with-optimized-collectio.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Replace brain activity maps with optimized collection diff --git a/net/minecraft/world/entity/ai/Brain.java b/net/minecraft/world/entity/ai/Brain.java -index ea6c8e85ccff67b1c24109732f74f1e8199cad07..e27284f9897923f67985e3d60c3438bd00cc4a51 100644 +index 778e3b99a7f941a53b87cbec510db8deed5d77c8..4dde1642a33349335f374f17123a700dde1079d7 100644 --- a/net/minecraft/world/entity/ai/Brain.java +++ b/net/minecraft/world/entity/ai/Brain.java @@ -390,8 +390,8 @@ public class Brain { diff --git a/leaf-server/minecraft-patches/features/0116-Remove-stream-in-villagers.patch b/leaf-server/minecraft-patches/features/0115-Remove-stream-in-villagers.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0116-Remove-stream-in-villagers.patch rename to leaf-server/minecraft-patches/features/0115-Remove-stream-in-villagers.patch diff --git a/leaf-server/minecraft-patches/features/0117-Optimize-baby-villager-sensor.patch b/leaf-server/minecraft-patches/features/0116-Optimize-baby-villager-sensor.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0117-Optimize-baby-villager-sensor.patch rename to leaf-server/minecraft-patches/features/0116-Optimize-baby-villager-sensor.patch diff --git a/leaf-server/minecraft-patches/features/0118-Only-player-pushable.patch b/leaf-server/minecraft-patches/features/0117-Only-player-pushable.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0118-Only-player-pushable.patch rename to leaf-server/minecraft-patches/features/0117-Only-player-pushable.patch diff --git a/leaf-server/minecraft-patches/features/0119-Remove-iterators-from-Inventory-contains.patch b/leaf-server/minecraft-patches/features/0118-Remove-iterators-from-Inventory-contains.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0119-Remove-iterators-from-Inventory-contains.patch rename to leaf-server/minecraft-patches/features/0118-Remove-iterators-from-Inventory-contains.patch diff --git a/leaf-server/minecraft-patches/features/0120-Cache-eligible-players-for-despawn-checks.patch b/leaf-server/minecraft-patches/features/0119-Cache-eligible-players-for-despawn-checks.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0120-Cache-eligible-players-for-despawn-checks.patch rename to leaf-server/minecraft-patches/features/0119-Cache-eligible-players-for-despawn-checks.patch diff --git a/leaf-server/minecraft-patches/features/0121-Slightly-optimise-getNearestPlayer.patch b/leaf-server/minecraft-patches/features/0120-Slightly-optimise-getNearestPlayer.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0121-Slightly-optimise-getNearestPlayer.patch rename to leaf-server/minecraft-patches/features/0120-Slightly-optimise-getNearestPlayer.patch diff --git a/leaf-server/minecraft-patches/features/0122-Use-ensureCapacity-to-pre-populate-the-size-of-ticki.patch b/leaf-server/minecraft-patches/features/0121-Use-ensureCapacity-to-pre-populate-the-size-of-ticki.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0122-Use-ensureCapacity-to-pre-populate-the-size-of-ticki.patch rename to leaf-server/minecraft-patches/features/0121-Use-ensureCapacity-to-pre-populate-the-size-of-ticki.patch diff --git a/leaf-server/minecraft-patches/features/0123-Directly-use-the-pre-filtered-ticking-chunks-list-as.patch b/leaf-server/minecraft-patches/features/0122-Directly-use-the-pre-filtered-ticking-chunks-list-as.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0123-Directly-use-the-pre-filtered-ticking-chunks-list-as.patch rename to leaf-server/minecraft-patches/features/0122-Directly-use-the-pre-filtered-ticking-chunks-list-as.patch diff --git a/leaf-server/minecraft-patches/features/0124-Bulk-writes-to-writeLongArray-during-chunk-loading.patch b/leaf-server/minecraft-patches/features/0123-Bulk-writes-to-writeLongArray-during-chunk-loading.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0124-Bulk-writes-to-writeLongArray-during-chunk-loading.patch rename to leaf-server/minecraft-patches/features/0123-Bulk-writes-to-writeLongArray-during-chunk-loading.patch diff --git a/leaf-server/minecraft-patches/features/0125-Improve-sorting-in-SortedArraySet.patch b/leaf-server/minecraft-patches/features/0124-Improve-sorting-in-SortedArraySet.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0125-Improve-sorting-in-SortedArraySet.patch rename to leaf-server/minecraft-patches/features/0124-Improve-sorting-in-SortedArraySet.patch diff --git a/leaf-server/minecraft-patches/features/0126-Make-removeIf-slightly-faster.patch b/leaf-server/minecraft-patches/features/0125-Make-removeIf-slightly-faster.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0126-Make-removeIf-slightly-faster.patch rename to leaf-server/minecraft-patches/features/0125-Make-removeIf-slightly-faster.patch diff --git a/leaf-server/minecraft-patches/features/0127-Optimize-LinearPalette.patch b/leaf-server/minecraft-patches/features/0126-Optimize-LinearPalette.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0127-Optimize-LinearPalette.patch rename to leaf-server/minecraft-patches/features/0126-Optimize-LinearPalette.patch diff --git a/leaf-server/minecraft-patches/features/0128-Slightly-optimized-VarInt-write.patch b/leaf-server/minecraft-patches/features/0127-Slightly-optimized-VarInt-write.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0128-Slightly-optimized-VarInt-write.patch rename to leaf-server/minecraft-patches/features/0127-Slightly-optimized-VarInt-write.patch diff --git a/leaf-server/minecraft-patches/features/0129-Rewrite-ClientboundLightUpdatePacketData.patch b/leaf-server/minecraft-patches/features/0128-Rewrite-ClientboundLightUpdatePacketData.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0129-Rewrite-ClientboundLightUpdatePacketData.patch rename to leaf-server/minecraft-patches/features/0128-Rewrite-ClientboundLightUpdatePacketData.patch diff --git a/leaf-server/minecraft-patches/features/0130-Async-chunk-send.patch b/leaf-server/minecraft-patches/features/0129-Async-chunk-send.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0130-Async-chunk-send.patch rename to leaf-server/minecraft-patches/features/0129-Async-chunk-send.patch diff --git a/leaf-server/minecraft-patches/features/0131-Spawner-Configurations.patch b/leaf-server/minecraft-patches/features/0130-Spawner-Configurations.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0131-Spawner-Configurations.patch rename to leaf-server/minecraft-patches/features/0130-Spawner-Configurations.patch diff --git a/leaf-server/minecraft-patches/features/0132-SparklyPaper-Parallel-world-ticking.patch b/leaf-server/minecraft-patches/features/0131-SparklyPaper-Parallel-world-ticking.patch similarity index 99% rename from leaf-server/minecraft-patches/features/0132-SparklyPaper-Parallel-world-ticking.patch rename to leaf-server/minecraft-patches/features/0131-SparklyPaper-Parallel-world-ticking.patch index 9f02149e..f38d95f9 100644 --- a/leaf-server/minecraft-patches/features/0132-SparklyPaper-Parallel-world-ticking.patch +++ b/leaf-server/minecraft-patches/features/0131-SparklyPaper-Parallel-world-ticking.patch @@ -42,10 +42,10 @@ index be820c6093dd2ae7642b9bee11edf65e3a8d7242..06ac3537f5655d048d770bb004243f20 boolean ret = false; final boolean canProcessFullUpdates = processFullUpdates & isTickThread; diff --git a/io/papermc/paper/redstone/RedstoneWireTurbo.java b/io/papermc/paper/redstone/RedstoneWireTurbo.java -index ff747a1ecdf3c888bca0d69de4f85dcd810b6139..62ecbbf7c167beaa3b67fc4c30e901c5d359d6b8 100644 +index ff747a1ecdf3c888bca0d69de4f85dcd810b6139..b288d57d9f7bd0ccf1877cf9920bd67288ff22f7 100644 --- a/io/papermc/paper/redstone/RedstoneWireTurbo.java +++ b/io/papermc/paper/redstone/RedstoneWireTurbo.java -@@ -829,14 +829,8 @@ public final class RedstoneWireTurbo { +@@ -829,14 +829,10 @@ public final class RedstoneWireTurbo { j = getMaxCurrentStrength(upd, j); int l = 0; @@ -57,8 +57,10 @@ index ff747a1ecdf3c888bca0d69de4f85dcd810b6139..62ecbbf7c167beaa3b67fc4c30e901c5 - // is consistency to what this call returns, we may be able to cache it. - final int k = worldIn.getBestNeighborSignal(upd.self); - wire.shouldSignal = true; ++ // Leaf start - SparklyPaper - parallel world ticking + // This now correctly calls the (conditionally) thread-safe method in RedStoneWireBlock + final int k = wire.getBlockSignal(worldIn, upd.self); ++ // Leaf end - SparklyPaper - parallel world ticking // The variable 'k' holds the maximum redstone power value of any adjacent blocks. // If 'k' has the highest level of all neighbors, then the power level of this @@ -1361,7 +1363,7 @@ index 904369f4d7db41026183f2de7c96c2f0f4dc204d..afd952ddc8942818ec01d1c750413776 return true; } else { diff --git a/net/minecraft/world/level/block/RedStoneWireBlock.java b/net/minecraft/world/level/block/RedStoneWireBlock.java -index 12c9d60314c99fb65e640d255a2d0c6b7790ad4d..5a60c5e4fe122d37a0aed1269128aa5e6e5e87b8 100644 +index 12c9d60314c99fb65e640d255a2d0c6b7790ad4d..9d655558e8a15e4861a66e545b0991968e747b58 100644 --- a/net/minecraft/world/level/block/RedStoneWireBlock.java +++ b/net/minecraft/world/level/block/RedStoneWireBlock.java @@ -91,7 +91,10 @@ public class RedStoneWireBlock extends Block { @@ -1427,7 +1429,7 @@ index 12c9d60314c99fb65e640d255a2d0c6b7790ad4d..5a60c5e4fe122d37a0aed1269128aa5e } private void checkCornerChangeAt(Level level, BlockPos pos) { -@@ -450,24 +472,34 @@ public class RedStoneWireBlock extends Block { +@@ -450,12 +472,21 @@ public class RedStoneWireBlock extends Block { @Override protected int getDirectSignal(BlockState blockState, BlockGetter blockAccess, BlockPos pos, Direction side) { @@ -1451,13 +1453,7 @@ index 12c9d60314c99fb65e640d255a2d0c6b7790ad4d..5a60c5e4fe122d37a0aed1269128aa5e int powerValue = blockState.getValue(POWER); if (powerValue == 0) { return 0; - } else { - return side != Direction.UP -- && !this.getConnectionState(blockAccess, blockState, pos).getValue(PROPERTY_BY_DIRECTION.get(side.getOpposite())).isConnected() -+ && !this.getConnectionState(blockAccess, blockState, pos).getValue(PROPERTY_BY_DIRECTION.get(side.getOpposite())).isConnected() - ? 0 - : powerValue; - } +@@ -468,6 +499,7 @@ public class RedStoneWireBlock extends Block { } else { return 0; } diff --git a/leaf-server/minecraft-patches/features/0133-SparklyPaper-Track-each-world-MSPT.patch b/leaf-server/minecraft-patches/features/0132-SparklyPaper-Track-each-world-MSPT.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0133-SparklyPaper-Track-each-world-MSPT.patch rename to leaf-server/minecraft-patches/features/0132-SparklyPaper-Track-each-world-MSPT.patch diff --git a/leaf-server/minecraft-patches/features/0134-PaperPR-Fix-cancelled-Projectile-Events-still-consum.patch b/leaf-server/minecraft-patches/features/0133-PaperPR-Fix-cancelled-Projectile-Events-still-consum.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0134-PaperPR-Fix-cancelled-Projectile-Events-still-consum.patch rename to leaf-server/minecraft-patches/features/0133-PaperPR-Fix-cancelled-Projectile-Events-still-consum.patch diff --git a/leaf-server/minecraft-patches/features/0135-Optimize-SetLookAndInteract-and-NearestVisibleLiving.patch b/leaf-server/minecraft-patches/features/0134-Optimize-SetLookAndInteract-and-NearestVisibleLiving.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0135-Optimize-SetLookAndInteract-and-NearestVisibleLiving.patch rename to leaf-server/minecraft-patches/features/0134-Optimize-SetLookAndInteract-and-NearestVisibleLiving.patch diff --git a/leaf-server/minecraft-patches/features/0136-Remove-streams-on-InsideBrownianWalk.patch b/leaf-server/minecraft-patches/features/0135-Remove-streams-on-InsideBrownianWalk.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0136-Remove-streams-on-InsideBrownianWalk.patch rename to leaf-server/minecraft-patches/features/0135-Remove-streams-on-InsideBrownianWalk.patch diff --git a/leaf-server/minecraft-patches/features/0137-Use-BFS-on-getSlopeDistance.patch b/leaf-server/minecraft-patches/features/0136-Use-BFS-on-getSlopeDistance.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0137-Use-BFS-on-getSlopeDistance.patch rename to leaf-server/minecraft-patches/features/0136-Use-BFS-on-getSlopeDistance.patch diff --git a/leaf-server/minecraft-patches/features/0138-Paper-PR-Throttle-failed-spawn-attempts.patch b/leaf-server/minecraft-patches/features/0137-Paper-PR-Throttle-failed-spawn-attempts.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0138-Paper-PR-Throttle-failed-spawn-attempts.patch rename to leaf-server/minecraft-patches/features/0137-Paper-PR-Throttle-failed-spawn-attempts.patch diff --git a/leaf-server/minecraft-patches/features/0139-Improve-BlockEntity-ticking-isRemoved-check.patch b/leaf-server/minecraft-patches/features/0138-Improve-BlockEntity-ticking-isRemoved-check.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0139-Improve-BlockEntity-ticking-isRemoved-check.patch rename to leaf-server/minecraft-patches/features/0138-Improve-BlockEntity-ticking-isRemoved-check.patch diff --git a/leaf-server/minecraft-patches/features/0140-Raytrace-AntiXray-SDK-integration.patch b/leaf-server/minecraft-patches/features/0139-Raytrace-AntiXray-SDK-integration.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0140-Raytrace-AntiXray-SDK-integration.patch rename to leaf-server/minecraft-patches/features/0139-Raytrace-AntiXray-SDK-integration.patch diff --git a/leaf-server/minecraft-patches/features/0141-Optimize-addOrUpdateTransientModifier.patch b/leaf-server/minecraft-patches/features/0140-Optimize-addOrUpdateTransientModifier.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0141-Optimize-addOrUpdateTransientModifier.patch rename to leaf-server/minecraft-patches/features/0140-Optimize-addOrUpdateTransientModifier.patch diff --git a/leaf-server/minecraft-patches/features/0142-Optimize-ContextMap.create.patch b/leaf-server/minecraft-patches/features/0141-Optimize-ContextMap.create.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0142-Optimize-ContextMap.create.patch rename to leaf-server/minecraft-patches/features/0141-Optimize-ContextMap.create.patch diff --git a/leaf-server/minecraft-patches/features/0143-Micro-optimizations-for-random-tick.patch b/leaf-server/minecraft-patches/features/0142-Micro-optimizations-for-random-tick.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0143-Micro-optimizations-for-random-tick.patch rename to leaf-server/minecraft-patches/features/0142-Micro-optimizations-for-random-tick.patch diff --git a/leaf-server/minecraft-patches/features/0144-Remove-streams-on-updateConnectedPlayersWithinRange.patch b/leaf-server/minecraft-patches/features/0143-Remove-streams-on-updateConnectedPlayersWithinRange.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0144-Remove-streams-on-updateConnectedPlayersWithinRange.patch rename to leaf-server/minecraft-patches/features/0143-Remove-streams-on-updateConnectedPlayersWithinRange.patch diff --git a/leaf-server/minecraft-patches/features/0145-Remove-streams-on-PlayerDetector.patch b/leaf-server/minecraft-patches/features/0144-Remove-streams-on-PlayerDetector.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0145-Remove-streams-on-PlayerDetector.patch rename to leaf-server/minecraft-patches/features/0144-Remove-streams-on-PlayerDetector.patch diff --git a/leaf-server/minecraft-patches/features/0146-Use-direct-iteration-on-Sensing.tick.patch b/leaf-server/minecraft-patches/features/0145-Use-direct-iteration-on-Sensing.tick.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0146-Use-direct-iteration-on-Sensing.tick.patch rename to leaf-server/minecraft-patches/features/0145-Use-direct-iteration-on-Sensing.tick.patch diff --git a/leaf-server/minecraft-patches/features/0147-Optimise-non-flush-packet-sending.patch b/leaf-server/minecraft-patches/features/0146-Optimise-non-flush-packet-sending.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0147-Optimise-non-flush-packet-sending.patch rename to leaf-server/minecraft-patches/features/0146-Optimise-non-flush-packet-sending.patch diff --git a/leaf-server/minecraft-patches/features/0148-Prevent-double-chunk-retrieving-in-entity-fluid-push.patch b/leaf-server/minecraft-patches/features/0147-Prevent-double-chunk-retrieving-in-entity-fluid-push.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0148-Prevent-double-chunk-retrieving-in-entity-fluid-push.patch rename to leaf-server/minecraft-patches/features/0147-Prevent-double-chunk-retrieving-in-entity-fluid-push.patch diff --git a/leaf-server/minecraft-patches/features/0149-Null-handling-on-MultifaceSpreader.patch b/leaf-server/minecraft-patches/features/0148-Null-handling-on-MultifaceSpreader.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0149-Null-handling-on-MultifaceSpreader.patch rename to leaf-server/minecraft-patches/features/0148-Null-handling-on-MultifaceSpreader.patch diff --git a/leaf-server/minecraft-patches/features/0150-More-virtual-threads.patch b/leaf-server/minecraft-patches/features/0149-More-virtual-threads.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0150-More-virtual-threads.patch rename to leaf-server/minecraft-patches/features/0149-More-virtual-threads.patch diff --git a/leaf-server/minecraft-patches/features/0151-Async-target-finding.patch b/leaf-server/minecraft-patches/features/0150-Async-target-finding.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0151-Async-target-finding.patch rename to leaf-server/minecraft-patches/features/0150-Async-target-finding.patch diff --git a/leaf-server/minecraft-patches/features/0152-Optimize-ThreadedTicketLevelPropagator.patch b/leaf-server/minecraft-patches/features/0151-Optimize-ThreadedTicketLevelPropagator.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0152-Optimize-ThreadedTicketLevelPropagator.patch rename to leaf-server/minecraft-patches/features/0151-Optimize-ThreadedTicketLevelPropagator.patch diff --git a/leaf-server/minecraft-patches/features/0153-Optimise-MobEffectUtil-getDigSpeedAmplification.patch b/leaf-server/minecraft-patches/features/0152-Optimise-MobEffectUtil-getDigSpeedAmplification.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0153-Optimise-MobEffectUtil-getDigSpeedAmplification.patch rename to leaf-server/minecraft-patches/features/0152-Optimise-MobEffectUtil-getDigSpeedAmplification.patch diff --git a/leaf-server/minecraft-patches/features/0154-Optimise-chunkUnloads.patch b/leaf-server/minecraft-patches/features/0153-Optimise-chunkUnloads.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0154-Optimise-chunkUnloads.patch rename to leaf-server/minecraft-patches/features/0153-Optimise-chunkUnloads.patch diff --git a/leaf-server/minecraft-patches/features/0155-Optimize-BlockEntityType-isValid.patch b/leaf-server/minecraft-patches/features/0154-Optimize-BlockEntityType-isValid.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0155-Optimize-BlockEntityType-isValid.patch rename to leaf-server/minecraft-patches/features/0154-Optimize-BlockEntityType-isValid.patch diff --git a/leaf-server/minecraft-patches/features/0156-PaperPR-Add-ticket-on-player-join-to-avoid-chunk-loa.patch b/leaf-server/minecraft-patches/features/0155-PaperPR-Add-ticket-on-player-join-to-avoid-chunk-loa.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0156-PaperPR-Add-ticket-on-player-join-to-avoid-chunk-loa.patch rename to leaf-server/minecraft-patches/features/0155-PaperPR-Add-ticket-on-player-join-to-avoid-chunk-loa.patch diff --git a/leaf-server/minecraft-patches/features/0157-PaperPR-Fix-save-load-NaN-Entity-Motion.patch b/leaf-server/minecraft-patches/features/0156-PaperPR-Fix-save-load-NaN-Entity-Motion.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0157-PaperPR-Fix-save-load-NaN-Entity-Motion.patch rename to leaf-server/minecraft-patches/features/0156-PaperPR-Fix-save-load-NaN-Entity-Motion.patch diff --git a/leaf-server/minecraft-patches/features/0158-PaperPR-Fix-unnecessary-map-data-saves.patch b/leaf-server/minecraft-patches/features/0157-PaperPR-Fix-unnecessary-map-data-saves.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0158-PaperPR-Fix-unnecessary-map-data-saves.patch rename to leaf-server/minecraft-patches/features/0157-PaperPR-Fix-unnecessary-map-data-saves.patch diff --git a/leaf-server/minecraft-patches/features/0159-Sakura-Optimise-check-inside-blocks-and-traverse-blo.patch b/leaf-server/minecraft-patches/features/0158-Sakura-Optimise-check-inside-blocks-and-traverse-blo.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0159-Sakura-Optimise-check-inside-blocks-and-traverse-blo.patch rename to leaf-server/minecraft-patches/features/0158-Sakura-Optimise-check-inside-blocks-and-traverse-blo.patch diff --git a/leaf-server/minecraft-patches/features/0160-Sakura-copy-EntityList-implementation-to-BasicEntity.patch b/leaf-server/minecraft-patches/features/0159-Sakura-copy-EntityList-implementation-to-BasicEntity.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0160-Sakura-copy-EntityList-implementation-to-BasicEntity.patch rename to leaf-server/minecraft-patches/features/0159-Sakura-copy-EntityList-implementation-to-BasicEntity.patch diff --git a/leaf-server/minecraft-patches/features/0161-Protocol-Core.patch b/leaf-server/minecraft-patches/features/0160-Protocol-Core.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0161-Protocol-Core.patch rename to leaf-server/minecraft-patches/features/0160-Protocol-Core.patch diff --git a/leaf-server/minecraft-patches/features/0162-Reduce-PlayerChunk-Updates.patch b/leaf-server/minecraft-patches/features/0161-Reduce-PlayerChunk-Updates.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0162-Reduce-PlayerChunk-Updates.patch rename to leaf-server/minecraft-patches/features/0161-Reduce-PlayerChunk-Updates.patch diff --git a/leaf-server/minecraft-patches/features/0163-Async-switch-connection-state.patch b/leaf-server/minecraft-patches/features/0162-Async-switch-connection-state.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0163-Async-switch-connection-state.patch rename to leaf-server/minecraft-patches/features/0162-Async-switch-connection-state.patch diff --git a/leaf-server/minecraft-patches/features/0164-Optimize-BlockEntities-tickersInLevel.patch b/leaf-server/minecraft-patches/features/0163-Optimize-BlockEntities-tickersInLevel.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0164-Optimize-BlockEntities-tickersInLevel.patch rename to leaf-server/minecraft-patches/features/0163-Optimize-BlockEntities-tickersInLevel.patch diff --git a/leaf-server/minecraft-patches/features/0165-Pluto-Check-if-the-cactus-can-even-survive-being-pla.patch b/leaf-server/minecraft-patches/features/0164-Pluto-Check-if-the-cactus-can-even-survive-being-pla.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0165-Pluto-Check-if-the-cactus-can-even-survive-being-pla.patch rename to leaf-server/minecraft-patches/features/0164-Pluto-Check-if-the-cactus-can-even-survive-being-pla.patch diff --git a/leaf-server/minecraft-patches/features/0166-Flush-location-while-knockback.patch b/leaf-server/minecraft-patches/features/0165-Flush-location-while-knockback.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0166-Flush-location-while-knockback.patch rename to leaf-server/minecraft-patches/features/0165-Flush-location-while-knockback.patch diff --git a/leaf-server/minecraft-patches/features/0167-Only-tick-items-at-hand.patch b/leaf-server/minecraft-patches/features/0166-Only-tick-items-at-hand.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0167-Only-tick-items-at-hand.patch rename to leaf-server/minecraft-patches/features/0166-Only-tick-items-at-hand.patch diff --git a/leaf-server/minecraft-patches/features/0168-Smart-sort-items-in-NearestItemSensor.patch b/leaf-server/minecraft-patches/features/0167-Smart-sort-items-in-NearestItemSensor.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0168-Smart-sort-items-in-NearestItemSensor.patch rename to leaf-server/minecraft-patches/features/0167-Smart-sort-items-in-NearestItemSensor.patch diff --git a/leaf-server/minecraft-patches/features/0169-Optimise-player-movement-checks.patch b/leaf-server/minecraft-patches/features/0168-Optimise-player-movement-checks.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0169-Optimise-player-movement-checks.patch rename to leaf-server/minecraft-patches/features/0168-Optimise-player-movement-checks.patch diff --git a/leaf-server/minecraft-patches/features/0170-Remove-streams-in-MobSensor.patch b/leaf-server/minecraft-patches/features/0169-Remove-streams-in-MobSensor.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0170-Remove-streams-in-MobSensor.patch rename to leaf-server/minecraft-patches/features/0169-Remove-streams-in-MobSensor.patch diff --git a/leaf-server/minecraft-patches/features/0171-Remove-streams-in-TemptingSensor.patch b/leaf-server/minecraft-patches/features/0170-Remove-streams-in-TemptingSensor.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0171-Remove-streams-in-TemptingSensor.patch rename to leaf-server/minecraft-patches/features/0170-Remove-streams-in-TemptingSensor.patch diff --git a/leaf-server/minecraft-patches/features/0172-Use-HashedList-on-WeightedRandomList.patch b/leaf-server/minecraft-patches/features/0171-Use-HashedList-on-WeightedRandomList.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0172-Use-HashedList-on-WeightedRandomList.patch rename to leaf-server/minecraft-patches/features/0171-Use-HashedList-on-WeightedRandomList.patch diff --git a/leaf-server/minecraft-patches/features/0173-Add-configurable-death-item-drop-knockback-settings.patch b/leaf-server/minecraft-patches/features/0172-Add-configurable-death-item-drop-knockback-settings.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0173-Add-configurable-death-item-drop-knockback-settings.patch rename to leaf-server/minecraft-patches/features/0172-Add-configurable-death-item-drop-knockback-settings.patch diff --git a/leaf-server/minecraft-patches/features/0174-Optimize-getScaledTrackingDistance.patch b/leaf-server/minecraft-patches/features/0173-Optimize-getScaledTrackingDistance.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0174-Optimize-getScaledTrackingDistance.patch rename to leaf-server/minecraft-patches/features/0173-Optimize-getScaledTrackingDistance.patch diff --git a/leaf-server/minecraft-patches/features/0175-Optimize-SynchedEntityData-packDirty.patch b/leaf-server/minecraft-patches/features/0174-Optimize-SynchedEntityData-packDirty.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0175-Optimize-SynchedEntityData-packDirty.patch rename to leaf-server/minecraft-patches/features/0174-Optimize-SynchedEntityData-packDirty.patch diff --git a/leaf-server/minecraft-patches/features/0176-Optimize-isEyeInFluid.patch b/leaf-server/minecraft-patches/features/0175-Optimize-isEyeInFluid.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0176-Optimize-isEyeInFluid.patch rename to leaf-server/minecraft-patches/features/0175-Optimize-isEyeInFluid.patch diff --git a/leaf-server/minecraft-patches/features/0177-Cache-block-path-type.patch b/leaf-server/minecraft-patches/features/0176-Cache-block-path-type.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0177-Cache-block-path-type.patch rename to leaf-server/minecraft-patches/features/0176-Cache-block-path-type.patch diff --git a/leaf-server/minecraft-patches/features/0178-optimize-getEntityStatus.patch b/leaf-server/minecraft-patches/features/0177-optimize-getEntityStatus.patch similarity index 83% rename from leaf-server/minecraft-patches/features/0178-optimize-getEntityStatus.patch rename to leaf-server/minecraft-patches/features/0177-optimize-getEntityStatus.patch index 58447a60..533f1aec 100644 --- a/leaf-server/minecraft-patches/features/0178-optimize-getEntityStatus.patch +++ b/leaf-server/minecraft-patches/features/0177-optimize-getEntityStatus.patch @@ -5,7 +5,7 @@ Subject: [PATCH] optimize getEntityStatus diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/EntityLookup.java b/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/EntityLookup.java -index 7554c109c35397bc1a43dd80e87764fd78645bbf..151476fd036839a416c226599279d0d8bf79717b 100644 +index 7554c109c35397bc1a43dd80e87764fd78645bbf..8ae35834bb35ace0bf0ad2c79a80500cbcb19cad 100644 --- a/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/EntityLookup.java +++ b/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/EntityLookup.java @@ -93,8 +93,14 @@ public abstract class EntityLookup implements LevelEntityGetter { @@ -14,14 +14,14 @@ index 7554c109c35397bc1a43dd80e87764fd78645bbf..151476fd036839a416c226599279d0d8 } - final Visibility visibility = EntityLookup.getEntityStatus(entity); - return visibility.isAccessible() ? entity : null; -+ // Leaf start ++ // Leaf start - optimize getEntityStatus + final FullChunkStatus entityStatus = ((ChunkSystemEntity) entity).moonrise$getChunkStatus(); + return switch (entityStatus) { + case INACCESSIBLE -> null; + case FULL, BLOCK_TICKING, ENTITY_TICKING -> entity; + case null -> null; + }; -+ // Leaf end ++ // Leaf end - optimize getEntityStatus } @Override @@ -30,26 +30,26 @@ index 7554c109c35397bc1a43dd80e87764fd78645bbf..151476fd036839a416c226599279d0d8 } final FullChunkStatus entityStatus = ((ChunkSystemEntity)entity).moonrise$getChunkStatus(); - return Visibility.fromFullChunkStatus(entityStatus == null ? FullChunkStatus.INACCESSIBLE : entityStatus); -+ // Leaf start ++ // Leaf start - optimize getEntityStatus + return switch (entityStatus) { + case INACCESSIBLE -> Visibility.HIDDEN; + case FULL, BLOCK_TICKING -> Visibility.TRACKED; + case ENTITY_TICKING -> Visibility.TICKING; + case null -> Visibility.HIDDEN; + }; -+ // Leaf end ++ // Leaf end - optimize getEntityStatus } protected boolean addEntity(final Entity entity, final boolean fromDisk, final boolean event) { diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index 64f24d3e0ecb91e0b4df6229354aeac549234f1b..80baa2dff5c1034a72271fc727fdb2acc1b69488 100644 +index 64f24d3e0ecb91e0b4df6229354aeac549234f1b..5ea5ff08c8e22b8a4aeef06ab0fc7a60255c27ee 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java @@ -381,6 +381,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess // Paper end // Paper start - rewrite chunk system private final boolean isHardColliding = this.moonrise$isHardCollidingUncached(); -+ @org.jetbrains.annotations.Nullable // Leaf ++ @org.jetbrains.annotations.Nullable // Leaf - optimize getEntityStatus private net.minecraft.server.level.FullChunkStatus chunkStatus; private ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkData chunkData; private int sectionX = Integer.MIN_VALUE; @@ -57,7 +57,7 @@ index 64f24d3e0ecb91e0b4df6229354aeac549234f1b..80baa2dff5c1034a72271fc727fdb2ac } @Override -+ @org.jetbrains.annotations.Nullable // Leaf ++ @org.jetbrains.annotations.Nullable // Leaf - optimize getEntityStatus public final net.minecraft.server.level.FullChunkStatus moonrise$getChunkStatus() { return this.chunkStatus; } diff --git a/leaf-server/minecraft-patches/features/0179-Rail-Optimization-optimized-PoweredRailBlock-logic.patch b/leaf-server/minecraft-patches/features/0178-Rail-Optimization-optimized-PoweredRailBlock-logic.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0179-Rail-Optimization-optimized-PoweredRailBlock-logic.patch rename to leaf-server/minecraft-patches/features/0178-Rail-Optimization-optimized-PoweredRailBlock-logic.patch diff --git a/leaf-server/minecraft-patches/features/0180-optimise-ChunkGenerator-getMobsAt.patch b/leaf-server/minecraft-patches/features/0179-optimise-ChunkGenerator-getMobsAt.patch similarity index 87% rename from leaf-server/minecraft-patches/features/0180-optimise-ChunkGenerator-getMobsAt.patch rename to leaf-server/minecraft-patches/features/0179-optimise-ChunkGenerator-getMobsAt.patch index a7facb01..ac024cc6 100644 --- a/leaf-server/minecraft-patches/features/0180-optimise-ChunkGenerator-getMobsAt.patch +++ b/leaf-server/minecraft-patches/features/0179-optimise-ChunkGenerator-getMobsAt.patch @@ -6,7 +6,7 @@ Subject: [PATCH] optimise ChunkGenerator#getMobsAt inline fillStartsForStructure diff --git a/net/minecraft/world/level/StructureManager.java b/net/minecraft/world/level/StructureManager.java -index 8bc6a6c86cd8db53feefba7508b6031ba67e242e..20a2bc31a8082afd4f758bd7e91691bbc58ba16e 100644 +index 8bc6a6c86cd8db53feefba7508b6031ba67e242e..90397f237c0cb79da03b3f9ca7445676324ebd11 100644 --- a/net/minecraft/world/level/StructureManager.java +++ b/net/minecraft/world/level/StructureManager.java @@ -78,7 +78,7 @@ public class StructureManager { @@ -14,7 +14,7 @@ index 8bc6a6c86cd8db53feefba7508b6031ba67e242e..20a2bc31a8082afd4f758bd7e91691bb public void fillStartsForStructure(Structure structure, LongSet structureRefs, Consumer startConsumer) { for (long l : structureRefs) { - SectionPos sectionPos = SectionPos.of(new ChunkPos(l), this.level.getMinSectionY()); -+ SectionPos sectionPos = SectionPos.of(ChunkPos.getX(l), this.level.getMinSectionY(), ChunkPos.getZ(l)); // Leaf ++ SectionPos sectionPos = SectionPos.of(ChunkPos.getX(l), this.level.getMinSectionY(), ChunkPos.getZ(l)); // Leaf - optimise ChunkGenerator#getMobsAt StructureStart startForStructure = this.getStartForStructure( sectionPos, structure, this.level.getChunk(sectionPos.x(), sectionPos.z(), ChunkStatus.STRUCTURE_STARTS) ); @@ -24,13 +24,13 @@ index 8bc6a6c86cd8db53feefba7508b6031ba67e242e..20a2bc31a8082afd4f758bd7e91691bb public Map getAllStructuresAt(BlockPos pos) { - SectionPos sectionPos = SectionPos.of(pos); - return this.level.getChunk(sectionPos.x(), sectionPos.z(), ChunkStatus.STRUCTURE_REFERENCES).getAllReferences(); -+ // SectionPos sectionPos = SectionPos.of(pos); // Leaf -+ return this.level.getChunk(pos.getX() >> 4, pos.getZ() >> 4, ChunkStatus.STRUCTURE_REFERENCES).getAllReferences(); // Leaf ++ //SectionPos sectionPos = SectionPos.of(pos); // Leaf - optimise ChunkGenerator#getMobsAt ++ return this.level.getChunk(pos.getX() >> 4, pos.getZ() >> 4, ChunkStatus.STRUCTURE_REFERENCES).getAllReferences(); // Leaf - optimise ChunkGenerator#getMobsAt } public StructureCheckResult checkStructurePresence(ChunkPos chunkPos, Structure structure, StructurePlacement placement, boolean skipKnownStructures) { diff --git a/net/minecraft/world/level/chunk/ChunkGenerator.java b/net/minecraft/world/level/chunk/ChunkGenerator.java -index 176adfcaa0fc458043d4bc05ead1861864b63606..87df3cd0981e94c28b816eb231942499c266a8da 100644 +index 176adfcaa0fc458043d4bc05ead1861864b63606..755e635a2ece6ab6d3b166cb437e48b527041160 100644 --- a/net/minecraft/world/level/chunk/ChunkGenerator.java +++ b/net/minecraft/world/level/chunk/ChunkGenerator.java @@ -501,18 +501,20 @@ public abstract class ChunkGenerator { @@ -44,7 +44,7 @@ index 176adfcaa0fc458043d4bc05ead1861864b63606..87df3cd0981e94c28b816eb231942499 - structureManager.fillStartsForStructure(structure, entry.getValue(), structureStart -> { - if (mutableBoolean.isFalse() && predicate.test(structureStart)) { - mutableBoolean.setTrue(); -+ // Leaf start ++ // Leaf start - optimise ChunkGenerator#getMobsAt + for (long l : entry.getValue()) { + StructureStart startForStructure = structureManager.getStartForStructure( + null, structure, structureManager.level.getChunk(ChunkPos.getX(l), ChunkPos.getZ(l), ChunkStatus.STRUCTURE_STARTS) @@ -60,7 +60,7 @@ index 176adfcaa0fc458043d4bc05ead1861864b63606..87df3cd0981e94c28b816eb231942499 - if (mutableBoolean.isTrue()) { - return structureSpawnOverride.spawns(); } -+ // Leaf end ++ // Leaf end - optimise ChunkGenerator#getMobsAt } } diff --git a/leaf-server/minecraft-patches/features/0181-optimise-getBiome.patch b/leaf-server/minecraft-patches/features/0180-optimise-getBiome.patch similarity index 95% rename from leaf-server/minecraft-patches/features/0181-optimise-getBiome.patch rename to leaf-server/minecraft-patches/features/0180-optimise-getBiome.patch index bd1a671c..98211eac 100644 --- a/leaf-server/minecraft-patches/features/0181-optimise-getBiome.patch +++ b/leaf-server/minecraft-patches/features/0180-optimise-getBiome.patch @@ -57,7 +57,7 @@ index ce2621a87dec1befb016b3437ceb2d02ed6d0b75..9b37b763c6555705f3e256010f508b5a public static boolean isInNetherFortressBounds(BlockPos pos, ServerLevel level, MobCategory category, StructureManager structureManager) { diff --git a/net/minecraft/world/level/biome/BiomeManager.java b/net/minecraft/world/level/biome/BiomeManager.java -index a48175a7ebb1788ace46395621ed78d910178a53..cb6b99dd4504681bdf2f7dbd7e3d2218304f891a 100644 +index a48175a7ebb1788ace46395621ed78d910178a53..00122472991ba0c1a0ea77053aad71cdfa92a7bd 100644 --- a/net/minecraft/world/level/biome/BiomeManager.java +++ b/net/minecraft/world/level/biome/BiomeManager.java @@ -15,10 +15,23 @@ public class BiomeManager { @@ -129,7 +129,7 @@ index a48175a7ebb1788ace46395621ed78d910178a53..cb6b99dd4504681bdf2f7dbd7e3d2218 return Mth.square(zNoise + fiddle2) + Mth.square(yNoise + fiddle1) + Mth.square(xNoise + fiddle); } -+ // Leaf start ++ // Leaf start - optimise getBiome + private static final double[] FIDDLE_TABLE = new double[1024]; + static { + for (int i = 0; i < 1024; i++) { @@ -139,9 +139,9 @@ index a48175a7ebb1788ace46395621ed78d910178a53..cb6b99dd4504681bdf2f7dbd7e3d2218 private static double getFiddle(long seed) { - return (double)(((seed >> 24) & (1024 - 1)) - (1024/2)) * (0.9 / 1024.0); // Paper - avoid floorMod, fp division, and fp subtraction + return FIDDLE_TABLE[(int)(seed >>> 24) & 1023]; -+ // return (double)(((seed >> 24) & (1024 - 1)) - (1024/2)) * (0.9 / 1024.0); // Paper - avoid floorMod, fp division, and fp subtraction ++ //return (double)(((seed >> 24) & (1024 - 1)) - (1024/2)) * (0.9 / 1024.0); // Paper - avoid floorMod, fp division, and fp subtraction } -+ // Leaf end ++ // Leaf end - optimise getBiome public interface NoiseBiomeSource { Holder getNoiseBiome(int x, int y, int z); diff --git a/leaf-server/minecraft-patches/features/0182-optimize-mob-spawning.patch b/leaf-server/minecraft-patches/features/0181-optimize-mob-spawning.patch similarity index 85% rename from leaf-server/minecraft-patches/features/0182-optimize-mob-spawning.patch rename to leaf-server/minecraft-patches/features/0181-optimize-mob-spawning.patch index 80ec7715..d606a09a 100644 --- a/leaf-server/minecraft-patches/features/0182-optimize-mob-spawning.patch +++ b/leaf-server/minecraft-patches/features/0181-optimize-mob-spawning.patch @@ -5,7 +5,7 @@ Subject: [PATCH] optimize mob spawning diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java -index f57f8e610dac80b8095bfc0c7e4b22ff5ad6b13c..55f20122732e88037d24be311469b6cab72c37ad 100644 +index f57f8e610dac80b8095bfc0c7e4b22ff5ad6b13c..c1efd558cfbfd2200295ef5755aa496e95deb7d7 100644 --- a/net/minecraft/server/level/ServerChunkCache.java +++ b/net/minecraft/server/level/ServerChunkCache.java @@ -70,7 +70,9 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon @@ -13,9 +13,9 @@ index f57f8e610dac80b8095bfc0c7e4b22ff5ad6b13c..55f20122732e88037d24be311469b6ca @Nullable @VisibleForDebug - private NaturalSpawner.SpawnState lastSpawnState; -+ private volatile NaturalSpawner.SpawnState lastSpawnState; // Leaf -+ private long delayTimeInhabited = 0L; // Leaf -+ private long delaySpawn = -1L; // Leaf ++ private volatile NaturalSpawner.SpawnState lastSpawnState; // Leaf - optimize mob spawning ++ private long delayTimeInhabited = 0L; // Leaf - optimize mob spawning ++ private long delaySpawn = -1L; // Leaf - optimize mob spawning // Paper start public final ca.spottedleaf.concurrentutil.map.ConcurrentLong2ReferenceChainedHashTable fullChunks = new ca.spottedleaf.concurrentutil.map.ConcurrentLong2ReferenceChainedHashTable<>(); public int getFullChunksCount() { @@ -28,7 +28,7 @@ index f57f8e610dac80b8095bfc0c7e4b22ff5ad6b13c..55f20122732e88037d24be311469b6ca - levelChunk.incrementInhabitedTime(timeInhabited); - if (!filteredSpawningCategories.isEmpty() && this.level.getWorldBorder().isWithinBounds(pos) && lastSpawnState != null && (!org.dreeam.leaf.config.modules.async.AsyncMobSpawning.enabled || _pufferfish_spawnCountsReady.get()) && this.chunkMap.anyPlayerCloseEnoughForSpawning(pos, true)) { // Spigot // Pufferfish // Leaf - Don't spawn if lastSpawnState is null - NaturalSpawner.spawnForChunk(this.level, levelChunk, lastSpawnState, filteredSpawningCategories); // Pufferfish -+ // Leaf start ++ // Leaf start - optimize mob spawning + var lastSpawnState1 = this.lastSpawnState; + if (lastSpawnState1 != null && (!org.dreeam.leaf.config.modules.async.AsyncMobSpawning.enabled || _pufferfish_spawnCountsReady.get())) { + long sumTimeInhabited = timeInhabited + delayTimeInhabited; @@ -56,27 +56,27 @@ index f57f8e610dac80b8095bfc0c7e4b22ff5ad6b13c..55f20122732e88037d24be311469b6ca + delayTimeInhabited += timeInhabited; + delaySpawn = level.getGameTime(); + } -+ // Leaf end ++ // Leaf end - optimize mob spawning -+ for (LevelChunk levelChunk : chunks) { // Leaf - split to 2 loop ++ for (LevelChunk levelChunk : chunks) { // Leaf - optimize mob spawning - split to 2 loop if (true) { // Paper - rewrite chunk system this.level.tickChunk(levelChunk, _int); } diff --git a/net/minecraft/world/level/NaturalSpawner.java b/net/minecraft/world/level/NaturalSpawner.java -index 9b37b763c6555705f3e256010f508b5a0c2cdb66..7bfc636fb442036f742903c4e69a8a9fcd0e6fc2 100644 +index 9b37b763c6555705f3e256010f508b5a0c2cdb66..bde7008e14a3b4c0a37a94a4890e2f7fa1ce2466 100644 --- a/net/minecraft/world/level/NaturalSpawner.java +++ b/net/minecraft/world/level/NaturalSpawner.java @@ -155,7 +155,13 @@ public final class NaturalSpawner { return list; } -+ @Deprecated(forRemoval = true) // Leaf ++ @Deprecated(forRemoval = true) // Leaf - optimize mob spawning public static void spawnForChunk(ServerLevel level, LevelChunk chunk, NaturalSpawner.SpawnState spawnState, List categories) { -+ // Leaf start ++ // Leaf start - optimize mob spawning + spawnForChunk(level, chunk, spawnState, categories, level.getGameTime()); + } + public static void spawnForChunk(ServerLevel level, LevelChunk chunk, NaturalSpawner.SpawnState spawnState, List categories, long gameTime) { -+ // Leaf end ++ // Leaf end - optimize mob spawning for (MobCategory mobCategory : categories) { // Paper start - Optional per player mob spawns final boolean canSpawn; @@ -85,7 +85,7 @@ index 9b37b763c6555705f3e256010f508b5a0c2cdb66..7bfc636fb442036f742903c4e69a8a9f // Paper end - throttle failed spawn attempts if (CraftSpawnCategory.isValidForLimits(spawnCategory)) { - spawnThisTick = ticksPerSpawnTmp != 0 && level.getGameTime() % ticksPerSpawn == 0; // Paper - throttle failed spawn attempts -+ spawnThisTick = ticksPerSpawnTmp != 0 && gameTime % ticksPerSpawn == 0; // Paper - throttle failed spawn attempts // Leaf ++ spawnThisTick = ticksPerSpawnTmp != 0 && gameTime % ticksPerSpawn == 0; // Paper - throttle failed spawn attempts // Leaf - optimize mob spawning limit = level.getWorld().getSpawnLimit(spawnCategory); } @@ -96,7 +96,7 @@ index 9b37b763c6555705f3e256010f508b5a0c2cdb66..7bfc636fb442036f742903c4e69a8a9f - BlockPos randomPosWithin = getRandomPosWithin(level, chunk); - if (randomPosWithin.getY() >= level.getMinY() + 1) { - return spawnCategoryForPosition(category, level, chunk, randomPosWithin, filter, callback, maxSpawns, trackEntity, false); // Paper - Optional per player mob spawns // Paper - throttle failed spawn attempts -+ // Leaf start ++ // Leaf start - optimize mob spawning + BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(); + mutableRandomPosWithin(pos, level, chunk); + if (pos.getY() < level.getMinY() + 1) { @@ -105,7 +105,7 @@ index 9b37b763c6555705f3e256010f508b5a0c2cdb66..7bfc636fb442036f742903c4e69a8a9f - - return 0; // Paper - throttle failed spawn attempts + return spawnCategoryForPosition(category, level, chunk, pos, filter, callback, maxSpawns, trackEntity, false); // Paper - Optional per player mob spawns // Paper - throttle failed spawn attempts -+ // Leaf end ++ // Leaf end - optimize mob spawning } @VisibleForDebug @@ -113,16 +113,16 @@ index 9b37b763c6555705f3e256010f508b5a0c2cdb66..7bfc636fb442036f742903c4e69a8a9f StructureManager structureManager = level.structureManager(); ChunkGenerator generator = level.getChunkSource().getGenerator(); int y = pos.getY(); -+ int posX = pos.getX(); // Leaf -+ int posZ = pos.getZ(); // Leaf ++ int posX = pos.getX(); // Leaf - optimize mob spawning ++ int posZ = pos.getZ(); // Leaf - optimize mob spawning int i = 0; // Paper - throttle failed spawn attempts BlockState blockState = level.getBlockStateIfLoadedAndInBounds(pos); // Paper - don't load chunks for mob spawn if (blockState != null && !blockState.isRedstoneConductor(chunk, pos)) { // Paper - don't load chunks for mob spawn - BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); -+ BlockPos.MutableBlockPos mutableBlockPos = pos instanceof BlockPos.MutableBlockPos pos2 ? pos2 : new BlockPos.MutableBlockPos(); // Leaf ++ BlockPos.MutableBlockPos mutableBlockPos = pos instanceof BlockPos.MutableBlockPos pos2 ? pos2 : new BlockPos.MutableBlockPos(); // Leaf - optimize mob spawning //int i = 0; // Paper - throttle failed spawn attempts - move up -+ // Leaf start ++ // Leaf start - optimize mob spawning + long rand = level.random.nextLong(); + int bits = 0; for (int i1 = 0; i1 < 3; i1++) { @@ -161,7 +161,7 @@ index 9b37b763c6555705f3e256010f508b5a0c2cdb66..7bfc636fb442036f742903c4e69a8a9f + } + x += rand1 - rand2; + z += rand3 - rand4; -+ // Leaf end ++ // Leaf end - optimize mob spawning mutableBlockPos.set(x, y, z); double d = x + 0.5; double d1 = z + 0.5; @@ -169,7 +169,7 @@ index 9b37b763c6555705f3e256010f508b5a0c2cdb66..7bfc636fb442036f742903c4e69a8a9f if (nearestPlayer != null) { double d2 = nearestPlayer.distanceToSqr(d, y, d1); - if (level.isLoadedAndInBounds(mutableBlockPos) && isRightDistanceToPlayerAndSpawnPoint(level, chunk, mutableBlockPos, d2)) { // Paper - don't load chunks for mob spawn -+ if (level.getWorldBorder().isWithinBounds(mutableBlockPos) && (chunk.getPos().longKey == ChunkPos.asLong(mutableBlockPos) || level.getChunkIfLoadedImmediately(mutableBlockPos.getX() >> 4, mutableBlockPos.getZ() >> 4) != null) && isRightDistanceToPlayerAndSpawnPoint(level, chunk, mutableBlockPos, d2)) { // Paper - don't load chunks for mob spawn // Leaf ++ if (level.getWorldBorder().isWithinBounds(mutableBlockPos) && (chunk.getPos().longKey == ChunkPos.asLong(mutableBlockPos) || level.getChunkIfLoadedImmediately(mutableBlockPos.getX() >> 4, mutableBlockPos.getZ() >> 4) != null) && isRightDistanceToPlayerAndSpawnPoint(level, chunk, mutableBlockPos, d2)) { // Paper - don't load chunks for mob spawn // Leaf - optimize mob spawning if (spawnerData == null) { Optional randomSpawnMobAt = getRandomSpawnMobAt( level, structureManager, generator, category, level.random, mutableBlockPos @@ -179,8 +179,8 @@ index 9b37b763c6555705f3e256010f508b5a0c2cdb66..7bfc636fb442036f742903c4e69a8a9f return !(distance <= 576.0) - && !level.getSharedSpawnPos().closerToCenterThan(new Vec3(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5), 24.0) - && (Objects.equals(new ChunkPos(pos), chunk.getPos()) || level.isNaturalSpawningAllowed(pos)); -+ && !(level.getSharedSpawnPos().distToCenterSqr(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5) < 576.0) // Leaf -+ && (ChunkPos.asLong(pos) == chunk.getPos().longKey || level.isNaturalSpawningAllowed(pos)); // Leaf ++ && !(level.getSharedSpawnPos().distToCenterSqr(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5) < 576.0) // Leaf - optimize mob spawning ++ && (ChunkPos.asLong(pos) == chunk.getPos().longKey || level.isNaturalSpawningAllowed(pos)); // Leaf - optimize mob spawning } // Paper start - PreCreatureSpawnEvent @@ -188,16 +188,16 @@ index 9b37b763c6555705f3e256010f508b5a0c2cdb66..7bfc636fb442036f742903c4e69a8a9f } } -+ // Leaf start ++ // Leaf start - optimize mob spawning + private static void mutableRandomPosWithin(BlockPos.MutableBlockPos pos1, Level level, LevelChunk chunk) { + ChunkPos pos = chunk.getPos(); -+ int i = pos.getMinBlockX() + level.random.nextInt(16); -+ int i1 = pos.getMinBlockZ() + level.random.nextInt(16); -+ int i2 = chunk.getHeight(Heightmap.Types.WORLD_SURFACE, i, i1) + 1; -+ int i3 = Mth.randomBetweenInclusive(level.random, level.getMinY(), i2); -+ pos1.set(i, i3, i1); ++ int randomX = pos.getMinBlockX() + level.random.nextInt(16); ++ int randomZ = pos.getMinBlockZ() + level.random.nextInt(16); ++ int surfaceY = chunk.getHeight(Heightmap.Types.WORLD_SURFACE, randomX, randomZ) + 1; ++ int randomY = Mth.randomBetweenInclusive(level.random, level.getMinY(), surfaceY); ++ pos1.set(randomX, randomY, randomZ); + } -+ // Leaf end ++ // Leaf end - optimize mob spawning + private static BlockPos getRandomPosWithin(Level level, LevelChunk chunk) { ChunkPos pos = chunk.getPos(); diff --git a/leaf-server/minecraft-patches/features/0183-optimize-structure-map.patch b/leaf-server/minecraft-patches/features/0182-optimize-structure-map.patch similarity index 87% rename from leaf-server/minecraft-patches/features/0183-optimize-structure-map.patch rename to leaf-server/minecraft-patches/features/0182-optimize-structure-map.patch index 34592250..de32ab83 100644 --- a/leaf-server/minecraft-patches/features/0183-optimize-structure-map.patch +++ b/leaf-server/minecraft-patches/features/0182-optimize-structure-map.patch @@ -5,7 +5,7 @@ Subject: [PATCH] optimize structure map diff --git a/net/minecraft/world/level/chunk/ChunkAccess.java b/net/minecraft/world/level/chunk/ChunkAccess.java -index 50a9903367f49ece2a267d10944b1515c7b93859..ceabb277bef2633de8f55e16431dbb4d0869817b 100644 +index 50a9903367f49ece2a267d10944b1515c7b93859..5117671a4391690c90e7577a2518d0298e4b8c74 100644 --- a/net/minecraft/world/level/chunk/ChunkAccess.java +++ b/net/minecraft/world/level/chunk/ChunkAccess.java @@ -76,8 +76,8 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh @@ -14,8 +14,8 @@ index 50a9903367f49ece2a267d10944b1515c7b93859..ceabb277bef2633de8f55e16431dbb4d // Paper - rewrite chunk system - private final Map structureStarts = Maps.newHashMap(); - private final Map structuresRefences = Maps.newHashMap(); -+ private final Map structureStarts = new it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap<>(); // Leaf -+ private final Map structuresRefences = new it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap<>(); // Leaf ++ private final Map structureStarts = new it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap<>(); // Leaf - optimize structure map ++ private final Map structuresRefences = new it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap<>(); // Leaf - optimize structure map protected final Map pendingBlockEntities = Maps.newHashMap(); public final Map blockEntities = new Object2ObjectOpenHashMap<>(); protected final LevelHeightAccessor levelHeightAccessor; @@ -24,7 +24,7 @@ index 50a9903367f49ece2a267d10944b1515c7b93859..ceabb277bef2633de8f55e16431dbb4d public Map getAllStarts() { - return Collections.unmodifiableMap(this.structureStarts); -+ return this.structureStarts; // Leaf ++ return this.structureStarts; // Leaf - optimize structure map } public void setAllStarts(Map structureStarts) { @@ -33,14 +33,14 @@ index 50a9903367f49ece2a267d10944b1515c7b93859..ceabb277bef2633de8f55e16431dbb4d @Override public void addReferenceForStructure(Structure structure, long reference) { - this.structuresRefences.computeIfAbsent(structure, key -> new LongOpenHashSet()).add(reference); -+ this.structuresRefences.computeIfAbsent(structure, key -> new it.unimi.dsi.fastutil.longs.LongArraySet()).add(reference); // Leaf ++ this.structuresRefences.computeIfAbsent(structure, key -> new it.unimi.dsi.fastutil.longs.LongArraySet()).add(reference); // Leaf - optimize structure map this.markUnsaved(); } @Override public Map getAllReferences() { - return Collections.unmodifiableMap(this.structuresRefences); -+ return this.structuresRefences; // Leaf ++ return this.structuresRefences; // Leaf - optimize structure map } @Override diff --git a/leaf-server/minecraft-patches/features/0184-throttle-mob-spawning.patch b/leaf-server/minecraft-patches/features/0183-throttle-mob-spawning.patch similarity index 88% rename from leaf-server/minecraft-patches/features/0184-throttle-mob-spawning.patch rename to leaf-server/minecraft-patches/features/0183-throttle-mob-spawning.patch index d4079d19..3f0377fd 100644 --- a/leaf-server/minecraft-patches/features/0184-throttle-mob-spawning.patch +++ b/leaf-server/minecraft-patches/features/0183-throttle-mob-spawning.patch @@ -5,14 +5,14 @@ Subject: [PATCH] throttle mob spawning diff --git a/net/minecraft/world/level/NaturalSpawner.java b/net/minecraft/world/level/NaturalSpawner.java -index 7bfc636fb442036f742903c4e69a8a9fcd0e6fc2..762bdf1fe19546f89d34b9efdad66b00dab80006 100644 +index bde7008e14a3b4c0a37a94a4890e2f7fa1ce2466..458b17dca84c87591b030679c5aac6259c0f8308 100644 --- a/net/minecraft/world/level/NaturalSpawner.java +++ b/net/minecraft/world/level/NaturalSpawner.java @@ -166,6 +166,17 @@ public final class NaturalSpawner { // Paper start - Optional per player mob spawns final boolean canSpawn; int maxSpawns = Integer.MAX_VALUE; -+ // Leaf start ++ // Leaf start - throttle mob spawning + if (org.dreeam.leaf.config.modules.opt.ThrottleNaturalMobSpawning.enabled) { + int spawnChance = org.dreeam.leaf.config.modules.opt.ThrottleNaturalMobSpawning.spawnChance[mobCategory.ordinal()]; + long failedAttempt = org.dreeam.leaf.config.modules.opt.ThrottleNaturalMobSpawning.failedAttempts[mobCategory.ordinal()]; @@ -22,7 +22,7 @@ index 7bfc636fb442036f742903c4e69a8a9fcd0e6fc2..762bdf1fe19546f89d34b9efdad66b00 + continue; + } + } -+ // Leaf end ++ // Leaf end - throttle mob spawning if (level.paperConfig().entities.spawning.perPlayerMobSpawns) { // Copied from getFilteredSpawningCategories int limit = mobCategory.getMaxInstancesPerChunk(); diff --git a/leaf-server/minecraft-patches/features/0185-preload-mob-spawning-position.patch b/leaf-server/minecraft-patches/features/0184-preload-mob-spawning-position.patch similarity index 82% rename from leaf-server/minecraft-patches/features/0185-preload-mob-spawning-position.patch rename to leaf-server/minecraft-patches/features/0184-preload-mob-spawning-position.patch index a48c0781..33a1b50f 100644 --- a/leaf-server/minecraft-patches/features/0185-preload-mob-spawning-position.patch +++ b/leaf-server/minecraft-patches/features/0184-preload-mob-spawning-position.patch @@ -5,17 +5,17 @@ Subject: [PATCH] preload mob spawning position diff --git a/net/minecraft/world/level/NaturalSpawner.java b/net/minecraft/world/level/NaturalSpawner.java -index 762bdf1fe19546f89d34b9efdad66b00dab80006..0443df34de4f940f64e563ea76453493cadf200b 100644 +index 458b17dca84c87591b030679c5aac6259c0f8308..c69922ac2b831d8af35c9e98a34825e6b8a268da 100644 --- a/net/minecraft/world/level/NaturalSpawner.java +++ b/net/minecraft/world/level/NaturalSpawner.java -@@ -257,9 +257,56 @@ public final class NaturalSpawner { +@@ -257,9 +257,57 @@ public final class NaturalSpawner { // Paper end - Optional per player mob spawns - // Leaf start + // Leaf start - optimize mob spawning BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(); - mutableRandomPosWithin(pos, level, chunk); - if (pos.getY() < level.getMinY() + 1) { - return 0; -+ // Leaf start ++ // Leaf start - preload mob spawning position + if (org.dreeam.leaf.config.modules.opt.PreloadNaturalMobSpawning.enabled) { + if (chunk.cacheSpawnPosIndex == 16 || chunk.cacheSpawnPosIndex == -1) { + if (chunk.cacheSpawnPos == null) { @@ -65,44 +65,45 @@ index 762bdf1fe19546f89d34b9efdad66b00dab80006..0443df34de4f940f64e563ea76453493 + if (bs == null || bs.isRedstoneConductor(level, pos)) { + return 0; + } ++ // Leaf end - preload mob spawning position } return spawnCategoryForPosition(category, level, chunk, pos, filter, callback, maxSpawns, trackEntity, false); // Paper - Optional per player mob spawns // Paper - throttle failed spawn attempts - // Leaf end -@@ -284,7 +331,12 @@ public final class NaturalSpawner { + // Leaf end - optimize mob spawning +@@ -284,7 +332,12 @@ public final class NaturalSpawner { MobCategory category, ServerLevel level, ChunkAccess chunk, BlockPos pos, NaturalSpawner.SpawnPredicate filter, NaturalSpawner.AfterSpawnCallback callback, final int maxSpawns, final @Nullable Consumer trackEntity // Paper start - throttle failed spawn attempts ) { - spawnCategoryForPosition(category, level, chunk, pos, filter, callback, maxSpawns, trackEntity, false); -+ // Leaf start ++ // Leaf start - preload mob spawning position + BlockState blockState = level.getBlockStateIfLoadedAndInBounds(pos); + if (blockState != null && !blockState.isRedstoneConductor(chunk, pos)) { + spawnCategoryForPosition(category, level, chunk, pos, filter, callback, maxSpawns, trackEntity, false); + } -+ // Leaf end ++ // Leaf end - preload mob spawning position } public static int spawnCategoryForPosition( MobCategory category, ServerLevel level, ChunkAccess chunk, BlockPos pos, NaturalSpawner.SpawnPredicate filter, NaturalSpawner.AfterSpawnCallback callback, final int maxSpawns, final @Nullable Consumer trackEntity, final boolean nothing -@@ -297,8 +349,8 @@ public final class NaturalSpawner { - int posX = pos.getX(); // Leaf - int posZ = pos.getZ(); // Leaf +@@ -297,8 +350,8 @@ public final class NaturalSpawner { + int posX = pos.getX(); // Leaf - optimize mob spawning + int posZ = pos.getZ(); // Leaf - optimize mob spawning int i = 0; // Paper - throttle failed spawn attempts - BlockState blockState = level.getBlockStateIfLoadedAndInBounds(pos); // Paper - don't load chunks for mob spawn - if (blockState != null && !blockState.isRedstoneConductor(chunk, pos)) { // Paper - don't load chunks for mob spawn -+ // BlockState blockState = level.getBlockStateIfLoadedAndInBounds(pos); // Paper - don't load chunks for mob spawn // Leaf -+ if (true /*blockState != null && !blockState.isRedstoneConductor(chunk, pos)*/) { // Paper - don't load chunks for mob spawn // Leaf - BlockPos.MutableBlockPos mutableBlockPos = pos instanceof BlockPos.MutableBlockPos pos2 ? pos2 : new BlockPos.MutableBlockPos(); // Leaf ++ //BlockState blockState = level.getBlockStateIfLoadedAndInBounds(pos); // Paper - don't load chunks for mob spawn // Leaf - preload mob spawning position ++ if (true /*blockState != null && !blockState.isRedstoneConductor(chunk, pos)*/) { // Paper - don't load chunks for mob spawn // Leaf - preload mob spawning position + BlockPos.MutableBlockPos mutableBlockPos = pos instanceof BlockPos.MutableBlockPos pos2 ? pos2 : new BlockPos.MutableBlockPos(); // Leaf - optimize mob spawning //int i = 0; // Paper - throttle failed spawn attempts - move up diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java -index e6eab6929b08503c49debbbd25497ffedad438e1..624a177695580510c0a49d4503dee72da7fd7114 100644 +index a90bf0d80ae4dac9b19b8e467b402917cc19a271..804f2118167b1607c50ca8378119254e8760427a 100644 --- a/net/minecraft/world/level/chunk/LevelChunk.java +++ b/net/minecraft/world/level/chunk/LevelChunk.java @@ -106,6 +106,8 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p // Paper start - rewrite chunk system private boolean postProcessingDone; private net.minecraft.server.level.ServerChunkCache.ChunkAndHolder chunkAndHolder; -+ public long[] cacheSpawnPos = null; // Leaf -+ public int cacheSpawnPosIndex = -1; // Leaf ++ public long[] cacheSpawnPos = null; // Leaf - preload mob spawning position ++ public int cacheSpawnPosIndex = -1; // Leaf - preload mob spawning position @Override public final boolean moonrise$isPostProcessingDone() { diff --git a/leaf-server/minecraft-patches/features/0186-Add-BlockExplosionHitEvent.patch b/leaf-server/minecraft-patches/features/0185-Add-BlockExplosionHitEvent.patch similarity index 86% rename from leaf-server/minecraft-patches/features/0186-Add-BlockExplosionHitEvent.patch rename to leaf-server/minecraft-patches/features/0185-Add-BlockExplosionHitEvent.patch index 92843555..ff3a13ec 100644 --- a/leaf-server/minecraft-patches/features/0186-Add-BlockExplosionHitEvent.patch +++ b/leaf-server/minecraft-patches/features/0185-Add-BlockExplosionHitEvent.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Add BlockExplosionHitEvent diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java -index 6030c4eefd77969a1a9251de76d4291dcb0a2092..ea9c641fe9a9685307b6de2999ea4ff5342269b7 100644 +index 6030c4eefd77969a1a9251de76d4291dcb0a2092..a43192a4c0b89cf9436e1e3144037420005d85d9 100644 --- a/net/minecraft/world/level/ServerExplosion.java +++ b/net/minecraft/world/level/ServerExplosion.java @@ -623,9 +623,13 @@ public class ServerExplosion implements Explosion { @@ -15,13 +15,13 @@ index 6030c4eefd77969a1a9251de76d4291dcb0a2092..ea9c641fe9a9685307b6de2999ea4ff5 - this.level - .getBlockState(blockPos) - .onExplosionHit(this.level, blockPos, this, (itemStack, blockPos1) -> addOrAppendStack(list, itemStack, blockPos1)); -+ // Leaf start - BlockExplosionHitEvent ++ // Leaf start - Add BlockExplosionHitEvent + if(new org.dreeam.leaf.event.BlockExplosionHitEvent(CraftLocation.toBukkit(blockPos, bworld).getBlock(), this.source == null ? null : this.source.getBukkitEntity(), org.bukkit.craftbukkit.CraftExplosionResult.toBukkit(this.blockInteraction)).callEvent()) { + this.level + .getBlockState(blockPos) + .onExplosionHit(this.level, blockPos, this, (itemStack, blockPos1) -> addOrAppendStack(list, itemStack, blockPos1)); + } -+ // Leaf end ++ // Leaf end - Add BlockExplosionHitEvent } for (ServerExplosion.StackCollector stackCollector : list) { diff --git a/leaf-server/minecraft-patches/features/0187-Old-Blast-Protection-explosion-knockback.patch b/leaf-server/minecraft-patches/features/0186-Old-Blast-Protection-explosion-knockback.patch similarity index 98% rename from leaf-server/minecraft-patches/features/0187-Old-Blast-Protection-explosion-knockback.patch rename to leaf-server/minecraft-patches/features/0186-Old-Blast-Protection-explosion-knockback.patch index 60d58d15..188eb903 100644 --- a/leaf-server/minecraft-patches/features/0187-Old-Blast-Protection-explosion-knockback.patch +++ b/leaf-server/minecraft-patches/features/0186-Old-Blast-Protection-explosion-knockback.patch @@ -17,7 +17,7 @@ index 0a5611b1ece4dbe2887e7fbdef45f58e7f4d53ad..9f6fc274525f2fe4e4e35e0feaa410bf public static final StringRepresentable.EnumCodec CODEC = StringRepresentable.fromEnum(EquipmentSlot::values); public static final StreamCodec STREAM_CODEC = ByteBufCodecs.idMapper(BY_ID, equipmentSlot -> equipmentSlot.id); diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java -index ea9c641fe9a9685307b6de2999ea4ff5342269b7..ae0dab1f8470cf53031a2ba776fa70d8ae074a87 100644 +index a43192a4c0b89cf9436e1e3144037420005d85d9..6ca263eead9b1fe527cc16a659eb9f55496a180a 100644 --- a/net/minecraft/world/level/ServerExplosion.java +++ b/net/minecraft/world/level/ServerExplosion.java @@ -532,7 +532,7 @@ public class ServerExplosion implements Explosion { diff --git a/leaf-server/minecraft-patches/features/0188-Paw-optimization.patch b/leaf-server/minecraft-patches/features/0187-Paw-optimization.patch similarity index 99% rename from leaf-server/minecraft-patches/features/0188-Paw-optimization.patch rename to leaf-server/minecraft-patches/features/0187-Paw-optimization.patch index 5c1e1b4b..64263972 100644 --- a/leaf-server/minecraft-patches/features/0188-Paw-optimization.patch +++ b/leaf-server/minecraft-patches/features/0187-Paw-optimization.patch @@ -100,7 +100,7 @@ index 4535858701b2bb232b9d2feb2af6551526232ddc..e65c62dbe4c1560ae153e4c4344e9194 - // Paper end - detailed watchdog information } diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java -index 55f20122732e88037d24be311469b6cab72c37ad..2f927b422c2c4f2f65d822befe3cbfd9e3bb3708 100644 +index c1efd558cfbfd2200295ef5755aa496e95deb7d7..15bbd1f7f2a90b4b5427026d622764bb1c92d465 100644 --- a/net/minecraft/server/level/ServerChunkCache.java +++ b/net/minecraft/server/level/ServerChunkCache.java @@ -506,9 +506,10 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon @@ -149,7 +149,7 @@ index 7955a8fa9c4de139b24c9d53018b055ff4008e02..eb849c57992658005e0f514c6f7923f8 private void tickPassenger(Entity ridingEntity, Entity passengerEntity, final boolean isActive) { // Paper - EAR 2 diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index 80baa2dff5c1034a72271fc727fdb2acc1b69488..9f581d5bdc3f658694bbd8c80abbce4e27e568d3 100644 +index 5ea5ff08c8e22b8a4aeef06ab0fc7a60255c27ee..02cd62b29f17307d82101bc4e0104afc813536c1 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java @@ -1147,31 +1147,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess diff --git a/leaf-server/minecraft-patches/features/0189-Use-UUID-for-cure-reputation.patch b/leaf-server/minecraft-patches/features/0188-Use-UUID-for-cure-reputation.patch similarity index 90% rename from leaf-server/minecraft-patches/features/0189-Use-UUID-for-cure-reputation.patch rename to leaf-server/minecraft-patches/features/0188-Use-UUID-for-cure-reputation.patch index abb59c03..243d8878 100644 --- a/leaf-server/minecraft-patches/features/0189-Use-UUID-for-cure-reputation.patch +++ b/leaf-server/minecraft-patches/features/0188-Use-UUID-for-cure-reputation.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Use UUID for cure reputation diff --git a/net/minecraft/world/entity/monster/ZombieVillager.java b/net/minecraft/world/entity/monster/ZombieVillager.java -index d4b6c93f9f0e109be300164c4fd9167aba2d951c..301228895f0347ec514cefc8a11d8ca7bc2f2225 100644 +index d4b6c93f9f0e109be300164c4fd9167aba2d951c..138e62965a4e532972e51c16b429e050bb147788 100644 --- a/net/minecraft/world/entity/monster/ZombieVillager.java +++ b/net/minecraft/world/entity/monster/ZombieVillager.java @@ -310,9 +310,10 @@ public class ZombieVillager extends Zombie implements VillagerDataHolder { @@ -16,7 +16,7 @@ index d4b6c93f9f0e109be300164c4fd9167aba2d951c..301228895f0347ec514cefc8a11d8ca7 if (playerByUuid instanceof ServerPlayer) { CriteriaTriggers.CURED_ZOMBIE_VILLAGER.trigger((ServerPlayer)playerByUuid, this, villager); - serverLevel.onReputationEvent(ReputationEventType.ZOMBIE_VILLAGER_CURED, playerByUuid, villager); -+ // serverLevel.onReputationEvent(ReputationEventType.ZOMBIE_VILLAGER_CURED, playerByUuid, villager); // Leaf - move up ++ //serverLevel.onReputationEvent(ReputationEventType.ZOMBIE_VILLAGER_CURED, playerByUuid, villager); // Leaf - Use UUID for cure reputation - move up } } diff --git a/leaf-server/minecraft-patches/features/0190-Cache-potential-behaviors-in-Brain.patch b/leaf-server/minecraft-patches/features/0189-Cache-potential-behaviors-in-Brain.patch similarity index 69% rename from leaf-server/minecraft-patches/features/0190-Cache-potential-behaviors-in-Brain.patch rename to leaf-server/minecraft-patches/features/0189-Cache-potential-behaviors-in-Brain.patch index 5b0006d5..05706456 100644 --- a/leaf-server/minecraft-patches/features/0190-Cache-potential-behaviors-in-Brain.patch +++ b/leaf-server/minecraft-patches/features/0189-Cache-potential-behaviors-in-Brain.patch @@ -5,14 +5,14 @@ Subject: [PATCH] Cache potential behaviors in Brain diff --git a/net/minecraft/world/entity/ai/Brain.java b/net/minecraft/world/entity/ai/Brain.java -index 97dad57ba873c0f6404a490e358739dbaf11bc55..34b66ee67927bc0796d6c5f069393618abca9d74 100644 +index 4dde1642a33349335f374f17123a700dde1079d7..5e86c8f6dffc7b4dd17acc43ec4c458368bf92a4 100644 --- a/net/minecraft/world/entity/ai/Brain.java +++ b/net/minecraft/world/entity/ai/Brain.java @@ -60,6 +60,7 @@ public class Brain { private Activity defaultActivity = Activity.IDLE; private long lastScheduleUpdate = -9999L; -+ private ObjectArrayList> cachedPotentialBehaviors; ++ private ObjectArrayList> cachedPotentialBehaviors; // Leaf - Cache potential behaviors in Brain public static Brain.Provider provider( Collection> memoryTypes, Collection>> sensorTypes ) { @@ -20,7 +20,7 @@ index 97dad57ba873c0f6404a490e358739dbaf11bc55..34b66ee67927bc0796d6c5f069393618 for (Brain.MemoryValue memoryValue : memoryValues) { memoryValue.setMemoryInternal(this); } -+ this.invalidateBehaviorCache(); ++ this.invalidateBehaviorCache(); // Leaf - Cache potential behaviors in Brain } public DataResult serializeStart(DynamicOps ops) { @@ -28,7 +28,7 @@ index 97dad57ba873c0f6404a490e358739dbaf11bc55..34b66ee67927bc0796d6c5f069393618 this.activeActivities.clear(); this.activeActivities.addAll(this.coreActivities); this.activeActivities.add(activity); -+ this.invalidateBehaviorCache(); ++ this.invalidateBehaviorCache(); // Leaf - Cache potential behaviors in Brain } } @@ -36,56 +36,47 @@ index 97dad57ba873c0f6404a490e358739dbaf11bc55..34b66ee67927bc0796d6c5f069393618 .computeIfAbsent(activity, activity1 -> new it.unimi.dsi.fastutil.objects.ObjectLinkedOpenHashSet<>()) // Leaf - Replace brain activity maps with optimized collection .add((BehaviorControl)pair.getSecond()); } -+ this.invalidateBehaviorCache(); ++ this.invalidateBehaviorCache(); // Leaf - Cache potential behaviors in Brain } @VisibleForTesting public void removeAllBehaviors() { this.availableBehaviorsByPriority.clear(); -+ this.invalidateBehaviorCache(); ++ this.invalidateBehaviorCache(); // Leaf - Cache potential behaviors in Brain } public boolean isActive(Activity activity) { -@@ -452,30 +457,40 @@ public class Brain { +@@ -452,23 +457,44 @@ public class Brain { } } - private void startEachNonRunningBehavior(ServerLevel level, E entity) { -- // Leaf start - Collect then startEachNonRunningBehavior in Brain -- final long gameTime = level.getGameTime(); -- List> behaviorsToStart = new ObjectArrayList<>(); -- -- for (Activity activeActivity : this.activeActivities) { -- for (Map>> priorityMap : this.availableBehaviorsByPriority.values()) { -- Set> behaviors = priorityMap.get(activeActivity); -- -- if (behaviors != null && !behaviors.isEmpty()) { -- for (BehaviorControl behaviorControl : behaviors) { -- if (behaviorControl.getStatus() == Behavior.Status.STOPPED) { -- behaviorsToStart.add(behaviorControl); -- } +- long gameTime = level.getGameTime(); ++ // Leaf start - Cache potential behaviors in Brain + private void invalidateBehaviorCache() { + this.cachedPotentialBehaviors = null; + } + + private void rebuildBehaviorCache() { + this.cachedPotentialBehaviors = new ObjectArrayList<>(30); -+ -+ for (Map>> map : this.availableBehaviorsByPriority.values()) { + + for (Map>> map : this.availableBehaviorsByPriority.values()) { +- for (Entry>> entry : map.entrySet()) { + for (Map.Entry>> entry : map.entrySet()) { -+ Activity activity = entry.getKey(); -+ if (this.activeActivities.contains(activity)) { + Activity activity = entry.getKey(); + if (this.activeActivities.contains(activity)) { +- for (BehaviorControl behaviorControl : entry.getValue()) { +- if (behaviorControl.getStatus() == Behavior.Status.STOPPED) { +- behaviorControl.tryStart(level, entity, gameTime); +- } + for (BehaviorControl task : entry.getValue()) { + this.cachedPotentialBehaviors.add(task); } } } } -- if (!behaviorsToStart.isEmpty()) { -- for (BehaviorControl behaviorControl : behaviorsToStart) { -- behaviorControl.tryStart(level, entity, gameTime); -+ } -+ + } + + private ObjectArrayList> getPotentialBehaviors() { + if (this.cachedPotentialBehaviors == null) { + this.rebuildBehaviorCache(); @@ -99,9 +90,11 @@ index 97dad57ba873c0f6404a490e358739dbaf11bc55..34b66ee67927bc0796d6c5f069393618 + for (BehaviorControl task : this.getPotentialBehaviors()) { + if (task.getStatus() == Behavior.Status.STOPPED) { + task.tryStart(level, entity, startTime); - } - } -- // Leaf end - Collect then startEachNonRunningBehavior in Brain - } - ++ } ++ } ++ } ++ // Leaf end - Cache potential behaviors in Brain ++ private void tickEachRunningBehavior(ServerLevel level, E entity) { + long gameTime = level.getGameTime(); + diff --git a/leaf-server/minecraft-patches/features/0191-Use-ActivationList-on-runningBehaviors.patch b/leaf-server/minecraft-patches/features/0190-Use-ActivationList-on-runningBehaviors.patch similarity index 77% rename from leaf-server/minecraft-patches/features/0191-Use-ActivationList-on-runningBehaviors.patch rename to leaf-server/minecraft-patches/features/0190-Use-ActivationList-on-runningBehaviors.patch index 667f2a4c..cc37bd53 100644 --- a/leaf-server/minecraft-patches/features/0191-Use-ActivationList-on-runningBehaviors.patch +++ b/leaf-server/minecraft-patches/features/0190-Use-ActivationList-on-runningBehaviors.patch @@ -5,14 +5,14 @@ Subject: [PATCH] Use ActivationList on runningBehaviors diff --git a/net/minecraft/world/entity/ai/Brain.java b/net/minecraft/world/entity/ai/Brain.java -index 34b66ee67927bc0796d6c5f069393618abca9d74..f7dd07feea8884c686e78becb1f9cbd0d2769915 100644 +index 5e86c8f6dffc7b4dd17acc43ec4c458368bf92a4..948731703d25eb3f86a83d45b7fd6ce4b4d3c4e8 100644 --- a/net/minecraft/world/entity/ai/Brain.java +++ b/net/minecraft/world/entity/ai/Brain.java @@ -61,6 +61,7 @@ public class Brain { private long lastScheduleUpdate = -9999L; - private ObjectArrayList> cachedPotentialBehaviors; -+ private org.dreeam.leaf.util.list.ActivationList> runningBehaviors; + private ObjectArrayList> cachedPotentialBehaviors; // Leaf - Cache potential behaviors in Brain ++ private org.dreeam.leaf.util.list.ActivationList> runningBehaviors; // Leaf - Use ActivationList on runningBehaviors public static Brain.Provider provider( Collection> memoryTypes, Collection>> sensorTypes ) { @@ -33,29 +33,31 @@ index 34b66ee67927bc0796d6c5f069393618abca9d74..f7dd07feea8884c686e78becb1f9cbd0 - } - - return list; -+ return this.getRunningBehaviorsList(); ++ return this.getRunningBehaviorsList(); // Leaf - Use ActivationList on runningBehaviors } public void useDefaultActivity() { -@@ -453,12 +442,14 @@ public class Brain { +@@ -453,6 +442,7 @@ public class Brain { long gameTime = owner.level().getGameTime(); for (BehaviorControl behaviorControl : this.getRunningBehaviors()) { -+ this.getRunningBehaviorsList().setVisibility(behaviorControl, false); ++ this.getRunningBehaviorsList().setVisibility(behaviorControl, false); // Leaf - Use ActivationList on runningBehaviors behaviorControl.doStop(level, owner, gameTime); } } - +@@ -460,6 +450,7 @@ public class Brain { + // Leaf start - Cache potential behaviors in Brain private void invalidateBehaviorCache() { this.cachedPotentialBehaviors = null; -+ this.runningBehaviors = null; ++ this.runningBehaviors = null; // Leaf - Use ActivationList on runningBehaviors } private void rebuildBehaviorCache() { -@@ -476,6 +467,25 @@ public class Brain { +@@ -477,6 +468,27 @@ public class Brain { } } ++ // Leaf start - Use ActivationList on runningBehaviors + private void initializeRunningBehaviors() { + this.runningBehaviors = new org.dreeam.leaf.util.list.ActivationList<>(false); + @@ -74,11 +76,12 @@ index 34b66ee67927bc0796d6c5f069393618abca9d74..f7dd07feea8884c686e78becb1f9cbd0 + } + return this.runningBehaviors; + } ++ // Leaf end - Use ActivationList on runningBehaviors + private ObjectArrayList> getPotentialBehaviors() { if (this.cachedPotentialBehaviors == null) { this.rebuildBehaviorCache(); -@@ -489,6 +499,9 @@ public class Brain { +@@ -490,6 +502,9 @@ public class Brain { for (BehaviorControl task : this.getPotentialBehaviors()) { if (task.getStatus() == Behavior.Status.STOPPED) { task.tryStart(level, entity, startTime); @@ -88,13 +91,15 @@ index 34b66ee67927bc0796d6c5f069393618abca9d74..f7dd07feea8884c686e78becb1f9cbd0 } } } -@@ -498,6 +511,9 @@ public class Brain { +@@ -500,6 +515,11 @@ public class Brain { for (BehaviorControl behaviorControl : this.getRunningBehaviors()) { behaviorControl.tickOrStop(level, entity, gameTime); ++ // Leaf start - Use ActivationList on runningBehaviors + if (behaviorControl.getStatus() != Behavior.Status.RUNNING) { + this.getRunningBehaviorsList().setVisibility(behaviorControl, false); + } ++ // Leaf end - Use ActivationList on runningBehaviors } } diff --git a/leaf-server/minecraft-patches/features/0192-Paper-Fix-infinite-loop-in-RegionFile-IO.patch b/leaf-server/minecraft-patches/features/0191-Paper-Fix-infinite-loop-in-RegionFile-IO.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0192-Paper-Fix-infinite-loop-in-RegionFile-IO.patch rename to leaf-server/minecraft-patches/features/0191-Paper-Fix-infinite-loop-in-RegionFile-IO.patch