From 860b64367cebf28103ef51ed5e9e60b67a2477e3 Mon Sep 17 00:00:00 2001 From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com> Date: Tue, 7 Jan 2025 18:39:31 -0500 Subject: [PATCH] Gale 1.21.4 --- .gitattributes | 14 +- .../{auto-update.yml => auto-update.yml.todo} | 4 +- .github/workflows/build.yml | 11 +- .gitignore | 64 +- build-data/dev-imports.txt | 5 +- build.gradle.kts | 118 +- gale-api/build.gradle.kts.patch | 84 + .../features/0001-Gale-branding-changes.patch | 17 - .../features/0002-Gale-configuration.patch | 4 +- .../0003-Make-timings-calls-final.patch | 2 +- .../features/0004-SIMD-support.patch | 20 - ...0005-Vectorized-map-color-conversion.patch | 2 +- ...0006-Do-not-log-plugin-library-loads.patch | 2 +- .../0007-Player-canSee-by-entity-UUID.patch | 4 +- .../0008-Specific-interval-TPS-API.patch | 12 +- .../features/0009-5-second-TPS-average.patch | 12 +- .../features/0010-Last-tick-time-API.patch | 8 +- .../0002-Dev-import-deobfuscation-fixes.patch | 2 + ...ve-iterators-from-Inventory-contains.patch | 2 + ...cow-rotation-when-shearing-mooshroom.patch | 2 + .../hardfork}/server/0058-Fix-MC-110386.patch | 2 + .../0011-Include-time-in-startup-logs.patch | 0 ...Include-server.properties-in-timings.patch | 0 ...13-Include-hardware-specs-in-timings.patch | 0 .../server/0014-Use-timin.gs-by-default.patch | 0 ...commend-disabling-timings-on-startup.patch | 0 .../0016-Make-timings-calls-final.patch | 0 ...0023-Improve-fluid-direction-caching.patch | 0 ...ove-container-checking-with-a-bitset.patch | 0 .../server/0027-Inline-level-height.patch | 0 ...reams-and-iterators-from-range-check.patch | 0 ...-ThreadUnsafeRandom-for-mob-spawning.patch | 0 .../legacy}/server/0059-Fix-MC-31819.patch | 0 .../legacy}/server/0060-Fix-MC-26304.patch | 0 ...signableFrom-call-in-ClassInstanceMu.patch | 0 ...hould-check-if-entity-can-use-portal.patch | 0 .../0079-Optimize-villager-data-storage.patch | 0 ...hape-full-block-cache-with-hashtable.patch | 0 ...I-goal-set-with-optimized-collection.patch | 0 ...ld-generation-chunk-and-block-access.patch | 0 ...ination-chunk-before-entity-teleport.patch | 0 ...ax-interaction-distance-configurable.patch | 0 ...tly-continue-on-world-upgrade-finish.patch | 0 gale-archived-patches/ver/README.md | 1 + ...ce-entity-fluid-lookups-if-no-fluids.patch | 0 ...e-aging-cache-for-biome-temperatures.patch | 0 ...otable-refresh-for-non-player-intera.patch | 0 ...079-Cache-CubeVoxelShape-shape-array.patch | 0 .../0079-Cache-ominous-banner-item.patch | 0 gale-server/build.gradle.kts.patch | 127 + .../features/0001-Gale-branding-changes.patch | 44 + .../features/0002-Gale-configuration.patch | 141 + .../features/0003-Gale-commands.patch | 26 + .../0004-Remove-vanilla-profiler.patch | 2292 ++++++++++++++++ .../0005-Use-platform-math-functions.patch | 32 +- ...aster-floating-point-positive-modulo.patch | 54 + ...apelessRecipe-comparison-for-vanilla.patch | 28 +- ...0008-Reduce-projectile-chunk-loading.patch | 45 +- .../features/0009-Predict-Halloween.patch | 20 +- .../0010-Move-random-tick-random.patch | 20 +- ...timize-random-calls-in-chunk-ticking.patch | 73 +- ...duce-enderman-teleport-chunk-lookups.patch | 30 +- ...educe-acquire-POI-for-stuck-entities.patch | 65 + ...ting-range-before-getting-visibility.patch | 24 +- .../0015-Cache-on-climbable-check.patch | 36 +- ...llisionContext-a-live-representation.patch | 42 +- ...er-checking-for-useless-move-packets.patch | 73 + ...0018-Block-goal-does-not-load-chunks.patch | 16 +- .../0019-Reduce-entity-allocations.patch | 26 +- ...020-Remove-lambda-from-ticking-guard.patch | 74 + .../features/0021-SIMD-support.patch | 32 + .../0022-Make-book-writing-configurable.patch | 39 + .../0023-Optimize-entity-coordinate-key.patch | 36 + .../features/0024-Reduce-in-wall-checks.patch | 38 +- ...chat-order-verification-configurable.patch | 23 +- ...n-respawn-attempt-after-placing-end-.patch | 44 + ...7-Make-saving-fireworks-configurable.patch | 37 + .../0028-Reduce-hopper-item-checks.patch | 149 ++ .../0029-Reduce-villager-item-re-pickup.patch | 41 + ...030-Variable-entity-wake-up-duration.patch | 25 +- ...hat-commands-before-player-has-joine.patch | 32 +- .../0032-Do-not-log-invalid-statistics.patch | 42 + ...33-Do-not-log-empty-message-warnings.patch | 21 + ...0034-Do-not-log-ignored-advancements.patch | 51 + ...35-Do-not-log-setBlock-in-far-chunks.patch | 31 +- ...0036-Do-not-log-unrecognized-recipes.patch | 51 + ...-Do-not-log-expired-message-warnings.patch | 21 + .../0038-Do-not-log-Not-Secure-marker.patch | 21 + ...-not-log-disconnections-with-null-id.patch | 22 +- .../0040-Do-not-log-run-as-root-warning.patch | 16 +- ...0041-Do-not-log-offline-mode-warning.patch | 14 +- ...ftly-log-invalid-pool-element-errors.patch | 36 + ...ver-showing-in-ping-before-server-fu.patch | 22 +- .../features/0044-Fix-MC-238526.patch | 56 + .../features/0045-Fix-MC-121706.patch | 34 +- ...ent-resetting-despawn-counter-config.patch | 30 +- ...logging-login-locations-configurable.patch | 32 + .../0048-Reduce-array-allocations.patch | 365 +++ .../0049-Optimize-sun-burn-tick.patch | 79 +- ...d-Optional-allocation-in-EntityBased.patch | 22 +- ...-rules-map-with-optimized-collection.patch | 10 +- ...ttributes-with-optimized-collections.patch | 8 +- ...-class-map-with-optimized-collection.patch | 8 +- ...tance-list-with-optimized-collection.patch | 12 +- ...-tracker-map-with-optimized-collecti.patch | 56 + ...signableFrom-call-in-ClassInstanceMu.patch | 16 +- .../0057-Cache-BlockStatePairKey-hash.patch | 33 +- .../0058-Cache-ShapePairKey-hash.patch | 31 +- ...-by-multiplication-in-CubePointRange.patch | 40 + ...lace-parts-by-size-in-CubePointRange.patch | 22 +- ...ck-frozen-ticks-before-landing-block.patch | 38 + .../0062-Faster-chunk-serialization.patch | 237 ++ .../0063-Update-boss-bar-within-tick.patch | 18 +- ...0064-Cache-world-generator-sea-level.patch | 30 +- ...-Skip-secondary-POI-sensor-if-absent.patch | 14 +- ...Skip-entity-move-if-movement-is-zero.patch | 24 +- .../0067-Store-mob-counts-in-an-array.patch | 36 + ...8-Use-linked-map-for-entity-trackers.patch | 27 + .../0069-Optimize-noise-generation.patch | 239 ++ .../0070-Optimize-sheep-offspring-color.patch | 40 +- ...mes-on-entities-with-fire-resistance.patch | 32 + ...72-Skip-cloning-advancement-criteria.patch | 8 +- ...block-destruction-packet-allocations.patch | 51 + ...4-Spread-out-sending-all-player-info.patch | 142 +- ...-player-list-for-sending-player-info.patch | 29 +- ...ndSendEvent-if-there-are-no-listener.patch | 24 +- ...077-Send-multiple-keep-alive-packets.patch | 77 +- ...Make-slow-login-timeout-configurable.patch | 24 + ...-Don-t-load-chunks-to-spawn-phantoms.patch | 35 + ...chunks-to-activate-climbing-entities.patch | 49 +- ...nimations-as-the-entity-being-critte.patch | 39 + ...82-Ignore-null-legacy-structure-data.patch | 38 + ...nnecessary-mob-spawning-computations.patch | 48 +- ...-random-strolling-into-non-ticking-c.patch | 27 + ...yer-in-world-if-kicked-before-being-.patch | 14 +- .../features/0086-Global-EULA-file.patch | 25 +- .../features/0087-5-second-TPS-average.patch | 58 + .../0088-Measure-last-tick-time.patch | 40 +- ...ncrease-time-statistics-in-intervals.patch | 45 +- ...heck-has-physics-before-same-vehicle.patch | 14 +- ...gible-planar-movement-multiplication.patch | 19 +- .../0092-Optimize-matching-item-checks.patch | 26 + .../0093-Pre-compute-VarLong-sizes.patch | 45 + ...imize-VarInt-write-and-VarLong-write.patch | 214 ++ .../0095-Reduce-RandomSource-instances.patch | 138 + .../features/0096-Add-xor-shift-random.patch | 69 + ...mStack-lookups-for-reduced-visibilit.patch | 65 + ...ine-of-sight-cache-with-low-capacity.patch | 12 +- ...e-of-sight-updates-and-cache-lookups.patch | 50 +- ...thread-priority-environment-variable.patch | 21 +- .../features/0001-Gale-branding-changes.patch | 358 +-- .../features/0002-Gale-metrics.patch | 12 +- .../features/0003-Gale-semantic-version.patch | 29 + .../features/0004-Gale-configuration.patch | 172 ++ .../0005-Set-Gale-permissions-root.patch | 2 +- ...apelessRecipe-comparison-for-vanilla.patch | 50 + ...e-for-plugins-not-shutting-down-task.patch | 2 +- .../features/0008-SIMD-support.patch | 61 +- .../0009-Make-book-writing-configurable.patch | 31 - .../0010-Optimize-entity-coordinate-key.patch | 13 - ...t-log-legacy-Material-initialization.patch | 12 - .../0012-Do-not-log-Not-Secure-marker.patch | 21 + .../0013-Reduce-array-allocations.patch | 168 ++ .../0014-CraftBukkit-UUID-to-world-map.patch | 8 +- .../0015-Specific-interval-TPS-API.patch | 4 +- .../features/0016-5-second-TPS-average.patch | 42 +- .../features/0017-Last-tick-time-API.patch | 4 +- ...8-Show-last-tick-time-in-tps-command.patch | 69 + .../0019-Pre-compute-VarLong-sizes.patch | 23 - ...imize-VarInt-write-and-VarLong-write.patch | 81 + .../features/0021-Add-xor-shift-random.patch | 67 + .../0022-Virtual-thread-support.patch | 35 + .../resources/data/.paperassetsroot.patch | 3 + .../java/me/titaniumtown/ArrayConstants.java | 19 + .../world/chunk/LithiumHashPalette.java | 215 ++ .../org/galemc/gale/command/GaleCommand.java | 179 ++ .../org/galemc/gale/command/GaleCommands.java | 31 + .../galemc/gale/command/GaleSubcommand.java | 27 + .../command/PermissionedGaleSubcommand.java | 32 + .../gale/command/subcommands/InfoCommand.java | 42 + .../command/subcommands/ReloadCommand.java | 46 + .../command/subcommands/VersionCommand.java | 39 + .../configuration/GaleConfigurations.java | 302 +++ .../GaleGlobalConfiguration.java | 151 ++ .../GaleRemovedConfigurations.java | 13 + .../configuration/GaleWorldConfiguration.java | 131 + .../galemc/gale/random/XorShiftRandom.java | 404 +++ .../version/AbstractPaperVersionFetcher.java | 154 ++ .../gale/version/GaleSemanticVersion.java | 37 + .../gale/version/GaleVersionFetcher.java | 17 + .../DirectVirtualThreadService.java | 50 + .../ReflectionVirtualThreadService.java | 75 + .../virtualthread/VirtualThreadService.java | 104 + gradle.properties | 9 +- gradle/wrapper/gradle-wrapper.properties | 2 +- gradlew | 3 +- ...Hide-irrelevant-compilation-warnings.patch | 37 - patches/server/0001-Gale-project-setup.patch | 21 - ...Hide-irrelevant-compilation-warnings.patch | 28 - ...review-features-for-development-runs.patch | 20 - .../server/0007-Gale-semantic-version.patch | 72 - patches/server/0008-Gale-configuration.patch | 707 ----- patches/server/0010-Gale-commands.patch | 464 ---- .../server/0011-Remove-vanilla-profiler.patch | 2351 ----------------- ...aster-floating-point-positive-modulo.patch | 54 - ...educe-acquire-POI-for-stuck-entities.patch | 83 - ...er-checking-for-useless-move-packets.patch | 52 - ...029-Remove-lambda-from-ticking-guard.patch | 81 - ...n-respawn-attempt-after-placing-end-.patch | 61 - ...6-Make-saving-fireworks-configurable.patch | 50 - .../0037-Reduce-hopper-item-checks.patch | 193 -- .../0038-Reduce-villager-item-re-pickup.patch | 53 - .../0041-Do-not-log-invalid-statistics.patch | 53 - ...42-Do-not-log-empty-message-warnings.patch | 36 - ...0043-Do-not-log-ignored-advancements.patch | 63 - ...0045-Do-not-log-unrecognized-recipes.patch | 63 - ...0047-Do-not-log-plugin-library-loads.patch | 75 - ...-Do-not-log-expired-message-warnings.patch | 33 - .../0049-Do-not-log-Not-Secure-marker.patch | 46 - ...ftly-log-invalid-pool-element-errors.patch | 85 - patches/server/0055-Fix-MC-238526.patch | 71 - ...logging-login-locations-configurable.patch | 44 - .../0061-Reduce-array-allocations.patch | 618 ----- ...-tracker-map-with-optimized-collecti.patch | 71 - ...-by-multiplication-in-CubePointRange.patch | 39 - ...ck-frozen-ticks-before-landing-block.patch | 39 - .../0075-Faster-chunk-serialization.patch | 444 ---- .../0080-Store-mob-counts-in-an-array.patch | 36 - ...1-Use-linked-map-for-entity-trackers.patch | 27 - .../0082-Optimize-noise-generation.patch | 248 -- ...mes-on-entities-with-fire-resistance.patch | 44 - ...block-destruction-packet-allocations.patch | 46 - ...Make-slow-login-timeout-configurable.patch | 36 - ...-Don-t-load-chunks-to-spawn-phantoms.patch | 51 - ...nimations-as-the-entity-being-critte.patch | 51 - ...95-Ignore-null-legacy-structure-data.patch | 51 - ...-random-strolling-into-non-ticking-c.patch | 39 - ...5-Show-last-tick-time-in-tps-command.patch | 89 - .../0109-Optimize-matching-item-checks.patch | 35 - ...imize-VarInt-write-and-VarLong-write.patch | 273 -- .../0112-Reduce-RandomSource-instances.patch | 132 - .../server/0113-Add-xor-shift-random.patch | 562 ---- ...mStack-lookups-for-reduced-visibilit.patch | 35 - .../server/0118-Virtual-thread-support.patch | 282 -- settings.gradle.kts | 28 +- 245 files changed, 9307 insertions(+), 9773 deletions(-) rename .github/workflows/{auto-update.yml => auto-update.yml.todo} (96%) create mode 100644 gale-api/build.gradle.kts.patch rename patches/api/0002-Gale-branding-changes.patch => gale-api/paper-patches/features/0001-Gale-branding-changes.patch (85%) rename patches/api/0003-Gale-configuration.patch => gale-api/paper-patches/features/0002-Gale-configuration.patch (87%) rename patches/api/0004-Make-timings-calls-final.patch => gale-api/paper-patches/features/0003-Make-timings-calls-final.patch (97%) rename patches/api/0005-SIMD-support.patch => gale-api/paper-patches/features/0004-SIMD-support.patch (85%) rename patches/api/0006-Vectorized-map-color-conversion.patch => gale-api/paper-patches/features/0005-Vectorized-map-color-conversion.patch (98%) rename patches/api/0007-Do-not-log-plugin-library-loads.patch => gale-api/paper-patches/features/0006-Do-not-log-plugin-library-loads.patch (97%) rename patches/api/0008-Player-canSee-by-entity-UUID.patch => gale-api/paper-patches/features/0007-Player-canSee-by-entity-UUID.patch (94%) rename patches/api/0009-Specific-interval-TPS-API.patch => gale-api/paper-patches/features/0008-Specific-interval-TPS-API.patch (87%) rename patches/api/0010-5-second-TPS-average.patch => gale-api/paper-patches/features/0009-5-second-TPS-average.patch (90%) rename patches/api/0011-Last-tick-time-API.patch => gale-api/paper-patches/features/0010-Last-tick-time-API.patch (91%) rename {patches => gale-archived-patches/removed/hardfork}/server/0002-Dev-import-deobfuscation-fixes.patch (99%) rename {patches => gale-archived-patches/removed/hardfork}/server/0021-Remove-iterators-from-Inventory-contains.patch (99%) rename {patches => gale-archived-patches/removed/hardfork}/server/0056-Fix-cow-rotation-when-shearing-mooshroom.patch (98%) rename {patches => gale-archived-patches/removed/hardfork}/server/0058-Fix-MC-110386.patch (97%) rename {patches/removed => gale-archived-patches/removed/legacy}/server/0011-Include-time-in-startup-logs.patch (100%) rename {patches/removed => gale-archived-patches/removed/legacy}/server/0012-Include-server.properties-in-timings.patch (100%) rename {patches/removed => gale-archived-patches/removed/legacy}/server/0013-Include-hardware-specs-in-timings.patch (100%) rename {patches/removed => gale-archived-patches/removed/legacy}/server/0014-Use-timin.gs-by-default.patch (100%) rename {patches/removed => gale-archived-patches/removed/legacy}/server/0015-Recommend-disabling-timings-on-startup.patch (100%) rename {patches/removed => gale-archived-patches/removed/legacy}/server/0016-Make-timings-calls-final.patch (100%) rename {patches/removed => gale-archived-patches/removed/legacy}/server/0023-Improve-fluid-direction-caching.patch (100%) rename {patches/removed => gale-archived-patches/removed/legacy}/server/0026-Improve-container-checking-with-a-bitset.patch (100%) rename {patches/removed => gale-archived-patches/removed/legacy}/server/0027-Inline-level-height.patch (100%) rename {patches/removed => gale-archived-patches/removed/legacy}/server/0028-Remove-streams-and-iterators-from-range-check.patch (100%) rename {patches/removed => gale-archived-patches/removed/legacy}/server/0035-Use-ThreadUnsafeRandom-for-mob-spawning.patch (100%) rename {patches/removed => gale-archived-patches/removed/legacy}/server/0059-Fix-MC-31819.patch (100%) rename {patches/removed => gale-archived-patches/removed/legacy}/server/0060-Fix-MC-26304.patch (100%) rename {patches/removed => gale-archived-patches/removed/legacy}/server/0075-Avoid-Class-isAssignableFrom-call-in-ClassInstanceMu.patch (100%) rename {patches/removed => gale-archived-patches/removed/legacy}/server/0075-End-gateway-should-check-if-entity-can-use-portal.patch (100%) rename {patches/removed => gale-archived-patches/removed/legacy}/server/0079-Optimize-villager-data-storage.patch (100%) rename {patches/removed => gale-archived-patches/removed/legacy}/server/0080-Replace-shape-full-block-cache-with-hashtable.patch (100%) rename {patches/removed => gale-archived-patches/removed/legacy}/server/0081-Replace-AI-goal-set-with-optimized-collection.patch (100%) rename {patches/removed => gale-archived-patches/removed/legacy}/server/0092-Optimize-world-generation-chunk-and-block-access.patch (100%) rename {patches/removed => gale-archived-patches/removed/legacy}/server/0093-Load-portal-destination-chunk-before-entity-teleport.patch (100%) rename {patches/removed => gale-archived-patches/removed/legacy}/server/0108-Make-max-interaction-distance-configurable.patch (100%) rename {patches/removed => gale-archived-patches/removed/legacy}/server/0136-Instantly-continue-on-world-upgrade-finish.patch (100%) create mode 100644 gale-archived-patches/ver/README.md rename {patches => gale-archived-patches}/work/server/0032-Reduce-entity-fluid-lookups-if-no-fluids.patch (100%) rename {patches => gale-archived-patches}/work/server/0033-Use-aging-cache-for-biome-temperatures.patch (100%) rename {patches => gale-archived-patches}/work/server/0046-Don-t-trigger-lootable-refresh-for-non-player-intera.patch (100%) rename {patches => gale-archived-patches}/work/server/0079-Cache-CubeVoxelShape-shape-array.patch (100%) rename {patches => gale-archived-patches}/work/server/0079-Cache-ominous-banner-item.patch (100%) create mode 100644 gale-server/build.gradle.kts.patch create mode 100644 gale-server/minecraft-patches/features/0001-Gale-branding-changes.patch create mode 100644 gale-server/minecraft-patches/features/0002-Gale-configuration.patch create mode 100644 gale-server/minecraft-patches/features/0003-Gale-commands.patch create mode 100644 gale-server/minecraft-patches/features/0004-Remove-vanilla-profiler.patch rename patches/server/0012-Use-platform-math-functions.patch => gale-server/minecraft-patches/features/0005-Use-platform-math-functions.patch (86%) create mode 100644 gale-server/minecraft-patches/features/0006-Faster-floating-point-positive-modulo.patch rename patches/server/0014-Simpler-ShapelessRecipe-comparison-for-vanilla.patch => gale-server/minecraft-patches/features/0007-Simpler-ShapelessRecipe-comparison-for-vanilla.patch (65%) rename patches/server/0015-Reduce-projectile-chunk-loading.patch => gale-server/minecraft-patches/features/0008-Reduce-projectile-chunk-loading.patch (63%) rename patches/server/0016-Predict-Halloween.patch => gale-server/minecraft-patches/features/0009-Predict-Halloween.patch (82%) rename patches/server/0017-Move-random-tick-random.patch => gale-server/minecraft-patches/features/0010-Move-random-tick-random.patch (72%) rename patches/server/0018-Optimize-random-calls-in-chunk-ticking.patch => gale-server/minecraft-patches/features/0011-Optimize-random-calls-in-chunk-ticking.patch (58%) rename patches/server/0019-Reduce-enderman-teleport-chunk-lookups.patch => gale-server/minecraft-patches/features/0012-Reduce-enderman-teleport-chunk-lookups.patch (53%) create mode 100644 gale-server/minecraft-patches/features/0013-Reduce-acquire-POI-for-stuck-entities.patch rename patches/server/0022-Check-targeting-range-before-getting-visibility.patch => gale-server/minecraft-patches/features/0014-Check-targeting-range-before-getting-visibility.patch (63%) rename patches/server/0024-Cache-on-climbable-check.patch => gale-server/minecraft-patches/features/0015-Cache-on-climbable-check.patch (59%) rename patches/server/0025-Make-EntityCollisionContext-a-live-representation.patch => gale-server/minecraft-patches/features/0016-Make-EntityCollisionContext-a-live-representation.patch (74%) create mode 100644 gale-server/minecraft-patches/features/0017-Better-checking-for-useless-move-packets.patch rename patches/server/0027-Block-goal-does-not-load-chunks.patch => gale-server/minecraft-patches/features/0018-Block-goal-does-not-load-chunks.patch (73%) rename patches/server/0028-Reduce-entity-allocations.patch => gale-server/minecraft-patches/features/0019-Reduce-entity-allocations.patch (65%) create mode 100644 gale-server/minecraft-patches/features/0020-Remove-lambda-from-ticking-guard.patch create mode 100644 gale-server/minecraft-patches/features/0021-SIMD-support.patch create mode 100644 gale-server/minecraft-patches/features/0022-Make-book-writing-configurable.patch create mode 100644 gale-server/minecraft-patches/features/0023-Optimize-entity-coordinate-key.patch rename patches/server/0033-Reduce-in-wall-checks.patch => gale-server/minecraft-patches/features/0024-Reduce-in-wall-checks.patch (55%) rename patches/server/0034-Make-chat-order-verification-configurable.patch => gale-server/minecraft-patches/features/0025-Make-chat-order-verification-configurable.patch (56%) create mode 100644 gale-server/minecraft-patches/features/0026-Make-ender-dragon-respawn-attempt-after-placing-end-.patch create mode 100644 gale-server/minecraft-patches/features/0027-Make-saving-fireworks-configurable.patch create mode 100644 gale-server/minecraft-patches/features/0028-Reduce-hopper-item-checks.patch create mode 100644 gale-server/minecraft-patches/features/0029-Reduce-villager-item-re-pickup.patch rename patches/server/0039-Variable-entity-wake-up-duration.patch => gale-server/minecraft-patches/features/0030-Variable-entity-wake-up-duration.patch (67%) rename patches/server/0040-Do-not-process-chat-commands-before-player-has-joine.patch => gale-server/minecraft-patches/features/0031-Do-not-process-chat-commands-before-player-has-joine.patch (55%) create mode 100644 gale-server/minecraft-patches/features/0032-Do-not-log-invalid-statistics.patch create mode 100644 gale-server/minecraft-patches/features/0033-Do-not-log-empty-message-warnings.patch create mode 100644 gale-server/minecraft-patches/features/0034-Do-not-log-ignored-advancements.patch rename patches/server/0044-Do-not-log-setBlock-in-far-chunks.patch => gale-server/minecraft-patches/features/0035-Do-not-log-setBlock-in-far-chunks.patch (50%) create mode 100644 gale-server/minecraft-patches/features/0036-Do-not-log-unrecognized-recipes.patch create mode 100644 gale-server/minecraft-patches/features/0037-Do-not-log-expired-message-warnings.patch create mode 100644 gale-server/minecraft-patches/features/0038-Do-not-log-Not-Secure-marker.patch rename patches/server/0050-Do-not-log-disconnections-with-null-id.patch => gale-server/minecraft-patches/features/0039-Do-not-log-disconnections-with-null-id.patch (50%) rename patches/server/0051-Do-not-log-run-as-root-warning.patch => gale-server/minecraft-patches/features/0040-Do-not-log-run-as-root-warning.patch (72%) rename patches/server/0052-Do-not-log-offline-mode-warning.patch => gale-server/minecraft-patches/features/0041-Do-not-log-offline-mode-warning.patch (78%) create mode 100644 gale-server/minecraft-patches/features/0042-Softly-log-invalid-pool-element-errors.patch rename patches/server/0054-Fix-outdated-server-showing-in-ping-before-server-fu.patch => gale-server/minecraft-patches/features/0043-Fix-outdated-server-showing-in-ping-before-server-fu.patch (70%) create mode 100644 gale-server/minecraft-patches/features/0044-Fix-MC-238526.patch rename patches/server/0057-Fix-MC-121706.patch => gale-server/minecraft-patches/features/0045-Fix-MC-121706.patch (59%) rename patches/server/0059-Make-arrow-movement-resetting-despawn-counter-config.patch => gale-server/minecraft-patches/features/0046-Make-arrow-movement-resetting-despawn-counter-config.patch (55%) create mode 100644 gale-server/minecraft-patches/features/0047-Make-logging-login-locations-configurable.patch create mode 100644 gale-server/minecraft-patches/features/0048-Reduce-array-allocations.patch rename patches/server/0062-Optimize-sun-burn-tick.patch => gale-server/minecraft-patches/features/0049-Optimize-sun-burn-tick.patch (51%) rename patches/server/0063-Reduce-lambda-and-Optional-allocation-in-EntityBased.patch => gale-server/minecraft-patches/features/0050-Reduce-lambda-and-Optional-allocation-in-EntityBased.patch (56%) rename patches/server/0064-Replace-game-rules-map-with-optimized-collection.patch => gale-server/minecraft-patches/features/0051-Replace-game-rules-map-with-optimized-collection.patch (72%) rename patches/server/0065-Replace-AI-attributes-with-optimized-collections.patch => gale-server/minecraft-patches/features/0052-Replace-AI-attributes-with-optimized-collections.patch (81%) rename patches/server/0066-Replace-class-map-with-optimized-collection.patch => gale-server/minecraft-patches/features/0053-Replace-class-map-with-optimized-collection.patch (75%) rename patches/server/0067-Replace-instance-list-with-optimized-collection.patch => gale-server/minecraft-patches/features/0054-Replace-instance-list-with-optimized-collection.patch (71%) create mode 100644 gale-server/minecraft-patches/features/0055-Replace-throttle-tracker-map-with-optimized-collecti.patch rename patches/server/0069-Avoid-Class-isAssignableFrom-call-in-ClassInstanceMu.patch => gale-server/minecraft-patches/features/0056-Avoid-Class-isAssignableFrom-call-in-ClassInstanceMu.patch (81%) rename patches/server/0070-Cache-BlockStatePairKey-hash.patch => gale-server/minecraft-patches/features/0057-Cache-BlockStatePairKey-hash.patch (64%) rename patches/server/0071-Cache-ShapePairKey-hash.patch => gale-server/minecraft-patches/features/0058-Cache-ShapePairKey-hash.patch (55%) create mode 100644 gale-server/minecraft-patches/features/0059-Replace-division-by-multiplication-in-CubePointRange.patch rename patches/server/0073-Replace-parts-by-size-in-CubePointRange.patch => gale-server/minecraft-patches/features/0060-Replace-parts-by-size-in-CubePointRange.patch (55%) create mode 100644 gale-server/minecraft-patches/features/0061-Check-frozen-ticks-before-landing-block.patch create mode 100644 gale-server/minecraft-patches/features/0062-Faster-chunk-serialization.patch rename patches/server/0076-Update-boss-bar-within-tick.patch => gale-server/minecraft-patches/features/0063-Update-boss-bar-within-tick.patch (73%) rename patches/server/0077-Cache-world-generator-sea-level.patch => gale-server/minecraft-patches/features/0064-Cache-world-generator-sea-level.patch (54%) rename patches/server/0078-Skip-secondary-POI-sensor-if-absent.patch => gale-server/minecraft-patches/features/0065-Skip-secondary-POI-sensor-if-absent.patch (68%) rename patches/server/0079-Skip-entity-move-if-movement-is-zero.patch => gale-server/minecraft-patches/features/0066-Skip-entity-move-if-movement-is-zero.patch (70%) create mode 100644 gale-server/minecraft-patches/features/0067-Store-mob-counts-in-an-array.patch create mode 100644 gale-server/minecraft-patches/features/0068-Use-linked-map-for-entity-trackers.patch create mode 100644 gale-server/minecraft-patches/features/0069-Optimize-noise-generation.patch rename patches/server/0083-Optimize-sheep-offspring-color.patch => gale-server/minecraft-patches/features/0070-Optimize-sheep-offspring-color.patch (71%) create mode 100644 gale-server/minecraft-patches/features/0071-Hide-flames-on-entities-with-fire-resistance.patch rename patches/server/0085-Skip-cloning-advancement-criteria.patch => gale-server/minecraft-patches/features/0072-Skip-cloning-advancement-criteria.patch (75%) create mode 100644 gale-server/minecraft-patches/features/0073-Reduce-block-destruction-packet-allocations.patch rename patches/server/0087-Spread-out-sending-all-player-info.patch => gale-server/minecraft-patches/features/0074-Spread-out-sending-all-player-info.patch (60%) rename patches/server/0088-Optimize-player-list-for-sending-player-info.patch => gale-server/minecraft-patches/features/0075-Optimize-player-list-for-sending-player-info.patch (69%) rename patches/server/0089-Skip-PlayerCommandSendEvent-if-there-are-no-listener.patch => gale-server/minecraft-patches/features/0076-Skip-PlayerCommandSendEvent-if-there-are-no-listener.patch (69%) rename patches/server/0090-Send-multiple-keep-alive-packets.patch => gale-server/minecraft-patches/features/0077-Send-multiple-keep-alive-packets.patch (57%) create mode 100644 gale-server/minecraft-patches/features/0078-Make-slow-login-timeout-configurable.patch create mode 100644 gale-server/minecraft-patches/features/0079-Don-t-load-chunks-to-spawn-phantoms.patch rename patches/server/0093-Don-t-load-chunks-to-activate-climbing-entities.patch => gale-server/minecraft-patches/features/0080-Don-t-load-chunks-to-activate-climbing-entities.patch (54%) create mode 100644 gale-server/minecraft-patches/features/0081-Broadcast-crit-animations-as-the-entity-being-critte.patch create mode 100644 gale-server/minecraft-patches/features/0082-Ignore-null-legacy-structure-data.patch rename patches/server/0096-Skip-unnecessary-mob-spawning-computations.patch => gale-server/minecraft-patches/features/0083-Skip-unnecessary-mob-spawning-computations.patch (59%) create mode 100644 gale-server/minecraft-patches/features/0084-Prevent-entities-random-strolling-into-non-ticking-c.patch rename patches/server/0098-Do-not-place-player-in-world-if-kicked-before-being-.patch => gale-server/minecraft-patches/features/0085-Do-not-place-player-in-world-if-kicked-before-being-.patch (71%) rename patches/server/0100-Global-EULA-file.patch => gale-server/minecraft-patches/features/0086-Global-EULA-file.patch (80%) create mode 100644 gale-server/minecraft-patches/features/0087-5-second-TPS-average.patch rename patches/server/0103-Measure-last-tick-time.patch => gale-server/minecraft-patches/features/0088-Measure-last-tick-time.patch (65%) rename patches/server/0106-Increase-time-statistics-in-intervals.patch => gale-server/minecraft-patches/features/0089-Increase-time-statistics-in-intervals.patch (65%) rename patches/server/0107-For-collision-check-has-physics-before-same-vehicle.patch => gale-server/minecraft-patches/features/0090-For-collision-check-has-physics-before-same-vehicle.patch (71%) rename patches/server/0108-Skip-negligible-planar-movement-multiplication.patch => gale-server/minecraft-patches/features/0091-Skip-negligible-planar-movement-multiplication.patch (66%) create mode 100644 gale-server/minecraft-patches/features/0092-Optimize-matching-item-checks.patch create mode 100644 gale-server/minecraft-patches/features/0093-Pre-compute-VarLong-sizes.patch create mode 100644 gale-server/minecraft-patches/features/0094-Optimize-VarInt-write-and-VarLong-write.patch create mode 100644 gale-server/minecraft-patches/features/0095-Reduce-RandomSource-instances.patch create mode 100644 gale-server/minecraft-patches/features/0096-Add-xor-shift-random.patch create mode 100644 gale-server/minecraft-patches/features/0097-Reduce-skull-ItemStack-lookups-for-reduced-visibilit.patch rename patches/server/0115-Initialize-line-of-sight-cache-with-low-capacity.patch => gale-server/minecraft-patches/features/0098-Initialize-line-of-sight-cache-with-low-capacity.patch (64%) rename patches/server/0116-Reduce-line-of-sight-updates-and-cache-lookups.patch => gale-server/minecraft-patches/features/0099-Reduce-line-of-sight-updates-and-cache-lookups.patch (66%) rename patches/server/0117-Server-thread-priority-environment-variable.patch => gale-server/minecraft-patches/features/0100-Server-thread-priority-environment-variable.patch (68%) rename patches/server/0005-Gale-branding-changes.patch => gale-server/paper-patches/features/0001-Gale-branding-changes.patch (75%) rename patches/server/0006-Gale-metrics.patch => gale-server/paper-patches/features/0002-Gale-metrics.patch (98%) create mode 100644 gale-server/paper-patches/features/0003-Gale-semantic-version.patch create mode 100644 gale-server/paper-patches/features/0004-Gale-configuration.patch rename patches/server/0009-Set-Gale-permissions-root.patch => gale-server/paper-patches/features/0005-Set-Gale-permissions-root.patch (90%) create mode 100644 gale-server/paper-patches/features/0006-Simpler-ShapelessRecipe-comparison-for-vanilla.patch rename patches/server/0023-Print-stack-trace-for-plugins-not-shutting-down-task.patch => gale-server/paper-patches/features/0007-Print-stack-trace-for-plugins-not-shutting-down-task.patch (96%) rename patches/server/0030-SIMD-support.patch => gale-server/paper-patches/features/0008-SIMD-support.patch (53%) rename patches/server/0031-Make-book-writing-configurable.patch => gale-server/paper-patches/features/0009-Make-book-writing-configurable.patch (56%) rename patches/server/0032-Optimize-entity-coordinate-key.patch => gale-server/paper-patches/features/0010-Optimize-entity-coordinate-key.patch (71%) rename patches/server/0046-Do-not-log-legacy-Material-initialization.patch => gale-server/paper-patches/features/0011-Do-not-log-legacy-Material-initialization.patch (73%) create mode 100644 gale-server/paper-patches/features/0012-Do-not-log-Not-Secure-marker.patch create mode 100644 gale-server/paper-patches/features/0013-Reduce-array-allocations.patch rename patches/server/0099-CraftBukkit-UUID-to-world-map.patch => gale-server/paper-patches/features/0014-CraftBukkit-UUID-to-world-map.patch (90%) rename patches/server/0101-Specific-interval-TPS-API.patch => gale-server/paper-patches/features/0015-Specific-interval-TPS-API.patch (88%) rename patches/server/0102-5-second-TPS-average.patch => gale-server/paper-patches/features/0016-5-second-TPS-average.patch (64%) rename patches/server/0104-Last-tick-time-API.patch => gale-server/paper-patches/features/0017-Last-tick-time-API.patch (93%) create mode 100644 gale-server/paper-patches/features/0018-Show-last-tick-time-in-tps-command.patch rename patches/server/0110-Pre-compute-VarLong-sizes.patch => gale-server/paper-patches/features/0019-Pre-compute-VarLong-sizes.patch (86%) create mode 100644 gale-server/paper-patches/features/0020-Optimize-VarInt-write-and-VarLong-write.patch create mode 100644 gale-server/paper-patches/features/0021-Add-xor-shift-random.patch create mode 100644 gale-server/paper-patches/features/0022-Virtual-thread-support.patch create mode 100644 gale-server/paper-patches/files/src/main/resources/data/.paperassetsroot.patch create mode 100644 gale-server/src/main/java/me/titaniumtown/ArrayConstants.java create mode 100644 gale-server/src/main/java/net/caffeinemc/mods/lithium/common/world/chunk/LithiumHashPalette.java create mode 100644 gale-server/src/main/java/org/galemc/gale/command/GaleCommand.java create mode 100644 gale-server/src/main/java/org/galemc/gale/command/GaleCommands.java create mode 100644 gale-server/src/main/java/org/galemc/gale/command/GaleSubcommand.java create mode 100644 gale-server/src/main/java/org/galemc/gale/command/PermissionedGaleSubcommand.java create mode 100644 gale-server/src/main/java/org/galemc/gale/command/subcommands/InfoCommand.java create mode 100644 gale-server/src/main/java/org/galemc/gale/command/subcommands/ReloadCommand.java create mode 100644 gale-server/src/main/java/org/galemc/gale/command/subcommands/VersionCommand.java create mode 100644 gale-server/src/main/java/org/galemc/gale/configuration/GaleConfigurations.java create mode 100644 gale-server/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java create mode 100644 gale-server/src/main/java/org/galemc/gale/configuration/GaleRemovedConfigurations.java create mode 100644 gale-server/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java create mode 100644 gale-server/src/main/java/org/galemc/gale/random/XorShiftRandom.java create mode 100644 gale-server/src/main/java/org/galemc/gale/version/AbstractPaperVersionFetcher.java create mode 100644 gale-server/src/main/java/org/galemc/gale/version/GaleSemanticVersion.java create mode 100644 gale-server/src/main/java/org/galemc/gale/version/GaleVersionFetcher.java create mode 100644 gale-server/src/main/java/org/galemc/gale/virtualthread/DirectVirtualThreadService.java create mode 100644 gale-server/src/main/java/org/galemc/gale/virtualthread/ReflectionVirtualThreadService.java create mode 100644 gale-server/src/main/java/org/galemc/gale/virtualthread/VirtualThreadService.java delete mode 100644 patches/api/0001-Hide-irrelevant-compilation-warnings.patch delete mode 100644 patches/server/0001-Gale-project-setup.patch delete mode 100644 patches/server/0003-Hide-irrelevant-compilation-warnings.patch delete mode 100644 patches/server/0004-Enable-preview-features-for-development-runs.patch delete mode 100644 patches/server/0007-Gale-semantic-version.patch delete mode 100644 patches/server/0008-Gale-configuration.patch delete mode 100644 patches/server/0010-Gale-commands.patch delete mode 100644 patches/server/0011-Remove-vanilla-profiler.patch delete mode 100644 patches/server/0013-Faster-floating-point-positive-modulo.patch delete mode 100644 patches/server/0020-Reduce-acquire-POI-for-stuck-entities.patch delete mode 100644 patches/server/0026-Better-checking-for-useless-move-packets.patch delete mode 100644 patches/server/0029-Remove-lambda-from-ticking-guard.patch delete mode 100644 patches/server/0035-Make-ender-dragon-respawn-attempt-after-placing-end-.patch delete mode 100644 patches/server/0036-Make-saving-fireworks-configurable.patch delete mode 100644 patches/server/0037-Reduce-hopper-item-checks.patch delete mode 100644 patches/server/0038-Reduce-villager-item-re-pickup.patch delete mode 100644 patches/server/0041-Do-not-log-invalid-statistics.patch delete mode 100644 patches/server/0042-Do-not-log-empty-message-warnings.patch delete mode 100644 patches/server/0043-Do-not-log-ignored-advancements.patch delete mode 100644 patches/server/0045-Do-not-log-unrecognized-recipes.patch delete mode 100644 patches/server/0047-Do-not-log-plugin-library-loads.patch delete mode 100644 patches/server/0048-Do-not-log-expired-message-warnings.patch delete mode 100644 patches/server/0049-Do-not-log-Not-Secure-marker.patch delete mode 100644 patches/server/0053-Softly-log-invalid-pool-element-errors.patch delete mode 100644 patches/server/0055-Fix-MC-238526.patch delete mode 100644 patches/server/0060-Make-logging-login-locations-configurable.patch delete mode 100644 patches/server/0061-Reduce-array-allocations.patch delete mode 100644 patches/server/0068-Replace-throttle-tracker-map-with-optimized-collecti.patch delete mode 100644 patches/server/0072-Replace-division-by-multiplication-in-CubePointRange.patch delete mode 100644 patches/server/0074-Check-frozen-ticks-before-landing-block.patch delete mode 100644 patches/server/0075-Faster-chunk-serialization.patch delete mode 100644 patches/server/0080-Store-mob-counts-in-an-array.patch delete mode 100644 patches/server/0081-Use-linked-map-for-entity-trackers.patch delete mode 100644 patches/server/0082-Optimize-noise-generation.patch delete mode 100644 patches/server/0084-Hide-flames-on-entities-with-fire-resistance.patch delete mode 100644 patches/server/0086-Reduce-block-destruction-packet-allocations.patch delete mode 100644 patches/server/0091-Make-slow-login-timeout-configurable.patch delete mode 100644 patches/server/0092-Don-t-load-chunks-to-spawn-phantoms.patch delete mode 100644 patches/server/0094-Broadcast-crit-animations-as-the-entity-being-critte.patch delete mode 100644 patches/server/0095-Ignore-null-legacy-structure-data.patch delete mode 100644 patches/server/0097-Prevent-entities-random-strolling-into-non-ticking-c.patch delete mode 100644 patches/server/0105-Show-last-tick-time-in-tps-command.patch delete mode 100644 patches/server/0109-Optimize-matching-item-checks.patch delete mode 100644 patches/server/0111-Optimize-VarInt-write-and-VarLong-write.patch delete mode 100644 patches/server/0112-Reduce-RandomSource-instances.patch delete mode 100644 patches/server/0113-Add-xor-shift-random.patch delete mode 100644 patches/server/0114-Reduce-skull-ItemStack-lookups-for-reduced-visibilit.patch delete mode 100644 patches/server/0118-Virtual-thread-support.patch diff --git a/.gitattributes b/.gitattributes index 2fb638f..a87d264 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,7 +1,11 @@ -* text=auto +# +# https://help.github.com/articles/dealing-with-line-endings/ +# +# Linux start script should use lf +/gradlew text eol=lf -*.sh text eol=lf -gradlew text eol=lf -*.bat text eol=crlf +# These are Windows script files and should use crlf +*.bat text eol=crlf -*.jar binary +# Binary files should be left untouched +*.jar binary diff --git a/.github/workflows/auto-update.yml b/.github/workflows/auto-update.yml.todo similarity index 96% rename from .github/workflows/auto-update.yml rename to .github/workflows/auto-update.yml.todo index 18cda00..6a4d01c 100644 --- a/.github/workflows/auto-update.yml +++ b/.github/workflows/auto-update.yml.todo @@ -51,7 +51,7 @@ jobs: - uses: actions/setup-java@main with: - distribution: 'temurin' + distribution: 'zulu' java-version: 21 - name: Running tests before push @@ -59,7 +59,7 @@ jobs: cd Gale if ! git diff --quiet; then echo "Running tests...." - ./gradlew applyPatches + ./gradlew applyAllPatches ./gradlew createMojmapPaperclipJar ./gradlew rebuildPatches fi diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2d5142e..f1a9153 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,5 +1,7 @@ name: Build Gale + on: [ push, pull_request ] + jobs: build: runs-on: ubuntu-latest @@ -8,8 +10,6 @@ jobs: steps: - name: Checkout Git repository uses: actions/checkout@main - - name: Validate Gradle wrapper - uses: gradle/actions/wrapper-validation@main - name: Setup Gradle uses: gradle/actions/setup-gradle@main - name: Set up JDK @@ -17,16 +17,19 @@ jobs: with: distribution: zulu java-version: 21 + - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Configure Git user details run: git config --global user.email "no-reply@github.com" && git config --global user.name "Github Actions" + - name: Apply patches - run: ./gradlew applyPatches + run: ./gradlew applyAllPatches - name: Create Paperclip jar run: ./gradlew createMojmapPaperclipJar + - name: Upload Paperclip jar uses: actions/upload-artifact@main with: name: Gale - path: build/libs/gale-paperclip-*-mojmap.jar + path: gale-server/build/libs/gale-paperclip-*-mojmap.jar diff --git a/.gitignore b/.gitignore index 4af002e..e0c4b71 100644 --- a/.gitignore +++ b/.gitignore @@ -1,54 +1,30 @@ -.gradle/ -build/ - -# Eclipse stuff -.classpath -.project -.settings/ - -# VSCode stuff -.vscode/ - -# netbeans -nbproject/ -nbactions.xml - -# we use maven! -build.xml - -# maven -target/ -dependency-reduced-pom.xml - -# vim -.*.sw[a-p] - -# various other potential build files -build/ -bin/ -dist/ -manifest.mf - # Mac filesystem dust .DS_Store/ .DS_Store -# intellij -*.iml -*.ipr -*.iws -.idea/ -out/ - # Linux temp files *~ -# other stuff -run/ - -gale-server -gale-api -paper-api-generator +# vim +.*.sw[a-p] +# IntelliJ +*.iml +.idea +# Gradle !gradle/wrapper/gradle-wrapper.jar +.gradle +build + +# Gale +build-data +run + +gale-api/build.gradle.kts +gale-server/build.gradle.kts +gale-server/src/minecraft +paper-api +paper-api-generator +paper-server +paper-api-generator.settings.gradle diff --git a/build-data/dev-imports.txt b/build-data/dev-imports.txt index 286aeea..1d9862a 100644 --- a/build-data/dev-imports.txt +++ b/build-data/dev-imports.txt @@ -8,4 +8,7 @@ # To import classes from the vanilla Minecraft jar use `minecraft` as the artifactId: # minecraft net.minecraft.world.level.entity.LevelEntityGetterAdapter # minecraft net/minecraft/world/level/entity/LevelEntityGetter.java - +# To import minecraft data files, like the default chat type, use `mc_data` as the prefix: +# mc_data chat_type/chat.json +# mc_data dimension_type/overworld.json +# diff --git a/build.gradle.kts b/build.gradle.kts index 54104c0..186b6e1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,31 +1,41 @@ import org.gradle.api.tasks.testing.logging.TestExceptionFormat import org.gradle.api.tasks.testing.logging.TestLogEvent -import io.papermc.paperweight.util.path -import kotlin.io.path.deleteRecursively plugins { java `maven-publish` - id("io.papermc.paperweight.patcher") version "1.7.7" -} - -allprojects { - apply(plugin = "java") - apply(plugin = "maven-publish") - - java { - toolchain { - languageVersion.set(JavaLanguageVersion.of(21)) - } - } + id("io.papermc.paperweight.patcher") version "2.0.0-beta.11" } val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/" subprojects { - tasks.withType().configureEach { + apply(plugin = "java-library") + apply(plugin = "maven-publish") + + extensions.configure { + toolchain { + languageVersion = JavaLanguageVersion.of(21) + } + } + + repositories { + mavenCentral() + maven(paperMavenPublicUrl) + } + + dependencies { + "testRuntimeOnly"("org.junit.platform:junit-platform-launcher") + } + + tasks.withType().configureEach { + isPreserveFileTimestamps = false + isReproducibleFileOrder = true + } + tasks.withType { options.encoding = Charsets.UTF_8.name() - options.release.set(21) + options.release = 21 + options.isFork = true } tasks.withType { options.encoding = Charsets.UTF_8.name() @@ -40,60 +50,36 @@ subprojects { events(TestLogEvent.STANDARD_OUT) } } - - repositories { - mavenCentral() - maven(paperMavenPublicUrl) - } -} - -repositories { - mavenCentral() - maven(paperMavenPublicUrl) { - content { - onlyForConfigurations(configurations.paperclip.name) - } - } -} - -dependencies { - remapper("net.fabricmc:tiny-remapper:0.10.3:fat") - decompiler("org.vineflower:vineflower:1.10.1") - paperclip("io.papermc:paperclip:3.0.3") } paperweight { - serverProject.set(project(":gale-server")) // Gale - build changes + upstreams.paper { + ref = providers.gradleProperty("paperRef") - remapRepo.set(paperMavenPublicUrl) - decompileRepo.set(paperMavenPublicUrl) - - usePaperUpstream(providers.gradleProperty("paperRef")) { - withPaperPatcher { - apiPatchDir.set(layout.projectDirectory.dir("patches/api")) - apiOutputDir.set(layout.projectDirectory.dir("gale-api")) // Gale - build changes - - serverPatchDir.set(layout.projectDirectory.dir("patches/server")) - serverOutputDir.set(layout.projectDirectory.dir("gale-server")) // Gale - build changes + patchFile { + path = "paper-server/build.gradle.kts" + outputFile = file("gale-server/build.gradle.kts") // Gale - build changes + patchFile = file("gale-server/build.gradle.kts.patch") // Gale - build changes } - - patchTasks.register("generatedApi") { - isBareDirectory = true - upstreamDirPath = "paper-api-generator/generated" - patchDir = layout.projectDirectory.dir("patches/generated-api") - outputDir = layout.projectDirectory.dir("paper-api-generator/generated") + patchFile { + path = "paper-api/build.gradle.kts" + outputFile = file("gale-api/build.gradle.kts") // Gale - build changes + patchFile = file("gale-api/build.gradle.kts.patch") // Gale - build changes + } + patchDir("paperApi") { + upstreamPath = "paper-api" + excludes = setOf("build.gradle.kts") + patchesDir = file("gale-api/paper-patches") // Gale - build changes + outputDir = file("paper-api") + } + patchDir("paperApiGenerator") { + upstreamPath = "paper-api-generator" + patchesDir = file("gale-api-generator/paper-patches") // Gale - build changes + outputDir = file("paper-api-generator") } } } -// Uncomment while updating for a new Minecraft version -//tasks.withType { -// extraPatchDir.set(layout.projectDirectory.dir("patches/unapplied/server")) -//} -// tasks.withType { -// filterPatches.set(false) -// } - tasks.register("printMinecraftVersion") { doLast { println(providers.gradleProperty("mcVersion").get().trim()) @@ -107,11 +93,12 @@ tasks.register("printGaleVersion") { // Gale - branding changes } // Gale start - branding changes - package license into jar -// Based on io.papermc.paperweight.taskcontainers.BundlerJarTasks -tasks.named("createMojmapPaperclipJar") { +// Based on io.papermc.paperweight.taskcontainers.PaperclipTasks +/* +tasks.named("createMojmapBundlerJar") { doLast { - // Based on io.papermc.paperweight.taskcontainers.BundlerJarTasks + // Based on io.papermc.paperweight.taskcontainers.PaperclipTasks val jarName = listOfNotNull( project.name, "paperclip", @@ -119,7 +106,7 @@ tasks.named("createMojmapPaperclipJar") { "mojmap" ).joinToString("-") + ".jar" - // Based on io.papermc.paperweight.taskcontainers.BundlerJarTasks + // Based on io.papermc.paperweight.taskcontainers.PaperclipTasks val zipFile = layout.buildDirectory.file("libs/$jarName").path val rootDir = io.papermc.paperweight.util.findOutputDir(zipFile) @@ -141,4 +128,5 @@ tasks.named("createMojmapPaperclipJar") { } } + */ // Gale end - branding changes - package license into jar diff --git a/gale-api/build.gradle.kts.patch b/gale-api/build.gradle.kts.patch new file mode 100644 index 0000000..1e0d6c8 --- /dev/null +++ b/gale-api/build.gradle.kts.patch @@ -0,0 +1,84 @@ +--- a/paper-api/build.gradle.kts ++++ b/paper-api/build.gradle.kts +@@ -103,6 +_,20 @@ + main { + java { + srcDir(generatedApiPath) ++ // Gale start - project setup ++ srcDir(file("../paper-api/src/main/java")) ++ } ++ resources { ++ srcDir(file("../paper-api/src/main/resources")) ++ } ++ } ++ test { ++ java { ++ srcDir(file("../paper-api/src/test/java")) ++ } ++ resources { ++ srcDir(file("../paper-api/src/test/resources")) ++ // Gale end - project setup + } + } + } +@@ -150,6 +_,16 @@ + } + } + ++// Gale start - hide irrelevant compilation warnings ++tasks.withType { ++ val compilerArgs = options.compilerArgs ++ compilerArgs.add("-Xlint:-module") ++ compilerArgs.add("-Xlint:-removal") ++ compilerArgs.add("-Xlint:-dep-ann") ++ compilerArgs.add("--add-modules=jdk.incubator.vector") // Gale - Pufferfish - SIMD support ++} ++// Gale end - hide irrelevant compilation warnings ++ + tasks.jar { + from(generateApiVersioningFile.map { it.outputs.files.singleFile }) { + into("META-INF/maven/${project.group}/${project.name}") +@@ -159,6 +_,12 @@ + "Automatic-Module-Name" to "org.bukkit" + ) + } ++ ++ // Gale start - package license into jar ++ from("${project.projectDir}/LICENSE.txt") { ++ into("") ++ } ++ // Gale end - package license into jar + } + + abstract class Services { +@@ -169,7 +_,7 @@ + + tasks.withType { + val options = options as StandardJavadocDocletOptions +- options.overview = "src/main/javadoc/overview.html" ++ options.overview = "../paper-api/src/main/javadoc/overview.html" // Gale - project setup + options.use() + options.isDocFilesSubDirs = true + options.links( +@@ -202,16 +_,19 @@ + } + + // workaround for https://github.com/gradle/gradle/issues/4046 +- inputs.dir("src/main/javadoc").withPropertyName("javadoc-sourceset") ++ inputs.dir("../paper-api/src/main/javadoc").withPropertyName("javadoc-sourceset") // Gale - project setup + val fsOps = services.fileSystemOperations + doLast { + fsOps.copy { +- from("src/main/javadoc") { ++ from("../paper-api/src/main/javadoc") { // Gale - project setup + include("**/doc-files/**") + } + into("build/docs/javadoc") + } + } ++ ++ options.addStringOption("Xdoclint:none", "-quiet") // Gale - hide irrelevant compilation warnings ++ options.addStringOption("-add-modules", "jdk.incubator.vector") // Gale - Pufferfish - SIMD support + } + + tasks.test { diff --git a/patches/api/0002-Gale-branding-changes.patch b/gale-api/paper-patches/features/0001-Gale-branding-changes.patch similarity index 85% rename from patches/api/0002-Gale-branding-changes.patch rename to gale-api/paper-patches/features/0001-Gale-branding-changes.patch index 5b53a61..460ef11 100644 --- a/patches/api/0002-Gale-branding-changes.patch +++ b/gale-api/paper-patches/features/0001-Gale-branding-changes.patch @@ -45,23 +45,6 @@ index 94a9ed024d3859793618152ea559a168bbcbb5e2..e60008693e017bec1b4eb49c84be3898 Public License instead of this License. But first, please read -. +. -diff --git a/build.gradle.kts b/build.gradle.kts -index 0225bbd7773527a34e267a0404ba7db7809d8e5a..f7ec84606d8e6c3c3af5ba5fe85fea4c35952c2e 100644 ---- a/build.gradle.kts -+++ b/build.gradle.kts -@@ -166,6 +166,12 @@ tasks.jar { - "Automatic-Module-Name" to "org.bukkit" - ) - } -+ -+ // Gale start - package license into jar -+ from("${project.projectDir}/LICENSE.txt") { -+ into("") -+ } -+ // Gale end - package license into jar - } - - tasks.withType { diff --git a/src/main/java/io/papermc/paper/ServerBuildInfo.java b/src/main/java/io/papermc/paper/ServerBuildInfo.java index 652ff54e7c50412503725d628bfe72ed03059790..b68770f6992b044d13e67d9affa6933c90ca8fb8 100644 --- a/src/main/java/io/papermc/paper/ServerBuildInfo.java diff --git a/patches/api/0003-Gale-configuration.patch b/gale-api/paper-patches/features/0002-Gale-configuration.patch similarity index 87% rename from patches/api/0003-Gale-configuration.patch rename to gale-api/paper-patches/features/0002-Gale-configuration.patch index 78d9b09..743f964 100644 --- a/patches/api/0003-Gale-configuration.patch +++ b/gale-api/paper-patches/features/0002-Gale-configuration.patch @@ -13,10 +13,10 @@ As part of: Paper (https://github.com/PaperMC/Paper) Licensed under: MIT (https://opensource.org/licenses/MIT) diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java -index 0b78564256ebc647ebac402e549d86ab6e307c8d..dac3a43ccbfffe19f6429cc8df5479fc3c233793 100644 +index 041ebeb28378c2f81ccbc586fea9583e059cfbd7..3d986e21674591f9a04b36231086085232c4d198 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java -@@ -2281,6 +2281,15 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi +@@ -2315,6 +2315,15 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi { throw new UnsupportedOperationException("Not supported yet."); } diff --git a/patches/api/0004-Make-timings-calls-final.patch b/gale-api/paper-patches/features/0003-Make-timings-calls-final.patch similarity index 97% rename from patches/api/0004-Make-timings-calls-final.patch rename to gale-api/paper-patches/features/0003-Make-timings-calls-final.patch index a3dfd47..4b74cb6 100644 --- a/patches/api/0004-Make-timings-calls-final.patch +++ b/gale-api/paper-patches/features/0003-Make-timings-calls-final.patch @@ -7,7 +7,7 @@ License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) Gale - https://galemc.org diff --git a/src/main/java/co/aikar/timings/FullServerTickHandler.java b/src/main/java/co/aikar/timings/FullServerTickHandler.java -index 3e747abde6fefae90f1c15cb00158bc5303cbe50..fd9c06853a503aa787c4d93801714024465a7ee2 100644 +index 73b125979e2f2dfd13cbf689a90b29cc68a36e09..d8dfaf5041ccf3f360e0bd94bf03580a8b3d9a38 100644 --- a/src/main/java/co/aikar/timings/FullServerTickHandler.java +++ b/src/main/java/co/aikar/timings/FullServerTickHandler.java @@ -22,8 +22,7 @@ public class FullServerTickHandler extends TimingHandler { diff --git a/patches/api/0005-SIMD-support.patch b/gale-api/paper-patches/features/0004-SIMD-support.patch similarity index 85% rename from patches/api/0005-SIMD-support.patch rename to gale-api/paper-patches/features/0004-SIMD-support.patch index b2d7102..a3bd25d 100644 --- a/patches/api/0005-SIMD-support.patch +++ b/gale-api/paper-patches/features/0004-SIMD-support.patch @@ -12,26 +12,6 @@ By: Kevin Raneri As part of: Pufferfish (https://github.com/pufferfish-gg/Pufferfish) Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) -diff --git a/build.gradle.kts b/build.gradle.kts -index f7ec84606d8e6c3c3af5ba5fe85fea4c35952c2e..3c50294a0a68fd8e9fd4028d41495ad3b9781b1e 100644 ---- a/build.gradle.kts -+++ b/build.gradle.kts -@@ -154,6 +154,7 @@ tasks.withType { - compilerArgs.add("-Xlint:-module") - compilerArgs.add("-Xlint:-removal") - compilerArgs.add("-Xlint:-dep-ann") -+ compilerArgs.add("--add-modules=jdk.incubator.vector") // Gale - Pufferfish - SIMD support - } - // Gale end - hide irrelevant compilation warnings - -@@ -224,6 +225,7 @@ tasks.withType { - } - - options.addStringOption("Xdoclint:none", "-quiet") // Gale - hide irrelevant compilation warnings -+ options.addStringOption("-add-modules", "jdk.incubator.vector") // Gale - Pufferfish - SIMD support - } - - tasks.test { diff --git a/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java new file mode 100644 index 0000000000000000000000000000000000000000..90d87374e9dddd79aeca3e05f9cd6c82eb3aad27 diff --git a/patches/api/0006-Vectorized-map-color-conversion.patch b/gale-api/paper-patches/features/0005-Vectorized-map-color-conversion.patch similarity index 98% rename from patches/api/0006-Vectorized-map-color-conversion.patch rename to gale-api/paper-patches/features/0005-Vectorized-map-color-conversion.patch index 335d788..2db68dc 100644 --- a/patches/api/0006-Vectorized-map-color-conversion.patch +++ b/gale-api/paper-patches/features/0005-Vectorized-map-color-conversion.patch @@ -110,7 +110,7 @@ index 0000000000000000000000000000000000000000..00b16e4aacba50996b81fac81c3f78b6 + +} diff --git a/src/main/java/org/bukkit/map/MapPalette.java b/src/main/java/org/bukkit/map/MapPalette.java -index 55a46db9d73885ea967ac929013906b687e476bb..a4cd1c4dc937c9905e91739e6760bf0bc772cabe 100644 +index 6995f9cc08d162e3adcd3a28f6bfa6d329661999..844ad65edd5ac9eb7ccce08905972ad0ba18ea69 100644 --- a/src/main/java/org/bukkit/map/MapPalette.java +++ b/src/main/java/org/bukkit/map/MapPalette.java @@ -45,7 +45,7 @@ public final class MapPalette { diff --git a/patches/api/0007-Do-not-log-plugin-library-loads.patch b/gale-api/paper-patches/features/0006-Do-not-log-plugin-library-loads.patch similarity index 97% rename from patches/api/0007-Do-not-log-plugin-library-loads.patch rename to gale-api/paper-patches/features/0006-Do-not-log-plugin-library-loads.patch index 391a1bf..d94b15c 100644 --- a/patches/api/0007-Do-not-log-plugin-library-loads.patch +++ b/gale-api/paper-patches/features/0006-Do-not-log-plugin-library-loads.patch @@ -37,7 +37,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java -index eaefbb00e9993d54906cc8cf35cf753c0d6c7707..92d20e70d26318fbaed8adffd21c6b77336eb9c5 100644 +index b412aaf08901d169ac9fc89b36f9d6ccb95c53d3..8acf45815b5841e3b2082a8bc5b7974e85cdd7f9 100644 --- a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java +++ b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java @@ -56,6 +56,13 @@ public final class JavaPluginLoader implements PluginLoader { diff --git a/patches/api/0008-Player-canSee-by-entity-UUID.patch b/gale-api/paper-patches/features/0007-Player-canSee-by-entity-UUID.patch similarity index 94% rename from patches/api/0008-Player-canSee-by-entity-UUID.patch rename to gale-api/paper-patches/features/0007-Player-canSee-by-entity-UUID.patch index 643cc96..5445a75 100644 --- a/patches/api/0008-Player-canSee-by-entity-UUID.patch +++ b/gale-api/paper-patches/features/0007-Player-canSee-by-entity-UUID.patch @@ -37,10 +37,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java -index 95f0b3186e313c7fbd5c8531d52b82a69e525f94..b9ccc3dda46ab0e759faff9a299798dd75a310eb 100644 +index 7d21ee64c9b9c14412a1eddb63fae812a91e7d9c..1ee59ed42de64ae1a0a580b3f640cdcb5f51c71b 100644 --- a/src/main/java/org/bukkit/entity/Player.java +++ b/src/main/java/org/bukkit/entity/Player.java -@@ -2153,6 +2153,16 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM +@@ -2154,6 +2154,16 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM boolean listPlayer(@NotNull Player other); // Paper end diff --git a/patches/api/0009-Specific-interval-TPS-API.patch b/gale-api/paper-patches/features/0008-Specific-interval-TPS-API.patch similarity index 87% rename from patches/api/0009-Specific-interval-TPS-API.patch rename to gale-api/paper-patches/features/0008-Specific-interval-TPS-API.patch index 5ab2925..94e379d 100644 --- a/patches/api/0009-Specific-interval-TPS-API.patch +++ b/gale-api/paper-patches/features/0008-Specific-interval-TPS-API.patch @@ -7,10 +7,10 @@ License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) Gale - https://galemc.org diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java -index 391a1e3e07657a404520c1462507a2c731f32b27..f56c771c92194587b586f3ada344fe540cd231eb 100644 +index 9eecd3a68a36d06c66d5f2cdc98c048fe8737337..a500bb9bc428c5fcefff3950503645a91e5d0161 100644 --- a/src/main/java/org/bukkit/Bukkit.java +++ b/src/main/java/org/bukkit/Bukkit.java -@@ -2409,6 +2409,37 @@ public final class Bukkit { +@@ -2407,6 +2407,37 @@ public final class Bukkit { return server.getTPS(); } @@ -49,12 +49,12 @@ index 391a1e3e07657a404520c1462507a2c731f32b27..f56c771c92194587b586f3ada344fe54 * Get a sample of the servers last tick times (in nanos) * diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java -index dac3a43ccbfffe19f6429cc8df5479fc3c233793..38fbc6e4ff6f0b08813a6a37dfcca24ec58c543f 100644 +index 3d986e21674591f9a04b36231086085232c4d198..e5c767dbcf8f987b4ab3abf631c66830ca2f9858 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java -@@ -2060,6 +2060,31 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi - @NotNull - public double[] getTPS(); +@@ -2095,6 +2095,31 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi + */ + public double @NotNull [] getTPS(); + // Gale start - specific interval TPS API + diff --git a/patches/api/0010-5-second-TPS-average.patch b/gale-api/paper-patches/features/0009-5-second-TPS-average.patch similarity index 90% rename from patches/api/0010-5-second-TPS-average.patch rename to gale-api/paper-patches/features/0009-5-second-TPS-average.patch index 0c20201..95ef8cc 100644 --- a/patches/api/0010-5-second-TPS-average.patch +++ b/gale-api/paper-patches/features/0009-5-second-TPS-average.patch @@ -37,10 +37,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java -index f56c771c92194587b586f3ada344fe540cd231eb..0dd0d3e2faf82432b621bad95d5d31f7d581ef2b 100644 +index a500bb9bc428c5fcefff3950503645a91e5d0161..7d125129860799c523a36ca039d6b34ed4103ffb 100644 --- a/src/main/java/org/bukkit/Bukkit.java +++ b/src/main/java/org/bukkit/Bukkit.java -@@ -2409,8 +2409,30 @@ public final class Bukkit { +@@ -2407,8 +2407,30 @@ public final class Bukkit { return server.getTPS(); } @@ -72,12 +72,12 @@ index f56c771c92194587b586f3ada344fe540cd231eb..0dd0d3e2faf82432b621bad95d5d31f7 * Gets the average server TPS over the last 1 minute * diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java -index 38fbc6e4ff6f0b08813a6a37dfcca24ec58c543f..e8346ff64783c505456cc7cd2ed91bc2b063e365 100644 +index e5c767dbcf8f987b4ab3abf631c66830ca2f9858..cbc50c83c1ad3b271fbeba8cb921eb95cae61e16 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java -@@ -2060,8 +2060,27 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi - @NotNull - public double[] getTPS(); +@@ -2095,8 +2095,27 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi + */ + public double @NotNull [] getTPS(); + // Gale start - Purpur - 5 second TPS average + /** diff --git a/patches/api/0011-Last-tick-time-API.patch b/gale-api/paper-patches/features/0010-Last-tick-time-API.patch similarity index 91% rename from patches/api/0011-Last-tick-time-API.patch rename to gale-api/paper-patches/features/0010-Last-tick-time-API.patch index 78fdca0..ad7917e 100644 --- a/patches/api/0011-Last-tick-time-API.patch +++ b/gale-api/paper-patches/features/0010-Last-tick-time-API.patch @@ -23,10 +23,10 @@ The above copyright notice and this permission notice shall be included in all c THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java -index a1d517e2415a1d4710da39ef5994fe2fbd411db4..68971f1503913175e941ec24db54ab12f023737d 100644 +index 7d125129860799c523a36ca039d6b34ed4103ffb..64fc2553da938f6df56c3e99ca2707d65dc75eda 100644 --- a/src/main/java/org/bukkit/Bukkit.java +++ b/src/main/java/org/bukkit/Bukkit.java -@@ -3017,6 +3017,20 @@ public final class Bukkit { +@@ -3014,6 +3014,20 @@ public final class Bukkit { } // Paper end - Folia region threading API @@ -48,10 +48,10 @@ index a1d517e2415a1d4710da39ef5994fe2fbd411db4..68971f1503913175e941ec24db54ab12 public static Server.Spigot spigot() { return server.spigot(); diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java -index edcd3ce45053568cb90ca7f69ffc23cb1a782d4e..dc02eb4016e3452ccf7b18a52309f921aac6278a 100644 +index cbc50c83c1ad3b271fbeba8cb921eb95cae61e16..afc439982d086090576a9c321eb36c021421c4e3 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java -@@ -2660,4 +2660,29 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi +@@ -2694,4 +2694,29 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi */ void allowPausing(@NotNull org.bukkit.plugin.Plugin plugin, boolean value); // Paper end - API to check if the server is sleeping diff --git a/patches/server/0002-Dev-import-deobfuscation-fixes.patch b/gale-archived-patches/removed/hardfork/server/0002-Dev-import-deobfuscation-fixes.patch similarity index 99% rename from patches/server/0002-Dev-import-deobfuscation-fixes.patch rename to gale-archived-patches/removed/hardfork/server/0002-Dev-import-deobfuscation-fixes.patch index cee225f..d4054b0 100644 --- a/patches/server/0002-Dev-import-deobfuscation-fixes.patch +++ b/gale-archived-patches/removed/hardfork/server/0002-Dev-import-deobfuscation-fixes.patch @@ -3,6 +3,8 @@ From: Martijn Muijsers Date: Tue, 29 Nov 2022 15:16:54 +0100 Subject: [PATCH] Dev import deobfuscation fixes +Removed since Paper 1.21.4, hardfork + License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) Gale - https://galemc.org diff --git a/patches/server/0021-Remove-iterators-from-Inventory-contains.patch b/gale-archived-patches/removed/hardfork/server/0021-Remove-iterators-from-Inventory-contains.patch similarity index 99% rename from patches/server/0021-Remove-iterators-from-Inventory-contains.patch rename to gale-archived-patches/removed/hardfork/server/0021-Remove-iterators-from-Inventory-contains.patch index db25b5d..877228c 100644 --- a/patches/server/0021-Remove-iterators-from-Inventory-contains.patch +++ b/gale-archived-patches/removed/hardfork/server/0021-Remove-iterators-from-Inventory-contains.patch @@ -3,6 +3,8 @@ From: Martijn Muijsers Date: Wed, 23 Nov 2022 20:18:05 +0100 Subject: [PATCH] Remove iterators from Inventory#contains +Removed since 1.21.4 + License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) Gale - https://galemc.org diff --git a/patches/server/0056-Fix-cow-rotation-when-shearing-mooshroom.patch b/gale-archived-patches/removed/hardfork/server/0056-Fix-cow-rotation-when-shearing-mooshroom.patch similarity index 98% rename from patches/server/0056-Fix-cow-rotation-when-shearing-mooshroom.patch rename to gale-archived-patches/removed/hardfork/server/0056-Fix-cow-rotation-when-shearing-mooshroom.patch index fa25bf7..6927637 100644 --- a/patches/server/0056-Fix-cow-rotation-when-shearing-mooshroom.patch +++ b/gale-archived-patches/removed/hardfork/server/0056-Fix-cow-rotation-when-shearing-mooshroom.patch @@ -3,6 +3,8 @@ From: Martijn Muijsers Date: Tue, 29 Nov 2022 15:55:05 +0100 Subject: [PATCH] Fix cow rotation when shearing mooshroom +Removed since Gale 1.21.4, fixed in Minecraft 1.21.2 24w36a + License: MIT (https://opensource.org/licenses/MIT) Gale - https://galemc.org diff --git a/patches/server/0058-Fix-MC-110386.patch b/gale-archived-patches/removed/hardfork/server/0058-Fix-MC-110386.patch similarity index 97% rename from patches/server/0058-Fix-MC-110386.patch rename to gale-archived-patches/removed/hardfork/server/0058-Fix-MC-110386.patch index b4eb70d..99182c1 100644 --- a/patches/server/0058-Fix-MC-110386.patch +++ b/gale-archived-patches/removed/hardfork/server/0058-Fix-MC-110386.patch @@ -3,6 +3,8 @@ From: Martijn Muijsers Date: Fri, 23 Dec 2022 15:30:58 +0100 Subject: [PATCH] Fix MC-110386 +Removed since Gale 1.21.4, fixed in Minecraft 1.21.2 24w33a + License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) Gale - https://galemc.org diff --git a/patches/removed/server/0011-Include-time-in-startup-logs.patch b/gale-archived-patches/removed/legacy/server/0011-Include-time-in-startup-logs.patch similarity index 100% rename from patches/removed/server/0011-Include-time-in-startup-logs.patch rename to gale-archived-patches/removed/legacy/server/0011-Include-time-in-startup-logs.patch diff --git a/patches/removed/server/0012-Include-server.properties-in-timings.patch b/gale-archived-patches/removed/legacy/server/0012-Include-server.properties-in-timings.patch similarity index 100% rename from patches/removed/server/0012-Include-server.properties-in-timings.patch rename to gale-archived-patches/removed/legacy/server/0012-Include-server.properties-in-timings.patch diff --git a/patches/removed/server/0013-Include-hardware-specs-in-timings.patch b/gale-archived-patches/removed/legacy/server/0013-Include-hardware-specs-in-timings.patch similarity index 100% rename from patches/removed/server/0013-Include-hardware-specs-in-timings.patch rename to gale-archived-patches/removed/legacy/server/0013-Include-hardware-specs-in-timings.patch diff --git a/patches/removed/server/0014-Use-timin.gs-by-default.patch b/gale-archived-patches/removed/legacy/server/0014-Use-timin.gs-by-default.patch similarity index 100% rename from patches/removed/server/0014-Use-timin.gs-by-default.patch rename to gale-archived-patches/removed/legacy/server/0014-Use-timin.gs-by-default.patch diff --git a/patches/removed/server/0015-Recommend-disabling-timings-on-startup.patch b/gale-archived-patches/removed/legacy/server/0015-Recommend-disabling-timings-on-startup.patch similarity index 100% rename from patches/removed/server/0015-Recommend-disabling-timings-on-startup.patch rename to gale-archived-patches/removed/legacy/server/0015-Recommend-disabling-timings-on-startup.patch diff --git a/patches/removed/server/0016-Make-timings-calls-final.patch b/gale-archived-patches/removed/legacy/server/0016-Make-timings-calls-final.patch similarity index 100% rename from patches/removed/server/0016-Make-timings-calls-final.patch rename to gale-archived-patches/removed/legacy/server/0016-Make-timings-calls-final.patch diff --git a/patches/removed/server/0023-Improve-fluid-direction-caching.patch b/gale-archived-patches/removed/legacy/server/0023-Improve-fluid-direction-caching.patch similarity index 100% rename from patches/removed/server/0023-Improve-fluid-direction-caching.patch rename to gale-archived-patches/removed/legacy/server/0023-Improve-fluid-direction-caching.patch diff --git a/patches/removed/server/0026-Improve-container-checking-with-a-bitset.patch b/gale-archived-patches/removed/legacy/server/0026-Improve-container-checking-with-a-bitset.patch similarity index 100% rename from patches/removed/server/0026-Improve-container-checking-with-a-bitset.patch rename to gale-archived-patches/removed/legacy/server/0026-Improve-container-checking-with-a-bitset.patch diff --git a/patches/removed/server/0027-Inline-level-height.patch b/gale-archived-patches/removed/legacy/server/0027-Inline-level-height.patch similarity index 100% rename from patches/removed/server/0027-Inline-level-height.patch rename to gale-archived-patches/removed/legacy/server/0027-Inline-level-height.patch diff --git a/patches/removed/server/0028-Remove-streams-and-iterators-from-range-check.patch b/gale-archived-patches/removed/legacy/server/0028-Remove-streams-and-iterators-from-range-check.patch similarity index 100% rename from patches/removed/server/0028-Remove-streams-and-iterators-from-range-check.patch rename to gale-archived-patches/removed/legacy/server/0028-Remove-streams-and-iterators-from-range-check.patch diff --git a/patches/removed/server/0035-Use-ThreadUnsafeRandom-for-mob-spawning.patch b/gale-archived-patches/removed/legacy/server/0035-Use-ThreadUnsafeRandom-for-mob-spawning.patch similarity index 100% rename from patches/removed/server/0035-Use-ThreadUnsafeRandom-for-mob-spawning.patch rename to gale-archived-patches/removed/legacy/server/0035-Use-ThreadUnsafeRandom-for-mob-spawning.patch diff --git a/patches/removed/server/0059-Fix-MC-31819.patch b/gale-archived-patches/removed/legacy/server/0059-Fix-MC-31819.patch similarity index 100% rename from patches/removed/server/0059-Fix-MC-31819.patch rename to gale-archived-patches/removed/legacy/server/0059-Fix-MC-31819.patch diff --git a/patches/removed/server/0060-Fix-MC-26304.patch b/gale-archived-patches/removed/legacy/server/0060-Fix-MC-26304.patch similarity index 100% rename from patches/removed/server/0060-Fix-MC-26304.patch rename to gale-archived-patches/removed/legacy/server/0060-Fix-MC-26304.patch diff --git a/patches/removed/server/0075-Avoid-Class-isAssignableFrom-call-in-ClassInstanceMu.patch b/gale-archived-patches/removed/legacy/server/0075-Avoid-Class-isAssignableFrom-call-in-ClassInstanceMu.patch similarity index 100% rename from patches/removed/server/0075-Avoid-Class-isAssignableFrom-call-in-ClassInstanceMu.patch rename to gale-archived-patches/removed/legacy/server/0075-Avoid-Class-isAssignableFrom-call-in-ClassInstanceMu.patch diff --git a/patches/removed/server/0075-End-gateway-should-check-if-entity-can-use-portal.patch b/gale-archived-patches/removed/legacy/server/0075-End-gateway-should-check-if-entity-can-use-portal.patch similarity index 100% rename from patches/removed/server/0075-End-gateway-should-check-if-entity-can-use-portal.patch rename to gale-archived-patches/removed/legacy/server/0075-End-gateway-should-check-if-entity-can-use-portal.patch diff --git a/patches/removed/server/0079-Optimize-villager-data-storage.patch b/gale-archived-patches/removed/legacy/server/0079-Optimize-villager-data-storage.patch similarity index 100% rename from patches/removed/server/0079-Optimize-villager-data-storage.patch rename to gale-archived-patches/removed/legacy/server/0079-Optimize-villager-data-storage.patch diff --git a/patches/removed/server/0080-Replace-shape-full-block-cache-with-hashtable.patch b/gale-archived-patches/removed/legacy/server/0080-Replace-shape-full-block-cache-with-hashtable.patch similarity index 100% rename from patches/removed/server/0080-Replace-shape-full-block-cache-with-hashtable.patch rename to gale-archived-patches/removed/legacy/server/0080-Replace-shape-full-block-cache-with-hashtable.patch diff --git a/patches/removed/server/0081-Replace-AI-goal-set-with-optimized-collection.patch b/gale-archived-patches/removed/legacy/server/0081-Replace-AI-goal-set-with-optimized-collection.patch similarity index 100% rename from patches/removed/server/0081-Replace-AI-goal-set-with-optimized-collection.patch rename to gale-archived-patches/removed/legacy/server/0081-Replace-AI-goal-set-with-optimized-collection.patch diff --git a/patches/removed/server/0092-Optimize-world-generation-chunk-and-block-access.patch b/gale-archived-patches/removed/legacy/server/0092-Optimize-world-generation-chunk-and-block-access.patch similarity index 100% rename from patches/removed/server/0092-Optimize-world-generation-chunk-and-block-access.patch rename to gale-archived-patches/removed/legacy/server/0092-Optimize-world-generation-chunk-and-block-access.patch diff --git a/patches/removed/server/0093-Load-portal-destination-chunk-before-entity-teleport.patch b/gale-archived-patches/removed/legacy/server/0093-Load-portal-destination-chunk-before-entity-teleport.patch similarity index 100% rename from patches/removed/server/0093-Load-portal-destination-chunk-before-entity-teleport.patch rename to gale-archived-patches/removed/legacy/server/0093-Load-portal-destination-chunk-before-entity-teleport.patch diff --git a/patches/removed/server/0108-Make-max-interaction-distance-configurable.patch b/gale-archived-patches/removed/legacy/server/0108-Make-max-interaction-distance-configurable.patch similarity index 100% rename from patches/removed/server/0108-Make-max-interaction-distance-configurable.patch rename to gale-archived-patches/removed/legacy/server/0108-Make-max-interaction-distance-configurable.patch diff --git a/patches/removed/server/0136-Instantly-continue-on-world-upgrade-finish.patch b/gale-archived-patches/removed/legacy/server/0136-Instantly-continue-on-world-upgrade-finish.patch similarity index 100% rename from patches/removed/server/0136-Instantly-continue-on-world-upgrade-finish.patch rename to gale-archived-patches/removed/legacy/server/0136-Instantly-continue-on-world-upgrade-finish.patch diff --git a/gale-archived-patches/ver/README.md b/gale-archived-patches/ver/README.md new file mode 100644 index 0000000..0e30879 --- /dev/null +++ b/gale-archived-patches/ver/README.md @@ -0,0 +1 @@ +# Note diff --git a/patches/work/server/0032-Reduce-entity-fluid-lookups-if-no-fluids.patch b/gale-archived-patches/work/server/0032-Reduce-entity-fluid-lookups-if-no-fluids.patch similarity index 100% rename from patches/work/server/0032-Reduce-entity-fluid-lookups-if-no-fluids.patch rename to gale-archived-patches/work/server/0032-Reduce-entity-fluid-lookups-if-no-fluids.patch diff --git a/patches/work/server/0033-Use-aging-cache-for-biome-temperatures.patch b/gale-archived-patches/work/server/0033-Use-aging-cache-for-biome-temperatures.patch similarity index 100% rename from patches/work/server/0033-Use-aging-cache-for-biome-temperatures.patch rename to gale-archived-patches/work/server/0033-Use-aging-cache-for-biome-temperatures.patch diff --git a/patches/work/server/0046-Don-t-trigger-lootable-refresh-for-non-player-intera.patch b/gale-archived-patches/work/server/0046-Don-t-trigger-lootable-refresh-for-non-player-intera.patch similarity index 100% rename from patches/work/server/0046-Don-t-trigger-lootable-refresh-for-non-player-intera.patch rename to gale-archived-patches/work/server/0046-Don-t-trigger-lootable-refresh-for-non-player-intera.patch diff --git a/patches/work/server/0079-Cache-CubeVoxelShape-shape-array.patch b/gale-archived-patches/work/server/0079-Cache-CubeVoxelShape-shape-array.patch similarity index 100% rename from patches/work/server/0079-Cache-CubeVoxelShape-shape-array.patch rename to gale-archived-patches/work/server/0079-Cache-CubeVoxelShape-shape-array.patch diff --git a/patches/work/server/0079-Cache-ominous-banner-item.patch b/gale-archived-patches/work/server/0079-Cache-ominous-banner-item.patch similarity index 100% rename from patches/work/server/0079-Cache-ominous-banner-item.patch rename to gale-archived-patches/work/server/0079-Cache-ominous-banner-item.patch diff --git a/gale-server/build.gradle.kts.patch b/gale-server/build.gradle.kts.patch new file mode 100644 index 0000000..2eaed16 --- /dev/null +++ b/gale-server/build.gradle.kts.patch @@ -0,0 +1,127 @@ +--- a/paper-server/build.gradle.kts ++++ b/paper-server/build.gradle.kts +@@ -21,8 +_,21 @@ + // macheOldPath = file("F:\\Projects\\PaperTooling\\mache\\versions\\1.21.4\\src\\main\\java") + // gitFilePatches = true + ++ // Gale start - project setup ++ val gale = forks.register("gale") { ++ upstream.patchDir("paperServer") { ++ upstreamPath = "paper-server" ++ excludes = setOf("src/minecraft", "patches", "build.gradle.kts") ++ patchesDir = rootDirectory.dir("gale-server/paper-patches") ++ outputDir = rootDirectory.dir("paper-server") ++ } ++ } ++ ++ activeFork = gale ++ // Gale end - project setup ++ + paper { +- reobfMappingsPatch = layout.projectDirectory.file("../build-data/reobf-mappings-patch.tiny") ++ paperServerDir = upstreamsDirectory().map { it.dir("paper/paper-server") } // Gale - project setup + } + + spigot { +@@ -105,7 +_,22 @@ + } + } + +-val log4jPlugins = sourceSets.create("log4jPlugins") ++// Gale start - project setup ++sourceSets { ++ main { ++ java { srcDir("../paper-server/src/main/java") } ++ resources { srcDir("../paper-server/src/main/resources") } ++ } ++ test { ++ java { srcDir("../paper-server/src/test/java") } ++ resources { srcDir("../paper-server/src/test/resources") } ++ } ++} ++ ++val log4jPlugins = sourceSets.create("log4jPlugins") { ++ java { srcDir("../paper-server/src/log4jPlugins/java") } ++} ++// Gale end - project setup + configurations.named(log4jPlugins.compileClasspathConfigurationName) { + extendsFrom(configurations.compileClasspath.get()) + } +@@ -123,7 +_,7 @@ + } + + dependencies { +- implementation(project(":paper-api")) ++ implementation(project(":gale-api")) // Gale - project setup - Depend on own API + implementation("ca.spottedleaf:concurrentutil:0.0.2") + implementation("org.jline:jline-terminal-ffm:3.27.1") // use ffm on java 22+ + implementation("org.jline:jline-terminal-jni:3.27.1") // fall back to jni on java 21 +@@ -180,6 +_,16 @@ + implementation("me.lucko:spark-paper:1.10.119-SNAPSHOT") + } + ++// Gale start - hide irrelevant compilation warnings ++tasks.withType { ++ val compilerArgs = options.compilerArgs ++ compilerArgs.add("-Xlint:-module") ++ compilerArgs.add("-Xlint:-removal") ++ compilerArgs.add("-Xlint:-dep-ann") ++ compilerArgs.add("--add-modules=jdk.incubator.vector") // Gale - Pufferfish - SIMD support ++} ++// Gale end - hide irrelevant compilation warnings ++ + tasks.jar { + manifest { + val git = Git(rootProject.layout.projectDirectory.path) +@@ -192,14 +_,14 @@ + val gitBranch = git.exec(providers, "rev-parse", "--abbrev-ref", "HEAD").get().trim() + attributes( + "Main-Class" to "org.bukkit.craftbukkit.Main", +- "Implementation-Title" to "Paper", ++ "Implementation-Title" to "Gale", // Gale - branding changes + "Implementation-Version" to implementationVersion, + "Implementation-Vendor" to date, +- "Specification-Title" to "Paper", ++ "Specification-Title" to "Gale", // Gale - branding changes + "Specification-Version" to project.version, +- "Specification-Vendor" to "Paper Team", +- "Brand-Id" to "papermc:paper", +- "Brand-Name" to "Paper", ++ "Specification-Vendor" to "GaleMC Team", // Gale - branding changes ++ "Brand-Id" to "galemc:gale", // Gale - branding changes ++ "Brand-Name" to "Gale", // Gale - branding changes + "Build-Number" to (build ?: ""), + "Build-Time" to buildTime.toString(), + "Git-Branch" to gitBranch, +@@ -285,6 +_,8 @@ + val memoryGb = providers.gradleProperty("paper.runMemoryGb").getOrElse("2") + minHeapSize = "${memoryGb}G" + maxHeapSize = "${memoryGb}G" ++ jvmArgs("--enable-preview") // Gale - enable preview features for development runs ++ jvmArgs("--add-modules=jdk.incubator.vector") // Gale - Pufferfish - SIMD support + + doFirst { + workingDir.mkdirs() +@@ -330,3 +_,22 @@ + classpath(tasks.createReobfPaperclipJar.flatMap { it.outputZip }) + mainClass.set(null as String?) + } ++ ++// Gale start - package license into jar ++tasks.register("copyLicense") { ++ from(layout.projectDirectory.file("LICENSE.txt")) ++ into(layout.buildDirectory.dir("tmp/copiedlicense")) ++} ++ ++tasks.processResources { ++ dependsOn("copyLicense") ++} ++ ++sourceSets { ++ main { ++ resources { ++ srcDir(layout.buildDirectory.dir("tmp/copiedlicense")) ++ } ++ } ++} ++// Gale end - package license into jar diff --git a/gale-server/minecraft-patches/features/0001-Gale-branding-changes.patch b/gale-server/minecraft-patches/features/0001-Gale-branding-changes.patch new file mode 100644 index 0000000..9c85d22 --- /dev/null +++ b/gale-server/minecraft-patches/features/0001-Gale-branding-changes.patch @@ -0,0 +1,44 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Mon, 26 Dec 2022 13:47:08 +0100 +Subject: [PATCH] Gale branding changes +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +No license is given for images. Images are copyright (©) Martijn Muijsers, all rights reserved. +License for non-image files: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) +Gale - https://galemc.org + +diff --git a/net/minecraft/world/damagesource/DamageSource.java b/net/minecraft/world/damagesource/DamageSource.java +index 48c9b26e023ad236b0bcb6441e8aee8f107ae381..aea139e47a0866c63c0fc6728840e5ad92a26403 100644 +--- a/net/minecraft/world/damagesource/DamageSource.java ++++ b/net/minecraft/world/damagesource/DamageSource.java +@@ -66,7 +66,7 @@ public class DamageSource { + + public DamageSource customEventDamager(Entity entity) { + if (this.directEntity != null) { +- throw new IllegalStateException("Cannot set custom event damager when direct entity is already set (report a bug to Paper)"); ++ throw new IllegalStateException("Cannot set custom event damager when direct entity is already set (report a bug to Paper, if you think this is a Gale bug, please report it at https://github.com/GaleMC/Gale/issues)"); // Gale - branding changes + } + DamageSource damageSource = this.cloneInstance(); + damageSource.customEventDamager = entity; +diff --git a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java +index dad7f94b611cf0fc68b1a3878c458233f6bb6d61..3abb8aefcca325e28f0af07bd859be74f0aee08d 100644 +--- a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java ++++ b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java +@@ -283,7 +283,13 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise + + // Paper start + private static void printOversizedLog(String msg, Path file, int x, int z) { +- org.apache.logging.log4j.LogManager.getLogger().fatal(msg + " (" + file.toString().replaceAll(".+[\\\\/]", "") + " - " + x + "," + z + ") Go clean it up to remove this message. /minecraft:tp " + (x<<4)+" 128 "+(z<<4) + " - DO NOT REPORT THIS TO PAPER - You may ask for help on Discord, but do not file an issue. These error messages can not be removed."); ++ // Gale start - branding changes ++ /* ++ We do not want people to report thread issues to Paper, ++ but we do want people to report thread issues to Gale. ++ */ ++ org.apache.logging.log4j.LogManager.getLogger().fatal(msg + " (" + file.toString().replaceAll(".+[\\\\/]", "") + " - " + x + "," + z + ") Go clean it up to remove this message. /minecraft:tp " + (x<<4)+" 128 "+(z<<4) + " - DO NOT REPORT THIS TO PAPER OR GALE - You may ask for help on Discord, but do not file an issue. These error messages can not be removed. - If you think this is a Gale bug, please report it at https://github.com/GaleMC/Gale/issues)"); ++ // Gale end - branding changes + } + + private static CompoundTag readOversizedChunk(RegionFile regionfile, ChunkPos chunkCoordinate) throws IOException { diff --git a/gale-server/minecraft-patches/features/0002-Gale-configuration.patch b/gale-server/minecraft-patches/features/0002-Gale-configuration.patch new file mode 100644 index 0000000..57b0b07 --- /dev/null +++ b/gale-server/minecraft-patches/features/0002-Gale-configuration.patch @@ -0,0 +1,141 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Wed, 23 Nov 2022 21:05:47 +0100 +Subject: [PATCH] Gale configuration + +License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) +Gale - https://galemc.org + +This patch is based on the following patch: +"Paper config files" +By: Jake Potrebic +As part of: Paper (https://github.com/PaperMC/Paper) +Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) + +diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java +index 107aa863bd4448628b013d0ccd49b6a956aeffef..d7916d4d4cec9ac376c8b7b4c3432fddd55a1940 100644 +--- a/net/minecraft/server/MinecraftServer.java ++++ b/net/minecraft/server/MinecraftServer.java +@@ -300,6 +300,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop pluginsBlockingSleep = new java.util.HashSet<>(); // Paper - API to allow/disallow tick sleeping + public static final long SERVER_INIT = System.nanoTime(); // Paper - Lag compensation +@@ -471,6 +472,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop public + + // Paper start - add paper configuration files + public Services(MinecraftSessionService sessionService, ServicesKeySet servicesKeySet, GameProfileRepository profileRepository, GameProfileCache profileCache) { +- this(sessionService, servicesKeySet, profileRepository, profileCache, null); ++ this(sessionService, servicesKeySet, profileRepository, profileCache, null, null); // Gale - Gale configuration + } + + @Override +@@ -25,6 +25,12 @@ public record Services( + return java.util.Objects.requireNonNull(this.paperConfigurations); + } + // Paper end - add paper configuration files ++ // Gale start - Gale configuration ++ @Override ++ public org.galemc.gale.configuration.GaleConfigurations galeConfigurations() { ++ return java.util.Objects.requireNonNull(this.galeConfigurations); ++ } ++ // Gale end - Gale configuration + + public static Services create(YggdrasilAuthenticationService authenticationService, File profileRepository, File userCacheFile, joptsimple.OptionSet optionSet) throws Exception { // Paper - add optionset to load paper config files; add userCacheFile parameter + MinecraftSessionService minecraftSessionService = authenticationService.createMinecraftSessionService(); +@@ -34,7 +40,10 @@ public record Services( + final java.nio.file.Path legacyConfigPath = ((File) optionSet.valueOf("paper-settings")).toPath(); + final java.nio.file.Path configDirPath = ((File) optionSet.valueOf("paper-settings-directory")).toPath(); + io.papermc.paper.configuration.PaperConfigurations paperConfigurations = io.papermc.paper.configuration.PaperConfigurations.setup(legacyConfigPath, configDirPath, profileRepository.toPath(), (File) optionSet.valueOf("spigot-settings")); +- return new Services(minecraftSessionService, authenticationService.getServicesKeySet(), gameProfileRepository, gameProfileCache, paperConfigurations); ++ // Gale start - Gale configuration ++ org.galemc.gale.configuration.GaleConfigurations galeConfigurations = org.galemc.gale.configuration.GaleConfigurations.setup(configDirPath); ++ return new Services(minecraftSessionService, authenticationService.getServicesKeySet(), gameProfileRepository, gameProfileCache, paperConfigurations, galeConfigurations); ++ // Gale end - Gale configuration + // Paper end - load paper config files from cli options + } + +diff --git a/net/minecraft/server/dedicated/DedicatedServer.java b/net/minecraft/server/dedicated/DedicatedServer.java +index 97a294d2f5c1ddf0af7ffec3e1425eb329c5751b..0655b169a1cb418aacc5761680d84a8bd9aed3c9 100644 +--- a/net/minecraft/server/dedicated/DedicatedServer.java ++++ b/net/minecraft/server/dedicated/DedicatedServer.java +@@ -212,6 +212,10 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface + this.paperConfigurations.initializeGlobalConfiguration(this.registryAccess()); + this.paperConfigurations.initializeWorldDefaultsConfiguration(this.registryAccess()); + // Paper end - initialize global and world-defaults configuration ++ // Gale start - Gale configuration ++ galeConfigurations.initializeGlobalConfiguration(this.registryAccess()); ++ galeConfigurations.initializeWorldDefaultsConfiguration(this.registryAccess()); ++ // Gale end - Gale configuration + this.server.spark.enableEarlyIfRequested(); // Paper - spark + // Paper start - fix converting txt to json file; convert old users earlier after PlayerList creation but before file load/save + if (this.convertOldUsers()) { +diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java +index ebeeb63c3dca505a3ce8b88feaa5d2ca20ec24a2..13db4411e5bd635315b27b92a3e97bf286d14577 100644 +--- a/net/minecraft/server/level/ServerLevel.java ++++ b/net/minecraft/server/level/ServerLevel.java +@@ -588,7 +588,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe + org.bukkit.generator.BiomeProvider biomeProvider // CraftBukkit + ) { + // CraftBukkit start +- super(serverLevelData, dimension, server.registryAccess(), levelStem.type(), false, isDebug, biomeZoomSeed, server.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> server.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(levelStorageAccess.levelDirectory.path(), serverLevelData.getLevelName(), dimension.location(), spigotConfig, server.registryAccess(), serverLevelData.getGameRules())), dispatcher); // Paper - create paper world configs; Async-Anti-Xray: Pass executor ++ super(serverLevelData, dimension, server.registryAccess(), levelStem.type(), false, isDebug, biomeZoomSeed, server.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> server.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(levelStorageAccess.levelDirectory.path(), serverLevelData.getLevelName(), dimension.location(), spigotConfig, server.registryAccess(), serverLevelData.getGameRules())), spigotConfig -> server.galeConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(levelStorageAccess.levelDirectory.path(), serverLevelData.getLevelName(), dimension.location(), spigotConfig, server.registryAccess(), serverLevelData.getGameRules())), dispatcher); // Paper - create paper world configs; Async-Anti-Xray: Pass executor // Gale - Gale configuration + this.pvpMode = server.isPvpAllowed(); + this.levelStorageAccess = levelStorageAccess; + this.uuid = org.bukkit.craftbukkit.util.WorldUUID.getUUID(levelStorageAccess.levelDirectory.path().toFile()); +diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java +index 2bbebb4335d927f240abcac67a5b423e38dc33d7..b9c930210f750aa9594d3acae584a8d11983a210 100644 +--- a/net/minecraft/world/level/Level.java ++++ b/net/minecraft/world/level/Level.java +@@ -168,6 +168,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl + return this.paperConfig; + } + // Paper end - add paper world config ++ // Gale start - Gale configuration ++ private final org.galemc.gale.configuration.GaleWorldConfiguration galeConfig; ++ public org.galemc.gale.configuration.GaleWorldConfiguration galeConfig() { ++ return this.galeConfig; ++ } ++ // Gale end - Gale configuration + + public final io.papermc.paper.antixray.ChunkPacketBlockController chunkPacketBlockController; // Paper - Anti-Xray + public static BlockPos lastPhysicsProblem; // Spigot +@@ -840,6 +846,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl + org.bukkit.World.Environment env, // CraftBukkit + java.util.function.Function paperWorldConfigCreator, // Paper - create paper world config ++ java.util.function.Function galeWorldConfigCreator, // Gale - Gale configuration + java.util.concurrent.Executor executor // Paper - Anti-Xray + ) { + // Paper start - getblock optimisations - cache world height/sections +@@ -853,6 +861,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl + // Paper end - getblock optimisations - cache world height/sections + this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) levelData).getLevelName()); // Spigot + this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper - create paper world config ++ this.galeConfig = galeWorldConfigCreator.apply(this.spigotConfig); // Gale - Gale configuration + this.generator = gen; + this.world = new CraftWorld((ServerLevel) this, gen, biomeProvider, env); + diff --git a/gale-server/minecraft-patches/features/0003-Gale-commands.patch b/gale-server/minecraft-patches/features/0003-Gale-commands.patch new file mode 100644 index 0000000..4a00871 --- /dev/null +++ b/gale-server/minecraft-patches/features/0003-Gale-commands.patch @@ -0,0 +1,26 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Sat, 26 Nov 2022 10:47:56 +0100 +Subject: [PATCH] Gale commands + +License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) +Gale - https://galemc.org + +This patch is based on the following patch: +"Paper command" +By: Zach Brown +As part of: Paper (https://github.com/PaperMC/Paper) +Licensed under: MIT (https://opensource.org/licenses/MIT) + +diff --git a/net/minecraft/server/dedicated/DedicatedServer.java b/net/minecraft/server/dedicated/DedicatedServer.java +index 0655b169a1cb418aacc5761680d84a8bd9aed3c9..f4a8c7fe830495434f06d45c1a4505e4ea536804 100644 +--- a/net/minecraft/server/dedicated/DedicatedServer.java ++++ b/net/minecraft/server/dedicated/DedicatedServer.java +@@ -226,6 +226,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface + org.spigotmc.WatchdogThread.doStart(org.spigotmc.SpigotConfig.timeoutTime, org.spigotmc.SpigotConfig.restartOnCrash); // Paper - start watchdog thread + thread.start(); // Paper - Enhance console tab completions for brigadier commands; start console thread after MinecraftServer.console & PaperConfig are initialized + io.papermc.paper.command.PaperCommands.registerCommands(this); // Paper - setup /paper command ++ org.galemc.gale.command.GaleCommands.registerCommands(this); // Gale - Gale commands - register commands + this.server.spark.registerCommandBeforePlugins(this.server); // Paper - spark + com.destroystokyo.paper.Metrics.PaperMetrics.startMetrics(); // Paper - start metrics + com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // Paper - load version history now diff --git a/gale-server/minecraft-patches/features/0004-Remove-vanilla-profiler.patch b/gale-server/minecraft-patches/features/0004-Remove-vanilla-profiler.patch new file mode 100644 index 0000000..bf720ca --- /dev/null +++ b/gale-server/minecraft-patches/features/0004-Remove-vanilla-profiler.patch @@ -0,0 +1,2292 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Thu, 22 Dec 2022 22:32:18 +0100 +Subject: [PATCH] Remove vanilla profiler + +License: MIT (https://opensource.org/licenses/MIT) +Gale - https://galemc.org + +This patch is based on the following patch: +"Remove Mojang Profiler" +By: BillyGalbreath +As part of: Purpur (https://github.com/PurpurMC/Purpur) +Licensed under: MIT (https://opensource.org/licenses/MIT) + +* Purpur copyright * + +MIT License + +Copyright (c) 2019-2022 PurpurMC + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +diff --git a/net/minecraft/commands/Commands.java b/net/minecraft/commands/Commands.java +index 19ccf3abf14c67f72a1ca065e4a304f50e645ef4..22d5c733df234e8fac286809bfb724859a600963 100644 +--- a/net/minecraft/commands/Commands.java ++++ b/net/minecraft/commands/Commands.java +@@ -55,7 +55,6 @@ import net.minecraft.server.commands.CloneCommands; + import net.minecraft.server.commands.DamageCommand; + import net.minecraft.server.commands.DataPackCommand; + import net.minecraft.server.commands.DeOpCommands; +-import net.minecraft.server.commands.DebugCommand; + import net.minecraft.server.commands.DebugConfigCommand; + import net.minecraft.server.commands.DebugMobSpawningCommand; + import net.minecraft.server.commands.DebugPathCommand; +@@ -132,7 +131,6 @@ import net.minecraft.server.commands.WorldBorderCommand; + import net.minecraft.server.commands.data.DataCommands; + import net.minecraft.server.level.ServerPlayer; + import net.minecraft.tags.TagKey; +-import net.minecraft.util.profiling.Profiler; + import net.minecraft.util.profiling.jfr.JvmProfiler; + import net.minecraft.world.flag.FeatureFlagSet; + import net.minecraft.world.flag.FeatureFlags; +@@ -159,7 +157,6 @@ public class Commands { + DamageCommand.register(this.dispatcher, context); + DataCommands.register(this.dispatcher); + DataPackCommand.register(this.dispatcher); +- DebugCommand.register(this.dispatcher); + DefaultGameModeCommands.register(this.dispatcher); + DifficultyCommand.register(this.dispatcher); + EffectCommands.register(this.dispatcher, context); +@@ -334,7 +331,6 @@ public class Commands { + public void performCommand(ParseResults parseResults, String command, String label, boolean throwCommandError) { + // Paper end + CommandSourceStack commandSourceStack = parseResults.getContext().getSource(); +- Profiler.get().push(() -> "/" + command); + ContextChain contextChain = this.finishParsing(parseResults, command, commandSourceStack, label); // CraftBukkit // Paper - Add UnknownCommandEvent + + try { +@@ -371,8 +367,6 @@ public class Commands { + commandSourceStack.sendFailure(Component.literal(Util.describeError(var12))); + LOGGER.error("'/{}' threw an exception", command, var12); + } +- } finally { +- Profiler.get().pop(); + } + } + +@@ -429,7 +423,7 @@ public class Commands { + int max = Math.max(1, server.getGameRules().getInt(GameRules.RULE_MAX_COMMAND_CHAIN_LENGTH)); + int _int = server.getGameRules().getInt(GameRules.RULE_MAX_COMMAND_FORK_COUNT); + +- try (ExecutionContext executionContext1 = new ExecutionContext<>(max, _int, Profiler.get())) { ++ try (ExecutionContext executionContext1 = new ExecutionContext<>(max, _int)) { // Gale - Purpur - remove vanilla profiler + CURRENT_EXECUTION_CONTEXT.set(executionContext1); + contextConsumer.accept(executionContext1); + executionContext1.runCommandQueue(); +diff --git a/net/minecraft/commands/execution/ExecutionContext.java b/net/minecraft/commands/execution/ExecutionContext.java +index 18c7fff36ca26a659fa8ea022c93ea65f3199181..5844db9e913ccb6a351907875aea2f37c3b4ceea 100644 +--- a/net/minecraft/commands/execution/ExecutionContext.java ++++ b/net/minecraft/commands/execution/ExecutionContext.java +@@ -20,7 +20,6 @@ public class ExecutionContext implements AutoCloseable { + private static final Logger LOGGER = LogUtils.getLogger(); + private final int commandLimit; + private final int forkLimit; +- private final ProfilerFiller profiler; + @Nullable + private TraceCallbacks tracer; + private int commandQuota; +@@ -29,10 +28,9 @@ public class ExecutionContext implements AutoCloseable { + private final List> newTopCommands = new ObjectArrayList<>(); + private int currentFrameDepth; + +- public ExecutionContext(int commandLimit, int forkLimit, ProfilerFiller profiler) { ++ public ExecutionContext(int commandLimit, int forkLimit) { // Gale - Purpur - remove vanilla profiler + this.commandLimit = commandLimit; + this.forkLimit = forkLimit; +- this.profiler = profiler; + this.commandQuota = commandLimit; + } + +@@ -132,7 +130,7 @@ public class ExecutionContext implements AutoCloseable { + } + + public ProfilerFiller profiler() { +- return this.profiler; ++ return net.minecraft.util.profiling.InactiveProfiler.INSTANCE; // Gale - Purpur - remove vanilla profiler + } + + public int forkLimit() { +diff --git a/net/minecraft/commands/execution/tasks/BuildContexts.java b/net/minecraft/commands/execution/tasks/BuildContexts.java +index 569abbea01f585990d2017c68580257275bbb06d..46cf0f3ab7146ba2f37eb1a3ef97eca864219eae 100644 +--- a/net/minecraft/commands/execution/tasks/BuildContexts.java ++++ b/net/minecraft/commands/execution/tasks/BuildContexts.java +@@ -42,9 +42,6 @@ public class BuildContexts> { + ChainModifiers chainModifiers1 = chainModifiers; + List list = sources; + if (contextChain.getStage() != Stage.EXECUTE) { +- context.profiler().push(() -> "prepare " + this.commandInput); +- +- try { + for (int forkLimit = context.forkLimit(); contextChain.getStage() != Stage.EXECUTE; contextChain = contextChain.nextStage()) { + CommandContext topContext = contextChain.getTopContext(); + if (topContext.isForked()) { +@@ -84,9 +81,6 @@ public class BuildContexts> { + list = list1; + } + } +- } finally { +- context.profiler().pop(); +- } + } + + if (list.isEmpty()) { +diff --git a/net/minecraft/commands/execution/tasks/ExecuteCommand.java b/net/minecraft/commands/execution/tasks/ExecuteCommand.java +index 18071dcc69cc28471dddb7de94e803ec1e5fc2e4..e30bb9c4046200c1a6e4e917d15b205f5e0f21c3 100644 +--- a/net/minecraft/commands/execution/tasks/ExecuteCommand.java ++++ b/net/minecraft/commands/execution/tasks/ExecuteCommand.java +@@ -23,7 +23,6 @@ public class ExecuteCommand> implements Unbo + + @Override + public void execute(T source, ExecutionContext executionContext, Frame frame) { +- executionContext.profiler().push(() -> "execute " + this.commandInput); + + try { + executionContext.incrementCost(); +@@ -34,8 +33,6 @@ public class ExecuteCommand> implements Unbo + } + } catch (CommandSyntaxException var9) { + source.handleError(var9, this.modifiers.isForked(), executionContext.tracer()); +- } finally { +- executionContext.profiler().pop(); + } + } + } +diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java +index d7916d4d4cec9ac376c8b7b4c3432fddd55a1940..d69f6146ed653ec28eae67c0142867ac5d0e21ef 100644 +--- a/net/minecraft/server/MinecraftServer.java ++++ b/net/minecraft/server/MinecraftServer.java +@@ -114,19 +114,8 @@ import net.minecraft.util.TimeUtil; + import net.minecraft.util.debugchart.RemoteDebugSampleType; + import net.minecraft.util.debugchart.SampleLogger; + import net.minecraft.util.debugchart.TpsDebugDimensions; +-import net.minecraft.util.profiling.EmptyProfileResults; +-import net.minecraft.util.profiling.ProfileResults; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; +-import net.minecraft.util.profiling.ResultField; +-import net.minecraft.util.profiling.SingleTickProfiler; + import net.minecraft.util.profiling.jfr.JvmProfiler; + import net.minecraft.util.profiling.jfr.callback.ProfiledDuration; +-import net.minecraft.util.profiling.metrics.profiling.ActiveMetricsRecorder; +-import net.minecraft.util.profiling.metrics.profiling.InactiveMetricsRecorder; +-import net.minecraft.util.profiling.metrics.profiling.MetricsRecorder; +-import net.minecraft.util.profiling.metrics.profiling.ServerMetricsSamplersProvider; +-import net.minecraft.util.profiling.metrics.storage.MetricsPersister; + import net.minecraft.util.thread.ReentrantBlockableEventLoop; + import net.minecraft.world.Difficulty; + import net.minecraft.world.RandomSequences; +@@ -199,13 +188,6 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop tickables = Lists.newArrayList(); +- private MetricsRecorder metricsRecorder = InactiveMetricsRecorder.INSTANCE; +- private Consumer onMetricsRecordingStopped = results -> this.stopRecordingMetrics(); +- private Consumer onMetricsRecordingFinished = path -> {}; +- private boolean willStartRecordingMetrics; +- @Nullable +- private MinecraftServer.TimeProfiler debugCommandProfiler; +- private boolean debugCommandProfilerDelayStart; + private ServerConnectionListener connection; + public final ChunkProgressListenerFactory progressListenerFactory; + @Nullable +@@ -997,9 +979,6 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop false : this::haveTime); + // Paper start - rewrite chunk system +@@ -1259,7 +1231,6 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 0 && this.tickCount % autosavePeriod == 0; + try { + this.isSaving = true; +@@ -1556,10 +1520,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop serverPlayer1.connection.suspendFlushing()); + this.server.getScheduler().mainThreadHeartbeat(); // CraftBukkit + // Paper start - Folia scheduler API +@@ -1674,9 +1630,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 0; // Paper - Add EntityMoveEvent + serverLevel.updateLagCompensationTick(); // Paper - lag compensation + net.minecraft.world.level.block.entity.HopperBlockEntity.skipHopperEvents = serverLevel.paperConfig().hopper.disableMoveEvent || org.bukkit.event.inventory.InventoryMoveItemEvent.getHandlerList().getRegisteredListeners().length == 0; // Paper - Perf: Optimize Hoppers +- profilerFiller.push(() -> serverLevel + " " + serverLevel.dimension().location()); + /* Drop global time updates + if (this.tickCount % 20 == 0) { +- profilerFiller.push("timeSync"); + this.synchronizeTime(serverLevel); +- profilerFiller.pop(); + } + // CraftBukkit end */ + +- profilerFiller.push("tick"); +- + try { + serverLevel.tick(hasTimeLeft); + } catch (Throwable var7) { +@@ -1729,34 +1678,24 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { +- this.executeBlocking(() -> this.saveDebugReport(path.resolve("server"))); +- this.onMetricsRecordingFinished.accept(path); +- } +- ); +- this.willStartRecordingMetrics = false; +- } +- +- this.metricsRecorder.startTick(); +- return SingleTickProfiler.decorateFiller(this.metricsRecorder.getProfiler(), SingleTickProfiler.createTickProfiler("Server")); +- } +- +- public void endMetricsRecordingTick() { +- this.metricsRecorder.endTick(); +- } +- +- public boolean isRecordingMetrics() { +- return this.metricsRecorder.isRecording(); +- } +- +- public void startRecordingMetrics(Consumer output, Consumer onMetricsRecordingFinished) { +- this.onMetricsRecordingStopped = profileResults -> { +- this.stopRecordingMetrics(); +- output.accept(profileResults); +- }; +- this.onMetricsRecordingFinished = onMetricsRecordingFinished; +- this.willStartRecordingMetrics = true; +- } +- +- public void stopRecordingMetrics() { +- this.metricsRecorder = InactiveMetricsRecorder.INSTANCE; +- } +- +- public void finishRecordingMetrics() { +- this.metricsRecorder.end(); +- } +- +- public void cancelRecordingMetrics() { +- this.metricsRecorder.cancel(); +- } +- + public Path getWorldPath(LevelResource levelResource) { + return this.storageSource.getLevelPath(levelResource); + } +@@ -2697,24 +2582,6 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop getTimes(String sectionPath) { +- return Collections.emptyList(); +- } +- +- @Override +- public boolean saveResults(Path path) { +- return false; +- } +- +- @Override +- public long getStartTimeNano() { +- return TimeProfiler.this.startNanos; +- } +- +- @Override +- public int getStartTimeTicks() { +- return TimeProfiler.this.startTick; +- } +- +- @Override +- public long getEndTimeNano() { +- return endTimeNano; +- } +- +- @Override +- public int getEndTimeTicks() { +- return endTimeTicks; +- } +- +- @Override +- public String getProfilerResults() { +- return ""; +- } +- }; +- } +- } +- + // Paper start - Add tick times API and /mspt command + public static class TickTimes { + private final long[] times; +diff --git a/net/minecraft/server/ReloadableServerResources.java b/net/minecraft/server/ReloadableServerResources.java +index d56ade6f45057f8c056152c08ad6258a9716604d..432a29d3692669f49e453e289d52c70fe45e5564 100644 +--- a/net/minecraft/server/ReloadableServerResources.java ++++ b/net/minecraft/server/ReloadableServerResources.java +@@ -98,7 +98,7 @@ public class ReloadableServerResources { + backgroundExecutor, + gameExecutor, + DATA_RELOAD_INITIAL_TASK, +- LOGGER.isDebugEnabled() ++ false // Gale - Purpur - remove vanilla profiler + ) + .done() + .thenApply(object -> reloadableServerResources); +diff --git a/net/minecraft/server/ServerFunctionManager.java b/net/minecraft/server/ServerFunctionManager.java +index e3cb5d9cd0332c32df82fa6aef37401c523e8af0..10c79570432491bfb2bbfedf0491ab2b803d0c71 100644 +--- a/net/minecraft/server/ServerFunctionManager.java ++++ b/net/minecraft/server/ServerFunctionManager.java +@@ -14,8 +14,6 @@ import net.minecraft.commands.execution.ExecutionContext; + import net.minecraft.commands.functions.CommandFunction; + import net.minecraft.commands.functions.InstantiatedFunction; + import net.minecraft.resources.ResourceLocation; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import org.slf4j.Logger; + + public class ServerFunctionManager { +@@ -50,19 +48,12 @@ public class ServerFunctionManager { + } + + private void executeTagFunctions(Collection> functionObjects, ResourceLocation identifier) { +- Profiler.get().push(identifier::toString); +- + for (CommandFunction commandFunction : functionObjects) { + this.execute(commandFunction, this.getGameLoopSender()); + } +- +- Profiler.get().pop(); + } + + public void execute(CommandFunction function, CommandSourceStack source) { +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push(() -> "function " + function.id()); +- + try { + InstantiatedFunction instantiatedFunction = function.instantiate(null, this.getDispatcher()); + Commands.executeCommandInContext( +@@ -72,8 +63,6 @@ public class ServerFunctionManager { + } catch (FunctionInstantiationException var9) { + } catch (Exception var10) { + LOGGER.warn("Failed to execute function {}", function.id(), var10); +- } finally { +- profilerFiller.pop(); + } + } + +diff --git a/net/minecraft/server/commands/DebugCommand.java b/net/minecraft/server/commands/DebugCommand.java +index b246c9885fd8c9cc0de2fd4faa53e0619dd3865c..b83d07a620d49b2c3741b73f3e41212a9f36fc6e 100644 +--- a/net/minecraft/server/commands/DebugCommand.java ++++ b/net/minecraft/server/commands/DebugCommand.java +@@ -67,6 +67,8 @@ public class DebugCommand { + } + + private static int start(CommandSourceStack source) throws CommandSyntaxException { ++ // Gale start - Purpur - remove vanilla profiler ++ /* + MinecraftServer server = source.getServer(); + if (server.isTimeProfilerRunning()) { + throw ERROR_ALREADY_RUNNING.create(); +@@ -75,9 +77,14 @@ public class DebugCommand { + source.sendSuccess(() -> Component.translatable("commands.debug.started"), true); + return 0; + } ++ */ ++ return 0; ++ // Gale end - Purpur - remove vanilla profiler + } + + private static int stop(CommandSourceStack source) throws CommandSyntaxException { ++ // Gale start - Purpur - remove vanilla profiler ++ /* + MinecraftServer server = source.getServer(); + if (!server.isTimeProfilerRunning()) { + throw ERROR_NOT_RUNNING.create(); +@@ -93,6 +100,9 @@ public class DebugCommand { + ); + return (int)d1; + } ++ */ ++ return 0; ++ // Gale end - Purpur - remove vanilla profiler + } + + static class TraceCustomExecutor +diff --git a/net/minecraft/server/commands/PerfCommand.java b/net/minecraft/server/commands/PerfCommand.java +index a3192400b37274620977e5a40d4283bfec3ab9b3..f23b17416eadc0e800ca34918ac78c031630edb4 100644 +--- a/net/minecraft/server/commands/PerfCommand.java ++++ b/net/minecraft/server/commands/PerfCommand.java +@@ -42,6 +42,9 @@ public class PerfCommand { + } + + private static int startProfilingDedicatedServer(CommandSourceStack source) throws CommandSyntaxException { ++ // Gale start - Purpur - remove vanilla profiler ++ return removedMessage(source); ++ /* + MinecraftServer server = source.getServer(); + if (server.isRecordingMetrics()) { + throw ERROR_ALREADY_RUNNING.create(); +@@ -52,9 +55,14 @@ public class PerfCommand { + source.sendSuccess(() -> Component.translatable("commands.perf.started"), false); + return 0; + } ++ */ ++ // Gale end - Purpur - remove vanilla profiler + } + + private static int stopProfilingDedicatedServer(CommandSourceStack source) throws CommandSyntaxException { ++ // Gale start - Purpur - remove vanilla profiler ++ return removedMessage(source); ++ /* + MinecraftServer server = source.getServer(); + if (!server.isRecordingMetrics()) { + throw ERROR_NOT_RUNNING.create(); +@@ -62,8 +70,22 @@ public class PerfCommand { + server.finishRecordingMetrics(); + return 0; + } ++ */ ++ // Gale end - Purpur - remove vanilla profiler + } + ++ // Gale start - Purpur - remove vanilla profiler ++ private static int removedMessage(CommandSourceStack source) { ++ net.kyori.adventure.text.minimessage.MiniMessage mm = net.kyori.adventure.text.minimessage.MiniMessage.miniMessage(); ++ ++ source.getSender().sendMessage(mm.deserialize("Gale has removed Mojang's Profiler to save your performance. Please use /spark instead")); ++ source.getSender().sendMessage(mm.deserialize("For more information, view its documentation at")); ++ source.getSender().sendMessage(mm.deserialize("https://spark.lucko.me/docs/Command-Usage")); ++ ++ return 0; ++ } ++ // Gale end - Purpur - remove vanilla profiler ++ + private static void saveResults(CommandSourceStack source, Path path, MinecraftServer server) { + String string = String.format( + Locale.ROOT, "%s-%s-%s", Util.getFilenameFormattedDateTime(), server.getWorldData().getLevelName(), SharedConstants.getCurrentVersion().getId() +diff --git a/net/minecraft/server/dedicated/DedicatedServer.java b/net/minecraft/server/dedicated/DedicatedServer.java +index f4a8c7fe830495434f06d45c1a4505e4ea536804..baa92ab485928b2e57adb14af00f7e6120694184 100644 +--- a/net/minecraft/server/dedicated/DedicatedServer.java ++++ b/net/minecraft/server/dedicated/DedicatedServer.java +@@ -798,12 +798,6 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface + return this.settings.getProperties().serverResourcePackInfo; + } + +- @Override +- public void endMetricsRecordingTick() { +- super.endMetricsRecordingTick(); +- this.debugSampleSubscriptionTracker.tick(this.getTickCount()); +- } +- + @Override + public SampleLogger getTickTimeLogger() { + return this.tickTimeLogger; +diff --git a/net/minecraft/server/level/ChunkGenerationTask.java b/net/minecraft/server/level/ChunkGenerationTask.java +index 4221af18f5087badb5cd8c7cf66ab3312edf0394..f102afff61d5577a0f5002f2a52335bd4810f150 100644 +--- a/net/minecraft/server/level/ChunkGenerationTask.java ++++ b/net/minecraft/server/level/ChunkGenerationTask.java +@@ -5,8 +5,6 @@ import java.util.List; + import java.util.concurrent.CompletableFuture; + import javax.annotation.Nullable; + import net.minecraft.util.StaticCache2D; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.Zone; + import net.minecraft.world.level.ChunkPos; + import net.minecraft.world.level.chunk.ChunkAccess; + import net.minecraft.world.level.chunk.status.ChunkDependencies; +@@ -113,8 +111,6 @@ public class ChunkGenerationTask { + } + + private void scheduleLayer(ChunkStatus status, boolean needsGeneration) { +- try (Zone zone = Profiler.get().zone("scheduleLayer")) { +- zone.addText(status::getName); + int radiusForLayer = this.getRadiusForLayer(status, needsGeneration); + + for (int i = this.pos.x - radiusForLayer; i <= this.pos.x + radiusForLayer; i++) { +@@ -125,7 +121,6 @@ public class ChunkGenerationTask { + } + } + } +- } + } + + private int getRadiusForLayer(ChunkStatus status, boolean needsGeneration) { +diff --git a/net/minecraft/server/level/ChunkMap.java b/net/minecraft/server/level/ChunkMap.java +index b3f498558614243cf633dcd71e3c49c2c55e6e0f..d3d9926d504fa6b3384be5ae06b2843ebb7f807c 100644 +--- a/net/minecraft/server/level/ChunkMap.java ++++ b/net/minecraft/server/level/ChunkMap.java +@@ -60,8 +60,6 @@ import net.minecraft.server.network.ServerPlayerConnection; + import net.minecraft.util.CsvOutput; + import net.minecraft.util.Mth; + import net.minecraft.util.StaticCache2D; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import net.minecraft.util.thread.BlockableEventLoop; + import net.minecraft.util.thread.ConsecutiveExecutor; + import net.minecraft.world.entity.Entity; +@@ -410,15 +408,10 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider + } + + protected void tick(BooleanSupplier hasMoreTime) { +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push("poi"); + this.poiManager.tick(hasMoreTime); +- profilerFiller.popPush("chunk_unload"); + if (!this.level.noSave()) { + this.processUnloads(hasMoreTime); + } +- +- profilerFiller.pop(); + } + + public boolean hasWork() { +diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java +index 6540b2d6a1062d883811ce240c49d30d1925b291..9500fc2f841819b0d40e8a6e48353bb28b6dbe49 100644 +--- a/net/minecraft/server/level/ServerChunkCache.java ++++ b/net/minecraft/server/level/ServerChunkCache.java +@@ -25,8 +25,6 @@ import net.minecraft.network.protocol.Packet; + import net.minecraft.server.MinecraftServer; + import net.minecraft.server.level.progress.ChunkProgressListener; + import net.minecraft.util.VisibleForDebug; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import net.minecraft.util.thread.BlockableEventLoop; + import net.minecraft.world.entity.Entity; + import net.minecraft.world.entity.MobCategory; +@@ -467,37 +465,28 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon + // CraftBukkit start - modelled on below + public void purgeUnload() { + if (true) return; // Paper - rewrite chunk system +- ProfilerFiller gameprofilerfiller = Profiler.get(); + +- gameprofilerfiller.push("purge"); + this.distanceManager.purgeStaleTickets(); + this.runDistanceManagerUpdates(); +- gameprofilerfiller.popPush("unload"); + this.chunkMap.tick(() -> true); +- gameprofilerfiller.pop(); + this.clearCache(); + } + // CraftBukkit end + + @Override + public void tick(BooleanSupplier hasTimeLeft, boolean tickChunks) { +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push("purge"); + if (this.level.tickRateManager().runsNormally() || !tickChunks || this.level.spigotConfig.unloadFrozenChunks) { // Spigot + this.distanceManager.purgeStaleTickets(); + } + + this.runDistanceManagerUpdates(); +- profilerFiller.popPush("chunks"); + if (tickChunks) { + ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)this.level).moonrise$getPlayerChunkLoader().tick(); // Paper - rewrite chunk system + this.tickChunks(); + this.chunkMap.tick(); + } + +- profilerFiller.popPush("unload"); + this.chunkMap.tick(hasTimeLeft); +- profilerFiller.pop(); + this.clearCache(); + } + +@@ -506,34 +495,26 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon + long l = gameTime - this.lastInhabitedUpdate; + this.lastInhabitedUpdate = gameTime; + if (!this.level.isDebug()) { +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push("pollingChunks"); + if (this.level.tickRateManager().runsNormally()) { + List list = this.tickingChunks; + + try { +- profilerFiller.push("filteringTickingChunks"); + this.collectTickingChunks(list); +- profilerFiller.popPush("shuffleChunks"); + // Paper start - chunk tick iteration optimisation + this.shuffleRandom.setSeed(this.level.random.nextLong()); + if (!this.level.paperConfig().entities.spawning.perPlayerMobSpawns) Util.shuffle(list, this.shuffleRandom); // Paper - Optional per player mob spawns; do not need this when per-player is enabled + // Paper end - chunk tick iteration optimisation +- this.tickChunks(profilerFiller, l, list); +- profilerFiller.pop(); ++ this.tickChunks(l, list); // Gale - Purpur - remove vanilla profiler + } finally { + list.clear(); + } + } + +- this.broadcastChangedChunks(profilerFiller); +- profilerFiller.pop(); ++ this.broadcastChangedChunks(); // Gale - Purpur - remove vanilla profiler + } + } + +- private void broadcastChangedChunks(ProfilerFiller profiler) { +- profiler.push("broadcast"); +- ++ private void broadcastChangedChunks() { // Gale - Purpur - remove vanilla profiler + for (ChunkHolder chunkHolder : this.chunkHoldersToBroadcast) { + LevelChunk tickingChunk = chunkHolder.getChunkToSend(); // Paper - rewrite chunk system + if (tickingChunk != null) { +@@ -542,7 +523,6 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon + } + + this.chunkHoldersToBroadcast.clear(); +- profiler.pop(); + } + + private void collectTickingChunks(List output) { +@@ -568,8 +548,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon + // Paper end - chunk tick iteration optimisation + } + +- private void tickChunks(ProfilerFiller profiler, long timeInhabited, List chunks) { +- profiler.popPush("naturalSpawnCount"); ++ private void tickChunks(long timeInhabited, List chunks) { // Gale - Purpur - remove vanilla profiler + int naturalSpawnChunkCount = this.distanceManager.getNaturalSpawnChunkCount(); + // Paper start - Optional per player mob spawns + NaturalSpawner.SpawnState spawnState; +@@ -594,7 +573,6 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon + } + // Paper end - Optional per player mob spawns + this.lastSpawnState = spawnState; +- profiler.popPush("spawnAndTick"); + boolean _boolean = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !this.level.players().isEmpty(); // CraftBukkit + int _int = this.level.getGameRules().getInt(GameRules.RULE_RANDOMTICKING); + List filteredSpawningCategories; +@@ -625,7 +603,6 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon + } + } + +- profiler.popPush("customSpawners"); + if (_boolean) { + this.level.tickCustomSpawners(this.spawnEnemies, this.spawnFriendlies); + } +@@ -814,7 +791,6 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon + + @Override + protected void doRunTask(Runnable task) { +- Profiler.get().incrementCounter("runTask"); + super.doRunTask(task); + } + +diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java +index 13db4411e5bd635315b27b92a3e97bf286d14577..93b0265e3b1ea133877682721ff28d735d9b688b 100644 +--- a/net/minecraft/server/level/ServerLevel.java ++++ b/net/minecraft/server/level/ServerLevel.java +@@ -77,8 +77,6 @@ import net.minecraft.util.ProgressListener; + import net.minecraft.util.RandomSource; + import net.minecraft.util.Unit; + import net.minecraft.util.datafix.DataFixTypes; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import net.minecraft.util.valueproviders.IntProvider; + import net.minecraft.util.valueproviders.UniformInt; + import net.minecraft.world.DifficultyInstance; +@@ -714,16 +712,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe + } + + public void tick(BooleanSupplier hasTimeLeft) { +- ProfilerFiller profilerFiller = Profiler.get(); + this.handlingTick = true; + TickRateManager tickRateManager = this.tickRateManager(); + boolean runsNormally = tickRateManager.runsNormally(); + if (runsNormally) { +- profilerFiller.push("world border"); + this.getWorldBorder().tick(); +- profilerFiller.popPush("weather"); + this.advanceWeatherCycle(); +- profilerFiller.pop(); + } + + int _int = this.getGameRules().getInt(GameRules.RULE_PLAYERS_SLEEPING_PERCENTAGE); +@@ -757,41 +751,30 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe + this.tickTime(); + } + +- profilerFiller.push("tickPending"); + if (!this.isDebug() && runsNormally) { + long l = this.getGameTime(); +- profilerFiller.push("blockTicks"); + this.blockTicks.tick(l, paperConfig().environment.maxBlockTicks, this::tickBlock); // Paper - configurable max block ticks +- profilerFiller.popPush("fluidTicks"); + this.fluidTicks.tick(l, paperConfig().environment.maxFluidTicks, this::tickFluid); // Paper - configurable max fluid ticks +- profilerFiller.pop(); + } + +- profilerFiller.popPush("raid"); + if (runsNormally) { + this.raids.tick(); + } + +- profilerFiller.popPush("chunkSource"); + this.getChunkSource().tick(hasTimeLeft, true); +- profilerFiller.popPush("blockEvents"); + if (runsNormally) { + this.runBlockEvents(); + } + + this.handlingTick = false; +- profilerFiller.pop(); + boolean flag = !paperConfig().unsupportedSettings.disableWorldTickingWhenEmpty || !this.players.isEmpty() || !this.getForcedChunks().isEmpty(); // CraftBukkit - this prevents entity cleanup, other issues on servers with no players // Paper - restore this + if (flag) { + this.resetEmptyTime(); + } + + if (flag || this.emptyTime++ < 300) { +- profilerFiller.push("entities"); + if (this.dragonFight != null && runsNormally) { +- profilerFiller.push("dragonFight"); + this.dragonFight.tick(); +- profilerFiller.pop(); + } + + io.papermc.paper.entity.activation.ActivationRange.activateEntities(this); // Paper - EAR +@@ -800,9 +783,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe + entity -> { + if (!entity.isRemoved()) { + if (!tickRateManager.isEntityFrozen(entity)) { +- profilerFiller.push("checkDespawn"); + entity.checkDespawn(); +- profilerFiller.pop(); + if (true) { // Paper - rewrite chunk system + Entity vehicle = entity.getVehicle(); + if (vehicle != null) { +@@ -813,21 +794,16 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe + entity.stopRiding(); + } + +- profilerFiller.push("tick"); + this.guardEntityTick(this::tickNonPassenger, entity); +- profilerFiller.pop(); + } + } + } + } + ); +- profilerFiller.pop(); + this.tickBlockEntities(); + } + +- profilerFiller.push("entityManagement"); + // Paper - rewrite chunk system +- profilerFiller.pop(); + } + + @Override +@@ -842,9 +818,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe + if (this.tickTime) { + long l = this.levelData.getGameTime() + 1L; + this.serverLevelData.setGameTime(l); +- Profiler.get().push("scheduledFunctions"); + this.serverLevelData.getScheduledEvents().tick(this.server, l); +- Profiler.get().pop(); + if (this.serverLevelData.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)) { + this.setDayTime(this.levelData.getDayTime() + 1L); + } +@@ -924,8 +898,6 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe + boolean isRaining = this.isRaining(); + int minBlockX = pos.getMinBlockX(); + int minBlockZ = pos.getMinBlockZ(); +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push("thunder"); + if (!this.paperConfig().environment.disableThunder && isRaining && this.isThundering() && this.spigotConfig.thunderChance > 0 && simpleRandom.nextInt(this.spigotConfig.thunderChance) == 0) { // Spigot // Paper - Option to disable thunder // Paper - optimise random ticking + BlockPos blockPos = this.findLightningTargetAround(this.getBlockRandomPos(minBlockX, 0, minBlockZ, 15)); + if (this.isRainingAt(blockPos)) { +@@ -952,8 +924,6 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe + } + } + +- profilerFiller.popPush("iceandsnow"); +- + if (!this.paperConfig().environment.disableIceAndSnow) { // Paper - Option to disable ice and snow + for (int i = 0; i < randomTickSpeed; i++) { + if (simpleRandom.nextInt(48) == 0) { // Paper - optimise random ticking +@@ -962,12 +932,9 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe + } + } // Paper - Option to disable ice and snow + +- profilerFiller.popPush("tickBlocks"); + if (randomTickSpeed > 0) { + this.optimiseRandomTick(chunk, randomTickSpeed); // Paper - optimise random ticking + } +- +- profilerFiller.pop(); + } + + @VisibleForTesting +@@ -1260,16 +1227,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe + } + // Paper end - log detailed entity tick information + entity.setOldPosAndRot(); +- ProfilerFiller profilerFiller = Profiler.get(); + entity.tickCount++; +- profilerFiller.push(() -> BuiltInRegistries.ENTITY_TYPE.getKey(entity.getType()).toString()); +- profilerFiller.incrementCounter("tickNonPassenger"); + final boolean isActive = io.papermc.paper.entity.activation.ActivationRange.checkIfActive(entity); // Paper - EAR 2 + if (isActive) { // Paper - EAR 2 + entity.tick(); + entity.postTick(); // CraftBukkit + } else {entity.inactiveTick();} // Paper - EAR 2 +- profilerFiller.pop(); + + for (Entity entity1 : entity.getPassengers()) { + this.tickPassenger(entity, entity1, isActive); // Paper - EAR 2 +@@ -1289,9 +1252,6 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe + } else if (passengerEntity instanceof Player || this.entityTickList.contains(passengerEntity)) { + passengerEntity.setOldPosAndRot(); + passengerEntity.tickCount++; +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push(() -> BuiltInRegistries.ENTITY_TYPE.getKey(passengerEntity.getType()).toString()); +- profilerFiller.incrementCounter("tickPassenger"); + // Paper start - EAR 2 + if (isActive) { + passengerEntity.rideTick(); +@@ -1303,7 +1263,6 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe + ridingEntity.positionRider(passengerEntity); + } + // Paper end - EAR 2 +- profilerFiller.pop(); + + for (Entity entity : passengerEntity.getPassengers()) { + this.tickPassenger(passengerEntity, entity, isActive); // Paper - EAR 2 +diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java +index f347ff8d863f4bcef46604c757de112cb3fe445c..b349da64650f914db8212e19b3c05ba92e74a1a3 100644 +--- a/net/minecraft/server/level/ServerPlayer.java ++++ b/net/minecraft/server/level/ServerPlayer.java +@@ -96,8 +96,6 @@ import net.minecraft.tags.FluidTags; + import net.minecraft.util.Mth; + import net.minecraft.util.RandomSource; + import net.minecraft.util.Unit; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import net.minecraft.world.Container; + import net.minecraft.world.Difficulty; + import net.minecraft.world.InteractionHand; +@@ -1426,14 +1424,10 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc + this.unsetRemoved(); + */ + // CraftBukkit end +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push("moving"); + if (level != null && resourceKey == net.minecraft.world.level.dimension.LevelStem.OVERWORLD && level.getTypeKey() == net.minecraft.world.level.dimension.LevelStem.NETHER) { // CraftBukkit - empty to fall through to null to event + this.enteredNetherPosition = this.position(); + } + +- profilerFiller.pop(); +- profilerFiller.push("placing"); + // CraftBukkit start + this.isChangingDimension = true; // CraftBukkit - Set teleport invulnerability only if player changing worlds + LevelData worlddata = level.getLevelData(); +@@ -1450,7 +1444,6 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc + this.connection.internalTeleport(PositionMoveRotation.of(teleportTransition), teleportTransition.relatives()); // CraftBukkit - use internal teleport without event + this.connection.resetPosition(); + level.addDuringTeleport(this); +- profilerFiller.pop(); + this.triggerDimensionChangeTriggers(serverLevel); + this.stopUsingItem(); + this.connection.send(new ClientboundPlayerAbilitiesPacket(this.getAbilities())); +diff --git a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java +index e71c1a564e5d4ac43460f89879ff709ee685706f..2b059bff0d24b52b106a0af4b7e79818f385596e 100644 +--- a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java ++++ b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java +@@ -24,7 +24,6 @@ import net.minecraft.network.protocol.cookie.ServerboundCookieResponsePacket; + import net.minecraft.server.MinecraftServer; + import net.minecraft.server.level.ClientInformation; + import net.minecraft.util.VisibleForDebug; +-import net.minecraft.util.profiling.Profiler; + import org.slf4j.Logger; + + public abstract class ServerCommonPacketListenerImpl implements ServerCommonPacketListener, org.bukkit.craftbukkit.entity.CraftPlayer.TransferCookieConnection { // CraftBukkit +@@ -233,7 +232,6 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack + } + + protected void keepConnectionAlive() { +- Profiler.get().push("keepAlive"); + long millis = Util.getMillis(); + // Paper start - give clients a longer time to respond to pings as per pre 1.12.2 timings + // This should effectively place the keepalive handling back to "as it was" before 1.12.2 +@@ -251,8 +249,6 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack + this.send(new ClientboundKeepAlivePacket(this.keepAliveChallenge)); + } + } +- +- Profiler.get().pop(); + } + + private boolean checkIfClosed(long time) { +diff --git a/net/minecraft/server/packs/resources/ProfiledReloadInstance.java b/net/minecraft/server/packs/resources/ProfiledReloadInstance.java +index 71a4a0b8535a21667261fd66d41cca1216fd9933..1e9edae4708e1b2c282a13bd6a74f71ec4116895 100644 +--- a/net/minecraft/server/packs/resources/ProfiledReloadInstance.java ++++ b/net/minecraft/server/packs/resources/ProfiledReloadInstance.java +@@ -9,8 +9,6 @@ import java.util.concurrent.TimeUnit; + import java.util.concurrent.atomic.AtomicLong; + import net.minecraft.Util; + import net.minecraft.util.Unit; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import org.slf4j.Logger; + + public class ProfiledReloadInstance extends SimpleReloadInstance { +@@ -51,12 +49,9 @@ public class ProfiledReloadInstance extends SimpleReloadInstance executor.execute(() -> { +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push(name); + long nanos = Util.getNanos(); + runnable.run(); + timeTaken.addAndGet(Util.getNanos() - nanos); +- profilerFiller.pop(); + }); + } + +diff --git a/net/minecraft/server/packs/resources/ReloadableResourceManager.java b/net/minecraft/server/packs/resources/ReloadableResourceManager.java +index 51cec338f5948b69ad1cff896ce19dc3adb74380..be7fd9e55957ba6fa70c711d1ea4d42e3bbfd752 100644 +--- a/net/minecraft/server/packs/resources/ReloadableResourceManager.java ++++ b/net/minecraft/server/packs/resources/ReloadableResourceManager.java +@@ -43,7 +43,7 @@ public class ReloadableResourceManager implements ResourceManager, AutoCloseable + LOGGER.info("Reloading ResourceManager: {}", LogUtils.defer(() -> resourcePacks.stream().map(PackResources::packId).collect(Collectors.joining(", ")))); + this.resources.close(); + this.resources = new MultiPackResourceManager(this.type, resourcePacks); +- return SimpleReloadInstance.create(this.resources, this.listeners, backgroundExecutor, gameExecutor, waitingFor, LOGGER.isDebugEnabled()); ++ return SimpleReloadInstance.create(this.resources, this.listeners, backgroundExecutor, gameExecutor, waitingFor, false); // Gale - Purpur - remove vanilla profiler + } + + @Override +diff --git a/net/minecraft/server/packs/resources/ResourceManagerReloadListener.java b/net/minecraft/server/packs/resources/ResourceManagerReloadListener.java +index 407bd4b8026869bc14ee5e79ff80e7bdd1a07bcb..6e2a3d4171dbb2a30ba18f165723691713fac0f6 100644 +--- a/net/minecraft/server/packs/resources/ResourceManagerReloadListener.java ++++ b/net/minecraft/server/packs/resources/ResourceManagerReloadListener.java +@@ -3,20 +3,13 @@ package net.minecraft.server.packs.resources; + import java.util.concurrent.CompletableFuture; + import java.util.concurrent.Executor; + import net.minecraft.util.Unit; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + + public interface ResourceManagerReloadListener extends PreparableReloadListener { + @Override + default CompletableFuture reload( + PreparableReloadListener.PreparationBarrier barrier, ResourceManager manager, Executor backgroundExecutor, Executor gameExecutor + ) { +- return barrier.wait(Unit.INSTANCE).thenRunAsync(() -> { +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push("listener"); +- this.onResourceManagerReload(manager); +- profilerFiller.pop(); +- }, gameExecutor); ++ return barrier.wait(Unit.INSTANCE).thenRunAsync(() -> this.onResourceManagerReload(manager), gameExecutor); // Gale - Purpur - remove vanilla profiler + } + + void onResourceManagerReload(ResourceManager resourceManager); +diff --git a/net/minecraft/server/packs/resources/SimplePreparableReloadListener.java b/net/minecraft/server/packs/resources/SimplePreparableReloadListener.java +index 64b0508ef21952c65b0b967b756b2a4c64d96899..bd7005d29ec81039e6fa1c487c9e5633fa90bd5e 100644 +--- a/net/minecraft/server/packs/resources/SimplePreparableReloadListener.java ++++ b/net/minecraft/server/packs/resources/SimplePreparableReloadListener.java +@@ -2,7 +2,8 @@ package net.minecraft.server.packs.resources; + + import java.util.concurrent.CompletableFuture; + import java.util.concurrent.Executor; +-import net.minecraft.util.profiling.Profiler; ++ ++import net.minecraft.util.profiling.InactiveProfiler; + import net.minecraft.util.profiling.ProfilerFiller; + + public abstract class SimplePreparableReloadListener implements PreparableReloadListener { +@@ -10,9 +11,9 @@ public abstract class SimplePreparableReloadListener implements PreparableRel + public final CompletableFuture reload( + PreparableReloadListener.PreparationBarrier barrier, ResourceManager manager, Executor backgroundExecutor, Executor gameExecutor + ) { +- return CompletableFuture.supplyAsync(() -> this.prepare(manager, Profiler.get()), backgroundExecutor) ++ return CompletableFuture.supplyAsync(() -> this.prepare(manager, InactiveProfiler.INSTANCE), backgroundExecutor) // Gale - Purpur - remove vanilla profiler + .thenCompose(barrier::wait) +- .thenAcceptAsync(object -> this.apply((T)object, manager, Profiler.get()), gameExecutor); ++ .thenAcceptAsync(object -> this.apply((T)object, manager, InactiveProfiler.INSTANCE), gameExecutor); // Gale - Purpur - remove vanilla profiler + } + + protected abstract T prepare(ResourceManager resourceManager, ProfilerFiller profiler); +diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java +index 1d0151a042ed5de4e235ef0bdac1a0e8240e85e7..3594240116d3b61dbf838490df7a30345d7d8925 100644 +--- a/net/minecraft/world/entity/Entity.java ++++ b/net/minecraft/world/entity/Entity.java +@@ -78,8 +78,6 @@ import net.minecraft.tags.FluidTags; + import net.minecraft.tags.TagKey; + import net.minecraft.util.Mth; + import net.minecraft.util.RandomSource; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import net.minecraft.world.InteractionHand; + import net.minecraft.world.InteractionResult; + import net.minecraft.world.Nameable; +@@ -829,8 +827,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess + // CraftBukkit end + + public void baseTick() { +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push("entityBaseTick"); + if (firstTick && this instanceof net.minecraft.world.entity.NeutralMob neutralMob) neutralMob.tickInitialPersistentAnger(level); // Paper - Prevent entity loading causing async lookups + this.inBlockState = null; + if (this.isPassenger() && this.getVehicle().isRemoved()) { +@@ -893,8 +889,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess + if (this.level() instanceof ServerLevel serverLevelx && this instanceof Leashable) { + Leashable.tickLeash(serverLevelx, (Entity & Leashable)this); + } +- +- profilerFiller.pop(); + } + + public void setSharedFlagOnFire(boolean isOnFire) { +@@ -1112,8 +1106,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess + } + } + +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push("move"); + if (this.stuckSpeedMultiplier.lengthSqr() > 1.0E-7) { + movement = movement.multiply(this.stuckSpeedMultiplier); + this.stuckSpeedMultiplier = Vec3.ZERO; +@@ -1122,7 +1114,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess + // Paper start - ignore movement changes while inactive. + if (isTemporarilyActive && !(this instanceof ItemEntity) && movement == getDeltaMovement() && type == MoverType.SELF) { + setDeltaMovement(Vec3.ZERO); +- profilerFiller.pop(); + return; + } + // Paper end +@@ -1144,8 +1135,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess + this.setPos(this.getX() + vec3.x, this.getY() + vec3.y, this.getZ() + vec3.z); + } + +- profilerFiller.pop(); +- profilerFiller.push("rest"); + boolean flag = !Mth.equal(movement.x, vec3.x); + boolean flag1 = !Mth.equal(movement.z, vec3.z); + this.horizontalCollision = flag || flag1; +@@ -1168,7 +1157,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess + } + + if (this.isRemoved()) { +- profilerFiller.pop(); + } else { + if (this.horizontalCollision) { + Vec3 deltaMovement = this.getDeltaMovement(); +@@ -1213,7 +1201,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess + + float blockSpeedFactor = this.getBlockSpeedFactor(); + this.setDeltaMovement(this.getDeltaMovement().multiply(blockSpeedFactor, 1.0, blockSpeedFactor)); +- profilerFiller.pop(); + } + } + // Paper start - detailed watchdog information +@@ -3263,8 +3250,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess + this.processPortalCooldown(); + if (this.portalProcess != null) { + if (this.portalProcess.processPortalTeleportation(serverLevel, this, this.canUsePortal(false))) { +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push("portal"); + this.setPortalCooldown(); + TeleportTransition portalDestination = this.portalProcess.getPortalDestination(serverLevel, this); + if (portalDestination != null) { +@@ -3275,7 +3260,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess + } + } + +- profilerFiller.pop(); + } else if (this.portalProcess.hasExpired()) { + this.portalProcess = null; + } +@@ -3795,15 +3779,12 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess + entity.teleport(this.calculatePassengerTransition(teleportTransition, entity)); + } + +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push("teleportSameDimension"); + this.teleportSetPosition(PositionMoveRotation.of(teleportTransition), teleportTransition.relatives()); + if (!teleportTransition.asPassenger()) { + this.sendTeleportTransitionToRidingPlayers(teleportTransition); + } + + teleportTransition.postTeleportTransition().onTransition(this); +- profilerFiller.pop(); + return this; + } + +@@ -3819,11 +3800,8 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess + } + } + +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push("teleportCrossDimension"); + Entity entityx = this.getType().create(level, EntitySpawnReason.DIMENSION_TRAVEL); + if (entityx == null) { +- profilerFiller.pop(); + return null; + } else { + // Paper start - Fix item duplication and teleport issues +@@ -3846,7 +3824,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess + + level.resetEmptyTime(); + teleportTransition.postTeleportTransition().onTransition(entityx); +- profilerFiller.pop(); + return entityx; + } + } +diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java +index 239c443ddc9bacc08a39a8ef2ab17016a2480549..00caebfabfc459eed86f0e6e2cc3f4b628f7ef99 100644 +--- a/net/minecraft/world/entity/LivingEntity.java ++++ b/net/minecraft/world/entity/LivingEntity.java +@@ -72,8 +72,6 @@ import net.minecraft.tags.FluidTags; + import net.minecraft.tags.ItemTags; + import net.minecraft.tags.TagKey; + import net.minecraft.util.Mth; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import net.minecraft.world.Difficulty; + import net.minecraft.world.InteractionHand; + import net.minecraft.world.damagesource.CombatRules; +@@ -443,8 +441,6 @@ public abstract class LivingEntity extends Entity implements Attackable { + } + + super.baseTick(); +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push("livingEntityBaseTick"); + if (this.fireImmune() || this.level().isClientSide) { + this.clearFire(); + } +@@ -554,7 +550,6 @@ public abstract class LivingEntity extends Entity implements Attackable { + this.yHeadRotO = this.yHeadRot; + this.yRotO = this.getYRot(); + this.xRotO = this.getXRot(); +- profilerFiller.pop(); + } + + @Override +@@ -3176,11 +3171,7 @@ public abstract class LivingEntity extends Entity implements Attackable { + } + + this.run = this.run + (f3 - this.run) * 0.3F; +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push("headTurn"); + f2 = this.tickHeadTurn(f1, f2); +- profilerFiller.pop(); +- profilerFiller.push("rangeChecks"); + + // Paper start - stop large pitch and yaw changes from crashing the server + this.yRotO += Math.round((this.getYRot() - this.yRotO) / 360.0F) * 360.0F; +@@ -3191,7 +3182,6 @@ public abstract class LivingEntity extends Entity implements Attackable { + + this.yHeadRotO += Math.round((this.yHeadRot - this.yHeadRotO) / 360.0F) * 360.0F; + +- profilerFiller.pop(); + this.animStep += f2; + if (this.isFallFlying()) { + this.fallFlyTicks++; +@@ -3385,20 +3375,14 @@ public abstract class LivingEntity extends Entity implements Attackable { + } + + this.setDeltaMovement(d, d1, d2); +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push("ai"); + if (this.isImmobile()) { + this.jumping = false; + this.xxa = 0.0F; + this.zza = 0.0F; + } else if (this.isEffectiveAi()) { +- profilerFiller.push("newAi"); + this.serverAiStep(); +- profilerFiller.pop(); + } + +- profilerFiller.pop(); +- profilerFiller.push("jump"); + if (this.jumping && this.isAffectedByFluids()) { + double fluidHeight; + if (this.isInLava()) { +@@ -3427,8 +3411,6 @@ public abstract class LivingEntity extends Entity implements Attackable { + this.noJumpDelay = 0; + } + +- profilerFiller.pop(); +- profilerFiller.push("travel"); + this.xxa *= 0.98F; + this.zza *= 0.98F; + if (this.isFallFlying()) { +@@ -3452,8 +3434,6 @@ public abstract class LivingEntity extends Entity implements Attackable { + } + + this.calculateEntityAnimation(this instanceof FlyingAnimal); +- profilerFiller.pop(); +- profilerFiller.push("freezing"); + if (!this.level().isClientSide && !this.isDeadOrDying() && !this.freezeLocked) { // Paper - Freeze Tick Lock API + int ticksFrozen = this.getTicksFrozen(); + if (this.isInPowderSnow && this.canFreeze()) { +@@ -3469,15 +3449,12 @@ public abstract class LivingEntity extends Entity implements Attackable { + this.hurtServer(serverLevel, this.damageSources().freeze(), 1.0F); + } + +- profilerFiller.pop(); +- profilerFiller.push("push"); + if (this.autoSpinAttackTicks > 0) { + this.autoSpinAttackTicks--; + this.checkAutoSpinAttack(boundingBox, this.getBoundingBox()); + } + + this.pushEntities(); +- profilerFiller.pop(); + // Paper start - Add EntityMoveEvent + if (((ServerLevel) this.level()).hasEntityMoveEvent && !(this instanceof Player)) { + if (this.xo != this.getX() || this.yo != this.getY() || this.zo != this.getZ() || this.yRotO != this.getYRot() || this.xRotO != this.getXRot()) { +diff --git a/net/minecraft/world/entity/Mob.java b/net/minecraft/world/entity/Mob.java +index 1ed07fd23985a6bf8cf8300f74c92b7531a79fc6..2568a7f2459ed783d4612546b86d46721d48a396 100644 +--- a/net/minecraft/world/entity/Mob.java ++++ b/net/minecraft/world/entity/Mob.java +@@ -33,8 +33,6 @@ import net.minecraft.sounds.SoundEvent; + import net.minecraft.tags.TagKey; + import net.minecraft.util.Mth; + import net.minecraft.util.RandomSource; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import net.minecraft.world.Difficulty; + import net.minecraft.world.DifficultyInstance; + import net.minecraft.world.InteractionHand; +@@ -329,14 +327,10 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab + @Override + public void baseTick() { + super.baseTick(); +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push("mobBaseTick"); + if (this.isAlive() && this.random.nextInt(1000) < this.ambientSoundTime++) { + this.resetAmbientSoundTime(); + this.playAmbientSound(); + } +- +- profilerFiller.pop(); + } + + @Override +@@ -614,8 +608,6 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab + @Override + public void aiStep() { + super.aiStep(); +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push("looting"); + if (this.level() instanceof ServerLevel serverLevel + && this.canPickUpLoot() + && this.isAlive() +@@ -638,8 +630,6 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab + } + } + } +- +- profilerFiller.pop(); + } + + protected Vec3i getPickupReach() { +@@ -854,42 +844,21 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab + return; + } + // Paper end - Allow nerfed mobs to jump and float +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push("sensing"); + this.sensing.tick(); +- profilerFiller.pop(); + int i = this.tickCount + this.getId(); + if (i % 2 != 0 && this.tickCount > 1) { +- profilerFiller.push("targetSelector"); + this.targetSelector.tickRunningGoals(false); +- profilerFiller.pop(); +- profilerFiller.push("goalSelector"); + this.goalSelector.tickRunningGoals(false); +- profilerFiller.pop(); + } else { +- profilerFiller.push("targetSelector"); + this.targetSelector.tick(); +- profilerFiller.pop(); +- profilerFiller.push("goalSelector"); + this.goalSelector.tick(); +- profilerFiller.pop(); + } + +- profilerFiller.push("navigation"); + this.navigation.tick(); +- profilerFiller.pop(); +- profilerFiller.push("mob tick"); + this.customServerAiStep((ServerLevel)this.level()); +- profilerFiller.pop(); +- profilerFiller.push("controls"); +- profilerFiller.push("move"); + this.moveControl.tick(); +- profilerFiller.popPush("look"); + this.lookControl.tick(); +- profilerFiller.popPush("jump"); + this.jumpControl.tick(); +- profilerFiller.pop(); +- profilerFiller.pop(); + this.sendDebugPackets(); + } + +diff --git a/net/minecraft/world/entity/ai/goal/GoalSelector.java b/net/minecraft/world/entity/ai/goal/GoalSelector.java +index a927c2790c8ab9ccaa7161b970e10b0b44817dd8..b816b2de8eb327060ca6ea7c4afc17373fa77ff6 100644 +--- a/net/minecraft/world/entity/ai/goal/GoalSelector.java ++++ b/net/minecraft/world/entity/ai/goal/GoalSelector.java +@@ -7,8 +7,6 @@ import java.util.EnumSet; + import java.util.Map; + import java.util.Set; + import java.util.function.Predicate; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + + public class GoalSelector { + private static final WrappedGoal NO_GOAL = new WrappedGoal(Integer.MAX_VALUE, new Goal() { +@@ -84,9 +82,6 @@ public class GoalSelector { + } + + public void tick() { +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push("goalCleanup"); +- + for (WrappedGoal wrappedGoal : this.availableGoals) { + if (wrappedGoal.isRunning() && (goalContainsAnyFlags(wrappedGoal, this.goalTypes) || !wrappedGoal.canContinueToUse())) { // Paper - Perf: optimize goal types by removing streams + wrappedGoal.stop(); +@@ -94,8 +89,6 @@ public class GoalSelector { + } + + this.lockedFlags.entrySet().removeIf(entry -> !entry.getValue().isRunning()); +- profilerFiller.pop(); +- profilerFiller.push("goalUpdate"); + + for (WrappedGoal wrappedGoalx : this.availableGoals) { + // Paper start +@@ -115,21 +108,15 @@ public class GoalSelector { + } + } + +- profilerFiller.pop(); + this.tickRunningGoals(true); + } + + public void tickRunningGoals(boolean tickAllRunning) { +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push("goalTick"); +- + for (WrappedGoal wrappedGoal : this.availableGoals) { + if (wrappedGoal.isRunning() && (tickAllRunning || wrappedGoal.requiresUpdateEveryTick())) { + wrappedGoal.tick(); + } + } +- +- profilerFiller.pop(); + } + + public Set getAvailableGoals() { +diff --git a/net/minecraft/world/entity/ai/navigation/PathNavigation.java b/net/minecraft/world/entity/ai/navigation/PathNavigation.java +index b44f2c49509d847817a78e9c4fb1499fb378054b..6c8fb611943aee8cabc471c63166f9b44ef14826 100644 +--- a/net/minecraft/world/entity/ai/navigation/PathNavigation.java ++++ b/net/minecraft/world/entity/ai/navigation/PathNavigation.java +@@ -10,8 +10,6 @@ import net.minecraft.core.Vec3i; + import net.minecraft.network.protocol.game.DebugPackets; + import net.minecraft.tags.BlockTags; + import net.minecraft.util.Mth; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import net.minecraft.world.entity.Entity; + import net.minecraft.world.entity.Mob; + import net.minecraft.world.entity.ai.attributes.Attributes; +@@ -189,13 +187,10 @@ public abstract class PathNavigation { + } + } + // Paper end - EntityPathfindEvent +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push("pathfind"); + BlockPos blockPos = offsetUpward ? this.mob.blockPosition().above() : this.mob.blockPosition(); + int i = (int)(followRange + regionOffset); + PathNavigationRegion pathNavigationRegion = new PathNavigationRegion(this.level, blockPos.offset(-i, -i, -i), blockPos.offset(i, i, i)); + Path path = this.pathFinder.findPath(pathNavigationRegion, this.mob, targets, followRange, accuracy, this.maxVisitedNodesMultiplier); +- profilerFiller.pop(); + if (path != null && path.getTarget() != null) { + this.targetPos = path.getTarget(); + this.reachRange = accuracy; +diff --git a/net/minecraft/world/entity/ai/sensing/Sensing.java b/net/minecraft/world/entity/ai/sensing/Sensing.java +index c569074403b1d8b443aaa98ba9cf9bbd0e98bd2d..b1aa7294f9479f45fcde77c5ea46db9f62370abf 100644 +--- a/net/minecraft/world/entity/ai/sensing/Sensing.java ++++ b/net/minecraft/world/entity/ai/sensing/Sensing.java +@@ -2,8 +2,6 @@ package net.minecraft.world.entity.ai.sensing; + + import it.unimi.dsi.fastutil.ints.IntOpenHashSet; + import it.unimi.dsi.fastutil.ints.IntSet; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import net.minecraft.world.entity.Entity; + import net.minecraft.world.entity.Mob; + +@@ -28,10 +26,7 @@ public class Sensing { + } else if (this.unseen.contains(id)) { + return false; + } else { +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push("hasLineOfSight"); + boolean hasLineOfSight = this.mob.hasLineOfSight(entity); +- profilerFiller.pop(); + if (hasLineOfSight) { + this.seen.add(id); + } else { +diff --git a/net/minecraft/world/entity/animal/allay/Allay.java b/net/minecraft/world/entity/animal/allay/Allay.java +index aafb32295d4ce239609bb62e6bdf2261739f7aa0..0c863f8b4683516916d51a0c49921c6bb5608e9f 100644 +--- a/net/minecraft/world/entity/animal/allay/Allay.java ++++ b/net/minecraft/world/entity/animal/allay/Allay.java +@@ -30,8 +30,6 @@ import net.minecraft.tags.GameEventTags; + import net.minecraft.tags.ItemTags; + import net.minecraft.tags.TagKey; + import net.minecraft.util.Mth; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import net.minecraft.world.InteractionHand; + import net.minecraft.world.InteractionResult; + import net.minecraft.world.SimpleContainer; +@@ -245,13 +243,8 @@ public class Allay extends PathfinderMob implements InventoryCarrier, VibrationS + + @Override + protected void customServerAiStep(ServerLevel level) { +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push("allayBrain"); + this.getBrain().tick(level, this); +- profilerFiller.pop(); +- profilerFiller.push("allayActivityUpdate"); + AllayAi.updateActivity(this); +- profilerFiller.pop(); + super.customServerAiStep(level); + } + +diff --git a/net/minecraft/world/entity/animal/armadillo/Armadillo.java b/net/minecraft/world/entity/animal/armadillo/Armadillo.java +index dfdbcb31458095a71c187efc2774ecc4945dd11b..86e78ce740b27f9714145a690e8b182a2ccb3fb9 100644 +--- a/net/minecraft/world/entity/animal/armadillo/Armadillo.java ++++ b/net/minecraft/world/entity/animal/armadillo/Armadillo.java +@@ -23,8 +23,6 @@ import net.minecraft.util.ByIdMap; + import net.minecraft.util.RandomSource; + import net.minecraft.util.StringRepresentable; + import net.minecraft.util.TimeUtil; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import net.minecraft.world.InteractionHand; + import net.minecraft.world.InteractionResult; + import net.minecraft.world.damagesource.DamageSource; +@@ -133,13 +131,8 @@ public class Armadillo extends Animal { + + @Override + protected void customServerAiStep(ServerLevel level) { +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push("armadilloBrain"); + ((Brain)this.brain).tick(level, this); +- profilerFiller.pop(); +- profilerFiller.push("armadilloActivityUpdate"); + ArmadilloAi.updateActivity(this); +- profilerFiller.pop(); + if (this.isAlive() && !this.isBaby() && --this.scuteTime <= 0) { + this.forceDrops = true; // CraftBukkit + if (this.dropFromGiftLootTable(level, BuiltInLootTables.ARMADILLO_SHED, this::spawnAtLocation)) { +diff --git a/net/minecraft/world/entity/animal/axolotl/Axolotl.java b/net/minecraft/world/entity/animal/axolotl/Axolotl.java +index 9faa929734035c167e54569ce34d841291856589..c351b0808422221b5358d6e546a206ef75e8173f 100644 +--- a/net/minecraft/world/entity/animal/axolotl/Axolotl.java ++++ b/net/minecraft/world/entity/animal/axolotl/Axolotl.java +@@ -26,8 +26,6 @@ import net.minecraft.util.ByIdMap; + import net.minecraft.util.Mth; + import net.minecraft.util.RandomSource; + import net.minecraft.util.StringRepresentable; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import net.minecraft.world.DifficultyInstance; + import net.minecraft.world.InteractionHand; + import net.minecraft.world.InteractionResult; +@@ -302,13 +300,8 @@ public class Axolotl extends Animal implements VariantHolder, B + + @Override + protected void customServerAiStep(ServerLevel level) { +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push("axolotlBrain"); + this.getBrain().tick(level, this); +- profilerFiller.pop(); +- profilerFiller.push("axolotlActivityUpdate"); + AxolotlAi.updateActivity(this); +- profilerFiller.pop(); + if (!this.isNoAi()) { + Optional memory = this.getBrain().getMemory(MemoryModuleType.PLAY_DEAD_TICKS); + this.setPlayingDead(memory.isPresent() && memory.get() > 0); +diff --git a/net/minecraft/world/entity/animal/camel/Camel.java b/net/minecraft/world/entity/animal/camel/Camel.java +index 3ac169f83c5619b5c00c866354a2e066a0a738cc..1ac4b13554d2699c3e04d41946e1adfd5e854a17 100644 +--- a/net/minecraft/world/entity/animal/camel/Camel.java ++++ b/net/minecraft/world/entity/animal/camel/Camel.java +@@ -17,8 +17,6 @@ import net.minecraft.sounds.SoundSource; + import net.minecraft.tags.BlockTags; + import net.minecraft.tags.ItemTags; + import net.minecraft.util.Mth; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import net.minecraft.world.DifficultyInstance; + import net.minecraft.world.InteractionHand; + import net.minecraft.world.InteractionResult; +@@ -145,14 +143,9 @@ public class Camel extends AbstractHorse { + + @Override + protected void customServerAiStep(ServerLevel level) { +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push("camelBrain"); + Brain brain = this.getBrain(); + ((Brain)brain).tick(level, this); +- profilerFiller.pop(); +- profilerFiller.push("camelActivityUpdate"); + CamelAi.updateActivity(this); +- profilerFiller.pop(); + super.customServerAiStep(level); + } + +diff --git a/net/minecraft/world/entity/animal/frog/Frog.java b/net/minecraft/world/entity/animal/frog/Frog.java +index 12c655b60087a2f6122ffa508b3224159d8777b0..67df4c0f47b2809c912f1dfb52124ca5e2c30b7b 100644 +--- a/net/minecraft/world/entity/animal/frog/Frog.java ++++ b/net/minecraft/world/entity/animal/frog/Frog.java +@@ -28,8 +28,6 @@ import net.minecraft.tags.ItemTags; + import net.minecraft.util.Mth; + import net.minecraft.util.RandomSource; + import net.minecraft.util.Unit; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import net.minecraft.world.DifficultyInstance; + import net.minecraft.world.damagesource.DamageSource; + import net.minecraft.world.entity.AgeableMob; +@@ -186,13 +184,8 @@ public class Frog extends Animal implements VariantHolder> { + + @Override + protected void customServerAiStep(ServerLevel level) { +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push("frogBrain"); + this.getBrain().tick(level, this); +- profilerFiller.pop(); +- profilerFiller.push("frogActivityUpdate"); + FrogAi.updateActivity(this); +- profilerFiller.pop(); + super.customServerAiStep(level); + } + +diff --git a/net/minecraft/world/entity/animal/frog/Tadpole.java b/net/minecraft/world/entity/animal/frog/Tadpole.java +index 97adf8142cdd322c4873c420ed760e9dee34da23..a04d71967976731b4858d44ac138b7ac390ef7e7 100644 +--- a/net/minecraft/world/entity/animal/frog/Tadpole.java ++++ b/net/minecraft/world/entity/animal/frog/Tadpole.java +@@ -12,8 +12,6 @@ import net.minecraft.server.level.ServerLevel; + import net.minecraft.sounds.SoundEvent; + import net.minecraft.sounds.SoundEvents; + import net.minecraft.tags.ItemTags; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import net.minecraft.world.InteractionHand; + import net.minecraft.world.InteractionResult; + import net.minecraft.world.damagesource.DamageSource; +@@ -97,13 +95,8 @@ public class Tadpole extends AbstractFish { + + @Override + protected void customServerAiStep(ServerLevel level) { +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push("tadpoleBrain"); + this.getBrain().tick(level, this); +- profilerFiller.pop(); +- profilerFiller.push("tadpoleActivityUpdate"); + TadpoleAi.updateActivity(this); +- profilerFiller.pop(); + super.customServerAiStep(level); + } + +diff --git a/net/minecraft/world/entity/animal/goat/Goat.java b/net/minecraft/world/entity/animal/goat/Goat.java +index 504a30ead8d2bb13d559acbde62f9d44a5dda1cb..25c0c27979f49f08d0cc150de9afe6112f115666 100644 +--- a/net/minecraft/world/entity/animal/goat/Goat.java ++++ b/net/minecraft/world/entity/animal/goat/Goat.java +@@ -21,8 +21,6 @@ import net.minecraft.tags.ItemTags; + import net.minecraft.tags.TagKey; + import net.minecraft.util.Mth; + import net.minecraft.util.RandomSource; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import net.minecraft.world.DifficultyInstance; + import net.minecraft.world.InteractionHand; + import net.minecraft.world.InteractionResult; +@@ -186,13 +184,8 @@ public class Goat extends Animal { + + @Override + protected void customServerAiStep(ServerLevel level) { +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push("goatBrain"); + this.getBrain().tick(level, this); +- profilerFiller.pop(); +- profilerFiller.push("goatActivityUpdate"); + GoatAi.updateActivity(this); +- profilerFiller.pop(); + super.customServerAiStep(level); + } + +diff --git a/net/minecraft/world/entity/animal/sniffer/Sniffer.java b/net/minecraft/world/entity/animal/sniffer/Sniffer.java +index 62ca7871d1e5d0fe611948ad43e44c23fdc2d3f8..5f0efcfb88bee09f1cccc53cedbef22b14c5f554 100644 +--- a/net/minecraft/world/entity/animal/sniffer/Sniffer.java ++++ b/net/minecraft/world/entity/animal/sniffer/Sniffer.java +@@ -29,8 +29,6 @@ import net.minecraft.tags.BlockTags; + import net.minecraft.tags.ItemTags; + import net.minecraft.util.ByIdMap; + import net.minecraft.util.Mth; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import net.minecraft.world.InteractionHand; + import net.minecraft.world.InteractionResult; + import net.minecraft.world.damagesource.DamageSource; +@@ -454,12 +452,8 @@ public class Sniffer extends Animal { + + @Override + protected void customServerAiStep(ServerLevel level) { +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push("snifferBrain"); + this.getBrain().tick(level, this); +- profilerFiller.popPush("snifferActivityUpdate"); + SnifferAi.updateActivity(this); +- profilerFiller.pop(); + super.customServerAiStep(level); + } + +diff --git a/net/minecraft/world/entity/monster/Zoglin.java b/net/minecraft/world/entity/monster/Zoglin.java +index 9b94e74f6317f835500225b087fe93487a7a0b22..8a7418db237553719671f3cd51f42ebed1eb7804 100644 +--- a/net/minecraft/world/entity/monster/Zoglin.java ++++ b/net/minecraft/world/entity/monster/Zoglin.java +@@ -15,8 +15,6 @@ import net.minecraft.network.syncher.SynchedEntityData; + import net.minecraft.server.level.ServerLevel; + import net.minecraft.sounds.SoundEvent; + import net.minecraft.sounds.SoundEvents; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import net.minecraft.util.valueproviders.UniformInt; + import net.minecraft.world.DifficultyInstance; + import net.minecraft.world.damagesource.DamageSource; +@@ -248,10 +246,7 @@ public class Zoglin extends Monster implements HoglinBase { + + @Override + protected void customServerAiStep(ServerLevel level) { +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push("zoglinBrain"); + this.getBrain().tick(level, this); +- profilerFiller.pop(); + this.updateActivity(); + } + +diff --git a/net/minecraft/world/entity/monster/breeze/Breeze.java b/net/minecraft/world/entity/monster/breeze/Breeze.java +index 23dff1d01387ce89b020aa93de99e6ef557c04e3..fb643596bd5fb12e4cd323706f51a479d78a5455 100644 +--- a/net/minecraft/world/entity/monster/breeze/Breeze.java ++++ b/net/minecraft/world/entity/monster/breeze/Breeze.java +@@ -12,8 +12,6 @@ import net.minecraft.sounds.SoundEvent; + import net.minecraft.sounds.SoundEvents; + import net.minecraft.sounds.SoundSource; + import net.minecraft.tags.EntityTypeTags; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import net.minecraft.world.damagesource.DamageSource; + import net.minecraft.world.entity.AnimationState; + import net.minecraft.world.entity.Entity; +@@ -232,12 +230,8 @@ public class Breeze extends Monster { + + @Override + protected void customServerAiStep(ServerLevel level) { +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push("breezeBrain"); + this.getBrain().tick(level, this); +- profilerFiller.popPush("breezeActivityUpdate"); + BreezeAi.updateActivity(this); +- profilerFiller.pop(); + super.customServerAiStep(level); + } + +diff --git a/net/minecraft/world/entity/monster/creaking/Creaking.java b/net/minecraft/world/entity/monster/creaking/Creaking.java +index eba1e78352f956618b2796ce7cbe5d6f7e6591b6..6cd7d0f82bd97c6adb521eda3bc84c60f87c0cda 100644 +--- a/net/minecraft/world/entity/monster/creaking/Creaking.java ++++ b/net/minecraft/world/entity/monster/creaking/Creaking.java +@@ -18,8 +18,6 @@ import net.minecraft.server.level.ServerLevel; + import net.minecraft.sounds.SoundEvent; + import net.minecraft.sounds.SoundEvents; + import net.minecraft.tags.DamageTypeTags; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import net.minecraft.world.damagesource.DamageSource; + import net.minecraft.world.entity.AnimationState; + import net.minecraft.world.entity.Entity; +@@ -203,10 +201,7 @@ public class Creaking extends Monster { + + @Override + protected void customServerAiStep(ServerLevel level) { +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push("creakingBrain"); + this.getBrain().tick((ServerLevel)this.level(), this); +- profilerFiller.pop(); + CreakingAi.updateActivity(this); + } + +diff --git a/net/minecraft/world/entity/monster/hoglin/Hoglin.java b/net/minecraft/world/entity/monster/hoglin/Hoglin.java +index 0ddc0fe06a1b701f88ed8f8041ecd68f7da6c86d..fe0cd6790875631cb98a73457d53d782b369bf1d 100644 +--- a/net/minecraft/world/entity/monster/hoglin/Hoglin.java ++++ b/net/minecraft/world/entity/monster/hoglin/Hoglin.java +@@ -16,8 +16,6 @@ import net.minecraft.sounds.SoundEvents; + import net.minecraft.sounds.SoundSource; + import net.minecraft.tags.ItemTags; + import net.minecraft.util.RandomSource; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import net.minecraft.world.DifficultyInstance; + import net.minecraft.world.InteractionHand; + import net.minecraft.world.InteractionResult; +@@ -158,10 +156,7 @@ public class Hoglin extends Animal implements Enemy, HoglinBase { + + @Override + protected void customServerAiStep(ServerLevel level) { +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push("hoglinBrain"); + this.getBrain().tick(level, this); +- profilerFiller.pop(); + HoglinAi.updateActivity(this); + if (this.isConverting()) { + this.timeInOverworld++; +diff --git a/net/minecraft/world/entity/monster/piglin/Piglin.java b/net/minecraft/world/entity/monster/piglin/Piglin.java +index 0257eada48b35ea024520afe30596beae8a7ef1e..daef9043d0eacea948e39b1daa2618287aa40f14 100644 +--- a/net/minecraft/world/entity/monster/piglin/Piglin.java ++++ b/net/minecraft/world/entity/monster/piglin/Piglin.java +@@ -17,8 +17,6 @@ import net.minecraft.tags.ItemTags; + import net.minecraft.tags.TagKey; + import net.minecraft.util.RandomSource; + import net.minecraft.util.VisibleForDebug; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import net.minecraft.world.DifficultyInstance; + import net.minecraft.world.InteractionHand; + import net.minecraft.world.InteractionResult; +@@ -344,10 +342,7 @@ public class Piglin extends AbstractPiglin implements CrossbowAttackMob, Invento + + @Override + protected void customServerAiStep(ServerLevel level) { +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push("piglinBrain"); + this.getBrain().tick(level, this); +- profilerFiller.pop(); + PiglinAi.updateActivity(this); + super.customServerAiStep(level); + } +diff --git a/net/minecraft/world/entity/monster/piglin/PiglinBrute.java b/net/minecraft/world/entity/monster/piglin/PiglinBrute.java +index 0964b138e87357b7601ddfe937a2b9132afd5478..e5f91e64f61bdb7b7f7e3f101083e9bd5dbe7551 100644 +--- a/net/minecraft/world/entity/monster/piglin/PiglinBrute.java ++++ b/net/minecraft/world/entity/monster/piglin/PiglinBrute.java +@@ -8,8 +8,6 @@ import net.minecraft.server.level.ServerLevel; + import net.minecraft.sounds.SoundEvent; + import net.minecraft.sounds.SoundEvents; + import net.minecraft.util.RandomSource; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import net.minecraft.world.DifficultyInstance; + import net.minecraft.world.damagesource.DamageSource; + import net.minecraft.world.entity.EntitySpawnReason; +@@ -115,10 +113,7 @@ public class PiglinBrute extends AbstractPiglin { + + @Override + protected void customServerAiStep(ServerLevel level) { +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push("piglinBruteBrain"); + this.getBrain().tick(level, this); +- profilerFiller.pop(); + PiglinBruteAi.updateActivity(this); + PiglinBruteAi.maybePlayActivitySound(this); + super.customServerAiStep(level); +diff --git a/net/minecraft/world/entity/monster/warden/Warden.java b/net/minecraft/world/entity/monster/warden/Warden.java +index 9f476e587d7df797129e49738f101cccca7e10b7..1c56355fe9c216a7cc8afbbbe94988a0079c8244 100644 +--- a/net/minecraft/world/entity/monster/warden/Warden.java ++++ b/net/minecraft/world/entity/monster/warden/Warden.java +@@ -32,8 +32,6 @@ import net.minecraft.tags.TagKey; + import net.minecraft.util.Mth; + import net.minecraft.util.RandomSource; + import net.minecraft.util.Unit; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import net.minecraft.world.DifficultyInstance; + import net.minecraft.world.damagesource.DamageSource; + import net.minecraft.world.effect.MobEffectInstance; +@@ -284,10 +282,7 @@ public class Warden extends Monster implements VibrationSystem { + + @Override + protected void customServerAiStep(ServerLevel level) { +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push("wardenBrain"); + this.getBrain().tick(level, this); +- profilerFiller.pop(); + super.customServerAiStep(level); + if ((this.tickCount + this.getId()) % 120 == 0) { + applyDarknessAround(level, this.position(), this, 20); +diff --git a/net/minecraft/world/entity/npc/Villager.java b/net/minecraft/world/entity/npc/Villager.java +index 2b83262e4a13eae86df82913ce4f3121e3631a43..ee7b4080a9e1e51273f4b48f61caaa21ad7e59d9 100644 +--- a/net/minecraft/world/entity/npc/Villager.java ++++ b/net/minecraft/world/entity/npc/Villager.java +@@ -35,8 +35,6 @@ import net.minecraft.stats.Stats; + import net.minecraft.tags.ItemTags; + import net.minecraft.util.Mth; + import net.minecraft.util.SpawnUtil; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import net.minecraft.world.Difficulty; + import net.minecraft.world.DifficultyInstance; + import net.minecraft.world.InteractionHand; +@@ -291,10 +289,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler + } + protected void customServerAiStep(ServerLevel level, final boolean inactive) { + // Paper end - EAR 2 +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push("villagerBrain"); + if (!inactive) this.getBrain().tick(level, this); // Paper - EAR 2 +- profilerFiller.pop(); + if (this.assignProfessionWhenSpawned) { + this.assignProfessionWhenSpawned = false; + } +diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java +index b9c930210f750aa9594d3acae584a8d11983a210..73678ed00529af2369c66900c948de5fb46cc128 100644 +--- a/net/minecraft/world/level/Level.java ++++ b/net/minecraft/world/level/Level.java +@@ -35,8 +35,6 @@ import net.minecraft.util.AbortableIterationConsumer; + import net.minecraft.util.Mth; + import net.minecraft.util.RandomSource; + import net.minecraft.util.StringRepresentable; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import net.minecraft.world.DifficultyInstance; + import net.minecraft.world.TickRateManager; + import net.minecraft.world.damagesource.DamageSource; +@@ -228,7 +226,6 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl + + @Override + public final List getEntitiesOfClass(final Class entityClass, final AABB boundingBox, final Predicate predicate) { +- Profiler.get().incrementCounter("getEntities"); + final List ret = new java.util.ArrayList<>(); + + ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemLevel)this).moonrise$getEntityLookup().getEntities(entityClass, null, boundingBox, ret, predicate); +@@ -238,7 +235,6 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl + + @Override + public final List moonrise$getHardCollidingEntities(final Entity entity, final AABB box, final Predicate predicate) { +- Profiler.get().incrementCounter("getEntities"); + final List ret = new java.util.ArrayList<>(); + + ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemLevel)this).moonrise$getEntityLookup().getHardCollidingEntities(entity, box, ret, predicate); +@@ -1467,8 +1463,6 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl + } + + protected void tickBlockEntities() { +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push("blockEntities"); + this.tickingBlockEntities = true; + if (!this.pendingBlockEntityTickers.isEmpty()) { + this.blockEntityTickers.addAll(this.pendingBlockEntityTickers); +@@ -1499,7 +1493,6 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl + this.blockEntityTickers.removeAll(toRemove); // Paper - Fix MC-117075 + + this.tickingBlockEntities = false; +- profilerFiller.pop(); + this.spigotConfig.currentPrimedTnt = 0; // Spigot + } + +@@ -1758,7 +1751,6 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl + + @Override + public List getEntities(@Nullable Entity entity, AABB boundingBox, Predicate predicate) { +- Profiler.get().incrementCounter("getEntities"); + List list = Lists.newArrayList(); + + // Paper start - rewrite chunk system +@@ -1787,8 +1779,6 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl + public void getEntities(final EntityTypeTest entityTypeTest, + final AABB boundingBox, final Predicate predicate, + final List into, final int maxCount) { +- Profiler.get().incrementCounter("getEntities"); +- + if (entityTypeTest instanceof net.minecraft.world.entity.EntityType byType) { + if (maxCount != Integer.MAX_VALUE) { + ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemLevel)this).moonrise$getEntityLookup().getEntities(byType, boundingBox, into, predicate, maxCount); +diff --git a/net/minecraft/world/level/NaturalSpawner.java b/net/minecraft/world/level/NaturalSpawner.java +index 17ce115e887cbbb06ad02ab7ddb488e27342c0e4..4bee1ba137d078563cedfdd184a8b4603df17487 100644 +--- a/net/minecraft/world/level/NaturalSpawner.java ++++ b/net/minecraft/world/level/NaturalSpawner.java +@@ -23,8 +23,6 @@ import net.minecraft.tags.BlockTags; + import net.minecraft.util.Mth; + import net.minecraft.util.RandomSource; + import net.minecraft.util.VisibleForDebug; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import net.minecraft.util.random.WeightedRandomList; + import net.minecraft.world.entity.Entity; + import net.minecraft.world.entity.EntitySpawnReason; +@@ -158,9 +156,6 @@ public final class NaturalSpawner { + } + + public static void spawnForChunk(ServerLevel level, LevelChunk chunk, NaturalSpawner.SpawnState spawnState, List categories) { +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push("spawner"); +- + for (MobCategory mobCategory : categories) { + // Paper start - Optional per player mob spawns + final boolean canSpawn; +@@ -195,8 +190,6 @@ public final class NaturalSpawner { + // Paper end - Optional per player mob spawns + } + } +- +- profilerFiller.pop(); + } + + // Paper start - Add mobcaps commands +diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java +index 7b132c55caf9d3c3df3b0a123f4b5bfc7ae35984..ea22342896a608036042b5f5800302eae29f6c40 100644 +--- a/net/minecraft/world/level/ServerExplosion.java ++++ b/net/minecraft/world/level/ServerExplosion.java +@@ -13,8 +13,6 @@ import net.minecraft.Util; + import net.minecraft.core.BlockPos; + import net.minecraft.server.level.ServerLevel; + import net.minecraft.util.Mth; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import net.minecraft.world.damagesource.DamageSource; + import net.minecraft.world.entity.Entity; + import net.minecraft.world.entity.EntityType; +@@ -665,10 +663,7 @@ public class ServerExplosion implements Explosion { + List list = this.calculateExplodedPositions(); + this.hurtEntities(); + if (this.interactsWithBlocks()) { +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push("explosion_blocks"); + this.interactWithBlocks(list); +- profilerFiller.pop(); + } + + if (this.fire) { +diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java +index 761fdcd4a4e18f45547afd8edff44f61c6eeacb4..3a7707427691a7862499a7efa3b39ead1ef78013 100644 +--- a/net/minecraft/world/level/chunk/LevelChunk.java ++++ b/net/minecraft/world/level/chunk/LevelChunk.java +@@ -23,8 +23,6 @@ import net.minecraft.network.FriendlyByteBuf; + import net.minecraft.network.protocol.game.ClientboundLevelChunkPacketData; + import net.minecraft.server.level.FullChunkStatus; + import net.minecraft.server.level.ServerLevel; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import net.minecraft.world.entity.Entity; + import net.minecraft.world.level.ChunkPos; + import net.minecraft.world.level.Level; +@@ -386,12 +384,8 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p + } + + if (LightEngine.hasDifferentLightProperties(blockState, state)) { +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push("updateSkyLightSources"); + // Paper - rewrite chunk system +- profilerFiller.popPush("queueCheckLight"); + this.level.getChunkSource().getLightEngine().checkBlock(pos); +- profilerFiller.pop(); + } + + boolean hasBlockEntity = blockState.hasBlockEntity(); +@@ -911,8 +905,6 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p + BlockPos blockPos = this.blockEntity.getBlockPos(); + if (LevelChunk.this.isTicking(blockPos)) { + try { +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push(this::getType); + BlockState blockState = LevelChunk.this.getBlockState(blockPos); + if (this.blockEntity.getType().isValid(blockState)) { + this.ticker.tick(LevelChunk.this.level, this.blockEntity.getBlockPos(), blockState, this.blockEntity); +@@ -926,8 +918,6 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p + } + // Paper end - Remove the Block Entity if it's invalid + } +- +- profilerFiller.pop(); + } catch (Throwable var5) { + // Paper start - Prevent block entity and entity crashes + final String msg = String.format("BlockEntity threw exception at %s:%s,%s,%s", LevelChunk.this.getLevel().getWorld().getName(), this.getPos().getX(), this.getPos().getY(), this.getPos().getZ()); +diff --git a/net/minecraft/world/level/pathfinder/PathFinder.java b/net/minecraft/world/level/pathfinder/PathFinder.java +index 81de6c1bbef1cafd3036e736dd305fbedc8368c6..d48057d387b6937a0194e5300eb1cb46dec2896b 100644 +--- a/net/minecraft/world/level/pathfinder/PathFinder.java ++++ b/net/minecraft/world/level/pathfinder/PathFinder.java +@@ -12,9 +12,6 @@ import java.util.function.Function; + import java.util.stream.Collectors; + import javax.annotation.Nullable; + import net.minecraft.core.BlockPos; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; +-import net.minecraft.util.profiling.metrics.MetricCategory; + import net.minecraft.world.entity.Mob; + import net.minecraft.world.level.PathNavigationRegion; + +@@ -57,9 +54,6 @@ public class PathFinder { + + @Nullable + private Path findPath(Node node, List> positions, float maxRange, int accuracy, float searchDepthMultiplier) { // Paper - optimize collection +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push("find_path"); +- profilerFiller.markForCharting(MetricCategory.PATH_FINDING); + // Set set = targetPositions.keySet(); // Paper + node.g = 0.0F; + node.h = this.getBestH(node, positions); // Paper - optimize collection +@@ -129,7 +123,7 @@ public class PathFinder { + best = path; + } + } +- profilerFiller.pop(); ++ + return best; + // Paper end - Perf: remove streams and optimize collection + } +diff --git a/net/minecraft/world/ticks/LevelTicks.java b/net/minecraft/world/ticks/LevelTicks.java +index 66abc2e7adee60fa98eed1ba36e018814fd02cad..fbf0d3b808c66e8971c747619f6acf7417af5ef7 100644 +--- a/net/minecraft/world/ticks/LevelTicks.java ++++ b/net/minecraft/world/ticks/LevelTicks.java +@@ -23,8 +23,6 @@ import net.minecraft.Util; + import net.minecraft.core.BlockPos; + import net.minecraft.core.SectionPos; + import net.minecraft.core.Vec3i; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import net.minecraft.world.level.ChunkPos; + import net.minecraft.world.level.levelgen.structure.BoundingBox; + +@@ -80,20 +78,13 @@ public class LevelTicks implements LevelTickAccess { + } + + public void tick(long gameTime, int maxAllowedTicks, BiConsumer ticker) { +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push("collect"); +- this.collectTicks(gameTime, maxAllowedTicks, profilerFiller); +- profilerFiller.popPush("run"); +- profilerFiller.incrementCounter("ticksToRun", this.toRunThisTick.size()); ++ this.collectTicks(gameTime, maxAllowedTicks); // Gale - Purpur - remove vanilla profiler + this.runCollectedTicks(ticker); +- profilerFiller.popPush("cleanup"); + this.cleanupAfterTick(); +- profilerFiller.pop(); + } + +- private void collectTicks(long gameTime, int maxAllowedTicks, ProfilerFiller profiler) { ++ private void collectTicks(long gameTime, int maxAllowedTicks) { // Gale - Purpur - remove vanilla profiler + this.sortContainersToTick(gameTime); +- profiler.incrementCounter("containersToTick", this.containersToTick.size()); + this.drainContainers(gameTime, maxAllowedTicks); + this.rescheduleLeftoverContainers(); + } diff --git a/patches/server/0012-Use-platform-math-functions.patch b/gale-server/minecraft-patches/features/0005-Use-platform-math-functions.patch similarity index 86% rename from patches/server/0012-Use-platform-math-functions.patch rename to gale-server/minecraft-patches/features/0005-Use-platform-math-functions.patch index f139274..266d941 100644 --- a/patches/server/0012-Use-platform-math-functions.patch +++ b/gale-server/minecraft-patches/features/0005-Use-platform-math-functions.patch @@ -98,28 +98,28 @@ public class Main { } ``` -diff --git a/src/main/java/net/minecraft/util/Mth.java b/src/main/java/net/minecraft/util/Mth.java -index f298cdfcf1539e467f57f9f7789de3cf2ca54665..3468b7fbc7440f220fce8039f237658a593df296 100644 ---- a/src/main/java/net/minecraft/util/Mth.java -+++ b/src/main/java/net/minecraft/util/Mth.java +diff --git a/net/minecraft/util/Mth.java b/net/minecraft/util/Mth.java +index d5d8134da9423cec199cf44762460104677194d6..e0eed27cb33348fcb46858c40014b5fe5dbaf426 100644 +--- a/net/minecraft/util/Mth.java ++++ b/net/minecraft/util/Mth.java @@ -58,18 +58,15 @@ public class Mth { } public static int floor(float value) { - int i = (int)value; -- return value < (float)i ? i - 1 : i; +- return value < i ? i - 1 : i; + return (int) Math.floor(value); // Gale - use platform math functions } public static int floor(double value) { - int i = (int)value; -- return value < (double)i ? i - 1 : i; +- return value < i ? i - 1 : i; + return (int) Math.floor(value); // Gale - use platform math functions } public static long lfloor(double value) { - long l = (long)value; -- return value < (double)l ? l - 1L : l; +- return value < l ? l - 1L : l; + return (long) Math.floor(value); // Gale - use platform math functions } @@ -129,13 +129,13 @@ index f298cdfcf1539e467f57f9f7789de3cf2ca54665..3468b7fbc7440f220fce8039f237658a public static int ceil(float value) { - int i = (int)value; -- return value > (float)i ? i + 1 : i; +- return value > i ? i + 1 : i; + return (int) Math.ceil(value); // Gale - use platform math functions } public static int ceil(double value) { - int i = (int)value; -- return value > (double)i ? i + 1 : i; +- return value > i ? i + 1 : i; + return (int) Math.ceil(value); // Gale - use platform math functions } @@ -143,17 +143,17 @@ index f298cdfcf1539e467f57f9f7789de3cf2ca54665..3468b7fbc7440f220fce8039f237658a @@ -123,15 +118,7 @@ public class Mth { } - public static double absMax(double a, double b) { -- if (a < 0.0) { -- a = -a; + public static double absMax(double x, double y) { +- if (x < 0.0) { +- x = -x; - } - -- if (b < 0.0) { -- b = -b; +- if (y < 0.0) { +- y = -y; - } - -- return Math.max(a, b); -+ return Math.max(Math.abs(a), Math.abs(b)); // Gale - use platform math functions +- return Math.max(x, y); ++ return Math.max(Math.abs(x), Math.abs(y)); // Gale - use platform math functions } public static int floorDiv(int dividend, int divisor) { diff --git a/gale-server/minecraft-patches/features/0006-Faster-floating-point-positive-modulo.patch b/gale-server/minecraft-patches/features/0006-Faster-floating-point-positive-modulo.patch new file mode 100644 index 0000000..5a8e00e --- /dev/null +++ b/gale-server/minecraft-patches/features/0006-Faster-floating-point-positive-modulo.patch @@ -0,0 +1,54 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Tue, 29 Aug 2023 22:29:08 +0200 +Subject: [PATCH] Faster floating-point positive modulo + +License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) +Gale - https://galemc.org + +diff --git a/net/minecraft/util/Mth.java b/net/minecraft/util/Mth.java +index e0eed27cb33348fcb46858c40014b5fe5dbaf426..85c329437f27fc2fc143d2873572f8d3cf30660d 100644 +--- a/net/minecraft/util/Mth.java ++++ b/net/minecraft/util/Mth.java +@@ -149,14 +149,26 @@ public class Mth { + return Math.floorMod(x, y); + } + +- public static float positiveModulo(float numerator, float denominator) { ++ public static float positiveModuloForAnyDenominator(float numerator, float denominator) { // Gale - faster floating-point positive modulo + return (numerator % denominator + denominator) % denominator; + } + +- public static double positiveModulo(double numerator, double denominator) { ++ public static double positiveModuloForAnyDenominator(double numerator, double denominator) { // Gale - faster floating-point positive modulo + return (numerator % denominator + denominator) % denominator; + } + ++ // Gale start - faster floating-point positive modulo ++ public static float positiveModuloForPositiveIntegerDenominator(float numerator, float denominator) { ++ var modulo = numerator % denominator; ++ return modulo < 0 ? modulo + denominator : modulo; ++ } ++ ++ public static double positiveModuloForPositiveIntegerDenominator(double numerator, double denominator) { ++ var modulo = numerator % denominator; ++ return modulo < 0 ? modulo + denominator : modulo; ++ } ++ // Gale end - faster floating-point positive modulo ++ + public static boolean isMultipleOf(int number, int multiple) { + return number % multiple == 0; + } +diff --git a/net/minecraft/world/level/levelgen/blending/Blender.java b/net/minecraft/world/level/levelgen/blending/Blender.java +index 01e5b29d6e9a5c53c0e23b61ed0c1d7be1a0fe08..314a189e2099e3688fd23e7100120abea6886ccd 100644 +--- a/net/minecraft/world/level/levelgen/blending/Blender.java ++++ b/net/minecraft/world/level/levelgen/blending/Blender.java +@@ -144,7 +144,7 @@ public class Blender { + private static double heightToOffset(double height) { + double d = 1.0; + double d1 = height + 0.5; +- double d2 = Mth.positiveModulo(d1, 8.0); ++ double d2 = Mth.positiveModuloForPositiveIntegerDenominator(d1, 8.0); // Gale - faster floating-point positive modulo + return 1.0 * (32.0 * (d1 - 128.0) - 3.0 * (d1 - 120.0) * d2 + 3.0 * d2 * d2) / (128.0 * (32.0 - 3.0 * d2)); + } + diff --git a/patches/server/0014-Simpler-ShapelessRecipe-comparison-for-vanilla.patch b/gale-server/minecraft-patches/features/0007-Simpler-ShapelessRecipe-comparison-for-vanilla.patch similarity index 65% rename from patches/server/0014-Simpler-ShapelessRecipe-comparison-for-vanilla.patch rename to gale-server/minecraft-patches/features/0007-Simpler-ShapelessRecipe-comparison-for-vanilla.patch index 202ba9a..0106f23 100644 --- a/patches/server/0014-Simpler-ShapelessRecipe-comparison-for-vanilla.patch +++ b/gale-server/minecraft-patches/features/0007-Simpler-ShapelessRecipe-comparison-for-vanilla.patch @@ -36,11 +36,11 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -diff --git a/src/main/java/net/minecraft/world/item/crafting/ShapelessRecipe.java b/src/main/java/net/minecraft/world/item/crafting/ShapelessRecipe.java -index 12f95bee2a69fd5df7c4a165537e01299e60c5f6..6567b103b27db2841d67c8f296ba6c57781b2b65 100644 ---- a/src/main/java/net/minecraft/world/item/crafting/ShapelessRecipe.java -+++ b/src/main/java/net/minecraft/world/item/crafting/ShapelessRecipe.java -@@ -31,8 +31,15 @@ public class ShapelessRecipe implements CraftingRecipe { +diff --git a/net/minecraft/world/item/crafting/ShapelessRecipe.java b/net/minecraft/world/item/crafting/ShapelessRecipe.java +index d601b54b1de2f2ae44fe2b20c8116c71a6340e45..03df50182a13978c88b05eff13e33de325de08c4 100644 +--- a/net/minecraft/world/item/crafting/ShapelessRecipe.java ++++ b/net/minecraft/world/item/crafting/ShapelessRecipe.java +@@ -23,8 +23,15 @@ public class ShapelessRecipe implements CraftingRecipe { final List ingredients; @Nullable private PlacementInfo placementInfo; @@ -56,10 +56,10 @@ index 12f95bee2a69fd5df7c4a165537e01299e60c5f6..6567b103b27db2841d67c8f296ba6c57 this.group = group; this.category = category; this.result = result; -@@ -80,6 +87,28 @@ public class ShapelessRecipe implements CraftingRecipe { - } +@@ -72,6 +79,28 @@ public class ShapelessRecipe implements CraftingRecipe { - public boolean matches(CraftingInput input, Level world) { + @Override + public boolean matches(CraftingInput input, Level level) { + // Gale start - Airplane - simpler ShapelessRecipe comparison for vanilla + if (!this.isBukkit) { + java.util.List ingredients = com.google.common.collect.Lists.newArrayList(this.ingredients.toArray(new Ingredient[0])); @@ -85,15 +85,3 @@ index 12f95bee2a69fd5df7c4a165537e01299e60c5f6..6567b103b27db2841d67c8f296ba6c57 // Paper start - Improve exact choice recipe ingredients & unwrap ternary if (input.ingredientCount() != this.ingredients.size()) { return false; -diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java -index 7c989318dc7ad89bb0d9143fcaac1e4bba6f5907..a90b294a99072ab576e61ddacb60a036cb7f0f5a 100644 ---- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java -+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java -@@ -44,6 +44,6 @@ public class CraftShapelessRecipe extends ShapelessRecipe implements CraftRecipe - data.add(this.toNMS(i, true)); - } - -- MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftRecipe.toMinecraft(this.getKey()), new net.minecraft.world.item.crafting.ShapelessRecipe(this.getGroup(), CraftRecipe.getCategory(this.getCategory()), CraftItemStack.asNMSCopy(this.getResult()), data))); -+ MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftRecipe.toMinecraft(this.getKey()), new net.minecraft.world.item.crafting.ShapelessRecipe(this.getGroup(), CraftRecipe.getCategory(this.getCategory()), CraftItemStack.asNMSCopy(this.getResult()), data, true))); // Gale - Airplane - simpler ShapelessRecipe comparison for vanilla - } - } diff --git a/patches/server/0015-Reduce-projectile-chunk-loading.patch b/gale-server/minecraft-patches/features/0008-Reduce-projectile-chunk-loading.patch similarity index 63% rename from patches/server/0015-Reduce-projectile-chunk-loading.patch rename to gale-server/minecraft-patches/features/0008-Reduce-projectile-chunk-loading.patch index e75ab5a..9e6a364 100644 --- a/patches/server/0015-Reduce-projectile-chunk-loading.patch +++ b/gale-server/minecraft-patches/features/0008-Reduce-projectile-chunk-loading.patch @@ -30,12 +30,12 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -diff --git a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java -index 6c2d4d6f3a36ab452dfd3c33f66e54f152906639..507a7f2116b020a5af4b8fff15b73dba9904874f 100644 ---- a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java -+++ b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java -@@ -58,6 +58,45 @@ public abstract class Projectile extends Entity implements TraceableEntity { - super(type, world); +diff --git a/net/minecraft/world/entity/projectile/Projectile.java b/net/minecraft/world/entity/projectile/Projectile.java +index af71a71ff11b418a43728fd464b1e673d593140f..689fede25ae3f73ebe897ab9b8abd70ead032f06 100644 +--- a/net/minecraft/world/entity/projectile/Projectile.java ++++ b/net/minecraft/world/entity/projectile/Projectile.java +@@ -49,6 +49,45 @@ public abstract class Projectile extends Entity implements TraceableEntity { + super(entityType, level); } + // Gale start - Airplane - reduce projectile chunk loading @@ -77,33 +77,6 @@ index 6c2d4d6f3a36ab452dfd3c33f66e54f152906639..507a7f2116b020a5af4b8fff15b73dba + } + // Gale end - Airplane - reduce projectile chunk loading + - public void setOwner(@Nullable Entity entity) { - if (entity != null) { - this.ownerUUID = entity.getUUID(); -diff --git a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -index b82bb95b524c95cdefb81abef906eded0717e9a1..eabe9e6a7f99a7ad1f2a9f210f8a7489a89dc4cc 100644 ---- a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -+++ b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -@@ -33,7 +33,21 @@ public class GaleWorldConfiguration extends ConfigurationPart { - public SmallOptimizations smallOptimizations; - public class SmallOptimizations extends ConfigurationPart { - -- public int dummyValue = 0; -+ // Gale start - Airplane - reduce projectile chunk loading -+ public MaxProjectileChunkLoads maxProjectileChunkLoads; -+ public class MaxProjectileChunkLoads extends ConfigurationPart { -+ -+ public int perTick = 10; -+ -+ public PerProjectile perProjectile; -+ public class PerProjectile extends ConfigurationPart { -+ public int max = 10; -+ public boolean resetMovementAfterReachLimit = false; -+ public boolean removeFromWorldAfterReachLimit = false; -+ } -+ -+ } -+ // Gale end - Airplane - reduce projectile chunk loading - - } - + public void setOwner(@Nullable Entity owner) { + if (owner != null) { + this.ownerUUID = owner.getUUID(); diff --git a/patches/server/0016-Predict-Halloween.patch b/gale-server/minecraft-patches/features/0009-Predict-Halloween.patch similarity index 82% rename from patches/server/0016-Predict-Halloween.patch rename to gale-server/minecraft-patches/features/0009-Predict-Halloween.patch index 34b6e4b..b1357b3 100644 --- a/patches/server/0016-Predict-Halloween.patch +++ b/gale-server/minecraft-patches/features/0009-Predict-Halloween.patch @@ -6,11 +6,11 @@ Subject: [PATCH] Predict Halloween License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) Gale - https://galemc.org -diff --git a/src/main/java/net/minecraft/world/entity/ambient/Bat.java b/src/main/java/net/minecraft/world/entity/ambient/Bat.java -index 60c2868f255d372226e0c1389caaa5477bbef41e..05ab901becfc7ffe4e4483ac2c7acb2e2a72490f 100644 ---- a/src/main/java/net/minecraft/world/entity/ambient/Bat.java -+++ b/src/main/java/net/minecraft/world/entity/ambient/Bat.java -@@ -242,12 +242,66 @@ public class Bat extends AmbientCreature { +diff --git a/net/minecraft/world/entity/ambient/Bat.java b/net/minecraft/world/entity/ambient/Bat.java +index 5ebe7b1dce367d5c5e1136b97b2b9f6737595201..62085eecd2bb55721208c5fd126aaae56a50ed6b 100644 +--- a/net/minecraft/world/entity/ambient/Bat.java ++++ b/net/minecraft/world/entity/ambient/Bat.java +@@ -243,11 +243,66 @@ public class Bat extends AmbientCreature { } } @@ -52,12 +52,12 @@ index 60c2868f255d372226e0c1389caaa5477bbef41e..05ab901becfc7ffe4e4483ac2c7acb2e + // and `nextHalloweenEnd` will adjust to the epoch ms of date of next year + // These two fields will not change during current Halloween period. private static boolean isHalloween() { -- LocalDate localdate = LocalDate.now(); -- int i = localdate.get(ChronoField.DAY_OF_MONTH); -- int j = localdate.get(ChronoField.MONTH_OF_YEAR); +- LocalDate localDate = LocalDate.now(); +- int i = localDate.get(ChronoField.DAY_OF_MONTH); +- int i1 = localDate.get(ChronoField.MONTH_OF_YEAR); +- return i1 == 10 && i >= 20 || i1 == 11 && i <= 3; + long currentEpochMillis = System.currentTimeMillis(); - -- return j == 10 && i >= 20 || j == 11 && i <= 3; ++ + if (currentEpochMillis > nextHalloweenEnd) { + // Update prediction + diff --git a/patches/server/0017-Move-random-tick-random.patch b/gale-server/minecraft-patches/features/0010-Move-random-tick-random.patch similarity index 72% rename from patches/server/0017-Move-random-tick-random.patch rename to gale-server/minecraft-patches/features/0010-Move-random-tick-random.patch index 9e9f169..8091b51 100644 --- a/patches/server/0017-Move-random-tick-random.patch +++ b/gale-server/minecraft-patches/features/0010-Move-random-tick-random.patch @@ -18,11 +18,11 @@ ThreadUnsafeRandom is initialized too late and some of our patches require it to be initialized earlier. By moving it to the superclass, we initialize it earlier, ensuring that it is available sooner. -diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index af783a62991cf996cf488ac7bdb7335082609337..d0b36a5340776e18469b35e0459b3b5d26c051c2 100644 ---- a/src/main/java/net/minecraft/server/level/ServerLevel.java -+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java -@@ -843,8 +843,6 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java +index 93b0265e3b1ea133877682721ff28d735d9b688b..e43fa760210cb4c956b2143a65452eecf5f923f4 100644 +--- a/net/minecraft/server/level/ServerLevel.java ++++ b/net/minecraft/server/level/ServerLevel.java +@@ -841,8 +841,6 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe } // Paper start - optimise random ticking @@ -31,11 +31,11 @@ index af783a62991cf996cf488ac7bdb7335082609337..d0b36a5340776e18469b35e0459b3b5d private void optimiseRandomTick(final LevelChunk chunk, final int tickSpeed) { final LevelChunkSection[] sections = chunk.getSections(); final int minSection = ca.spottedleaf.moonrise.common.util.WorldUtil.getMinSection((ServerLevel)(Object)this); -diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index 37ed8ec7cac117e674d39a3dbc3ce8b99e4459e9..5419efc40cd27c532acff423edaa259edacd862a 100644 ---- a/src/main/java/net/minecraft/world/level/Level.java -+++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -185,6 +185,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java +index 73678ed00529af2369c66900c948de5fb46cc128..c4563e827a8333d57aabce1ff8e4c28d7e3a295b 100644 +--- a/net/minecraft/world/level/Level.java ++++ b/net/minecraft/world/level/Level.java +@@ -181,6 +181,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl public final Map explosionDensityCache = new HashMap<>(); // Paper - Optimize explosions public java.util.ArrayDeque redstoneUpdateInfos; // Paper - Faster redstone torch rapid clock removal; Move from Map in BlockRedstoneTorch to here diff --git a/patches/server/0018-Optimize-random-calls-in-chunk-ticking.patch b/gale-server/minecraft-patches/features/0011-Optimize-random-calls-in-chunk-ticking.patch similarity index 58% rename from patches/server/0018-Optimize-random-calls-in-chunk-ticking.patch rename to gale-server/minecraft-patches/features/0011-Optimize-random-calls-in-chunk-ticking.patch index 1c29739..6bf96a7 100644 --- a/patches/server/0018-Optimize-random-calls-in-chunk-ticking.patch +++ b/gale-server/minecraft-patches/features/0011-Optimize-random-calls-in-chunk-ticking.patch @@ -51,23 +51,23 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index 2b8c4ee8ad8eb96060e82911c07b01f7b01a4329..370d8ab3cb7f4b066d94b2f4eeda794b79179fa7 100644 ---- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java -+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -@@ -468,6 +468,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon - - this.lastInhabitedUpdate = i; +diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java +index 9500fc2f841819b0d40e8a6e48353bb28b6dbe49..5c8d76b80c6cefd87088282e59f5f0f72a4f1611 100644 +--- a/net/minecraft/server/level/ServerChunkCache.java ++++ b/net/minecraft/server/level/ServerChunkCache.java +@@ -495,6 +495,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon + long l = gameTime - this.lastInhabitedUpdate; + this.lastInhabitedUpdate = gameTime; if (!this.level.isDebug()) { + this.level.resetIceAndSnowTick(); // Gale - Airplane - optimize random calls in chunk ticking - reset ice & snow tick random if (this.level.tickRateManager().runsNormally()) { List list = this.tickingChunks; -diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index d0b36a5340776e18469b35e0459b3b5d26c051c2..b424fe78d3c9410e6d6378a7f104cfd5069f0d1e 100644 ---- a/src/main/java/net/minecraft/server/level/ServerLevel.java -+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java -@@ -892,6 +892,8 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java +index e43fa760210cb4c956b2143a65452eecf5f923f4..b35fe7112f2ad94e85e98931c403b3ffa8608382 100644 +--- a/net/minecraft/server/level/ServerLevel.java ++++ b/net/minecraft/server/level/ServerLevel.java +@@ -890,13 +890,15 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe } // Paper end - optimise random ticking @@ -75,32 +75,31 @@ index d0b36a5340776e18469b35e0459b3b5d26c051c2..b424fe78d3c9410e6d6378a7f104cfd5 + public void tickChunk(LevelChunk chunk, int randomTickSpeed) { final ca.spottedleaf.moonrise.common.util.SimpleThreadUnsafeRandom simpleRandom = this.simpleRandom; // Paper - optimise random ticking - ChunkPos chunkcoordintpair = chunk.getPos(); -@@ -899,7 +901,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe - int j = chunkcoordintpair.getMinBlockX(); - int k = chunkcoordintpair.getMinBlockZ(); - -- if (!this.paperConfig().environment.disableThunder && flag && this.isThundering() && this.spigotConfig.thunderChance > 0 && simpleRandom.nextInt(this.spigotConfig.thunderChance) == 0) { // Spigot // Paper - Option to disable thunder // Paper - optimise random ticking -+ if (!this.paperConfig().environment.disableThunder && flag && this.isThundering() && this.spigotConfig.thunderChance > 0 /*&& simpleRandom.nextInt(this.spigotConfig.thunderChance) == 0*/ && chunk.shouldDoLightning(this.random)) { // Spigot // Paper - Option to disable thunder // Paper - optimise random ticking // Gale - Airplane - optimize random calls in chunk ticking - replace random with shouldDoLightning - BlockPos blockposition = this.findLightningTargetAround(this.getBlockRandomPos(j, 0, k, 15)); - - if (this.isRainingAt(blockposition)) { -@@ -927,7 +929,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe + ChunkPos pos = chunk.getPos(); + boolean isRaining = this.isRaining(); + int minBlockX = pos.getMinBlockX(); + int minBlockZ = pos.getMinBlockZ(); +- if (!this.paperConfig().environment.disableThunder && isRaining && this.isThundering() && this.spigotConfig.thunderChance > 0 && simpleRandom.nextInt(this.spigotConfig.thunderChance) == 0) { // Spigot // Paper - Option to disable thunder // Paper - optimise random ticking ++ if (!this.paperConfig().environment.disableThunder && isRaining && this.isThundering() && this.spigotConfig.thunderChance > 0 /*&& simpleRandom.nextInt(this.spigotConfig.thunderChance) == 0*/ && chunk.shouldDoLightning(this.random)) { // Spigot // Paper - Option to disable thunder // Paper - optimise random ticking // Gale - Airplane - optimize random calls in chunk ticking - replace random with shouldDoLightning + BlockPos blockPos = this.findLightningTargetAround(this.getBlockRandomPos(minBlockX, 0, minBlockZ, 15)); + if (this.isRainingAt(blockPos)) { + DifficultyInstance currentDifficultyAt = this.getCurrentDifficultyAt(blockPos); +@@ -922,7 +924,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe } } - if (!this.paperConfig().environment.disableIceAndSnow) { // Paper - Option to disable ice and snow + if (!this.paperConfig().environment.disableIceAndSnow && (this.currentIceAndSnowTick++ & 15) == 0) { // Paper - Option to disable ice and snow // Gale - Airplane - optimize random calls in chunk ticking - optimize further random ticking - for (int l = 0; l < randomTickSpeed; ++l) { - if (simpleRandom.nextInt(48) == 0) { // Paper - optimise random ticking - this.tickPrecipitation(this.getBlockRandomPos(j, 0, k, 15)); -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 09a6d7410bc029889ce4b89ab149a52f31468b9b..3f6d60601cbfc138ab004e38bf442d985192fd3f 100644 ---- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java -+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java -@@ -86,6 +86,18 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p - private final LevelChunkTicks fluidTicks; - private LevelChunk.UnsavedListener unsavedListener; + for (int i = 0; i < randomTickSpeed; i++) { + if (simpleRandom.nextInt(48) == 0) { // Paper - optimise random ticking + this.tickPrecipitation(this.getBlockRandomPos(minBlockX, 0, minBlockZ, 15)); +diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java +index 3a7707427691a7862499a7efa3b39ead1ef78013..95972e7d5e0357ff5884f1cb2f7596c5029f999d 100644 +--- a/net/minecraft/world/level/chunk/LevelChunk.java ++++ b/net/minecraft/world/level/chunk/LevelChunk.java +@@ -125,6 +125,18 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p + } + // Paper end - get block chunk optimisation + // Gale start - Airplane - optimize random calls in chunk ticking - instead of using a random every time the chunk is ticked, define when lightning strikes preemptively + private int lightningTick; @@ -114,10 +113,10 @@ index 09a6d7410bc029889ce4b89ab149a52f31468b9b..3f6d60601cbfc138ab004e38bf442d98 + } + // Gale end - Airplane - optimize random calls in chunk ticking - instead of using a random every time the chunk is ticked, define when lightning strikes preemptively + - public LevelChunk(Level world, ChunkPos pos) { - this(world, pos, UpgradeData.EMPTY, new LevelChunkTicks<>(), new LevelChunkTicks<>(), 0L, (LevelChunkSection[]) null, (LevelChunk.PostLoadProcessor) null, (BlendingData) null); + public LevelChunk(Level level, ChunkPos pos) { + this(level, pos, UpgradeData.EMPTY, new LevelChunkTicks<>(), new LevelChunkTicks<>(), 0L, null, null, null); } -@@ -119,6 +131,8 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p +@@ -161,6 +173,8 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p this.debug = !empty && this.level.isDebug(); this.defaultBlockState = empty ? VOID_AIR_BLOCKSTATE : AIR_BLOCKSTATE; // Paper end - get block chunk optimisation @@ -125,4 +124,4 @@ index 09a6d7410bc029889ce4b89ab149a52f31468b9b..3f6d60601cbfc138ab004e38bf442d98 + this.lightningTick = this.level.simpleRandom.nextInt(100000) << 1; // Gale - Airplane - optimize random calls in chunk ticking - initialize lightning tick } - // CraftBukkit start + public LevelChunk(ServerLevel level, ProtoChunk chunk, @Nullable LevelChunk.PostLoadProcessor postLoad) { diff --git a/patches/server/0019-Reduce-enderman-teleport-chunk-lookups.patch b/gale-server/minecraft-patches/features/0012-Reduce-enderman-teleport-chunk-lookups.patch similarity index 53% rename from patches/server/0019-Reduce-enderman-teleport-chunk-lookups.patch rename to gale-server/minecraft-patches/features/0012-Reduce-enderman-teleport-chunk-lookups.patch index b0b82f2..d024b19 100644 --- a/patches/server/0019-Reduce-enderman-teleport-chunk-lookups.patch +++ b/gale-server/minecraft-patches/features/0012-Reduce-enderman-teleport-chunk-lookups.patch @@ -30,28 +30,28 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -diff --git a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java -index 48dcd2bc12ce1d08cc5195bff5460dc0dd9902d3..35ffcd82df6af65a9c1b9a1a6acdd8b7567b8645 100644 ---- a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java -+++ b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java -@@ -307,11 +307,18 @@ public class EnderMan extends Monster implements NeutralMob { +diff --git a/net/minecraft/world/entity/monster/EnderMan.java b/net/minecraft/world/entity/monster/EnderMan.java +index 4b5ffd278e0e9d47100e5452949e8d757bbfece4..c7a77b16ba032eb24b070fd6a5f0f824b3cbcc1a 100644 +--- a/net/minecraft/world/entity/monster/EnderMan.java ++++ b/net/minecraft/world/entity/monster/EnderMan.java +@@ -309,11 +309,18 @@ public class EnderMan extends Monster implements NeutralMob { private boolean teleport(double x, double y, double z) { - BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos(x, y, z); + BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(x, y, z); -- while (blockposition_mutableblockposition.getY() > this.level().getMinY() && !this.level().getBlockState(blockposition_mutableblockposition).blocksMotion()) { +- while (mutableBlockPos.getY() > this.level().getMinY() && !this.level().getBlockState(mutableBlockPos).blocksMotion()) { + // Gale start - Airplane - single chunk lookup -+ net.minecraft.world.level.chunk.LevelChunk chunk = this.level().getChunkIfLoaded(blockposition_mutableblockposition); ++ net.minecraft.world.level.chunk.LevelChunk chunk = this.level().getChunkIfLoaded(mutableBlockPos); + if (chunk == null) { + return false; + } + -+ while (blockposition_mutableblockposition.getY() > this.level().getMinY() && !chunk.getBlockState(blockposition_mutableblockposition).blocksMotion()) { ++ while (mutableBlockPos.getY() > this.level().getMinY() && !chunk.getBlockState(mutableBlockPos).blocksMotion()) { + // Gale end - Airplane - single chunk lookup - blockposition_mutableblockposition.move(Direction.DOWN); + mutableBlockPos.move(Direction.DOWN); } -- BlockState iblockdata = this.level().getBlockState(blockposition_mutableblockposition); -+ BlockState iblockdata = chunk.getBlockState(blockposition_mutableblockposition); // Gale - Airplane - single chunk lookup - boolean flag = iblockdata.blocksMotion(); - boolean flag1 = iblockdata.getFluidState().is(FluidTags.WATER); - +- BlockState blockState = this.level().getBlockState(mutableBlockPos); ++ BlockState blockState = chunk.getBlockState(mutableBlockPos); // Gale - Airplane - single chunk lookup + boolean flag = blockState.blocksMotion(); + boolean isWater = blockState.getFluidState().is(FluidTags.WATER); + if (flag && !isWater) { diff --git a/gale-server/minecraft-patches/features/0013-Reduce-acquire-POI-for-stuck-entities.patch b/gale-server/minecraft-patches/features/0013-Reduce-acquire-POI-for-stuck-entities.patch new file mode 100644 index 0000000..5ae5466 --- /dev/null +++ b/gale-server/minecraft-patches/features/0013-Reduce-acquire-POI-for-stuck-entities.patch @@ -0,0 +1,65 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Wed, 23 Nov 2022 20:12:48 +0100 +Subject: [PATCH] Reduce acquire POI for stuck entities + +License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) +Gale - https://galemc.org + +This patch is based on the following patch: +"Skip POI finding if stuck in vehicle" +By: Paul Sauve +As part of: Airplane (https://github.com/TECHNOVE/Airplane) +Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) + +* Airplane copyright * + +Airplane +Copyright (C) 2020 Technove LLC + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . + +diff --git a/net/minecraft/world/entity/ai/behavior/AcquirePoi.java b/net/minecraft/world/entity/ai/behavior/AcquirePoi.java +index b9174ae7e3a3e2de2d570b95ab5012ac3c3a2eda..751e91a922b20c96f27885c3eb085ec4ae39091b 100644 +--- a/net/minecraft/world/entity/ai/behavior/AcquirePoi.java ++++ b/net/minecraft/world/entity/ai/behavior/AcquirePoi.java +@@ -28,6 +28,13 @@ import org.apache.commons.lang3.mutable.MutableLong; + public class AcquirePoi { + public static final int SCAN_RANGE = 48; + ++ // Gale start - Airplane - reduce acquire POI for stuck entities ++ private static void addAdditionalTimeToMutableLongIfMobIsStuck(MutableLong mutableLong, net.minecraft.server.level.ServerLevel level, PathfinderMob mob) { ++ long stuckEntityAdditionalWaitTime = level.galeConfig().smallOptimizations.reducedIntervals.acquirePoiForStuckEntity; ++ mutableLong.add(stuckEntityAdditionalWaitTime <= 0L ? 0L : mob.getNavigation().isStuck() ? stuckEntityAdditionalWaitTime : 0L); ++ } ++ // Gale end - Airplane - reduce acquire POI for stuck entities ++ + public static BehaviorControl create( + Predicate> acquirablePois, + MemoryModuleType acquiringMemory, +@@ -65,12 +72,13 @@ public class AcquirePoi { + return false; + } else if (mutableLong.getValue() == 0L) { + mutableLong.setValue(level.getGameTime() + level.random.nextInt(20)); ++ addAdditionalTimeToMutableLongIfMobIsStuck(mutableLong, level, mob); // Gale - Airplane - reduce acquire POI for stuck entities + return false; + } else if (level.getGameTime() < mutableLong.getValue()) { + return false; + } else { + mutableLong.setValue(time + 20L + level.getRandom().nextInt(20)); +- if (mob.getNavigation().isStuck()) mutableLong.add(200); // Paper - Perf: Wait an additional 10s to check again if they're stuck // TODO Modifies Vanilla behavior, add config option ++ addAdditionalTimeToMutableLongIfMobIsStuck(mutableLong, level, mob); // Paper - Perf: Wait an additional 10s to check again if they're stuck // TODO Modifies Vanilla behavior, add config option // Gale - Airplane - reduce acquire POI for stuck entities + PoiManager poiManager = level.getPoiManager(); + map.long2ObjectEntrySet().removeIf(entry -> !entry.getValue().isStillValid(time)); + Predicate predicate1 = pos -> { diff --git a/patches/server/0022-Check-targeting-range-before-getting-visibility.patch b/gale-server/minecraft-patches/features/0014-Check-targeting-range-before-getting-visibility.patch similarity index 63% rename from patches/server/0022-Check-targeting-range-before-getting-visibility.patch rename to gale-server/minecraft-patches/features/0014-Check-targeting-range-before-getting-visibility.patch index b070364..a182c1e 100644 --- a/patches/server/0022-Check-targeting-range-before-getting-visibility.patch +++ b/gale-server/minecraft-patches/features/0014-Check-targeting-range-before-getting-visibility.patch @@ -30,28 +30,28 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -diff --git a/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java b/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java -index 52982c1e6a4da36392569c791853279f5f9ac31a..b51a04d3e006bc770006cff790791bc0f6bee77d 100644 ---- a/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java -+++ b/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java +diff --git a/net/minecraft/world/entity/ai/targeting/TargetingConditions.java b/net/minecraft/world/entity/ai/targeting/TargetingConditions.java +index 2f8920d8ee765d057a22d76f24f7d7dc1b0b17ca..17a08a3af468093668a41f154c2beb69c6617efa 100644 +--- a/net/minecraft/world/entity/ai/targeting/TargetingConditions.java ++++ b/net/minecraft/world/entity/ai/targeting/TargetingConditions.java @@ -75,9 +75,18 @@ public class TargetingConditions { } if (this.range > 0.0) { -- double d = this.testInvisible ? target.getVisibilityPercent(tester) : 1.0; -- double e = Math.max(this.range * d, 2.0); +- double d = this.testInvisible ? target.getVisibilityPercent(entity) : 1.0; +- double max = Math.max(this.range * d, 2.0); + // Gale start - Airplane - check targeting range before getting visibility -+ // d = invisibility percent, e = follow range adjusted for invisibility, f = distance - double f = tester.distanceToSqr(target.getX(), target.getY(), target.getZ()); ++ // d = invisibility percent, max = follow range adjusted for invisibility, d1 = distance + double d1 = entity.distanceToSqr(target.getX(), target.getY(), target.getZ()); + double followRangeRaw = this.range; + -+ if (f > followRangeRaw * followRangeRaw) { // the actual follow range will always be this value or smaller, so if the distance is larger then it never will return true after getting invis ++ if (d1 > followRangeRaw * followRangeRaw) { // the actual follow range will always be this value or smaller, so if the distance is larger then it never will return true after getting invis + return false; + } + -+ double d = this.testInvisible ? target.getVisibilityPercent(tester) : 1.0; -+ double e = Math.max(followRangeRaw * d, 2.0); ++ double d = this.testInvisible ? target.getVisibilityPercent(entity) : 1.0; ++ double max = Math.max(followRangeRaw * d, 2.0); + // Gale end - Airplane - check targeting range before getting visibility - if (f > e * e) { + if (d1 > max * max) { return false; } diff --git a/patches/server/0024-Cache-on-climbable-check.patch b/gale-server/minecraft-patches/features/0015-Cache-on-climbable-check.patch similarity index 59% rename from patches/server/0024-Cache-on-climbable-check.patch rename to gale-server/minecraft-patches/features/0015-Cache-on-climbable-check.patch index 76567ab..abed8f4 100644 --- a/patches/server/0024-Cache-on-climbable-check.patch +++ b/gale-server/minecraft-patches/features/0015-Cache-on-climbable-check.patch @@ -30,11 +30,24 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index b1af5a5eafcd7e090beb36b1a1734e3f1a063f03..fbb1b17ade83e0fe043765369d53e140771778c9 100644 ---- a/src/main/java/net/minecraft/world/entity/LivingEntity.java -+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -2115,6 +2115,20 @@ public abstract class LivingEntity extends Entity implements Attackable { +diff --git a/io/papermc/paper/entity/activation/ActivationRange.java b/io/papermc/paper/entity/activation/ActivationRange.java +index bd888ef719b9bfc93bace0b1d0fb771ac659f515..5d1e83658bb9646cf56885627256f0be7a84831e 100644 +--- a/io/papermc/paper/entity/activation/ActivationRange.java ++++ b/io/papermc/paper/entity/activation/ActivationRange.java +@@ -215,7 +215,7 @@ public final class ActivationRange { + } + // special cases. + if (entity instanceof final LivingEntity living) { +- if (living.onClimbable() || living.jumping || living.hurtTime > 0 || !living.activeEffects.isEmpty() || living.isFreezing()) { ++ if (living.onClimbableCached() || living.jumping || living.hurtTime > 0 || !living.activeEffects.isEmpty() || living.isFreezing()) { // Gale - Airplane - cache on climbable check - use cached + return 1; + } + if (entity instanceof final Mob mob && mob.getTarget() != null) { +diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java +index 00caebfabfc459eed86f0e6e2cc3f4b628f7ef99..d17020508a1f8d6c7da630b89a11db9bf7d1748f 100644 +--- a/net/minecraft/world/entity/LivingEntity.java ++++ b/net/minecraft/world/entity/LivingEntity.java +@@ -2015,6 +2015,20 @@ public abstract class LivingEntity extends Entity implements Attackable { return this.lastClimbablePos; } @@ -55,16 +68,3 @@ index b1af5a5eafcd7e090beb36b1a1734e3f1a063f03..fbb1b17ade83e0fe043765369d53e140 public boolean onClimbable() { if (this.isSpectator()) { return false; -diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java -index 1d438ef44cbe4d1eedfba36d8fe5d2ad53464921..9cee5e8b9188b094a2428da5d9cf42db1c18f7a3 100644 ---- a/src/main/java/org/spigotmc/ActivationRange.java -+++ b/src/main/java/org/spigotmc/ActivationRange.java -@@ -295,7 +295,7 @@ public class ActivationRange - if ( entity instanceof LivingEntity ) - { - LivingEntity living = (LivingEntity) entity; -- if ( living.onClimbable() || living.jumping || living.hurtTime > 0 || living.activeEffects.size() > 0 || living.isFreezing()) // Paper -+ if ( living.onClimbableCached() || living.jumping || living.hurtTime > 0 || living.activeEffects.size() > 0 || living.isFreezing()) // Paper // Gale - Airplane - cache on climbable check - use cached - { - return 1; // Paper - } diff --git a/patches/server/0025-Make-EntityCollisionContext-a-live-representation.patch b/gale-server/minecraft-patches/features/0016-Make-EntityCollisionContext-a-live-representation.patch similarity index 74% rename from patches/server/0025-Make-EntityCollisionContext-a-live-representation.patch rename to gale-server/minecraft-patches/features/0016-Make-EntityCollisionContext-a-live-representation.patch index 070ee51..b924c01 100644 --- a/patches/server/0025-Make-EntityCollisionContext-a-live-representation.patch +++ b/gale-server/minecraft-patches/features/0016-Make-EntityCollisionContext-a-live-representation.patch @@ -39,12 +39,12 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -diff --git a/src/main/java/net/minecraft/world/phys/shapes/EntityCollisionContext.java b/src/main/java/net/minecraft/world/phys/shapes/EntityCollisionContext.java -index a94fbedaf0297c006c561a145913bb91f2d0a817..121d155be5213cb4d9a4258b4b9a27ca3f335209 100644 ---- a/src/main/java/net/minecraft/world/phys/shapes/EntityCollisionContext.java -+++ b/src/main/java/net/minecraft/world/phys/shapes/EntityCollisionContext.java -@@ -19,23 +19,33 @@ public class EntityCollisionContext implements CollisionContext { - return defaultValue; +diff --git a/net/minecraft/world/phys/shapes/EntityCollisionContext.java b/net/minecraft/world/phys/shapes/EntityCollisionContext.java +index dafcba6eeba62a5e35ad53c9b38605a17139d8b0..a8ad7c304eca5a1b5b8247077fcb148d760d6ac9 100644 +--- a/net/minecraft/world/phys/shapes/EntityCollisionContext.java ++++ b/net/minecraft/world/phys/shapes/EntityCollisionContext.java +@@ -19,25 +19,35 @@ public class EntityCollisionContext implements CollisionContext { + return canAscend; } }; + // Gale start - Airplane - make EntityCollisionContext a live representation - remove these and pray no plugin uses them @@ -53,32 +53,34 @@ index a94fbedaf0297c006c561a145913bb91f2d0a817..121d155be5213cb4d9a4258b4b9a27ca private final double entityBottom; private final ItemStack heldItem; private final Predicate canStandOnFluid; -+ */ ++ */ + // Gale end - Airplane - make EntityCollisionContext a live representation - remove these and pray no plugin uses them @Nullable private final Entity entity; - protected EntityCollisionContext(boolean descending, double minY, ItemStack heldItem, Predicate walkOnFluidPredicate, @Nullable Entity entity) { + protected EntityCollisionContext( + boolean descending, double entityBottom, ItemStack heldItem, Predicate canStandOnFluid, @Nullable Entity entity + ) { + // Gale start - Airplane - make EntityCollisionContext a live representation - remove these and pray no plugin uses them + /* this.descending = descending; - this.entityBottom = minY; + this.entityBottom = entityBottom; this.heldItem = heldItem; - this.canStandOnFluid = walkOnFluidPredicate; -+ */ + this.canStandOnFluid = canStandOnFluid; ++ */ + // Gale end - Airplane - make EntityCollisionContext a live representation - remove these and pray no plugin uses them this.entity = entity; } @Deprecated - protected EntityCollisionContext(Entity entity, boolean collidesWithFluid) { + protected EntityCollisionContext(Entity entity, boolean canStandOnFluid) { + // Gale start - Airplane - make EntityCollisionContext a live representation - remove unneeded things + /* this( entity.isDescending(), entity.getY(), -@@ -43,16 +53,31 @@ public class EntityCollisionContext implements CollisionContext { - collidesWithFluid ? state -> true : (entity instanceof LivingEntity ? ((LivingEntity)entity)::canStandOnFluid : state -> false), +@@ -45,16 +55,31 @@ public class EntityCollisionContext implements CollisionContext { + canStandOnFluid ? fluidState -> true : (entity instanceof LivingEntity ? ((LivingEntity)entity)::canStandOnFluid : fluidState -> false), entity ); + */ @@ -99,19 +101,19 @@ index a94fbedaf0297c006c561a145913bb91f2d0a817..121d155be5213cb4d9a4258b4b9a27ca } @Override - public boolean canStandOnFluid(FluidState stateAbove, FluidState state) { -- return this.canStandOnFluid.test(state) && !stateAbove.getType().isSame(state.getType()); + public boolean canStandOnFluid(FluidState fluid1, FluidState fluid2) { +- return this.canStandOnFluid.test(fluid2) && !fluid1.getType().isSame(fluid2.getType()); + // Gale start - Airplane - make EntityCollisionContext a live representation + Entity entity = this.entity; + if (entity instanceof LivingEntity livingEntity) { -+ return livingEntity.canStandOnFluid(state) && !stateAbove.getType().isSame(state.getType()); ++ return livingEntity.canStandOnFluid(fluid2) && !fluid1.getType().isSame(fluid2.getType()); + } + return false; + // Gale end - Airplane - make EntityCollisionContext a live representation } @Override -@@ -62,12 +87,12 @@ public class EntityCollisionContext implements CollisionContext { +@@ -64,12 +89,12 @@ public class EntityCollisionContext implements CollisionContext { @Override public boolean isDescending() { @@ -120,8 +122,8 @@ index a94fbedaf0297c006c561a145913bb91f2d0a817..121d155be5213cb4d9a4258b4b9a27ca } @Override - public boolean isAbove(VoxelShape shape, BlockPos pos, boolean defaultValue) { -- return this.entityBottom > (double)pos.getY() + shape.max(Direction.Axis.Y) - 1.0E-5F; + public boolean isAbove(VoxelShape shape, BlockPos pos, boolean canAscend) { +- return this.entityBottom > pos.getY() + shape.max(Direction.Axis.Y) - 1.0E-5F; + return (this.entity == null ? -Double.MAX_VALUE : entity.getY()) > (double) pos.getY() + shape.max(Direction.Axis.Y) - (double) 1.0E-5F; // Gale - Airplane - make EntityCollisionContext a live representation } diff --git a/gale-server/minecraft-patches/features/0017-Better-checking-for-useless-move-packets.patch b/gale-server/minecraft-patches/features/0017-Better-checking-for-useless-move-packets.patch new file mode 100644 index 0000000..144a2f4 --- /dev/null +++ b/gale-server/minecraft-patches/features/0017-Better-checking-for-useless-move-packets.patch @@ -0,0 +1,73 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Wed, 23 Nov 2022 22:26:37 +0100 +Subject: [PATCH] Better checking for useless move packets + +License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) +Gale - https://galemc.org + +This patch is based on the following patch: +"Better checking for useless move packets" +By: Paul Sauve +As part of: Airplane (https://github.com/TECHNOVE/Airplane) +Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) + +* Airplane copyright * + +Airplane +Copyright (C) 2020 Technove LLC + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . + +diff --git a/net/minecraft/server/level/ServerEntity.java b/net/minecraft/server/level/ServerEntity.java +index 0fb253aa55a24b56b17f524b3261c5b75c7d7e59..d985555a029d06ffc73dd10115df47b83c9afafd 100644 +--- a/net/minecraft/server/level/ServerEntity.java ++++ b/net/minecraft/server/level/ServerEntity.java +@@ -179,19 +179,25 @@ public class ServerEntity { + packet = ClientboundEntityPositionSyncPacket.of(this.entity); + flag3 = true; + flag4 = true; +- } else if ((!flag2 || !flag) && !(this.entity instanceof AbstractArrow)) { +- if (flag2) { +- packet = new ClientboundMoveEntityPacket.Pos(this.entity.getId(), (short)l, (short)l1, (short)l2, this.entity.onGround()); +- flag3 = true; +- } else if (flag) { +- packet = new ClientboundMoveEntityPacket.Rot(this.entity.getId(), b, b1, this.entity.onGround()); +- flag4 = true; +- } ++ // Gale start - Airplane - better checking for useless move packets + } else { +- packet = new ClientboundMoveEntityPacket.PosRot(this.entity.getId(), (short)l, (short)l1, (short)l2, b, b1, this.entity.onGround()); +- flag3 = true; +- flag4 = true; ++ if (flag2 || flag || this.entity instanceof AbstractArrow) { ++ if ((!flag2 || !flag) && !(this.entity instanceof AbstractArrow)) { ++ if (flag2) { ++ packet = new ClientboundMoveEntityPacket.Pos(this.entity.getId(), (short) l, (short) l1, (short) l2, this.entity.onGround()); ++ flag3 = true; ++ } else if (flag) { ++ packet = new ClientboundMoveEntityPacket.Rot(this.entity.getId(), b, b1, this.entity.onGround()); ++ flag4 = true; ++ } ++ } else { ++ packet = new ClientboundMoveEntityPacket.PosRot(this.entity.getId(), (short) l, (short) l1, (short) l2, b, b1, this.entity.onGround()); ++ flag3 = true; ++ flag4 = true; ++ } ++ } + } ++ // Gale end - Airplane - better checking for useless move packets + + if (this.entity.hasImpulse || this.trackDelta || this.entity instanceof LivingEntity && ((LivingEntity)this.entity).isFallFlying()) { + Vec3 deltaMovement = this.entity.getDeltaMovement(); diff --git a/patches/server/0027-Block-goal-does-not-load-chunks.patch b/gale-server/minecraft-patches/features/0018-Block-goal-does-not-load-chunks.patch similarity index 73% rename from patches/server/0027-Block-goal-does-not-load-chunks.patch rename to gale-server/minecraft-patches/features/0018-Block-goal-does-not-load-chunks.patch index 4ae96bb..0998587 100644 --- a/patches/server/0027-Block-goal-does-not-load-chunks.patch +++ b/gale-server/minecraft-patches/features/0018-Block-goal-does-not-load-chunks.patch @@ -30,14 +30,14 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java b/src/main/java/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java -index aee0147649d458b87d92496eda0c1723ebe570d2..7e9243f76f77df2f2c5744d2dd17187c215d6e08 100644 ---- a/src/main/java/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java -+++ b/src/main/java/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java -@@ -121,6 +121,7 @@ public abstract class MoveToBlockGoal extends Goal { - for (int m = 0; m <= l; m = m > 0 ? -m : 1 - m) { - for (int n = m < l && m > -l ? l : 0; n <= l; n = n > 0 ? -n : 1 - n) { - mutableBlockPos.setWithOffset(blockPos, m, k - 1, n); +diff --git a/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java b/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java +index d0ab3db7bbd2942db19f473474371b20ce822608..3f080b15543bf8c5fa0774b62d7f12e13b82511a 100644 +--- a/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java ++++ b/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java +@@ -119,6 +119,7 @@ public abstract class MoveToBlockGoal extends Goal { + for (int i4 = 0; i4 <= i3; i4 = i4 > 0 ? -i4 : 1 - i4) { + for (int i5 = i4 < i3 && i4 > -i3 ? i3 : 0; i5 <= i3; i5 = i5 > 0 ? -i5 : 1 - i5) { + mutableBlockPos.setWithOffset(blockPos, i4, i2 - 1, i5); + if (!this.mob.level().hasChunkAt(mutableBlockPos)) continue; // Gale - Airplane - block goal does not load chunks - if this block isn't loaded, continue if (this.mob.isWithinRestriction(mutableBlockPos) && this.isValidTarget(this.mob.level(), mutableBlockPos)) { this.blockPos = mutableBlockPos; diff --git a/patches/server/0028-Reduce-entity-allocations.patch b/gale-server/minecraft-patches/features/0019-Reduce-entity-allocations.patch similarity index 65% rename from patches/server/0028-Reduce-entity-allocations.patch rename to gale-server/minecraft-patches/features/0019-Reduce-entity-allocations.patch index 02ce46d..b07f709 100644 --- a/patches/server/0028-Reduce-entity-allocations.patch +++ b/gale-server/minecraft-patches/features/0019-Reduce-entity-allocations.patch @@ -30,11 +30,11 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index cd4461c175e88b9dd6f05a8bcd9363de60725370..44028368322ac91a4f6848f632d51d34269cb64a 100644 ---- a/src/main/java/net/minecraft/world/entity/Entity.java -+++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -403,6 +403,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java +index 3594240116d3b61dbf838490df7a30345d7d8925..72da610c4d0301ddf2940bbc067430d05ff46684 100644 +--- a/net/minecraft/world/entity/Entity.java ++++ b/net/minecraft/world/entity/Entity.java +@@ -360,6 +360,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess return this.originWorld; } // Paper end - Entity origin API @@ -42,19 +42,19 @@ index cd4461c175e88b9dd6f05a8bcd9363de60725370..44028368322ac91a4f6848f632d51d34 public float getBukkitYaw() { return this.yRot; } -diff --git a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java -index 94d04a20f97405e02d7cccaabadc7a7e86e336f7..edd791da70fd7e18c42133dcd771f212cb25abab 100644 ---- a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java -+++ b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java +diff --git a/net/minecraft/world/entity/ai/attributes/AttributeMap.java b/net/minecraft/world/entity/ai/attributes/AttributeMap.java +index 4c808c7ef336de74048f40bd1cc8b14131a9325d..beebe81e13c99c6ddd9ffb2c7a3fdd74cb9c7afa 100644 +--- a/net/minecraft/world/entity/ai/attributes/AttributeMap.java ++++ b/net/minecraft/world/entity/ai/attributes/AttributeMap.java @@ -23,9 +23,11 @@ public class AttributeMap { private final Set attributesToSync = new ObjectOpenHashSet<>(); private final Set attributesToUpdate = new ObjectOpenHashSet<>(); private final AttributeSupplier supplier; + private final java.util.function.Function, AttributeInstance> createInstance; // Gale - Airplane - reduce entity allocations - public AttributeMap(AttributeSupplier defaultAttributes) { - this.supplier = defaultAttributes; -+ this.createInstance = attributex -> this.supplier.createInstance(this::onAttributeModified, attributex); // Gale - Airplane - reduce entity allocations + public AttributeMap(AttributeSupplier supplier) { + this.supplier = supplier; ++ this.createInstance = holder -> this.supplier.createInstance(this::onAttributeModified, holder); // Gale - Airplane - reduce entity allocations } private void onAttributeModified(AttributeInstance instance) { @@ -62,7 +62,7 @@ index 94d04a20f97405e02d7cccaabadc7a7e86e336f7..edd791da70fd7e18c42133dcd771f212 @Nullable public AttributeInstance getInstance(Holder attribute) { -- return this.attributes.computeIfAbsent(attribute, attributex -> this.supplier.createInstance(this::onAttributeModified, attributex)); +- return this.attributes.computeIfAbsent(attribute, holder -> this.supplier.createInstance(this::onAttributeModified, (Holder)holder)); + return this.attributes.computeIfAbsent(attribute, this.createInstance); // Gale - Airplane - reduce entity allocations - cache lambda, as for some reason java allocates it anyways } diff --git a/gale-server/minecraft-patches/features/0020-Remove-lambda-from-ticking-guard.patch b/gale-server/minecraft-patches/features/0020-Remove-lambda-from-ticking-guard.patch new file mode 100644 index 0000000..ef2aa58 --- /dev/null +++ b/gale-server/minecraft-patches/features/0020-Remove-lambda-from-ticking-guard.patch @@ -0,0 +1,74 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Wed, 23 Nov 2022 23:13:56 +0100 +Subject: [PATCH] Remove lambda from ticking guard + +License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) +Gale - https://galemc.org + +This patch is based on the following patch: +"Remove lambda from ticking guard" +By: Paul Sauve +As part of: Airplane (https://github.com/TECHNOVE/Airplane) +Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) + +* Airplane copyright * + +Airplane +Copyright (C) 2020 Technove LLC + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . + +diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java +index b35fe7112f2ad94e85e98931c403b3ffa8608382..2caeb69306a42d02b7a5c27e00fb969e392ac6ba 100644 +--- a/net/minecraft/server/level/ServerLevel.java ++++ b/net/minecraft/server/level/ServerLevel.java +@@ -794,7 +794,19 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe + entity.stopRiding(); + } + +- this.guardEntityTick(this::tickNonPassenger, entity); ++ // Gale start - Airplane - remove lambda from ticking guard - copied from guardEntityTick ++ try { ++ this.tickNonPassenger(entity); // Gale - Airplane - remove lambda from ticking guard - changed ++ } catch (Throwable var6) { ++ // Paper start - Prevent block entity and entity crashes ++ final String msg = String.format("Entity threw exception at %s:%s,%s,%s", entity.level().getWorld().getName(), entity.getX(), entity.getY(), entity.getZ()); ++ MinecraftServer.LOGGER.error(msg, var6); ++ getCraftServer().getPluginManager().callEvent(new com.destroystokyo.paper.event.server.ServerExceptionEvent(new com.destroystokyo.paper.exception.ServerInternalException(msg, var6))); // Paper - ServerExceptionEvent ++ entity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD); ++ // Paper end - Prevent block entity and entity crashes ++ } ++ this.moonrise$midTickTasks(); // Paper - rewrite chunk system ++ // Gale end - Airplane - remove lambda from ticking guard - copied from guardEntityTick + } + } + } +diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java +index c4563e827a8333d57aabce1ff8e4c28d7e3a295b..51fa382b930ccbeb605064488ab4df985df94ed6 100644 +--- a/net/minecraft/world/level/Level.java ++++ b/net/minecraft/world/level/Level.java +@@ -1506,10 +1506,10 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl + final String msg = String.format("Entity threw exception at %s:%s,%s,%s", entity.level().getWorld().getName(), entity.getX(), entity.getY(), entity.getZ()); + MinecraftServer.LOGGER.error(msg, var6); + getCraftServer().getPluginManager().callEvent(new com.destroystokyo.paper.event.server.ServerExceptionEvent(new com.destroystokyo.paper.exception.ServerInternalException(msg, var6))); // Paper - ServerExceptionEvent +- entity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD); ++ entity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD); // Gale - Airplane - remove lambda from ticking guard - diff on change ServerLevel#tick + // Paper end - Prevent block entity and entity crashes + } +- this.moonrise$midTickTasks(); // Paper - rewrite chunk system ++ this.moonrise$midTickTasks(); // Paper - rewrite chunk system // Gale - Airplane - remove lambda from ticking guard - diff on change ServerLevel#tick + } + + // Paper start - Option to prevent armor stands from doing entity lookups diff --git a/gale-server/minecraft-patches/features/0021-SIMD-support.patch b/gale-server/minecraft-patches/features/0021-SIMD-support.patch new file mode 100644 index 0000000..727855d --- /dev/null +++ b/gale-server/minecraft-patches/features/0021-SIMD-support.patch @@ -0,0 +1,32 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Thu, 24 Nov 2022 01:19:12 +0100 +Subject: [PATCH] SIMD support + +License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) +Gale - https://galemc.org + +This patch is based on the following patch: +"Add SIMD utilities" +By: Kevin Raneri +As part of: Pufferfish (https://github.com/pufferfish-gg/Pufferfish) +Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) + +diff --git a/net/minecraft/server/dedicated/DedicatedServer.java b/net/minecraft/server/dedicated/DedicatedServer.java +index baa92ab485928b2e57adb14af00f7e6120694184..3cd6e63ea6c18a26ef1aa394cf53d9e3463f8e50 100644 +--- a/net/minecraft/server/dedicated/DedicatedServer.java ++++ b/net/minecraft/server/dedicated/DedicatedServer.java +@@ -231,6 +231,13 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface + com.destroystokyo.paper.Metrics.PaperMetrics.startMetrics(); // Paper - start metrics + com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // Paper - load version history now + ++ // Gale start - Pufferfish - SIMD support ++ // Initialize vectorization ++ try { ++ gg.pufferfish.pufferfish.simd.SIMDDetection.initialize(); ++ } catch (Throwable ignored) {} ++ // Gale end - Pufferfish - SIMD support ++ + this.setPvpAllowed(properties.pvp); + this.setFlightAllowed(properties.allowFlight); + this.setMotd(properties.motd); diff --git a/gale-server/minecraft-patches/features/0022-Make-book-writing-configurable.patch b/gale-server/minecraft-patches/features/0022-Make-book-writing-configurable.patch new file mode 100644 index 0000000..8b4a83e --- /dev/null +++ b/gale-server/minecraft-patches/features/0022-Make-book-writing-configurable.patch @@ -0,0 +1,39 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Mon, 26 Dec 2022 02:11:29 +0100 +Subject: [PATCH] Make book writing configurable + +License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) +Gale - https://galemc.org + +This patch is based on the following patch: +"Add option to disable books" +By: Kevin Raneri +As part of: Pufferfish (https://github.com/pufferfish-gg/Pufferfish) +Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) + +* Pufferfish description * + +Books are commonly the target of duping-related exploits. If you +anticipate that your server will be an early target of duping attacks in +the event that new exploits are found, you may want to consider removing +the ability for non-privileged players to edit books. This patch allows +you to easily disable books, should you want to preemptively remove this +functionality before additional exploits are found. + +diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java +index d248671b2e1c6256fc4d74320bdb29ca078bad0b..089a903607c0d16dc2744981a6dcb23115df010d 100644 +--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java ++++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java +@@ -1161,6 +1161,11 @@ public class ServerGamePacketListenerImpl + + @Override + public void handleEditBook(ServerboundEditBookPacket packet) { ++ // Gale start - Pufferfish - make book writing configurable ++ if (!(org.galemc.gale.configuration.GaleGlobalConfiguration.get().gameplayMechanics.enableBookWriting || this.player.getBukkitEntity().hasPermission(org.bukkit.craftbukkit.util.permissions.CraftDefaultPermissions.writeBooks) || this.player.getBukkitEntity().hasPermission("pufferfish.usebooks"))) { ++ return; ++ } ++ // Gale end - Pufferfish - make book writing configurable + // Paper start - Book size limits + final io.papermc.paper.configuration.type.number.IntOr.Disabled pageMax = io.papermc.paper.configuration.GlobalConfiguration.get().itemValidation.bookSize.pageMax; + if (!this.cserver.isPrimaryThread() && pageMax.enabled()) { diff --git a/gale-server/minecraft-patches/features/0023-Optimize-entity-coordinate-key.patch b/gale-server/minecraft-patches/features/0023-Optimize-entity-coordinate-key.patch new file mode 100644 index 0000000..c5c70e1 --- /dev/null +++ b/gale-server/minecraft-patches/features/0023-Optimize-entity-coordinate-key.patch @@ -0,0 +1,36 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Wed, 23 Nov 2022 23:32:51 +0100 +Subject: [PATCH] Optimize entity coordinate key + +License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) +Gale - https://galemc.org + +This patch is based on the following patch: +"Optimize entity coordinate key" +By: Kevin Raneri +As part of: Pufferfish (https://github.com/pufferfish-gg/Pufferfish) +Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) + +* Pufferfish description * + +When executing getCoordinateKey for entities (a hotpath), the JVM is +required to repeatedly cast doubles to longs. The performance impact of +this depends on the CPU architecture, but generally switching between +FPU and ALU incurs a significant performance hit. The casted/rounded +data is already available in the blockPosition struct, so we use that +instead of re-doing the casting. + +diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java +index 72da610c4d0301ddf2940bbc067430d05ff46684..0bbac68dbd891da8892ba40fc18578c4f9e67c11 100644 +--- a/net/minecraft/world/entity/Entity.java ++++ b/net/minecraft/world/entity/Entity.java +@@ -225,7 +225,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess + public double yo; + public double zo; + private Vec3 position; +- private BlockPos blockPosition; ++ public BlockPos blockPosition; // Gale - Pufferfish - optimize entity coordinate key - private -> public + private ChunkPos chunkPosition; + private Vec3 deltaMovement = Vec3.ZERO; + private float yRot; diff --git a/patches/server/0033-Reduce-in-wall-checks.patch b/gale-server/minecraft-patches/features/0024-Reduce-in-wall-checks.patch similarity index 55% rename from patches/server/0033-Reduce-in-wall-checks.patch rename to gale-server/minecraft-patches/features/0024-Reduce-in-wall-checks.patch index 97b5ba9..539b2d5 100644 --- a/patches/server/0033-Reduce-in-wall-checks.patch +++ b/gale-server/minecraft-patches/features/0024-Reduce-in-wall-checks.patch @@ -27,23 +27,23 @@ damage in the first place. This check doesn't improve performance much but is so much cheaper than the suffocation check that it's worth keeping it. -diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index 206a1461178706e56f4b3c92c9121dd4177edd4c..244857d69b52e1689d932cab914ed8c1331e96d3 100644 ---- a/src/main/java/net/minecraft/world/entity/LivingEntity.java -+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -463,7 +463,10 @@ public abstract class LivingEntity extends Entity implements Attackable { - - if (world1 instanceof ServerLevel) { - worldserver1 = (ServerLevel) world1; +diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java +index d17020508a1f8d6c7da630b89a11db9bf7d1748f..1fbc971f4bb2473dc67021b4cec9228109e0c43b 100644 +--- a/net/minecraft/world/entity/LivingEntity.java ++++ b/net/minecraft/world/entity/LivingEntity.java +@@ -448,7 +448,10 @@ public abstract class LivingEntity extends Entity implements Attackable { + if (this.isAlive()) { + boolean flag = this instanceof Player; + if (this.level() instanceof ServerLevel serverLevel1) { - if (this.isInWall()) { + // Gale start - Pufferfish - reduce in wall checks + long checkStuckInWallInterval = this.level().galeConfig().smallOptimizations.reducedIntervals.checkStuckInWall; + if ((checkStuckInWallInterval <= 1 || (tickCount % checkStuckInWallInterval == 0 && couldPossiblyBeHurt(1.0F))) && this.isInWall()) { + // Gale end - Pufferfish - reduce in wall checks - this.hurtServer(worldserver1, this.damageSources().inWall(), 1.0F); + this.hurtServer(serverLevel1, this.damageSources().inWall(), 1.0F); } else if (flag && !this.level().getWorldBorder().isWithinBounds(this.getBoundingBox())) { - double d1 = this.level().getWorldBorder().getDistanceToBorder(this) + this.level().getWorldBorder().getDamageSafeZone(); -@@ -1432,6 +1435,15 @@ public abstract class LivingEntity extends Entity implements Attackable { + double d = this.level().getWorldBorder().getDistanceToBorder(this) + this.level().getWorldBorder().getDamageSafeZone(); +@@ -1354,6 +1357,15 @@ public abstract class LivingEntity extends Entity implements Attackable { return this.getHealth() <= 0.0F; } @@ -57,17 +57,5 @@ index 206a1461178706e56f4b3c92c9121dd4177edd4c..244857d69b52e1689d932cab914ed8c1 + // Gale end - Pufferfish - reduce in wall checks + @Override - public boolean hurtServer(ServerLevel world, DamageSource source, float amount) { - if (this.isInvulnerableTo(world, source)) { -diff --git a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -index 8a0416775d00148bf3478b51d92b00d9d485c667..08a02055b535c024cc806db17bb45fd333a56929 100644 ---- a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -+++ b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -@@ -53,6 +53,7 @@ public class GaleWorldConfiguration extends ConfigurationPart { - public class ReducedIntervals extends ConfigurationPart { - - public int acquirePoiForStuckEntity = 60; // Gale - Airplane - reduce acquire POI for stuck entities -+ public int checkStuckInWall = 10; // Gale - Pufferfish - reduce in wall checks - - } - + public boolean hurtServer(ServerLevel level, DamageSource damageSource, float amount) { + if (this.isInvulnerableTo(level, damageSource)) { diff --git a/patches/server/0034-Make-chat-order-verification-configurable.patch b/gale-server/minecraft-patches/features/0025-Make-chat-order-verification-configurable.patch similarity index 56% rename from patches/server/0034-Make-chat-order-verification-configurable.patch rename to gale-server/minecraft-patches/features/0025-Make-chat-order-verification-configurable.patch index 4ea36fb..39905a8 100644 --- a/patches/server/0034-Make-chat-order-verification-configurable.patch +++ b/gale-server/minecraft-patches/features/0025-Make-chat-order-verification-configurable.patch @@ -12,10 +12,10 @@ By: Kevin Raneri As part of: Pufferfish (https://github.com/pufferfish-gg/Pufferfish) Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) -diff --git a/src/main/java/net/minecraft/network/chat/SignedMessageChain.java b/src/main/java/net/minecraft/network/chat/SignedMessageChain.java -index 300929a406905f5ff1ede664d5b99fb0938d4d2e..987e595ba3d19b081f22891f01dc25fbabb5bb9f 100644 ---- a/src/main/java/net/minecraft/network/chat/SignedMessageChain.java -+++ b/src/main/java/net/minecraft/network/chat/SignedMessageChain.java +diff --git a/net/minecraft/network/chat/SignedMessageChain.java b/net/minecraft/network/chat/SignedMessageChain.java +index f6eed34b2fd72ab74cc9dc4b99ca184d512c0a66..23872fac07fa36f10ef090df2423c978998dcb99 100644 +--- a/net/minecraft/network/chat/SignedMessageChain.java ++++ b/net/minecraft/network/chat/SignedMessageChain.java @@ -45,7 +45,7 @@ public class SignedMessageChain { SignedMessageLink signedMessageLink = SignedMessageChain.this.nextLink; if (signedMessageLink == null) { @@ -25,18 +25,3 @@ index 300929a406905f5ff1ede664d5b99fb0938d4d2e..987e595ba3d19b081f22891f01dc25fb this.setChainBroken(); throw new SignedMessageChain.DecodeException(SignedMessageChain.DecodeException.OUT_OF_ORDER_CHAT, org.bukkit.event.player.PlayerKickEvent.Cause.OUT_OF_ORDER_CHAT); // Paper - kick event causes } else { -diff --git a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -index d180ea6099d8fed3cf19f0f32bbfced7df57c9d7..8075e5c17f469f1bf5b7758a1334943d6ed8383f 100644 ---- a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -+++ b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -@@ -41,4 +41,10 @@ public class GaleGlobalConfiguration extends ConfigurationPart { - public boolean enableBookWriting = true; // Gale - Pufferfish - make book writing configurable - - } -+ -+ public Misc misc; -+ public class Misc extends ConfigurationPart { -+ -+ public boolean verifyChatOrder = true; // Gale - Pufferfish - make chat order verification configurable -+ } - } diff --git a/gale-server/minecraft-patches/features/0026-Make-ender-dragon-respawn-attempt-after-placing-end-.patch b/gale-server/minecraft-patches/features/0026-Make-ender-dragon-respawn-attempt-after-placing-end-.patch new file mode 100644 index 0000000..a6e88af --- /dev/null +++ b/gale-server/minecraft-patches/features/0026-Make-ender-dragon-respawn-attempt-after-placing-end-.patch @@ -0,0 +1,44 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Mon, 7 Aug 2023 21:35:57 +0200 +Subject: [PATCH] Make ender dragon respawn attempt after placing end crystals + configurable + +The original Pufferfish description has been included below for reference, +but please note that on Gale, there is no need to disable end crystal +spawning for performance: Gale already contains other performance +enhancements that make the end crystal checks very fast. + +License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) +Gale - https://galemc.org + +This patch is based on the following patch: +"Option to disable end crystal dragon respawning" +By: Kevin Raneri +As part of: Pufferfish (https://github.com/pufferfish-gg/Pufferfish) +Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) + +* Pufferfish description * + +On servers that expect end crystal fights in the end dimension, +disabling this will prevent the server from performing an expensive +search to attempt respawning the ender dragon whenever a player places +an end crystal. + +diff --git a/net/minecraft/world/item/EndCrystalItem.java b/net/minecraft/world/item/EndCrystalItem.java +index 1bc4c8be71b445f64134548a85fd81442298c0f1..a1570503d3e4dcc9f1cd0b119ab2e60f7c63b6d8 100644 +--- a/net/minecraft/world/item/EndCrystalItem.java ++++ b/net/minecraft/world/item/EndCrystalItem.java +@@ -49,10 +49,12 @@ public class EndCrystalItem extends Item { + // CraftBukkit end + level.addFreshEntity(endCrystal); + level.gameEvent(context.getPlayer(), GameEvent.ENTITY_PLACE, blockPos); ++ if (level.galeConfig().gameplayMechanics.tryRespawnEnderDragonAfterEndCrystalPlace) { // Gale - Pufferfish - make ender dragon respawn attempt after placing end crystals configurable + EndDragonFight dragonFight = ((ServerLevel)level).getDragonFight(); + if (dragonFight != null) { + dragonFight.tryRespawn(aboveBlockPosition); // Paper - Perf: Do crystal-portal proximity check before entity lookup + } ++ } // Gale - Pufferfish - make ender dragon respawn attempt after placing end crystals configurable + } + + context.getItemInHand().shrink(1); diff --git a/gale-server/minecraft-patches/features/0027-Make-saving-fireworks-configurable.patch b/gale-server/minecraft-patches/features/0027-Make-saving-fireworks-configurable.patch new file mode 100644 index 0000000..585254c --- /dev/null +++ b/gale-server/minecraft-patches/features/0027-Make-saving-fireworks-configurable.patch @@ -0,0 +1,37 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Mon, 26 Dec 2022 07:30:30 +0100 +Subject: [PATCH] Make saving fireworks configurable + +License: MIT (https://opensource.org/licenses/MIT) +Gale - https://galemc.org + +This patch is based on the following patch: +"Don't save Fireworks" +By: Aikar +As part of: EmpireCraft (https://github.com/starlis/empirecraft) +Licensed under: MIT (https://opensource.org/licenses/MIT) + +* EmpireCraft description * + +Fireworks can bug out and not detonate, and an automated +launcher can very easily fill a chunk. + +Prevent saving Fireworks so that chunk unloads will wipe a chunks fireworks in this case. + +diff --git a/net/minecraft/world/entity/projectile/FireworkRocketEntity.java b/net/minecraft/world/entity/projectile/FireworkRocketEntity.java +index 774ca9e0b56fd175ae246051de762d0c4256ca58..7f370f938d84240d763f60e51cddc705b3eaf5ea 100644 +--- a/net/minecraft/world/entity/projectile/FireworkRocketEntity.java ++++ b/net/minecraft/world/entity/projectile/FireworkRocketEntity.java +@@ -364,4 +364,11 @@ public class FireworkRocketEntity extends Projectile implements ItemSupplier { + double d1 = entity.position().z - this.position().z; + return DoubleDoubleImmutablePair.of(d, d1); + } ++ ++ // Gale start - EMC - make saving fireworks configurable ++ @Override ++ public boolean shouldBeSaved() { ++ return this.level().galeConfig().smallOptimizations.saveFireworks; ++ } ++ // Gale end - EMC - make saving fireworks configurable + } diff --git a/gale-server/minecraft-patches/features/0028-Reduce-hopper-item-checks.patch b/gale-server/minecraft-patches/features/0028-Reduce-hopper-item-checks.patch new file mode 100644 index 0000000..bf3abb2 --- /dev/null +++ b/gale-server/minecraft-patches/features/0028-Reduce-hopper-item-checks.patch @@ -0,0 +1,149 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Thu, 24 Nov 2022 23:03:52 +0100 +Subject: [PATCH] Reduce hopper item checks + +License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) +Gale - https://galemc.org + +This patch is based on the following patch: +"Improve Hopper Performance" +By: Aikar +As part of: EmpireCraft (https://github.com/starlis/empirecraft) +Licensed under: MIT (https://opensource.org/licenses/MIT) + +* EmpireCraft description * + +Only do an item "suck in" action once per second + +diff --git a/net/minecraft/world/entity/item/ItemEntity.java b/net/minecraft/world/entity/item/ItemEntity.java +index 52a7ed0d991758bad0dcedcb7f97fb15ac6c6d04..45c152856c46d11f3bd790a01fac89a7c3b68af1 100644 +--- a/net/minecraft/world/entity/item/ItemEntity.java ++++ b/net/minecraft/world/entity/item/ItemEntity.java +@@ -143,7 +143,13 @@ public class ItemEntity extends Entity implements TraceableEntity { + } + // CraftBukkit end + this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause ++ return; // Gale - EMC - reduce hopper item checks + } ++ // Gale start - EMC - reduce hopper item checks ++ if (level().galeConfig().smallOptimizations.reducedIntervals.checkNearbyItem.hopper.minecart.temporaryImmunity.checkForMinecartNearItemWhileInactive) { ++ this.markNearbyHopperCartsAsImmune(); ++ } ++ // Gale end - EMC - reduce hopper item checks + } + // Paper end - EAR 2 + +@@ -227,9 +233,29 @@ public class ItemEntity extends Entity implements TraceableEntity { + } + // CraftBukkit end + this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause ++ return; // Gale - EMC - reduce hopper item checks ++ } ++ this.markNearbyHopperCartsAsImmune(); // Gale - EMC - reduce hopper item checks ++ } ++ } ++ ++ // Gale start - EMC - reduce hopper item checks ++ private void markNearbyHopperCartsAsImmune() { ++ var config = this.level().galeConfig().smallOptimizations.reducedIntervals.checkNearbyItem.hopper.minecart; ++ // No need to mark hopper minecarts as immune if they can pull every tick anyway ++ if (config.interval <= 1) { ++ return; ++ } ++ if (config.temporaryImmunity.duration > 0 && this.isAlive() && this.onGround && !this.isRemoved() && (config.temporaryImmunity.nearbyItemMaxAge == -1 || this.age <= config.temporaryImmunity.nearbyItemMaxAge) && this.age % Math.max(1, config.temporaryImmunity.checkForMinecartNearItemInterval) == 0 && config.temporaryImmunity.maxItemHorizontalDistance >= 0 && config.temporaryImmunity.maxItemVerticalDistance >= 0) { ++ net.minecraft.world.phys.AABB aabb = this.getBoundingBox().inflate(config.temporaryImmunity.maxItemHorizontalDistance, config.temporaryImmunity.maxItemVerticalDistance, config.temporaryImmunity.maxItemHorizontalDistance); ++ for (Entity entity : this.level().getEntities(this, aabb)) { ++ if (entity instanceof net.minecraft.world.entity.vehicle.MinecartHopper hopper) { ++ hopper.pickupImmunity = net.minecraft.server.MinecraftServer.currentTick + config.temporaryImmunity.duration; ++ } + } + } + } ++ // Gale end - EMC - reduce hopper item checks + + @Override + public BlockPos getBlockPosBelowThatAffectsMyMovement() { +diff --git a/net/minecraft/world/entity/vehicle/MinecartHopper.java b/net/minecraft/world/entity/vehicle/MinecartHopper.java +index 8341e7f01606fca90e69384c16fc19bb9e20d1b7..c5a3dc3e704a9f6d67d9049e49cd1b33b6994766 100644 +--- a/net/minecraft/world/entity/vehicle/MinecartHopper.java ++++ b/net/minecraft/world/entity/vehicle/MinecartHopper.java +@@ -21,6 +21,7 @@ import net.minecraft.world.level.block.state.properties.RailShape; + public class MinecartHopper extends AbstractMinecartContainer implements Hopper { + private boolean enabled = true; + private boolean consumedItemThisFrame = false; ++ public int pickupImmunity = 0; // Gale - EMC - reduce hopper item checks + + public MinecartHopper(EntityType entityType, Level level) { + super(entityType, level); +@@ -149,4 +150,12 @@ public class MinecartHopper extends AbstractMinecartContainer implements Hopper + } + // Paper end + ++ // Gale start - EMC - reduce hopper item checks ++ private long tickAttempts = 0; ++ @Override ++ public long getAndIncrementAttemptCounter() { ++ return tickAttempts++; ++ } ++ // Gale end EMC - - reduce hopper item checks ++ + } +diff --git a/net/minecraft/world/level/block/entity/Hopper.java b/net/minecraft/world/level/block/entity/Hopper.java +index 5f042e294db605827000123252b0df646968f897..e1cc15f28fe8da23b74ff4504c5b2da2236fda3f 100644 +--- a/net/minecraft/world/level/block/entity/Hopper.java ++++ b/net/minecraft/world/level/block/entity/Hopper.java +@@ -11,6 +11,8 @@ public interface Hopper extends Container { + return SUCK_AABB; + } + ++ long getAndIncrementAttemptCounter(); // Gale - EMC - reduce hopper item checks ++ + double getLevelX(); + + double getLevelY(); +diff --git a/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/net/minecraft/world/level/block/entity/HopperBlockEntity.java +index 5cd1326ad5d046c88b2b3449d610a78fa880b4cd..276cb0dffaa253a6c13b4c68d8c703732118d0d1 100644 +--- a/net/minecraft/world/level/block/entity/HopperBlockEntity.java ++++ b/net/minecraft/world/level/block/entity/HopperBlockEntity.java +@@ -540,7 +540,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen + return false; + } else { + boolean flag = hopper.isGridAligned() && blockState.isCollisionShapeFullBlock(level, blockPos) && !blockState.is(BlockTags.DOES_NOT_BLOCK_HOPPERS); +- if (!flag) { ++ if (!flag && shouldSuckIn(level, hopper)) { // Gale - EMC - reduce hopper item checks + for (ItemEntity itemEntity : getItemsAtAndAbove(level, hopper)) { + if (addItem(hopper, itemEntity)) { + return true; +@@ -816,6 +816,31 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen + return stack1.getCount() < stack1.getMaxStackSize() && ItemStack.isSameItemSameComponents(stack1, stack2); // Paper - Perf: Optimize Hoppers; used to return true for full itemstacks?! + } + ++ // Gale start - EMC - reduce hopper item checks ++ private long tickAttempts = 0; ++ @Override ++ public long getAndIncrementAttemptCounter() { ++ return tickAttempts++; ++ } ++ private static boolean shouldSuckIn(Level level, Hopper hopper) { ++ int suckInterval; ++ if (hopper instanceof net.minecraft.world.entity.vehicle.MinecartHopper minecartHopper) { ++ if (minecartHopper.pickupImmunity > net.minecraft.server.MinecraftServer.currentTick) { ++ return true; ++ } ++ suckInterval = level.galeConfig().smallOptimizations.reducedIntervals.checkNearbyItem.hopper.minecart.interval; ++ } else { ++ suckInterval = level.galeConfig().smallOptimizations.reducedIntervals.checkNearbyItem.hopper.interval; ++ } ++ if (suckInterval <= 1) { ++ return true; ++ } ++ ++ final int hopperId = (int) hopper.getLevelX() + (int) hopper.getLevelY() + (int) hopper.getLevelZ(); ++ return (hopper.getAndIncrementAttemptCounter() + hopperId) % suckInterval == 0; ++ } ++ // Gale end - EMC - reduce hopper item checks ++ + @Override + public double getLevelX() { + return this.worldPosition.getX() + 0.5; diff --git a/gale-server/minecraft-patches/features/0029-Reduce-villager-item-re-pickup.patch b/gale-server/minecraft-patches/features/0029-Reduce-villager-item-re-pickup.patch new file mode 100644 index 0000000..1af3d8d --- /dev/null +++ b/gale-server/minecraft-patches/features/0029-Reduce-villager-item-re-pickup.patch @@ -0,0 +1,41 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Thu, 24 Nov 2022 23:15:49 +0100 +Subject: [PATCH] Reduce villager item re-pickup + +License: MIT (https://opensource.org/licenses/MIT) +Gale - https://galemc.org + +This patch is based on the following patch: +"Slow down villager pickup of thrown items" +By: Aikar +As part of: EmpireCraft (https://github.com/starlis/empirecraft) +Licensed under: MIT (https://opensource.org/licenses/MIT) + +* EmpireCraft description * + +Helps 1.8 Farms let hoppers pick it up before Villager +due to our hopper changes + +diff --git a/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java b/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java +index 2664d72c3b6906d0505df2e63c0e5075eba9461b..800bc29502ed46bd77cb04c0a79143898f109a48 100644 +--- a/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java ++++ b/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java +@@ -87,7 +87,16 @@ public class BehaviorUtils { + Vec3 vec3 = offset.subtract(entity.position()); + vec3 = vec3.normalize().multiply(speedMultiplier.x, speedMultiplier.y, speedMultiplier.z); + itemEntity.setDeltaMovement(vec3); +- itemEntity.setDefaultPickUpDelay(); ++ // Gale start - EMC - reduce villager item re-pickup ++ if (entity instanceof net.minecraft.world.entity.npc.Villager) { ++ int repickupDelay = entity.level().galeConfig().smallOptimizations.reducedIntervals.villagerItemRepickup; ++ if (repickupDelay <= -1) { ++ itemEntity.setDefaultPickUpDelay(); ++ } else { ++ itemEntity.pickupDelay = repickupDelay; ++ } ++ } ++ // Gale end - EMC - reduce villager item re-pickup + // CraftBukkit start + org.bukkit.event.entity.EntityDropItemEvent event = new org.bukkit.event.entity.EntityDropItemEvent(entity.getBukkitEntity(), (org.bukkit.entity.Item) itemEntity.getBukkitEntity()); + itemEntity.level().getCraftServer().getPluginManager().callEvent(event); diff --git a/patches/server/0039-Variable-entity-wake-up-duration.patch b/gale-server/minecraft-patches/features/0030-Variable-entity-wake-up-duration.patch similarity index 67% rename from patches/server/0039-Variable-entity-wake-up-duration.patch rename to gale-server/minecraft-patches/features/0030-Variable-entity-wake-up-duration.patch index 210dd62..2dd086f 100644 --- a/patches/server/0039-Variable-entity-wake-up-duration.patch +++ b/gale-server/minecraft-patches/features/0030-Variable-entity-wake-up-duration.patch @@ -6,23 +6,11 @@ Subject: [PATCH] Variable entity wake-up duration License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) Gale - https://galemc.org -diff --git a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -index 9ac3c235a7adc42af1ba22aaa4efbce5b006f98d..42306d45d3b8f7807b344422fca7382eec52cde2 100644 ---- a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -+++ b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -@@ -96,6 +96,7 @@ public class GaleWorldConfiguration extends ConfigurationPart { - public GameplayMechanics gameplayMechanics; - public class GameplayMechanics extends ConfigurationPart { - -+ public double entityWakeUpDurationRatioStandardDeviation = 0.2; // Gale - variable entity wake-up duration - public boolean tryRespawnEnderDragonAfterEndCrystalPlace = true; // Gale - Pufferfish - make ender dragon respawn attempt after placing end crystals configurable - - } -diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java -index 24536f70309f802d45714e06bace339f1d9f1013..21363541030d0381a8e139b409453b57a4eb6eaf 100644 ---- a/src/main/java/org/spigotmc/ActivationRange.java -+++ b/src/main/java/org/spigotmc/ActivationRange.java -@@ -69,28 +69,40 @@ public class ActivationRange +diff --git a/io/papermc/paper/entity/activation/ActivationRange.java b/io/papermc/paper/entity/activation/ActivationRange.java +index 5d1e83658bb9646cf56885627256f0be7a84831e..b9c8bcf3136939a1c8f215af53c4fa343b344e38 100644 +--- a/io/papermc/paper/entity/activation/ActivationRange.java ++++ b/io/papermc/paper/entity/activation/ActivationRange.java +@@ -53,27 +53,39 @@ public final class ActivationRange { if (entity.activationType == ActivationType.VILLAGER) { if (inactiveFor > config.wakeUpInactiveVillagersEvery && world.wakeupInactiveRemainingVillagers > 0) { world.wakeupInactiveRemainingVillagers--; @@ -50,7 +38,6 @@ index 24536f70309f802d45714e06bace339f1d9f1013..21363541030d0381a8e139b409453b57 } return -1; } - // Paper end + // Gale start - variable entity wake-up duration + private static final java.util.Random wakeUpDurationRandom = new java.util.Random(); @@ -64,6 +51,6 @@ index 24536f70309f802d45714e06bace339f1d9f1013..21363541030d0381a8e139b409453b57 + } + // Gale end - variable entity wake-up duration + - static AABB maxBB = new AABB( 0, 0, 0, 0, 0, 0 ); + static AABB maxBB = new AABB(0, 0, 0, 0, 0, 0); /** diff --git a/patches/server/0040-Do-not-process-chat-commands-before-player-has-joine.patch b/gale-server/minecraft-patches/features/0031-Do-not-process-chat-commands-before-player-has-joine.patch similarity index 55% rename from patches/server/0040-Do-not-process-chat-commands-before-player-has-joine.patch rename to gale-server/minecraft-patches/features/0031-Do-not-process-chat-commands-before-player-has-joine.patch index 5d06344..08f03e7 100644 --- a/patches/server/0040-Do-not-process-chat-commands-before-player-has-joine.patch +++ b/gale-server/minecraft-patches/features/0031-Do-not-process-chat-commands-before-player-has-joine.patch @@ -12,11 +12,11 @@ By: chickeneer As part of: EmpireCraft (https://github.com/starlis/empirecraft) Licensed under: MIT (https://opensource.org/licenses/MIT) -diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java -index a0d940312e37d7b74df7103878ff547a45fc5c05..ada9814d24b32140f365eb01a231bc123d99c72e 100644 ---- a/src/main/java/net/minecraft/server/level/ServerPlayer.java -+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java -@@ -322,6 +322,7 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple +diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java +index b349da64650f914db8212e19b3c05ba92e74a1a3..9c2f9bc5e5bef96fb7ad0f04aa1cb72db9d10638 100644 +--- a/net/minecraft/server/level/ServerPlayer.java ++++ b/net/minecraft/server/level/ServerPlayer.java +@@ -386,6 +386,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc public boolean joining = true; public boolean sentListPacket = false; public boolean supressTrackerForLogin = false; // Paper - Fire PlayerJoinEvent when Player is actually ready @@ -24,12 +24,12 @@ index a0d940312e37d7b74df7103878ff547a45fc5c05..ada9814d24b32140f365eb01a231bc12 // CraftBukkit end public boolean isRealPlayer; // Paper public com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper - PlayerNaturallySpawnCreaturesEvent -diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index c13aadf03462faf04bf0fc50525a130112debdff..ad53a045efaa6ed44a5b345586366b7c50e5688a 100644 ---- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -2385,7 +2385,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl - this.disconnectAsync((Component) Component.translatable("multiplayer.disconnect.illegal_characters"), org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_CHARACTERS); // Paper // Paper - add proper async disconnect +diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java +index 089a903607c0d16dc2744981a6dcb23115df010d..1a2b9a2e2cabf542523982f6f8742840933b0f4a 100644 +--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java ++++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java +@@ -2325,7 +2325,7 @@ public class ServerGamePacketListenerImpl + this.disconnectAsync(Component.translatable("multiplayer.disconnect.illegal_characters"), org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_CHARACTERS); // Paper - add proper async disconnect } else if (this.player.isRemoved() || this.player.getChatVisibility() == ChatVisiblity.HIDDEN) { // CraftBukkit - dead men tell no tales this.send(new ClientboundSystemChatPacket(Component.translatable("chat.disabled.options").withStyle(ChatFormatting.RED), false)); - } else { @@ -37,11 +37,11 @@ index c13aadf03462faf04bf0fc50525a130112debdff..ad53a045efaa6ed44a5b345586366b7c this.player.resetLastActionTime(); // CraftBukkit start if (sync) { -diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index 30de3d1a7792c38ae946f19cb0e14637919b5001..0e2b903dbd783bea891b88902136e1ac9f7fd66c 100644 ---- a/src/main/java/net/minecraft/server/players/PlayerList.java -+++ b/src/main/java/net/minecraft/server/players/PlayerList.java -@@ -353,6 +353,8 @@ public abstract class PlayerList { +diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java +index 03feaf0adb8ee87e33744a4615dc2507a02f92d7..23645f84f705bfbea29d7eaeaca84d0b115aae5a 100644 +--- a/net/minecraft/server/players/PlayerList.java ++++ b/net/minecraft/server/players/PlayerList.java +@@ -330,6 +330,8 @@ public abstract class PlayerList { return; } diff --git a/gale-server/minecraft-patches/features/0032-Do-not-log-invalid-statistics.patch b/gale-server/minecraft-patches/features/0032-Do-not-log-invalid-statistics.patch new file mode 100644 index 0000000..6072494 --- /dev/null +++ b/gale-server/minecraft-patches/features/0032-Do-not-log-invalid-statistics.patch @@ -0,0 +1,42 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Thu, 24 Nov 2022 23:39:32 +0100 +Subject: [PATCH] Do not log invalid statistics + +License: MIT (https://opensource.org/licenses/MIT) +Gale - https://galemc.org + +This patch is based on the following patch: +"Ignore statistics warnings" +By: Aikar +As part of: EmpireCraft (https://github.com/starlis/empirecraft) +Licensed under: MIT (https://opensource.org/licenses/MIT) + +diff --git a/net/minecraft/stats/ServerStatsCounter.java b/net/minecraft/stats/ServerStatsCounter.java +index 6c5205fe1dc6387a77b1edbdcab748d39e775d7f..b26dbe807e5cb0a42f6c06b933397902310e5616 100644 +--- a/net/minecraft/stats/ServerStatsCounter.java ++++ b/net/minecraft/stats/ServerStatsCounter.java +@@ -113,16 +113,20 @@ public class ServerStatsCounter extends StatsCounter { + Util.ifElse( + this.getStat(type, string1), + stat -> this.stats.put(stat, compound1.getInt(string1)), +- () -> LOGGER.warn("Invalid statistic in {}: Don't know what {} is", this.file, string1) ++ () -> { ++ if (org.galemc.gale.configuration.GaleGlobalConfiguration.get().logToConsole.invalidStatistics) LOGGER.warn("Invalid statistic in {}: Don't know what {} is", this.file, string1); // Gale - EMC - do not log invalid statistics ++ } + ); + } else { +- LOGGER.warn( ++ if (org.galemc.gale.configuration.GaleGlobalConfiguration.get().logToConsole.invalidStatistics) LOGGER.warn( // Gale - EMC - do not log invalid statistics + "Invalid statistic value in {}: Don't know what {} is for key {}", this.file, compound1.get(string1), string1 + ); + } + } + }, +- () -> LOGGER.warn("Invalid statistic type in {}: Don't know what {} is", this.file, string) ++ () -> { ++ if (org.galemc.gale.configuration.GaleGlobalConfiguration.get().logToConsole.invalidStatistics) LOGGER.warn("Invalid statistic type in {}: Don't know what {} is", this.file, string); // Gale - EMC - do not log invalid statistics ++ } + ); + } + } diff --git a/gale-server/minecraft-patches/features/0033-Do-not-log-empty-message-warnings.patch b/gale-server/minecraft-patches/features/0033-Do-not-log-empty-message-warnings.patch new file mode 100644 index 0000000..7d740d5 --- /dev/null +++ b/gale-server/minecraft-patches/features/0033-Do-not-log-empty-message-warnings.patch @@ -0,0 +1,21 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Thu, 24 Nov 2022 23:45:57 +0100 +Subject: [PATCH] Do not log empty message warnings + +License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) +Gale - https://galemc.org + +diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java +index 1a2b9a2e2cabf542523982f6f8742840933b0f4a..1fa2bb9e9866ad6f0394327df934388b7fcd7f93 100644 +--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java ++++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java +@@ -2479,7 +2479,7 @@ public class ServerGamePacketListenerImpl + // CraftBukkit start + String rawMessage = message.signedContent(); + if (rawMessage.isEmpty()) { +- LOGGER.warn("{} tried to send an empty message", this.player.getScoreboardName()); ++ if (org.galemc.gale.configuration.GaleGlobalConfiguration.get().logToConsole.chat.emptyMessageWarning) LOGGER.warn("{} tried to send an empty message", this.player.getScoreboardName()); // Gale - do not log empty message warnings + } else if (this.getCraftPlayer().isConversing()) { + final String conversationInput = rawMessage; + this.server.processQueue.add(() -> ServerGamePacketListenerImpl.this.getCraftPlayer().acceptConversationInput(conversationInput)); diff --git a/gale-server/minecraft-patches/features/0034-Do-not-log-ignored-advancements.patch b/gale-server/minecraft-patches/features/0034-Do-not-log-ignored-advancements.patch new file mode 100644 index 0000000..57a7586 --- /dev/null +++ b/gale-server/minecraft-patches/features/0034-Do-not-log-ignored-advancements.patch @@ -0,0 +1,51 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Fri, 25 Nov 2022 13:18:54 +0100 +Subject: [PATCH] Do not log ignored advancements + +License: MIT (https://opensource.org/licenses/MIT) +Gale - https://galemc.org + +This patch is based on the following patch: +"Logger settings (suppressing pointless logs)" +By: William Blake Galbreath +As part of: Purpur (https://github.com/PurpurMC/Purpur) +Licensed under: MIT (https://opensource.org/licenses/MIT) + +* Purpur copyright * + +MIT License + +Copyright (c) 2019-2022 PurpurMC + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +diff --git a/net/minecraft/server/PlayerAdvancements.java b/net/minecraft/server/PlayerAdvancements.java +index 64dbee1f67eaa17c93c13bfa38fbe27de57651e4..ecb7edc1b10d23bb1979152341cd4a2b89613a65 100644 +--- a/net/minecraft/server/PlayerAdvancements.java ++++ b/net/minecraft/server/PlayerAdvancements.java +@@ -148,7 +148,7 @@ public class PlayerAdvancements { + AdvancementHolder advancementHolder = advancementManager.get(path); + if (advancementHolder == null) { + if (!path.getNamespace().equals(ResourceLocation.DEFAULT_NAMESPACE)) return; // CraftBukkit +- LOGGER.warn("Ignored advancement '{}' in progress file {} - it doesn't exist anymore?", path, this.playerSavePath); ++ if (org.galemc.gale.configuration.GaleGlobalConfiguration.get().logToConsole.ignoredAdvancements) LOGGER.warn("Ignored advancement '{}' in progress file {} - it doesn't exist anymore?", path, this.playerSavePath); // Gale - Purpur - do not log ignored advancements + } else { + this.startProgress(advancementHolder, progress); + this.progressChanged.add(advancementHolder); diff --git a/patches/server/0044-Do-not-log-setBlock-in-far-chunks.patch b/gale-server/minecraft-patches/features/0035-Do-not-log-setBlock-in-far-chunks.patch similarity index 50% rename from patches/server/0044-Do-not-log-setBlock-in-far-chunks.patch rename to gale-server/minecraft-patches/features/0035-Do-not-log-setBlock-in-far-chunks.patch index a51b15d..4a272cc 100644 --- a/patches/server/0044-Do-not-log-setBlock-in-far-chunks.patch +++ b/gale-server/minecraft-patches/features/0035-Do-not-log-setBlock-in-far-chunks.patch @@ -36,27 +36,16 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -diff --git a/src/main/java/net/minecraft/server/level/WorldGenRegion.java b/src/main/java/net/minecraft/server/level/WorldGenRegion.java -index e4b0dc3121101d54394a0c3a413dabf8103b2ea6..4212d2522a0619267902c8230d424495378ee743 100644 ---- a/src/main/java/net/minecraft/server/level/WorldGenRegion.java -+++ b/src/main/java/net/minecraft/server/level/WorldGenRegion.java -@@ -336,6 +336,7 @@ public class WorldGenRegion implements WorldGenLevel { +diff --git a/net/minecraft/server/level/WorldGenRegion.java b/net/minecraft/server/level/WorldGenRegion.java +index 7fa41dea184b01891f45d8e404bc1cba19cf1bcf..c41f68a84fce082140cf1b18db328cfacae35208 100644 +--- a/net/minecraft/server/level/WorldGenRegion.java ++++ b/net/minecraft/server/level/WorldGenRegion.java +@@ -312,7 +312,7 @@ public class WorldGenRegion implements WorldGenLevel { return true; } else { // Paper start - Buffer OOB setBlock calls -+ if (org.galemc.gale.configuration.GaleGlobalConfiguration.get().logToConsole.setBlockInFarChunk) // Gale - Purpur - do not log setBlock in far chunks - if (!hasSetFarWarned) { - Util.logAndPauseIfInIde("Detected setBlock in a far chunk [" + i + ", " + j + "], pos: " + String.valueOf(pos) + ", status: " + String.valueOf(this.generatingStep.targetStatus()) + (this.currentlyGenerating == null ? "" : ", currently generating: " + (String) this.currentlyGenerating.get())); - hasSetFarWarned = true; -diff --git a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -index 0ffbe284abfc8ef8f9ed21c8539c497cad685380..0844babd79d3743abe240e68a50e082f58e2f01c 100644 ---- a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -+++ b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -@@ -53,6 +53,7 @@ public class GaleGlobalConfiguration extends ConfigurationPart { - - public boolean invalidStatistics = true; // Gale - EMC - do not log invalid statistics - public boolean ignoredAdvancements = true; // Gale - Purpur - do not log ignored advancements -+ public boolean setBlockInFarChunk = true; // Gale - Purpur - do not log setBlock in far chunks - - public Chat chat; - public class Chat extends ConfigurationPart { +- if (!hasSetFarWarned) { ++ if (org.galemc.gale.configuration.GaleGlobalConfiguration.get().logToConsole.setBlockInFarChunk && !hasSetFarWarned) { // Gale - Purpur - do not log setBlock in far chunks + Util.logAndPauseIfInIde( + "Detected setBlock in a far chunk [" + + sectionPosX diff --git a/gale-server/minecraft-patches/features/0036-Do-not-log-unrecognized-recipes.patch b/gale-server/minecraft-patches/features/0036-Do-not-log-unrecognized-recipes.patch new file mode 100644 index 0000000..4ddb0d3 --- /dev/null +++ b/gale-server/minecraft-patches/features/0036-Do-not-log-unrecognized-recipes.patch @@ -0,0 +1,51 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Fri, 25 Nov 2022 15:01:30 +0100 +Subject: [PATCH] Do not log unrecognized recipes + +License: MIT (https://opensource.org/licenses/MIT) +Gale - https://galemc.org + +This patch is based on the following patch: +"Logger settings (suppressing pointless logs)" +By: William Blake Galbreath +As part of: Purpur (https://github.com/PurpurMC/Purpur) +Licensed under: MIT (https://opensource.org/licenses/MIT) + +* Purpur copyright * + +MIT License + +Copyright (c) 2019-2022 PurpurMC + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +diff --git a/net/minecraft/stats/ServerRecipeBook.java b/net/minecraft/stats/ServerRecipeBook.java +index e3985b70cee7f7d56f179aeef8c2a6a6b312d83a..3418d7d3cf1116479f793e76e101d1c68bfe175c 100644 +--- a/net/minecraft/stats/ServerRecipeBook.java ++++ b/net/minecraft/stats/ServerRecipeBook.java +@@ -138,7 +138,7 @@ public class ServerRecipeBook extends RecipeBook { + try { + ResourceKey> resourceKey = ResourceKey.create(Registries.RECIPE, ResourceLocation.parse(string)); + if (!isRecognized.test(resourceKey)) { +- LOGGER.error("Tried to load unrecognized recipe: {} removed now.", resourceKey); ++ if (org.galemc.gale.configuration.GaleGlobalConfiguration.get().logToConsole.unrecognizedRecipes) LOGGER.error("Tried to load unrecognized recipe: {} removed now.", resourceKey); // Gale - Purpur - do not log unrecognized recipes + } else { + output.accept(resourceKey); + } diff --git a/gale-server/minecraft-patches/features/0037-Do-not-log-expired-message-warnings.patch b/gale-server/minecraft-patches/features/0037-Do-not-log-expired-message-warnings.patch new file mode 100644 index 0000000..7a63091 --- /dev/null +++ b/gale-server/minecraft-patches/features/0037-Do-not-log-expired-message-warnings.patch @@ -0,0 +1,21 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Fri, 25 Nov 2022 15:07:55 +0100 +Subject: [PATCH] Do not log expired message warnings + +License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) +Gale - https://galemc.org + +diff --git a/net/minecraft/network/chat/SignedMessageChain.java b/net/minecraft/network/chat/SignedMessageChain.java +index 23872fac07fa36f10ef090df2423c978998dcb99..44b166f5802468d7b1aefc8641496e0fefd6998f 100644 +--- a/net/minecraft/network/chat/SignedMessageChain.java ++++ b/net/minecraft/network/chat/SignedMessageChain.java +@@ -56,7 +56,7 @@ public class SignedMessageChain { + throw new SignedMessageChain.DecodeException(SignedMessageChain.DecodeException.INVALID_SIGNATURE); + } else { + if (playerChatMessage.hasExpiredServer(Instant.now())) { +- SignedMessageChain.LOGGER.warn("Received expired chat: '{}'. Is the client/server system time unsynchronized?", body.content()); ++ if (org.galemc.gale.configuration.GaleGlobalConfiguration.get().logToConsole.chat.expiredMessageWarning) SignedMessageChain.LOGGER.warn("Received expired chat: '{}'. Is the client/server system time unsynchronized?", body.content()); // Gale - do not log expired message warnings + } + + SignedMessageChain.this.nextLink = signedMessageLink.advance(); diff --git a/gale-server/minecraft-patches/features/0038-Do-not-log-Not-Secure-marker.patch b/gale-server/minecraft-patches/features/0038-Do-not-log-Not-Secure-marker.patch new file mode 100644 index 0000000..4e8509f --- /dev/null +++ b/gale-server/minecraft-patches/features/0038-Do-not-log-Not-Secure-marker.patch @@ -0,0 +1,21 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Fri, 25 Nov 2022 15:13:38 +0100 +Subject: [PATCH] Do not log Not Secure marker + +License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) +Gale - https://galemc.org + +diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java +index 23645f84f705bfbea29d7eaeaca84d0b115aae5a..a0d56fcd58f943353b55821557d79c4dc0cdf46b 100644 +--- a/net/minecraft/server/players/PlayerList.java ++++ b/net/minecraft/server/players/PlayerList.java +@@ -1258,7 +1258,7 @@ public abstract class PlayerList { + public void broadcastChatMessage(PlayerChatMessage message, Predicate shouldFilterMessageTo, @Nullable ServerPlayer sender, ChatType.Bound boundChatType, @Nullable Function unsignedFunction) { + // Paper end + boolean flag = this.verifyChatTrusted(message); +- this.server.logChatMessage((unsignedFunction == null ? message.decoratedContent() : unsignedFunction.apply(this.server.console)), boundChatType, flag ? null : "Not Secure"); // Paper ++ this.server.logChatMessage((unsignedFunction == null ? message.decoratedContent() : unsignedFunction.apply(this.server.console)), boundChatType, flag || !org.galemc.gale.configuration.GaleGlobalConfiguration.get().logToConsole.chat.notSecureMarker ? null : "Not Secure"); // Paper // Gale - do not log Not Secure marker + OutgoingChatMessage outgoingChatMessage = OutgoingChatMessage.create(message); + boolean flag1 = false; + diff --git a/patches/server/0050-Do-not-log-disconnections-with-null-id.patch b/gale-server/minecraft-patches/features/0039-Do-not-log-disconnections-with-null-id.patch similarity index 50% rename from patches/server/0050-Do-not-log-disconnections-with-null-id.patch rename to gale-server/minecraft-patches/features/0039-Do-not-log-disconnections-with-null-id.patch index 92f7355..14d5f6c 100644 --- a/patches/server/0050-Do-not-log-disconnections-with-null-id.patch +++ b/gale-server/minecraft-patches/features/0039-Do-not-log-disconnections-with-null-id.patch @@ -16,10 +16,10 @@ Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) This can help to hide annoying scanning bots from showing up in console. -diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -index 033755682c61c889723c3669b5cff4de147f637e..f89eb72f34ff3dcbb04ec0c9e98dfedce203911a 100644 ---- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +diff --git a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +index 6689aeacf50d1498e8d23cce696fb4fecbd1cf39..d9c0831dd58a5cdf1b23444489ac04629f8916f9 100644 +--- a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java ++++ b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java @@ -146,6 +146,14 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, public void disconnect(Component reason) { @@ -32,18 +32,6 @@ index 033755682c61c889723c3669b5cff4de147f637e..f89eb72f34ff3dcbb04ec0c9e98dfedc + } + } + // Gale end - Pufferfish - do not log disconnections with null id - ServerLoginPacketListenerImpl.LOGGER.info("Disconnecting {}: {}", this.getUserName(), reason.getString()); + LOGGER.info("Disconnecting {}: {}", this.getUserName(), reason.getString()); this.connection.send(new ClientboundLoginDisconnectPacket(reason)); this.connection.disconnect(reason); -diff --git a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -index 413c41e8c2fead4de859535007641094a64e97dd..a1b98b0f92618764304de484c373ce5e106f34f0 100644 ---- a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -+++ b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -@@ -58,6 +58,7 @@ public class GaleGlobalConfiguration extends ConfigurationPart { - public boolean setBlockInFarChunk = true; // Gale - Purpur - do not log setBlock in far chunks - public boolean unrecognizedRecipes = false; // Gale - Purpur - do not log unrecognized recipes - public boolean legacyMaterialInitialization = false; // Gale - Purpur - do not log legacy Material initialization -+ public boolean nullIdDisconnections = true; // Gale - Pufferfish - do not log disconnections with null id - - public Chat chat; - public class Chat extends ConfigurationPart { diff --git a/patches/server/0051-Do-not-log-run-as-root-warning.patch b/gale-server/minecraft-patches/features/0040-Do-not-log-run-as-root-warning.patch similarity index 72% rename from patches/server/0051-Do-not-log-run-as-root-warning.patch rename to gale-server/minecraft-patches/features/0040-Do-not-log-run-as-root-warning.patch index b377cc6..9779b7a 100644 --- a/patches/server/0051-Do-not-log-run-as-root-warning.patch +++ b/gale-server/minecraft-patches/features/0040-Do-not-log-run-as-root-warning.patch @@ -40,16 +40,16 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -index 3c63a956b5b04de5181a1827a4df8a1efb726b0c..46d97e4997babbf6e5b71f1f0fb37c46a887087e 100644 ---- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -@@ -194,7 +194,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +diff --git a/net/minecraft/server/dedicated/DedicatedServer.java b/net/minecraft/server/dedicated/DedicatedServer.java +index 3cd6e63ea6c18a26ef1aa394cf53d9e3463f8e50..3c1e6320305fa41b27a78c844dcf6172b244cc9b 100644 +--- a/net/minecraft/server/dedicated/DedicatedServer.java ++++ b/net/minecraft/server/dedicated/DedicatedServer.java +@@ -183,7 +183,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface } // Paper start - detect running as root - if (io.papermc.paper.util.ServerEnvironment.userIsRootOrAdmin()) { + if (!"false".equalsIgnoreCase(System.getProperty("gale.log.warning.root")) && io.papermc.paper.util.ServerEnvironment.userIsRootOrAdmin()) { // Gale - KeYi - do not log run as root warning - DedicatedServer.LOGGER.warn("****************************"); - DedicatedServer.LOGGER.warn("YOU ARE RUNNING THIS SERVER AS AN ADMINISTRATIVE OR ROOT USER. THIS IS NOT ADVISED."); - DedicatedServer.LOGGER.warn("YOU ARE OPENING YOURSELF UP TO POTENTIAL RISKS WHEN DOING THIS."); + LOGGER.warn("****************************"); + LOGGER.warn("YOU ARE RUNNING THIS SERVER AS AN ADMINISTRATIVE OR ROOT USER. THIS IS NOT ADVISED."); + LOGGER.warn("YOU ARE OPENING YOURSELF UP TO POTENTIAL RISKS WHEN DOING THIS."); diff --git a/patches/server/0052-Do-not-log-offline-mode-warning.patch b/gale-server/minecraft-patches/features/0041-Do-not-log-offline-mode-warning.patch similarity index 78% rename from patches/server/0052-Do-not-log-offline-mode-warning.patch rename to gale-server/minecraft-patches/features/0041-Do-not-log-offline-mode-warning.patch index 3f42287..353670c 100644 --- a/patches/server/0052-Do-not-log-offline-mode-warning.patch +++ b/gale-server/minecraft-patches/features/0041-Do-not-log-offline-mode-warning.patch @@ -40,16 +40,16 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -index 46d97e4997babbf6e5b71f1f0fb37c46a887087e..feb1758ae47d0d2fe9b049a2167ab52f3e03406b 100644 ---- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -@@ -307,7 +307,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +diff --git a/net/minecraft/server/dedicated/DedicatedServer.java b/net/minecraft/server/dedicated/DedicatedServer.java +index 3c1e6320305fa41b27a78c844dcf6172b244cc9b..f2e24d52240a84ff7ca69ad2c8ec0d1c197467c0 100644 +--- a/net/minecraft/server/dedicated/DedicatedServer.java ++++ b/net/minecraft/server/dedicated/DedicatedServer.java +@@ -295,7 +295,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface String proxyFlavor = (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) ? "Velocity" : "BungeeCord"; String proxyLink = (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) ? "https://docs.papermc.io/velocity/security" : "http://www.spigotmc.org/wiki/firewall-guide/"; // Paper end - Add Velocity IP Forwarding Support - if (!this.usesAuthentication()) { + if (!"false".equalsIgnoreCase(System.getProperty("gale.log.warning.offline.mode")) && !this.usesAuthentication()) { // Gale - KeYi - do not log offline mode warning - DedicatedServer.LOGGER.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!"); - DedicatedServer.LOGGER.warn("The server will make no attempt to authenticate usernames. Beware."); + LOGGER.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!"); + LOGGER.warn("The server will make no attempt to authenticate usernames. Beware."); // Spigot start diff --git a/gale-server/minecraft-patches/features/0042-Softly-log-invalid-pool-element-errors.patch b/gale-server/minecraft-patches/features/0042-Softly-log-invalid-pool-element-errors.patch new file mode 100644 index 0000000..157db53 --- /dev/null +++ b/gale-server/minecraft-patches/features/0042-Softly-log-invalid-pool-element-errors.patch @@ -0,0 +1,36 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Fri, 25 Nov 2022 16:26:04 +0100 +Subject: [PATCH] Softly log invalid pool element errors + +License: MIT (https://opensource.org/licenses/MIT) +Gale - https://galemc.org + +This patch is based on the following patch: +"Change vanilla structure error to info log level" +By: chickeneer +As part of: EmpireCraft (https://github.com/starlis/empirecraft) +Licensed under: MIT (https://opensource.org/licenses/MIT) + +diff --git a/net/minecraft/world/level/levelgen/structure/PoolElementStructurePiece.java b/net/minecraft/world/level/levelgen/structure/PoolElementStructurePiece.java +index 5c91b11fdb12cd51d9d6c662f4ba7a7f78891e26..c63c357a28e7911c7a227e911a4dc36d914da9b5 100644 +--- a/net/minecraft/world/level/levelgen/structure/PoolElementStructurePiece.java ++++ b/net/minecraft/world/level/levelgen/structure/PoolElementStructurePiece.java +@@ -27,7 +27,7 @@ import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemp + import org.slf4j.Logger; + + public class PoolElementStructurePiece extends StructurePiece { +- private static final Logger LOGGER = LogUtils.getLogger(); ++ public static final Logger LOGGER = LogUtils.getLogger(); // Gale - EMC - softly log invalid pool element errors - private -> public + protected final StructurePoolElement element; + protected BlockPos position; + private final int groundLevelDelta; +@@ -80,7 +80,7 @@ public class PoolElementStructurePiece extends StructurePiece { + DynamicOps dynamicOps = context.registryAccess().createSerializationContext(NbtOps.INSTANCE); + StructurePoolElement.CODEC + .encodeStart(dynamicOps, this.element) +- .resultOrPartial(LOGGER::error) ++ .resultOrPartial(org.galemc.gale.configuration.GaleGlobalConfiguration.get().logToConsole.invalidPoolElementErrorStringConsumer) // Gale - EMC - softly log invalid pool element errors) + .ifPresent(elementTag -> tag.put("pool_element", elementTag)); + tag.putString("rotation", this.rotation.name()); + ListTag listTag = new ListTag(); diff --git a/patches/server/0054-Fix-outdated-server-showing-in-ping-before-server-fu.patch b/gale-server/minecraft-patches/features/0043-Fix-outdated-server-showing-in-ping-before-server-fu.patch similarity index 70% rename from patches/server/0054-Fix-outdated-server-showing-in-ping-before-server-fu.patch rename to gale-server/minecraft-patches/features/0043-Fix-outdated-server-showing-in-ping-before-server-fu.patch index 2b7e56f..f6fb9d5 100644 --- a/patches/server/0054-Fix-outdated-server-showing-in-ping-before-server-fu.patch +++ b/gale-server/minecraft-patches/features/0043-Fix-outdated-server-showing-in-ping-before-server-fu.patch @@ -37,18 +37,18 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -diff --git a/src/main/java/net/minecraft/server/network/ServerStatusPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerStatusPacketListenerImpl.java -index 532f09089b8d6798999cf3f83e852df7479e450e..ae31c667ece5a84772d9c9009d3e66fd37d38908 100644 ---- a/src/main/java/net/minecraft/server/network/ServerStatusPacketListenerImpl.java -+++ b/src/main/java/net/minecraft/server/network/ServerStatusPacketListenerImpl.java -@@ -154,6 +154,10 @@ public class ServerStatusPacketListenerImpl implements ServerStatusPacketListene - this.connection.send(new ClientboundStatusResponsePacket(ping)); - // CraftBukkit end - */ +diff --git a/net/minecraft/server/network/ServerStatusPacketListenerImpl.java b/net/minecraft/server/network/ServerStatusPacketListenerImpl.java +index 465559113071a47e706f77a5b0996597ee986b3d..628fa5afe8eae4ae422ecdd6096a821731d97ac1 100644 +--- a/net/minecraft/server/network/ServerStatusPacketListenerImpl.java ++++ b/net/minecraft/server/network/ServerStatusPacketListenerImpl.java +@@ -37,6 +37,10 @@ public class ServerStatusPacketListenerImpl implements ServerStatusPacketListene + } else { + this.hasRequestedStatus = true; + // this.connection.send(new ClientboundStatusResponsePacket(this.status)); // Paper + // Gale start - Purpur - fix 'outdated server' showing in ping before server fully boots - do not respond to pings before we know the protocol version -+ var version = MinecraftServer.getServer().getStatus().version(); ++ var version = net.minecraft.server.MinecraftServer.getServer().getStatus().version(); + if (version == null || version.isEmpty()) return; + // Gale end - Purpur - fix 'outdated server' showing in ping before server fully boots - do not respond to pings before we know the protocol version - com.destroystokyo.paper.network.StandardPaperServerListPingEventImpl.processRequest(MinecraftServer.getServer(), this.connection); - // Paper end + com.destroystokyo.paper.network.StandardPaperServerListPingEventImpl.processRequest(net.minecraft.server.MinecraftServer.getServer(), this.connection); // Paper - handle status request } + } diff --git a/gale-server/minecraft-patches/features/0044-Fix-MC-238526.patch b/gale-server/minecraft-patches/features/0044-Fix-MC-238526.patch new file mode 100644 index 0000000..a30bbae --- /dev/null +++ b/gale-server/minecraft-patches/features/0044-Fix-MC-238526.patch @@ -0,0 +1,56 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Tue, 29 Nov 2022 16:16:35 +0100 +Subject: [PATCH] Fix MC-238526 + +License: MIT (https://opensource.org/licenses/MIT) +Gale - https://galemc.org + +This patch is based on the following patch: +"MC-238526 - Fix spawner not spawning water animals correctly" +By: BillyGalbreath +As part of: Purpur (https://github.com/PurpurMC/Purpur) +Licensed under: MIT (https://opensource.org/licenses/MIT) + +* Purpur copyright * + +MIT License + +Copyright (c) 2019-2022 PurpurMC + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +diff --git a/net/minecraft/world/entity/animal/WaterAnimal.java b/net/minecraft/world/entity/animal/WaterAnimal.java +index ed4f4c76a53c39c1a912fc0ff0d84f7fdb494b20..8910e2578bf8b7541a98f20ddc34255343ec4e4d 100644 +--- a/net/minecraft/world/entity/animal/WaterAnimal.java ++++ b/net/minecraft/world/entity/animal/WaterAnimal.java +@@ -74,8 +74,11 @@ public abstract class WaterAnimal extends PathfinderMob { + seaLevel = level.getMinecraftWorld().paperConfig().entities.spawning.wateranimalSpawnHeight.maximum.or(seaLevel); + i = level.getMinecraftWorld().paperConfig().entities.spawning.wateranimalSpawnHeight.minimum.or(i); + // Paper end - Make water animal spawn height configurable +- return pos.getY() >= i +- && pos.getY() <= seaLevel ++ // Gale start - Purpur - fix MC-238526 ++ boolean shouldFixMC238526 = spawnReason == EntitySpawnReason.SPAWNER && level.getMinecraftWorld().galeConfig().gameplayMechanics.fixes.mc238526; ++ boolean isAllowedHeight = pos.getY() >= i && pos.getY() <= seaLevel; ++ return (shouldFixMC238526 || isAllowedHeight) ++ // Gale end - Purpur - fix MC-238526 + && level.getFluidState(pos.below()).is(FluidTags.WATER) + && level.getBlockState(pos.above()).is(Blocks.WATER); + } diff --git a/patches/server/0057-Fix-MC-121706.patch b/gale-server/minecraft-patches/features/0045-Fix-MC-121706.patch similarity index 59% rename from patches/server/0057-Fix-MC-121706.patch rename to gale-server/minecraft-patches/features/0045-Fix-MC-121706.patch index d7b61d0..90a3ebf 100644 --- a/patches/server/0057-Fix-MC-121706.patch +++ b/gale-server/minecraft-patches/features/0045-Fix-MC-121706.patch @@ -36,10 +36,10 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/RangedBowAttackGoal.java b/src/main/java/net/minecraft/world/entity/ai/goal/RangedBowAttackGoal.java -index 515c1f671cb2c3a7cc23053aedf404bbbe77af3e..df002c7277a718dc156d2d5271fa4768b97f8d86 100644 ---- a/src/main/java/net/minecraft/world/entity/ai/goal/RangedBowAttackGoal.java -+++ b/src/main/java/net/minecraft/world/entity/ai/goal/RangedBowAttackGoal.java +diff --git a/net/minecraft/world/entity/ai/goal/RangedBowAttackGoal.java b/net/minecraft/world/entity/ai/goal/RangedBowAttackGoal.java +index 722f378bb3726200b6fe88948bf1e1d3514a7b5c..dc3c709912367fc2789b789f178d16feb3c0a2ed 100644 +--- a/net/minecraft/world/entity/ai/goal/RangedBowAttackGoal.java ++++ b/net/minecraft/world/entity/ai/goal/RangedBowAttackGoal.java @@ -103,7 +103,10 @@ public class RangedBowAttackGoal extends Go this.strafingTime = 0; } @@ -49,34 +49,18 @@ index 515c1f671cb2c3a7cc23053aedf404bbbe77af3e..df002c7277a718dc156d2d5271fa4768 + boolean hasStrafingTime = this.strafingTime > -1; + if (hasStrafingTime) { + // Gale end - Purpur - fix MC-121706 - if (d > (double)(this.attackRadiusSqr * 0.75F)) { + if (d > this.attackRadiusSqr * 0.75F) { this.strafingBackwards = false; - } else if (d < (double)(this.attackRadiusSqr * 0.25F)) { + } else if (d < this.attackRadiusSqr * 0.25F) { @@ -116,7 +119,10 @@ public class RangedBowAttackGoal extends Go } - this.mob.lookAt(livingEntity, 30.0F, 30.0F); + this.mob.lookAt(target, 30.0F, 30.0F); - } else { + // Gale start - Purpur - fix MC-121706 + } + if (!hasStrafingTime || this.mob.level().galeConfig().gameplayMechanics.fixes.mc121706) { -+ // Gale end - Purpur - fix MC-121706 - this.mob.getLookControl().setLookAt(livingEntity, 30.0F, 30.0F); ++ // Gale end - Purpur - fix MC-121706 + this.mob.getLookControl().setLookAt(target, 30.0F, 30.0F); } -diff --git a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -index 3fa354ceef3ec5ab9bca3f13f23aca586dfe09c4..c53cb97b271ca5390b544a1af66182e3c4aefc74 100644 ---- a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -+++ b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -@@ -106,6 +106,11 @@ public class GaleWorldConfiguration extends ConfigurationPart { - public boolean mc238526 = false; - // Gale end - Purpur - fix MC-238526 - -+ // Gale start - Purpur - fix MC-121706 -+ @Setting("mc-121706") -+ public boolean mc121706 = false; -+ // Gale end - Purpur - fix MC-121706 -+ - } - - public double entityWakeUpDurationRatioStandardDeviation = 0.2; // Gale - variable entity wake-up duration diff --git a/patches/server/0059-Make-arrow-movement-resetting-despawn-counter-config.patch b/gale-server/minecraft-patches/features/0046-Make-arrow-movement-resetting-despawn-counter-config.patch similarity index 55% rename from patches/server/0059-Make-arrow-movement-resetting-despawn-counter-config.patch rename to gale-server/minecraft-patches/features/0046-Make-arrow-movement-resetting-despawn-counter-config.patch index a28be9b..e18bc27 100644 --- a/patches/server/0059-Make-arrow-movement-resetting-despawn-counter-config.patch +++ b/gale-server/minecraft-patches/features/0046-Make-arrow-movement-resetting-despawn-counter-config.patch @@ -41,28 +41,16 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -diff --git a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java -index 8ce573042ea87631eb6539f2a0d5036655c2b809..6e313a45356ed2b043ef626c7ca191b294acaf70 100644 ---- a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java -+++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java -@@ -371,7 +371,7 @@ public abstract class AbstractArrow extends Projectile { - Vec3 vec3d = this.getDeltaMovement(); - - this.setDeltaMovement(vec3d.multiply((double) (this.random.nextFloat() * 0.2F), (double) (this.random.nextFloat() * 0.2F), (double) (this.random.nextFloat() * 0.2F))); +diff --git a/net/minecraft/world/entity/projectile/AbstractArrow.java b/net/minecraft/world/entity/projectile/AbstractArrow.java +index 541ee32182b595de7dd6717f8faea00d53c105a3..d206ac2b9cade292b0d69e9aeb0f81227ec0b49e 100644 +--- a/net/minecraft/world/entity/projectile/AbstractArrow.java ++++ b/net/minecraft/world/entity/projectile/AbstractArrow.java +@@ -347,7 +347,7 @@ public abstract class AbstractArrow extends Projectile { + this.setInGround(false); + Vec3 deltaMovement = this.getDeltaMovement(); + this.setDeltaMovement(deltaMovement.multiply(this.random.nextFloat() * 0.2F, this.random.nextFloat() * 0.2F, this.random.nextFloat() * 0.2F)); - this.life = 0; + if (this.level().galeConfig().gameplayMechanics.arrowMovementResetsDespawnCounter) this.life = 0; // Gale - Purpur - make arrow movement resetting despawn counter configurable } - public boolean isInGround() { -diff --git a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -index 266079aed0610e0fa9e35da81680b7f388a8844a..cc843de2d62bdaadb4efb7032162f8f04b10c286 100644 ---- a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -+++ b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -@@ -118,6 +118,7 @@ public class GaleWorldConfiguration extends ConfigurationPart { - - } - -+ public boolean arrowMovementResetsDespawnCounter = true; // Gale - Purpur - make arrow movement resetting despawn counter configurable - public double entityWakeUpDurationRatioStandardDeviation = 0.2; // Gale - variable entity wake-up duration - public boolean tryRespawnEnderDragonAfterEndCrystalPlace = true; // Gale - Pufferfish - make ender dragon respawn attempt after placing end crystals configurable - + public boolean isInGround() { // Paper - protected -> public diff --git a/gale-server/minecraft-patches/features/0047-Make-logging-login-locations-configurable.patch b/gale-server/minecraft-patches/features/0047-Make-logging-login-locations-configurable.patch new file mode 100644 index 0000000..d23a48c --- /dev/null +++ b/gale-server/minecraft-patches/features/0047-Make-logging-login-locations-configurable.patch @@ -0,0 +1,32 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Mon, 26 Dec 2022 00:17:40 +0100 +Subject: [PATCH] Make logging login locations configurable + +License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) +Gale - https://galemc.org + +This patch is based on the following patch: +"configurable logging of player login location" +By: Simon Gardling +As part of: JettPack (https://gitlab.com/Titaniumtown/JettPack) +Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) + +diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java +index a0d56fcd58f943353b55821557d79c4dc0cdf46b..b4258db165b509d54b9c15a661c5b66ca984ffb3 100644 +--- a/net/minecraft/server/players/PlayerList.java ++++ b/net/minecraft/server/players/PlayerList.java +@@ -398,7 +398,13 @@ public abstract class PlayerList { + scoreboard.addPlayerToTeam(player.getScoreboardName(), collideRuleTeam); + } + // Paper end - Configurable player collision ++ if (org.galemc.gale.configuration.GaleGlobalConfiguration.get().logToConsole.playerLoginLocations) { // Gale - JettPack - make logging login location configurable + PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ([{}]{}, {}, {})", player.getName().getString(), loggableAddress, player.getId(), serverLevel.serverLevelData.getLevelName(), player.getX(), player.getY(), player.getZ()); ++ // Gale start - JettPack - make logging login location configurable ++ } else { ++ PlayerList.LOGGER.info("{}[{}] logged in with entity id {}", player.getName().getString(), loggableAddress, player.getId()); ++ } ++ // Gale end - JettPack - make logging login location configurable + // Paper start - Send empty chunk, so players aren't stuck in the world loading screen with our chunk system not sending chunks when dead + if (player.isDeadOrDying()) { + net.minecraft.core.Holder plains = serverLevel.registryAccess().lookupOrThrow(net.minecraft.core.registries.Registries.BIOME) diff --git a/gale-server/minecraft-patches/features/0048-Reduce-array-allocations.patch b/gale-server/minecraft-patches/features/0048-Reduce-array-allocations.patch new file mode 100644 index 0000000..56953ff --- /dev/null +++ b/gale-server/minecraft-patches/features/0048-Reduce-array-allocations.patch @@ -0,0 +1,365 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Sat, 26 Nov 2022 11:25:45 +0100 +Subject: [PATCH] Reduce array allocations + +License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) +Gale - https://galemc.org + +This patch is based on the following patch: +"reduce allocs" +By: Simon Gardling +As part of: JettPack (https://gitlab.com/Titaniumtown/JettPack) +Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) + +diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java b/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java +index d21ce54ebb5724c04eadf56a2cde701d5eeb5db2..848374fa7383d6a82c33dad03deb0e97eca97d23 100644 +--- a/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java ++++ b/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java +@@ -378,7 +378,6 @@ public final class ChunkEntitySlices { + + private static final class BasicEntityList { + +- private static final Entity[] EMPTY = new Entity[0]; + private static final int DEFAULT_CAPACITY = 4; + + private E[] storage; +@@ -389,8 +388,8 @@ public final class ChunkEntitySlices { + } + + public BasicEntityList(final int cap) { +- this.storage = (E[])(cap <= 0 ? EMPTY : new Entity[cap]); +- } ++ this.storage = (E[])(cap <= 0 ? me.titaniumtown.ArrayConstants.emptyEntityArray : new Entity[cap]); // Gale - JettPack - reduce array allocations ++ } // Gale - JettPack - reduce array allocations + + public boolean isEmpty() { + return this.size == 0; +@@ -401,7 +400,7 @@ public final class ChunkEntitySlices { + } + + private void resize() { +- if (this.storage == EMPTY) { ++ if (this.storage == me.titaniumtown.ArrayConstants.emptyEntityArray) { // Gale - JettPack - reduce array allocations + this.storage = (E[])new Entity[DEFAULT_CAPACITY]; + } else { + this.storage = Arrays.copyOf(this.storage, this.storage.length * 2); +diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/server/ServerEntityLookup.java b/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/server/ServerEntityLookup.java +index 26207443b1223119c03db478d7e816d9cdf8e618..bbd1c262674b42eb9ea2830acb8bf94182f971f9 100644 +--- a/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/server/ServerEntityLookup.java ++++ b/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/server/ServerEntityLookup.java +@@ -14,10 +14,8 @@ import net.minecraft.world.level.entity.LevelCallback; + + public final class ServerEntityLookup extends EntityLookup { + +- private static final Entity[] EMPTY_ENTITY_ARRAY = new Entity[0]; +- + private final ServerLevel serverWorld; +- public final ReferenceList trackerEntities = new ReferenceList<>(EMPTY_ENTITY_ARRAY); // Moonrise - entity tracker ++ public final ReferenceList trackerEntities = new ReferenceList<>(me.titaniumtown.ArrayConstants.emptyEntityArray); // Moonrise - entity tracker // Gale - JettPack - reduce array allocations + + public ServerEntityLookup(final ServerLevel world, final LevelCallback worldCallback) { + super(world, worldCallback); +diff --git a/net/minecraft/nbt/ByteArrayTag.java b/net/minecraft/nbt/ByteArrayTag.java +index 6927124a4ea1f460158bf25679104b6f9e9ccee4..dba08f2668d65ae5483f325af3a79b5a63919c50 100644 +--- a/net/minecraft/nbt/ByteArrayTag.java ++++ b/net/minecraft/nbt/ByteArrayTag.java +@@ -174,7 +174,7 @@ public class ByteArrayTag extends CollectionTag { + + @Override + public void clear() { +- this.data = new byte[0]; ++ this.data = me.titaniumtown.ArrayConstants.emptyByteArray; // Gale - JettPack - reduce array allocations + } + + @Override +diff --git a/net/minecraft/nbt/CompoundTag.java b/net/minecraft/nbt/CompoundTag.java +index 361bc458e0bb590c43da60a1cd993a2785ee45e9..3bce1e8ef90e95abd8b1111f1160f952d2493e69 100644 +--- a/net/minecraft/nbt/CompoundTag.java ++++ b/net/minecraft/nbt/CompoundTag.java +@@ -409,7 +409,7 @@ public class CompoundTag implements Tag { + throw new ReportedException(this.createReport(key, ByteArrayTag.TYPE, var3)); + } + +- return new byte[0]; ++ return me.titaniumtown.ArrayConstants.emptyByteArray; // Gale - JettPack - reduce array allocations + } + + public int[] getIntArray(String key) { +@@ -421,7 +421,7 @@ public class CompoundTag implements Tag { + throw new ReportedException(this.createReport(key, IntArrayTag.TYPE, var3)); + } + +- return new int[0]; ++ return me.titaniumtown.ArrayConstants.emptyIntArray; // Gale - JettPack - reduce array allocations + } + + public long[] getLongArray(String key) { +@@ -433,7 +433,7 @@ public class CompoundTag implements Tag { + throw new ReportedException(this.createReport(key, LongArrayTag.TYPE, var3)); + } + +- return new long[0]; ++ return me.titaniumtown.ArrayConstants.emptyLongArray; // Gale - JettPack - reduce array allocations + } + + public CompoundTag getCompound(String key) { +diff --git a/net/minecraft/nbt/IntArrayTag.java b/net/minecraft/nbt/IntArrayTag.java +index 7e27546bcb587d03b6de2ab43244e6c61fdb55f4..c7f35f332117305bf0e34eb8b73ddfa73958e434 100644 +--- a/net/minecraft/nbt/IntArrayTag.java ++++ b/net/minecraft/nbt/IntArrayTag.java +@@ -181,7 +181,7 @@ public class IntArrayTag extends CollectionTag { + + @Override + public void clear() { +- this.data = new int[0]; ++ this.data = me.titaniumtown.ArrayConstants.emptyIntArray; // Gale - JettPack - reduce array allocations + } + + @Override +diff --git a/net/minecraft/nbt/ListTag.java b/net/minecraft/nbt/ListTag.java +index 8bbe48a4d7d1771d17bec60b70bdf8e086bfd1c7..5ab487178544f6bc6b0c90d7a54b5c3ea1cdfbe9 100644 +--- a/net/minecraft/nbt/ListTag.java ++++ b/net/minecraft/nbt/ListTag.java +@@ -258,7 +258,7 @@ public class ListTag extends CollectionTag { + } + } + +- return new int[0]; ++ return me.titaniumtown.ArrayConstants.emptyIntArray; // Gale - JettPack - reduce array allocations + } + + public long[] getLongArray(int index) { +@@ -269,7 +269,7 @@ public class ListTag extends CollectionTag { + } + } + +- return new long[0]; ++ return me.titaniumtown.ArrayConstants.emptyLongArray; // Gale - JettPack - reduce array allocations + } + + public double getDouble(int index) { +diff --git a/net/minecraft/nbt/LongArrayTag.java b/net/minecraft/nbt/LongArrayTag.java +index 7274aa8ccae9294dcdb718cbd4997f841eeb9eba..d33466f2ad3aa967fd2e6c0efa73805ba725b3c2 100644 +--- a/net/minecraft/nbt/LongArrayTag.java ++++ b/net/minecraft/nbt/LongArrayTag.java +@@ -185,7 +185,7 @@ public class LongArrayTag extends CollectionTag { + + @Override + public void clear() { +- this.data = new long[0]; ++ this.data = me.titaniumtown.ArrayConstants.emptyLongArray; // Gale - JettPack - reduce array allocations + } + + @Override +diff --git a/net/minecraft/network/CipherBase.java b/net/minecraft/network/CipherBase.java +index 121685cacef111fbec0057d386f748497bc3a36d..b4a4fafec1a8e279ec1e31e58fee2d5d34fb8289 100644 +--- a/net/minecraft/network/CipherBase.java ++++ b/net/minecraft/network/CipherBase.java +@@ -7,8 +7,8 @@ import javax.crypto.ShortBufferException; + + public class CipherBase { + private final Cipher cipher; +- private byte[] heapIn = new byte[0]; +- private byte[] heapOut = new byte[0]; ++ private byte[] heapIn = me.titaniumtown.ArrayConstants.emptyByteArray; // Gale - JettPack - reduce array allocations ++ private byte[] heapOut = me.titaniumtown.ArrayConstants.emptyByteArray; // Gale - JettPack - reduce array allocations + + protected CipherBase(Cipher cipher) { + this.cipher = cipher; +diff --git a/net/minecraft/network/chat/contents/TranslatableContents.java b/net/minecraft/network/chat/contents/TranslatableContents.java +index 68727deaedd55aa86e76fbc6cc2cfb67913f7add..bad5787de2034dbb0eabb9458a47a89e30dec886 100644 +--- a/net/minecraft/network/chat/contents/TranslatableContents.java ++++ b/net/minecraft/network/chat/contents/TranslatableContents.java +@@ -29,7 +29,7 @@ import net.minecraft.util.ExtraCodecs; + import net.minecraft.world.entity.Entity; + + public class TranslatableContents implements ComponentContents { +- public static final Object[] NO_ARGS = new Object[0]; ++ public static final Object[] NO_ARGS = me.titaniumtown.ArrayConstants.emptyObjectArray; // Gale - JettPack - reduce array allocations + private static final Codec PRIMITIVE_ARG_CODEC = ExtraCodecs.JAVA.validate(TranslatableContents::filterAllowedArguments); + private static final Codec ARG_CODEC = Codec.either(PRIMITIVE_ARG_CODEC, ComponentSerialization.CODEC) + .xmap( +diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java +index 2caeb69306a42d02b7a5c27e00fb969e392ac6ba..2b9b683023943435a86c42e3a61e0b3329df19d8 100644 +--- a/net/minecraft/server/level/ServerLevel.java ++++ b/net/minecraft/server/level/ServerLevel.java +@@ -1224,7 +1224,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe + + public static List getCurrentlyTickingEntities() { + Entity ticking = currentlyTickingEntity.get(); +- List ret = java.util.Arrays.asList(ticking == null ? new Entity[0] : new Entity[] { ticking }); ++ List ret = java.util.Arrays.asList(ticking == null ? me.titaniumtown.ArrayConstants.emptyEntityArray : new Entity[] { ticking }); // Gale - JettPack - reduce array allocations + + return ret; + } +diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java +index 1fa2bb9e9866ad6f0394327df934388b7fcd7f93..247ff694e3d97365a9149b3c2fc99574a21aa9f9 100644 +--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java ++++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java +@@ -2767,7 +2767,7 @@ public class ServerGamePacketListenerImpl + target.refreshEntityData(ServerGamePacketListenerImpl.this.player); + // SPIGOT-7136 - Allays + if (target instanceof Allay || target instanceof net.minecraft.world.entity.animal.horse.AbstractHorse) { // Paper - Fix horse armor desync +- ServerGamePacketListenerImpl.this.send(new net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket(target.getId(), Arrays.stream(net.minecraft.world.entity.EquipmentSlot.values()).map((slot) -> Pair.of(slot, ((LivingEntity) target).getItemBySlot(slot).copy())).collect(Collectors.toList()), true)); // Paper - sanitize ++ ServerGamePacketListenerImpl.this.send(new net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket(target.getId(), Arrays.stream(net.minecraft.world.entity.EquipmentSlot.VALUES_ARRAY).map((slot) -> Pair.of(slot, ((LivingEntity) target).getItemBySlot(slot).copy())).collect(Collectors.toList()), true)); // Paper - sanitize // Gale - JettPack - reduce array allocations + } + + ServerGamePacketListenerImpl.this.player.containerMenu.sendAllDataToRemote(); // Paper - fix slot desync - always refresh player inventory +diff --git a/net/minecraft/server/players/StoredUserList.java b/net/minecraft/server/players/StoredUserList.java +index d445e8f126f077d8419c52fa5436ea963a1a42a4..39483f7b453d6faedeccc1ab1eda76669395ea5a 100644 +--- a/net/minecraft/server/players/StoredUserList.java ++++ b/net/minecraft/server/players/StoredUserList.java +@@ -70,7 +70,7 @@ public abstract class StoredUserList> { + } + + public String[] getUserList() { +- return this.map.keySet().toArray(new String[0]); ++ return this.map.keySet().toArray(me.titaniumtown.ArrayConstants.emptyStringArray); // Gale - JettPack - reduce array allocations + } + + public boolean isEmpty() { +diff --git a/net/minecraft/util/ZeroBitStorage.java b/net/minecraft/util/ZeroBitStorage.java +index 09fd99c9cbd23b5f3c899bfb00c9b89651948ed8..5c1103ef028e5ffe6ce0eadc861dd3b2c8f3ed9f 100644 +--- a/net/minecraft/util/ZeroBitStorage.java ++++ b/net/minecraft/util/ZeroBitStorage.java +@@ -5,7 +5,7 @@ import java.util.function.IntConsumer; + import org.apache.commons.lang3.Validate; + + public class ZeroBitStorage implements BitStorage { +- public static final long[] RAW = new long[0]; ++ public static final long[] RAW = me.titaniumtown.ArrayConstants.emptyLongArray; // Gale - JettPack - reduce array allocations + private final int size; + + public ZeroBitStorage(int size) { +diff --git a/net/minecraft/world/entity/EquipmentSlot.java b/net/minecraft/world/entity/EquipmentSlot.java +index c65595c0a55b0aeebb2cf858da99329d2192976e..0a5611b1ece4dbe2887e7fbdef45f58e7f4d53ad 100644 +--- a/net/minecraft/world/entity/EquipmentSlot.java ++++ b/net/minecraft/world/entity/EquipmentSlot.java +@@ -19,7 +19,8 @@ public enum EquipmentSlot implements StringRepresentable { + BODY(EquipmentSlot.Type.ANIMAL_ARMOR, 0, 1, 6, "body"); + + public static final int NO_COUNT_LIMIT = 0; +- public static final List VALUES = List.of(values()); ++ public static final EquipmentSlot[] VALUES_ARRAY = values(); // Gale - JettPack - reduce array allocations ++ public static final List VALUES = List.of(VALUES_ARRAY); // Gale - JettPack - reduce array allocations + public static final IntFunction BY_ID = ByIdMap.continuous(equipmentSlot -> equipmentSlot.id, values(), ByIdMap.OutOfBoundsStrategy.ZERO); + 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/entity/EquipmentSlotGroup.java b/net/minecraft/world/entity/EquipmentSlotGroup.java +index 028dff862850c63d0b66902e99dd0bf685a7aa0d..b2d8b6883e2527c13794d23d27a4647ab1e255dd 100644 +--- a/net/minecraft/world/entity/EquipmentSlotGroup.java ++++ b/net/minecraft/world/entity/EquipmentSlotGroup.java +@@ -29,6 +29,7 @@ public enum EquipmentSlotGroup implements StringRepresentable { + private final int id; + private final String key; + private final Predicate predicate; ++ public static final EquipmentSlotGroup[] VALUES_ARRAY = EquipmentSlotGroup.values(); // Gale - JettPack - reduce array allocations + + private EquipmentSlotGroup(final int id, final String key, final Predicate predicate) { + this.id = id; +diff --git a/net/minecraft/world/item/ItemStack.java b/net/minecraft/world/item/ItemStack.java +index ba31bbdac96e58d299dc260b47aaedf767735a42..badcb066ad66d9d4b17510fb1d633022c19d35d1 100644 +--- a/net/minecraft/world/item/ItemStack.java ++++ b/net/minecraft/world/item/ItemStack.java +@@ -1126,7 +1126,7 @@ public final class ItemStack implements DataComponentHolder { + private void addAttributeTooltips(Consumer tooltipAdder, @Nullable Player player) { + ItemAttributeModifiers itemAttributeModifiers = this.getOrDefault(DataComponents.ATTRIBUTE_MODIFIERS, ItemAttributeModifiers.EMPTY); + if (itemAttributeModifiers.showInTooltip()) { +- for (EquipmentSlotGroup equipmentSlotGroup : EquipmentSlotGroup.values()) { ++ for (EquipmentSlotGroup equipmentSlotGroup : EquipmentSlotGroup.VALUES_ARRAY) { // Gale - JettPack - reduce array allocations + MutableBoolean mutableBoolean = new MutableBoolean(true); + this.forEachModifier(equipmentSlotGroup, (attribute, modifier) -> { + if (mutableBoolean.isTrue()) { +diff --git a/net/minecraft/world/item/crafting/ShapedRecipePattern.java b/net/minecraft/world/item/crafting/ShapedRecipePattern.java +index bfda76974ea8d4397e2c2ebf5bdcb5d7e5f0bab5..cabbc93409ca99180d115e2f23419ee1824d5801 100644 +--- a/net/minecraft/world/item/crafting/ShapedRecipePattern.java ++++ b/net/minecraft/world/item/crafting/ShapedRecipePattern.java +@@ -121,7 +121,7 @@ public final class ShapedRecipePattern { + } + + if (pattern.size() == i3) { +- return new String[0]; ++ return me.titaniumtown.ArrayConstants.emptyStringArray; // Gale - JettPack - reduce array allocations + } else { + String[] strings = new String[pattern.size() - i3 - i2]; + +diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java +index 51fa382b930ccbeb605064488ab4df985df94ed6..d732a021351d80210e6411565c7a5e9d1b277f0f 100644 +--- a/net/minecraft/world/level/Level.java ++++ b/net/minecraft/world/level/Level.java +@@ -1849,7 +1849,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl + public org.bukkit.entity.Entity[] getChunkEntities(int chunkX, int chunkZ) { + ca.spottedleaf.moonrise.patches.chunk_system.level.entity.ChunkEntitySlices slices = ((ServerLevel)this).moonrise$getEntityLookup().getChunk(chunkX, chunkZ); + if (slices == null) { +- return new org.bukkit.entity.Entity[0]; ++ return me.titaniumtown.ArrayConstants.emptyBukkitEntityArray; // Gale - JettPack - reduce array allocations + } + + List ret = new java.util.ArrayList<>(); +@@ -1860,7 +1860,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl + } + } + +- return ret.toArray(new org.bukkit.entity.Entity[0]); ++ return ret.toArray(me.titaniumtown.ArrayConstants.emptyBukkitEntityArray); // Gale - JettPack - reduce array allocations + } + // Paper end - rewrite chunk system + +diff --git a/net/minecraft/world/level/block/ComposterBlock.java b/net/minecraft/world/level/block/ComposterBlock.java +index 5bc259ad1f9f56f4f596a4ae7b1b324b5e1219e6..0d34839618648bb8c606dd2d9b1f9db93641c742 100644 +--- a/net/minecraft/world/level/block/ComposterBlock.java ++++ b/net/minecraft/world/level/block/ComposterBlock.java +@@ -410,7 +410,7 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder { + + @Override + public int[] getSlotsForFace(Direction side) { +- return new int[0]; ++ return me.titaniumtown.ArrayConstants.emptyIntArray; // Gale - JettPack - reduce array allocations + } + + @Override +@@ -446,7 +446,7 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder { + + @Override + public int[] getSlotsForFace(Direction side) { +- return side == Direction.UP ? new int[]{0} : new int[0]; ++ return side == Direction.UP ? me.titaniumtown.ArrayConstants.zeroSingletonIntArray : me.titaniumtown.ArrayConstants.emptyIntArray; // Gale - JettPack - reduce array allocations + } + + @Override +@@ -496,7 +496,7 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder { + + @Override + public int[] getSlotsForFace(Direction side) { +- return side == Direction.DOWN ? new int[]{0} : new int[0]; ++ return side == Direction.DOWN ? me.titaniumtown.ArrayConstants.zeroSingletonIntArray : me.titaniumtown.ArrayConstants.emptyIntArray; // Gale - JettPack - reduce array allocations + } + + @Override +diff --git a/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java b/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java +index 38f145525a8ef4440ab06abb35d5aba1e5746f5d..f772d2542922eddf666ff375fc2546150c39ad32 100644 +--- a/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java ++++ b/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java +@@ -44,7 +44,7 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit + protected static final int SLOT_FUEL = 1; + protected static final int SLOT_RESULT = 2; + public static final int DATA_LIT_TIME = 0; +- private static final int[] SLOTS_FOR_UP = new int[]{0}; ++ private static final int[] SLOTS_FOR_UP = me.titaniumtown.ArrayConstants.zeroSingletonIntArray; // Gale - JettPack - reduce array allocations + private static final int[] SLOTS_FOR_DOWN = new int[]{2, 1}; + private static final int[] SLOTS_FOR_SIDES = new int[]{1}; + public static final int DATA_LIT_DURATION = 1; +diff --git a/net/minecraft/world/scores/Team.java b/net/minecraft/world/scores/Team.java +index 7b08f2fba99e3eef98f5b36db4081da9ab93f415..9192cb0761c6ec2ddec2c75dbc654d16951d6352 100644 +--- a/net/minecraft/world/scores/Team.java ++++ b/net/minecraft/world/scores/Team.java +@@ -70,7 +70,7 @@ public abstract class Team { + public final int id; + + public static String[] getAllNames() { +- return BY_NAME.keySet().toArray(new String[0]); ++ return BY_NAME.keySet().toArray(me.titaniumtown.ArrayConstants.emptyStringArray); // Gale - JettPack - reduce array allocations + } + + @Nullable diff --git a/patches/server/0062-Optimize-sun-burn-tick.patch b/gale-server/minecraft-patches/features/0049-Optimize-sun-burn-tick.patch similarity index 51% rename from patches/server/0062-Optimize-sun-burn-tick.patch rename to gale-server/minecraft-patches/features/0049-Optimize-sun-burn-tick.patch index e462291..425806d 100644 --- a/patches/server/0062-Optimize-sun-burn-tick.patch +++ b/gale-server/minecraft-patches/features/0049-Optimize-sun-burn-tick.patch @@ -12,11 +12,11 @@ By: Simon Gardling As part of: JettPack (https://gitlab.com/Titaniumtown/JettPack) Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) -diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index d7c0a78c17de70037cca43bea758edcbe457cd73..1a03a415d17fec083beaaafb0fc9da1f00f514de 100644 ---- a/src/main/java/net/minecraft/world/entity/Entity.java -+++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -271,7 +271,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java +index 0bbac68dbd891da8892ba40fc18578c4f9e67c11..b68013f83db13f4aeb94be4777c5341ce8ebfde4 100644 +--- a/net/minecraft/world/entity/Entity.java ++++ b/net/minecraft/world/entity/Entity.java +@@ -224,7 +224,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess public double xo; public double yo; public double zo; @@ -24,35 +24,36 @@ index d7c0a78c17de70037cca43bea758edcbe457cd73..1a03a415d17fec083beaaafb0fc9da1f + public Vec3 position; // Gale - JettPack - optimize sun burn tick - private -> public public BlockPos blockPosition; // Gale - Pufferfish - optimize entity coordinate key - private -> public private ChunkPos chunkPosition; - private Vec3 deltaMovement; -@@ -2145,9 +2145,19 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess - /** @deprecated */ + private Vec3 deltaMovement = Vec3.ZERO; +@@ -2024,10 +2024,20 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess + @Deprecated public float getLightLevelDependentMagicValue() { -- return this.level().hasChunkAt(this.getBlockX(), this.getBlockZ()) ? this.level().getLightLevelDependentMagicValue(BlockPos.containing(this.getX(), this.getEyeY(), this.getZ())) : 0.0F; + return this.getLightLevelDependentMagicValue(BlockPos.containing(this.getX(), this.getEyeY(), this.getZ())); // Gale - JettPack - optimize sun burn tick - allow passing BlockPos to getLightLevelDependentMagicValue - } - ++ } ++ + // Gale start - JettPack - optimize sun burn tick - allow passing BlockPos to getLightLevelDependentMagicValue + /** + * @deprecated + */ + @Deprecated + public float getLightLevelDependentMagicValue(BlockPos pos) { -+ return this.level().hasChunkAt(this.getBlockX(), this.getBlockZ()) ? this.level.getLightLevelDependentMagicValue(pos) : 0.0F; -+ } + return this.level().hasChunkAt(this.getBlockX(), this.getBlockZ()) +- ? this.level().getLightLevelDependentMagicValue(BlockPos.containing(this.getX(), this.getEyeY(), this.getZ())) ++ ? this.level.getLightLevelDependentMagicValue(pos) + : 0.0F; + } + // Gale end - JettPack - optimize sun burn tick - allow passing BlockPos to getLightLevelDependentMagicValue -+ - public void absMoveTo(double x, double y, double z, float yaw, float pitch) { - this.absMoveTo(x, y, z); - this.absRotateTo(yaw, pitch); -diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java -index 3ccc39e142f946e3fc34753fdc91a2cb62f9bd2d..3b10055c589575078bed8c79b3a0967d3f237957 100644 ---- a/src/main/java/net/minecraft/world/entity/Mob.java -+++ b/src/main/java/net/minecraft/world/entity/Mob.java -@@ -1710,13 +1710,28 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab - protected void playAttackSound() {} + public void absMoveTo(double x, double y, double z, float yRot, float xRot) { + this.absMoveTo(x, y, z); +diff --git a/net/minecraft/world/entity/Mob.java b/net/minecraft/world/entity/Mob.java +index 2568a7f2459ed783d4612546b86d46721d48a396..f3eec8b75fcda47e6632a2a7db9a238b515bc8a0 100644 +--- a/net/minecraft/world/entity/Mob.java ++++ b/net/minecraft/world/entity/Mob.java +@@ -1594,20 +1594,30 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab + protected void playAttackSound() { + } + // Gale start - JettPack - optimize sun burn tick - cache eye blockpos + private BlockPos cached_eye_blockpos; @@ -61,24 +62,32 @@ index 3ccc39e142f946e3fc34753fdc91a2cb62f9bd2d..3b10055c589575078bed8c79b3a0967d + public boolean isSunBurnTick() { if (this.level().isDay() && !this.level().isClientSide) { -- float f = this.getLightLevelDependentMagicValue(); -- BlockPos blockposition = BlockPos.containing(this.getX(), this.getEyeY(), this.getZ()); +- float lightLevelDependentMagicValue = this.getLightLevelDependentMagicValue(); +- BlockPos blockPos = BlockPos.containing(this.getX(), this.getEyeY(), this.getZ()); +- boolean flag = this.isInWaterRainOrBubble() || this.isInPowderSnow || this.wasInPowderSnow; +- if (lightLevelDependentMagicValue > 0.5F +- && this.random.nextFloat() * 30.0F < (lightLevelDependentMagicValue - 0.4F) * 2.0F +- && !flag +- && this.level().canSeeSky(blockPos)) { +- return true; + // Gale start - JettPack - optimize sun burn tick - optimizations and cache eye blockpos + if (this.cached_position != this.position) { + this.cached_eye_blockpos = BlockPos.containing(this.getX(), this.getEyeY(), this.getZ()); + this.cached_position = this.position; -+ } + } + -+ float f = this.getLightLevelDependentMagicValue(cached_eye_blockpos); // Pass BlockPos to getBrightness ++ float lightLevelDependentMagicValue = this.getLightLevelDependentMagicValue(cached_eye_blockpos); // Pass BlockPos to getBrightness + + // Check brightness first -+ if (f <= 0.5F) return false; -+ if (this.random.nextFloat() * 30.0F >= (f - 0.4F) * 2.0F) return false; ++ if (lightLevelDependentMagicValue <= 0.5F) return false; ++ if (this.random.nextFloat() * 30.0F >= (lightLevelDependentMagicValue - 0.4F) * 2.0F) return false; + // Gale end - JettPack - optimize sun burn tick - optimizations and cache eye blockpos - boolean flag = this.isInWaterRainOrBubble() || this.isInPowderSnow || this.wasInPowderSnow; - -- if (f > 0.5F && this.random.nextFloat() * 30.0F < (f - 0.4F) * 2.0F && !flag && this.level().canSeeSky(blockposition)) { -+ if (!flag && this.level().canSeeSky(this.cached_eye_blockpos)) { // Gale - JettPack - optimize sun burn tick - optimizations and cache eye blockpos - return true; - } ++ boolean flag = this.isInWaterRainOrBubble() || this.isInPowderSnow || this.wasInPowderSnow; ++ return !flag && this.level().canSeeSky(this.cached_eye_blockpos); // Gale - JettPack - optimize sun burn tick - optimizations and cache eye blockpos } + +- return false; ++ return false; // Gale - JettPack - optimize sun burn tick - optimizations and cache eye blockpos - diff on change + } + + @Override diff --git a/patches/server/0063-Reduce-lambda-and-Optional-allocation-in-EntityBased.patch b/gale-server/minecraft-patches/features/0050-Reduce-lambda-and-Optional-allocation-in-EntityBased.patch similarity index 56% rename from patches/server/0063-Reduce-lambda-and-Optional-allocation-in-EntityBased.patch rename to gale-server/minecraft-patches/features/0050-Reduce-lambda-and-Optional-allocation-in-EntityBased.patch index ffde5a0..775dd9e 100644 --- a/patches/server/0063-Reduce-lambda-and-Optional-allocation-in-EntityBased.patch +++ b/gale-server/minecraft-patches/features/0050-Reduce-lambda-and-Optional-allocation-in-EntityBased.patch @@ -13,22 +13,22 @@ By: 2No2Name <2No2Name@web.de> As part of: Lithium (https://github.com/CaffeineMC/lithium-fabric) Licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html) -diff --git a/src/main/java/net/minecraft/world/level/EntityBasedExplosionDamageCalculator.java b/src/main/java/net/minecraft/world/level/EntityBasedExplosionDamageCalculator.java -index 3527f1621ef9b4f3f8d8bbb93379f13ff141c3be..4e4dfb72d5a0b46917999b709c655ccfdae27183 100644 ---- a/src/main/java/net/minecraft/world/level/EntityBasedExplosionDamageCalculator.java -+++ b/src/main/java/net/minecraft/world/level/EntityBasedExplosionDamageCalculator.java +diff --git a/net/minecraft/world/level/EntityBasedExplosionDamageCalculator.java b/net/minecraft/world/level/EntityBasedExplosionDamageCalculator.java +index 52cb2dcd714cf8c16f167466333eeb923e4ff183..9661def1311102bbb7e8afdd69f5484320e58d01 100644 +--- a/net/minecraft/world/level/EntityBasedExplosionDamageCalculator.java ++++ b/net/minecraft/world/level/EntityBasedExplosionDamageCalculator.java @@ -15,8 +15,17 @@ public class EntityBasedExplosionDamageCalculator extends ExplosionDamageCalcula @Override - public Optional getBlockExplosionResistance(Explosion explosion, BlockGetter world, BlockPos pos, BlockState blockState, FluidState fluidState) { -- return super.getBlockExplosionResistance(explosion, world, pos, blockState, fluidState) -- .map(max -> this.source.getBlockExplosionResistance(explosion, world, pos, blockState, fluidState, max)); + public Optional getBlockExplosionResistance(Explosion explosion, BlockGetter reader, BlockPos pos, BlockState state, FluidState fluid) { +- return super.getBlockExplosionResistance(explosion, reader, pos, state, fluid) +- .map(resistance -> this.source.getBlockExplosionResistance(explosion, reader, pos, state, fluid, resistance)); + // Gale start - Lithium - reduce lambda and Optional allocation in EntityBasedExplosionDamageCalculator -+ Optional optionalBlastResistance = super.getBlockExplosionResistance(explosion, world, pos, blockState, fluidState); ++ Optional optionalBlastResistance = super.getBlockExplosionResistance(explosion, reader, pos, state, fluid); + if (optionalBlastResistance.isPresent()) { -+ float blastResistance = optionalBlastResistance.get(); -+ float effectiveExplosionResistance = this.source.getBlockExplosionResistance(explosion, world, pos, blockState, fluidState, blastResistance); -+ if (effectiveExplosionResistance != blastResistance) { ++ float resistance = optionalBlastResistance.get(); ++ float effectiveExplosionResistance = this.source.getBlockExplosionResistance(explosion, reader, pos, state, fluid, resistance); ++ if (effectiveExplosionResistance != resistance) { + return Optional.of(effectiveExplosionResistance); + } + } diff --git a/patches/server/0064-Replace-game-rules-map-with-optimized-collection.patch b/gale-server/minecraft-patches/features/0051-Replace-game-rules-map-with-optimized-collection.patch similarity index 72% rename from patches/server/0064-Replace-game-rules-map-with-optimized-collection.patch rename to gale-server/minecraft-patches/features/0051-Replace-game-rules-map-with-optimized-collection.patch index 90dd2f6..7808ec5 100644 --- a/patches/server/0064-Replace-game-rules-map-with-optimized-collection.patch +++ b/gale-server/minecraft-patches/features/0051-Replace-game-rules-map-with-optimized-collection.patch @@ -12,11 +12,11 @@ By: 2No2Name <2No2Name@web.de> As part of: Lithium (https://github.com/CaffeineMC/lithium-fabric) Licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html) -diff --git a/src/main/java/net/minecraft/world/level/GameRules.java b/src/main/java/net/minecraft/world/level/GameRules.java -index 7c363d59c6567cae8e6caf213be51804efa5a96d..43d31e45f47f390a87be66a6fc8c95eb0d17a87f 100644 ---- a/src/main/java/net/minecraft/world/level/GameRules.java -+++ b/src/main/java/net/minecraft/world/level/GameRules.java -@@ -168,7 +168,7 @@ public class GameRules { +diff --git a/net/minecraft/world/level/GameRules.java b/net/minecraft/world/level/GameRules.java +index b21337d826ad33ce874301b070ad7f5361a2a493..bbd09a317d01dee709e8964329e68f176e660846 100644 +--- a/net/minecraft/world/level/GameRules.java ++++ b/net/minecraft/world/level/GameRules.java +@@ -249,7 +249,7 @@ public class GameRules { } private GameRules(Map, GameRules.Value> rules, FeatureFlagSet enabledFeatures) { diff --git a/patches/server/0065-Replace-AI-attributes-with-optimized-collections.patch b/gale-server/minecraft-patches/features/0052-Replace-AI-attributes-with-optimized-collections.patch similarity index 81% rename from patches/server/0065-Replace-AI-attributes-with-optimized-collections.patch rename to gale-server/minecraft-patches/features/0052-Replace-AI-attributes-with-optimized-collections.patch index 3fb1878..fb8d7c5 100644 --- a/patches/server/0065-Replace-AI-attributes-with-optimized-collections.patch +++ b/gale-server/minecraft-patches/features/0052-Replace-AI-attributes-with-optimized-collections.patch @@ -12,10 +12,10 @@ By: 2No2Name <2No2Name@web.de> As part of: Lithium (https://github.com/CaffeineMC/lithium-fabric) Licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html) -diff --git a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java -index edd791da70fd7e18c42133dcd771f212cb25abab..e45ed0ffa031f7ab5fa39b71a2678c5a282e0561 100644 ---- a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java -+++ b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java +diff --git a/net/minecraft/world/entity/ai/attributes/AttributeMap.java b/net/minecraft/world/entity/ai/attributes/AttributeMap.java +index beebe81e13c99c6ddd9ffb2c7a3fdd74cb9c7afa..df3724294a3297ebdc11aef3f935bf0cf36b9c95 100644 +--- a/net/minecraft/world/entity/ai/attributes/AttributeMap.java ++++ b/net/minecraft/world/entity/ai/attributes/AttributeMap.java @@ -19,9 +19,11 @@ import org.slf4j.Logger; public class AttributeMap { diff --git a/patches/server/0066-Replace-class-map-with-optimized-collection.patch b/gale-server/minecraft-patches/features/0053-Replace-class-map-with-optimized-collection.patch similarity index 75% rename from patches/server/0066-Replace-class-map-with-optimized-collection.patch rename to gale-server/minecraft-patches/features/0053-Replace-class-map-with-optimized-collection.patch index 28d9697..5dca791 100644 --- a/patches/server/0066-Replace-class-map-with-optimized-collection.patch +++ b/gale-server/minecraft-patches/features/0053-Replace-class-map-with-optimized-collection.patch @@ -12,10 +12,10 @@ By: 2No2Name <2No2Name@web.de> As part of: Lithium (https://github.com/CaffeineMC/lithium-fabric) Licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html) -diff --git a/src/main/java/net/minecraft/util/ClassInstanceMultiMap.java b/src/main/java/net/minecraft/util/ClassInstanceMultiMap.java -index 038710ba934a9a57815dfe9f414b98223b848385..f1a288b6a29f3ba31e2364a9bc412c5e939b6ef7 100644 ---- a/src/main/java/net/minecraft/util/ClassInstanceMultiMap.java -+++ b/src/main/java/net/minecraft/util/ClassInstanceMultiMap.java +diff --git a/net/minecraft/util/ClassInstanceMultiMap.java b/net/minecraft/util/ClassInstanceMultiMap.java +index 2a708ae0d5bb209650b525e3c56051f8b5655074..3bc4aba806e254a01ce5c71c723196ac01393192 100644 +--- a/net/minecraft/util/ClassInstanceMultiMap.java ++++ b/net/minecraft/util/ClassInstanceMultiMap.java @@ -14,7 +14,7 @@ import java.util.Map.Entry; import net.minecraft.Util; diff --git a/patches/server/0067-Replace-instance-list-with-optimized-collection.patch b/gale-server/minecraft-patches/features/0054-Replace-instance-list-with-optimized-collection.patch similarity index 71% rename from patches/server/0067-Replace-instance-list-with-optimized-collection.patch rename to gale-server/minecraft-patches/features/0054-Replace-instance-list-with-optimized-collection.patch index 8fa1b16..3dcea8d 100644 --- a/patches/server/0067-Replace-instance-list-with-optimized-collection.patch +++ b/gale-server/minecraft-patches/features/0054-Replace-instance-list-with-optimized-collection.patch @@ -12,10 +12,10 @@ By: ishland As part of: VMP (https://github.com/RelativityMC/VMP-fabric) Licensed under: MIT (https://opensource.org/licenses/MIT) -diff --git a/src/main/java/net/minecraft/util/ClassInstanceMultiMap.java b/src/main/java/net/minecraft/util/ClassInstanceMultiMap.java -index f1a288b6a29f3ba31e2364a9bc412c5e939b6ef7..4264b3a69b5cbe2e56058927ceb5409389cecf4b 100644 ---- a/src/main/java/net/minecraft/util/ClassInstanceMultiMap.java -+++ b/src/main/java/net/minecraft/util/ClassInstanceMultiMap.java +diff --git a/net/minecraft/util/ClassInstanceMultiMap.java b/net/minecraft/util/ClassInstanceMultiMap.java +index 3bc4aba806e254a01ce5c71c723196ac01393192..4cd1b8ce60f7befca63a5b6396c0781ae3583dcd 100644 +--- a/net/minecraft/util/ClassInstanceMultiMap.java ++++ b/net/minecraft/util/ClassInstanceMultiMap.java @@ -16,7 +16,7 @@ import net.minecraft.Util; public class ClassInstanceMultiMap extends AbstractCollection { private final Map, List> byClass = new it.unimi.dsi.fastutil.objects.Reference2ReferenceOpenHashMap<>(2); // Gale - Lithium - replace class map with optimized collection @@ -23,5 +23,5 @@ index f1a288b6a29f3ba31e2364a9bc412c5e939b6ef7..4264b3a69b5cbe2e56058927ceb54093 - private final List allInstances = Lists.newArrayList(); + private final List allInstances = new it.unimi.dsi.fastutil.objects.ObjectArrayList<>(); // Gale - VMP - replace instance map with optimized collection - public ClassInstanceMultiMap(Class elementType) { - this.baseClass = elementType; + public ClassInstanceMultiMap(Class baseClass) { + this.baseClass = baseClass; diff --git a/gale-server/minecraft-patches/features/0055-Replace-throttle-tracker-map-with-optimized-collecti.patch b/gale-server/minecraft-patches/features/0055-Replace-throttle-tracker-map-with-optimized-collecti.patch new file mode 100644 index 0000000..b744265 --- /dev/null +++ b/gale-server/minecraft-patches/features/0055-Replace-throttle-tracker-map-with-optimized-collecti.patch @@ -0,0 +1,56 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Fri, 23 Dec 2022 22:22:47 +0100 +Subject: [PATCH] Replace throttle tracker map with optimized collection + +License: MIT (https://opensource.org/licenses/MIT) +Gale - https://galemc.org + +This patch is based on the following patch: +"Use more fastutil data structures" +By: nopjmp +As part of: Dionysus (https://github.com/nopjmp/Dionysus) +Licensed under: MIT (https://opensource.org/licenses/MIT) + +* Dionysus description * + +Use them in more places. + +* Dionysus copyright * + +Copyright 2021 Kayla Thompson + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit +persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +diff --git a/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java b/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java +index c6e53b56c55ebf2c13b08b9896ffd545b04762d1..c166091d1b33c8f0ea57fb723e9d9b0c83bcedfb 100644 +--- a/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java ++++ b/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java +@@ -25,7 +25,7 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL + static final java.util.regex.Pattern PROP_PATTERN = java.util.regex.Pattern.compile("\\w{0,16}"); + // Spigot end + // CraftBukkit start - add fields +- private static final HashMap throttleTracker = new HashMap<>(); ++ private static final it.unimi.dsi.fastutil.objects.Object2LongMap throttleTracker = new it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap<>(); // Gale - Dionysus - replace throttle tracker map with optimized collection + private static int throttleCounter = 0; + // CraftBukkit end + private static final boolean BYPASS_HOSTCHECK = Boolean.getBoolean("Paper.bypassHostCheck"); // Paper +@@ -84,7 +84,7 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL + InetAddress address = ((java.net.InetSocketAddress) this.connection.getRemoteAddress()).getAddress(); + + synchronized (ServerHandshakePacketListenerImpl.throttleTracker) { +- if (ServerHandshakePacketListenerImpl.throttleTracker.containsKey(address) && !"127.0.0.1".equals(address.getHostAddress()) && currentTime - ServerHandshakePacketListenerImpl.throttleTracker.get(address) < connectionThrottle) { ++ if (ServerHandshakePacketListenerImpl.throttleTracker.containsKey(address) && !"127.0.0.1".equals(address.getHostAddress()) && currentTime - ServerHandshakePacketListenerImpl.throttleTracker.getLong(address) < connectionThrottle) { // Gale - Dionysus - replace throttle tracker map with optimized collection + ServerHandshakePacketListenerImpl.throttleTracker.put(address, currentTime); + Component chatmessage = io.papermc.paper.adventure.PaperAdventure.asVanilla(io.papermc.paper.configuration.GlobalConfiguration.get().messages.kick.connectionThrottle); // Paper - Configurable connection throttle kick message + this.connection.send(new ClientboundLoginDisconnectPacket(chatmessage)); diff --git a/patches/server/0069-Avoid-Class-isAssignableFrom-call-in-ClassInstanceMu.patch b/gale-server/minecraft-patches/features/0056-Avoid-Class-isAssignableFrom-call-in-ClassInstanceMu.patch similarity index 81% rename from patches/server/0069-Avoid-Class-isAssignableFrom-call-in-ClassInstanceMu.patch rename to gale-server/minecraft-patches/features/0056-Avoid-Class-isAssignableFrom-call-in-ClassInstanceMu.patch index a8eb69a..9f46266 100644 --- a/patches/server/0069-Avoid-Class-isAssignableFrom-call-in-ClassInstanceMu.patch +++ b/gale-server/minecraft-patches/features/0056-Avoid-Class-isAssignableFrom-call-in-ClassInstanceMu.patch @@ -12,10 +12,10 @@ By: ishland As part of: VMP (https://github.com/RelativityMC/VMP-fabric) Licensed under: MIT (https://opensource.org/licenses/MIT) -diff --git a/src/main/java/net/minecraft/util/ClassInstanceMultiMap.java b/src/main/java/net/minecraft/util/ClassInstanceMultiMap.java -index 4264b3a69b5cbe2e56058927ceb5409389cecf4b..ff545f6d36c265d70c79fc1acc7a279f10fbfcfd 100644 ---- a/src/main/java/net/minecraft/util/ClassInstanceMultiMap.java -+++ b/src/main/java/net/minecraft/util/ClassInstanceMultiMap.java +diff --git a/net/minecraft/util/ClassInstanceMultiMap.java b/net/minecraft/util/ClassInstanceMultiMap.java +index 4cd1b8ce60f7befca63a5b6396c0781ae3583dcd..c7420c599aea9d79927419e881aaca8aae11461b 100644 +--- a/net/minecraft/util/ClassInstanceMultiMap.java ++++ b/net/minecraft/util/ClassInstanceMultiMap.java @@ -56,18 +56,41 @@ public class ClassInstanceMultiMap extends AbstractCollection { } @@ -24,13 +24,13 @@ index 4264b3a69b5cbe2e56058927ceb5409389cecf4b..ff545f6d36c265d70c79fc1acc7a279f - throw new IllegalArgumentException("Don't know how to search for " + type); - } else { - List list = this.byClass -- .computeIfAbsent(type, typeClass -> this.allInstances.stream().filter(typeClass::isInstance).collect(Util.toMutableList())); +- .computeIfAbsent(type, clazz -> this.allInstances.stream().filter(clazz::isInstance).collect(Util.toMutableList())); - return (Collection)Collections.unmodifiableCollection(list); + // Gale start - VMP - avoid Class#isAssignableFrom call in ClassInstanceMultiMap + /* + Only perform the slow Class#isAssignableFrom(Class) if a list doesn't exist for the type, otherwise + we can assume it's already valid. The slow-path code is moved to a separate method to help the JVM inline this. -+ */ ++ */ + Collection collection = this.byClass.get(type); + + if (collection == null) { @@ -43,11 +43,11 @@ index 4264b3a69b5cbe2e56058927ceb5409389cecf4b..ff545f6d36c265d70c79fc1acc7a279f + private Collection createAllOfType(Class type) { + return this.byClass.computeIfAbsent( + type, -+ typeClass -> { ++ clazz -> { + it.unimi.dsi.fastutil.objects.ObjectArrayList ts = new it.unimi.dsi.fastutil.objects.ObjectArrayList<>(this.allInstances.size()); + + for (T _allElement : ((it.unimi.dsi.fastutil.objects.ObjectArrayList) this.allInstances).elements()) { -+ if (typeClass.isInstance(_allElement)) { ++ if (clazz.isInstance(_allElement)) { + ts.add(_allElement); + } + } diff --git a/patches/server/0070-Cache-BlockStatePairKey-hash.patch b/gale-server/minecraft-patches/features/0057-Cache-BlockStatePairKey-hash.patch similarity index 64% rename from patches/server/0070-Cache-BlockStatePairKey-hash.patch rename to gale-server/minecraft-patches/features/0057-Cache-BlockStatePairKey-hash.patch index dfecb26..26b44b0 100644 --- a/patches/server/0070-Cache-BlockStatePairKey-hash.patch +++ b/gale-server/minecraft-patches/features/0057-Cache-BlockStatePairKey-hash.patch @@ -12,17 +12,17 @@ By: Angeline As part of: Lithium (https://github.com/CaffeineMC/lithium-fabric) Licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html) -diff --git a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java -index f4fbcbb8ff6d2677af1a02a0801a323c06dce9b1..221978c64cf6171db078c6cbfc850f6aeae73884 100644 ---- a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java -+++ b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java -@@ -577,8 +577,27 @@ public abstract class FlowingFluid extends Fluid { - }); +diff --git a/net/minecraft/world/level/material/FlowingFluid.java b/net/minecraft/world/level/material/FlowingFluid.java +index e30499bdcd6600e5c9d4a755c1182fb6dff3735f..c47a33a989d7ffea4f0bbae39fd64869369e9bda 100644 +--- a/net/minecraft/world/level/material/FlowingFluid.java ++++ b/net/minecraft/world/level/material/FlowingFluid.java +@@ -535,7 +535,26 @@ public abstract class FlowingFluid extends Fluid { + : this.shapes.computeIfAbsent(state, fluidState -> Shapes.box(0.0, 0.0, 0.0, 1.0, fluidState.getHeight(level, pos), 1.0)); } -- private static record BlockStatePairKey(BlockState first, BlockState second, Direction direction) { +- record BlockStatePairKey(BlockState first, BlockState second, Direction direction) { + // Gale start - Lithium - cache BlockStatePairKey hash -+ private static class BlockStatePairKey { ++ static class BlockStatePairKey { + + private final BlockState first; + private final BlockState second; @@ -39,23 +39,18 @@ index f4fbcbb8ff6d2677af1a02a0801a323c06dce9b1..221978c64cf6171db078c6cbfc850f6a + hash = 31 * hash + this.direction.hashCode(); + this.hash = hash; + } - -+ @Override + // Gale end - Lithium - cache BlockStatePairKey hash ++ + @Override public boolean equals(Object object) { - boolean flag; + return object instanceof FlowingFluid.BlockStatePairKey blockStatePairKey +@@ -546,9 +565,7 @@ public abstract class FlowingFluid extends Fluid { -@@ -593,12 +612,9 @@ public abstract class FlowingFluid extends Fluid { - return flag; - } - -+ @Override // Gale - Lithium - cache BlockStatePairKey hash + @Override public int hashCode() { - int i = System.identityHashCode(this.first); -- - i = 31 * i + System.identityHashCode(this.second); -- i = 31 * i + this.direction.hashCode(); -- return i; +- return 31 * i + this.direction.hashCode(); + return this.hash; // Gale - Lithium - cache BlockStatePairKey hash } } diff --git a/patches/server/0071-Cache-ShapePairKey-hash.patch b/gale-server/minecraft-patches/features/0058-Cache-ShapePairKey-hash.patch similarity index 55% rename from patches/server/0071-Cache-ShapePairKey-hash.patch rename to gale-server/minecraft-patches/features/0058-Cache-ShapePairKey-hash.patch index 9e302c4..6f93e60 100644 --- a/patches/server/0071-Cache-ShapePairKey-hash.patch +++ b/gale-server/minecraft-patches/features/0058-Cache-ShapePairKey-hash.patch @@ -4,18 +4,18 @@ Date: Thu, 12 Dec 2024 02:58:34 -0500 Subject: [PATCH] Cache ShapePairKey hash -diff --git a/src/main/java/net/minecraft/world/level/block/Block.java b/src/main/java/net/minecraft/world/level/block/Block.java -index b6d6c2cb9b227a17fb4ce42bc75f92206fbea043..ef8d8990a8a98c0cbc3e7aa45d22c6008f0ff2bb 100644 ---- a/src/main/java/net/minecraft/world/level/block/Block.java -+++ b/src/main/java/net/minecraft/world/level/block/Block.java -@@ -583,8 +583,21 @@ public class Block extends BlockBehaviour implements ItemLike { +diff --git a/net/minecraft/world/level/block/Block.java b/net/minecraft/world/level/block/Block.java +index 976de81d65b6494cdad20f4ec5125fceec86f951..79de4c558f7cbeff7e55b6d9ad2644be46d72cd9 100644 +--- a/net/minecraft/world/level/block/Block.java ++++ b/net/minecraft/world/level/block/Block.java +@@ -557,7 +557,20 @@ public class Block extends BlockBehaviour implements ItemLike { } // Spigot end -- private static record ShapePairKey(VoxelShape first, VoxelShape second) { +- record ShapePairKey(VoxelShape first, VoxelShape second) { + // Gale start - cache ShapePairKey hash -+ private static class ShapePairKey { - ++ static class ShapePairKey { ++ + private final VoxelShape first; + private final VoxelShape second; + private final int hash; @@ -25,17 +25,14 @@ index b6d6c2cb9b227a17fb4ce42bc75f92206fbea043..ef8d8990a8a98c0cbc3e7aa45d22c600 + this.second = second; + this.hash = System.identityHashCode(this.first) * 31 + System.identityHashCode(this.second); + } -+ -+ @Override + // Gale end - cache ShapePairKey hash - public boolean equals(Object object) { - boolean flag; ++ + @Override + public boolean equals(Object other) { + return other instanceof Block.ShapePairKey shapePairKey && this.first == shapePairKey.first && this.second == shapePairKey.second; +@@ -565,7 +578,7 @@ public class Block extends BlockBehaviour implements ItemLike { -@@ -599,8 +612,9 @@ public class Block extends BlockBehaviour implements ItemLike { - return flag; - } - -+ @Override // Gale - cache ShapePairKey hash + @Override public int hashCode() { - return System.identityHashCode(this.first) * 31 + System.identityHashCode(this.second); + return this.hash; // Gale - cache ShapePairKey hash diff --git a/gale-server/minecraft-patches/features/0059-Replace-division-by-multiplication-in-CubePointRange.patch b/gale-server/minecraft-patches/features/0059-Replace-division-by-multiplication-in-CubePointRange.patch new file mode 100644 index 0000000..34944fe --- /dev/null +++ b/gale-server/minecraft-patches/features/0059-Replace-division-by-multiplication-in-CubePointRange.patch @@ -0,0 +1,40 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Wed, 30 Nov 2022 17:24:24 +0100 +Subject: [PATCH] Replace division by multiplication in CubePointRange + +License: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html) +Gale - https://galemc.org + +This patch is based on the following mixin: +"net/caffeinemc/mods/lithium/mixin/shapes/precompute_shape_arrays/CubePointRangeMixin.java" +By: 2No2Name <2No2Name@web.de> +As part of: Lithium (https://github.com/CaffeineMC/lithium-fabric) +Licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html) + +diff --git a/net/minecraft/world/phys/shapes/CubePointRange.java b/net/minecraft/world/phys/shapes/CubePointRange.java +index 62aea61c5f240aa59b8489dd0bbb3d1b69b54b1c..513adb0e75fb70d26f6056d22fe2be30b1a39296 100644 +--- a/net/minecraft/world/phys/shapes/CubePointRange.java ++++ b/net/minecraft/world/phys/shapes/CubePointRange.java +@@ -4,6 +4,7 @@ import it.unimi.dsi.fastutil.doubles.AbstractDoubleList; + + public class CubePointRange extends AbstractDoubleList { + private final int parts; ++ private final double scale; // Gale - Lithium - replace division by multiplication in CubePointRange + + public CubePointRange(int parts) { + if (parts <= 0) { +@@ -11,11 +12,12 @@ public class CubePointRange extends AbstractDoubleList { + } else { + this.parts = parts; + } ++ this.scale = 1.0D / parts; // Gale - Lithium - replace division by multiplication in CubePointRange + } + + @Override + public double getDouble(int value) { +- return (double)value / this.parts; ++ return value * this.scale; // Gale - Lithium - replace division by multiplication in CubePointRange + } + + @Override diff --git a/patches/server/0073-Replace-parts-by-size-in-CubePointRange.patch b/gale-server/minecraft-patches/features/0060-Replace-parts-by-size-in-CubePointRange.patch similarity index 55% rename from patches/server/0073-Replace-parts-by-size-in-CubePointRange.patch rename to gale-server/minecraft-patches/features/0060-Replace-parts-by-size-in-CubePointRange.patch index 7467ab0..405d51a 100644 --- a/patches/server/0073-Replace-parts-by-size-in-CubePointRange.patch +++ b/gale-server/minecraft-patches/features/0060-Replace-parts-by-size-in-CubePointRange.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Replace parts by size in CubePointRange License: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html) Gale - https://galemc.org -diff --git a/src/main/java/net/minecraft/world/phys/shapes/CubePointRange.java b/src/main/java/net/minecraft/world/phys/shapes/CubePointRange.java -index 0b6f3fca7e7b8f2f7cfa0c8f01068f234888f66d..2ac87dfb3d9756c0bf63d5a81470efad5b826371 100644 ---- a/src/main/java/net/minecraft/world/phys/shapes/CubePointRange.java -+++ b/src/main/java/net/minecraft/world/phys/shapes/CubePointRange.java +diff --git a/net/minecraft/world/phys/shapes/CubePointRange.java b/net/minecraft/world/phys/shapes/CubePointRange.java +index 513adb0e75fb70d26f6056d22fe2be30b1a39296..9838c090a6476d9ab7b17f2556a74cba7f8b4bd9 100644 +--- a/net/minecraft/world/phys/shapes/CubePointRange.java ++++ b/net/minecraft/world/phys/shapes/CubePointRange.java @@ -3,14 +3,14 @@ package net.minecraft.world.phys.shapes; import it.unimi.dsi.fastutil.doubles.AbstractDoubleList; @@ -18,18 +18,18 @@ index 0b6f3fca7e7b8f2f7cfa0c8f01068f234888f66d..2ac87dfb3d9756c0bf63d5a81470efad + private final int size; // Gale - replace parts by size in CubePointRange private final double scale; // Gale - Lithium - replace division by multiplication in CubePointRange - public CubePointRange(int sectionCount) { - if (sectionCount <= 0) { + public CubePointRange(int parts) { + if (parts <= 0) { throw new IllegalArgumentException("Need at least 1 part"); } else { -- this.parts = sectionCount; -+ this.size = sectionCount + 1; // Gale - replace parts by size in CubePointRange +- this.parts = parts; ++ this.size = parts + 1; // Gale - replace parts by size in CubePointRange } - this.scale = 1.0D / sectionCount; // Gale - Lithium - replace division by multiplication in CubePointRange - } -@@ -20,6 +20,6 @@ public class CubePointRange extends AbstractDoubleList { + this.scale = 1.0D / parts; // Gale - Lithium - replace division by multiplication in CubePointRange } +@@ -22,6 +22,6 @@ public class CubePointRange extends AbstractDoubleList { + @Override public int size() { - return this.parts + 1; + return this.size; // Gale - replace parts by size in CubePointRange diff --git a/gale-server/minecraft-patches/features/0061-Check-frozen-ticks-before-landing-block.patch b/gale-server/minecraft-patches/features/0061-Check-frozen-ticks-before-landing-block.patch new file mode 100644 index 0000000..01fbbe4 --- /dev/null +++ b/gale-server/minecraft-patches/features/0061-Check-frozen-ticks-before-landing-block.patch @@ -0,0 +1,38 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Wed, 30 Nov 2022 20:17:41 +0100 +Subject: [PATCH] Check frozen ticks before landing block + +License: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html) +Gale - https://galemc.org + +This patch is based on the following mixin: +"net/caffeinemc/mods/lithium/mixin/entity/fast_powder_snow_check/LivingEntityMixin.java" +By: 2No2Name <2No2Name@web.de> +As part of: Lithium (https://github.com/CaffeineMC/lithium-fabric) +Licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html) + +diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java +index 1fbc971f4bb2473dc67021b4cec9228109e0c43b..d341bf76b4679470a7fb5ff081b79425e4bc1264 100644 +--- a/net/minecraft/world/entity/LivingEntity.java ++++ b/net/minecraft/world/entity/LivingEntity.java +@@ -570,10 +570,9 @@ public abstract class LivingEntity extends Entity implements Attackable { + } + + protected void tryAddFrost() { +- if (!this.getBlockStateOnLegacy().isAir()) { + int ticksFrozen = this.getTicksFrozen(); + if (ticksFrozen > 0) { +- AttributeInstance attribute = this.getAttribute(Attributes.MOVEMENT_SPEED); ++ AttributeInstance attribute = this.getBlockStateOnLegacy().isAir() ? null : this.getAttribute(Attributes.MOVEMENT_SPEED); // Gale - Lithium - check frozen ticks before landing block + if (attribute == null) { + return; + } +@@ -581,7 +580,6 @@ public abstract class LivingEntity extends Entity implements Attackable { + float f = -0.05F * this.getPercentFrozen(); + attribute.addTransientModifier(new AttributeModifier(SPEED_MODIFIER_POWDER_SNOW_ID, f, AttributeModifier.Operation.ADD_VALUE)); + } +- } + } + + protected void onChangedBlock(ServerLevel level, BlockPos pos) { diff --git a/gale-server/minecraft-patches/features/0062-Faster-chunk-serialization.patch b/gale-server/minecraft-patches/features/0062-Faster-chunk-serialization.patch new file mode 100644 index 0000000..66b0575 --- /dev/null +++ b/gale-server/minecraft-patches/features/0062-Faster-chunk-serialization.patch @@ -0,0 +1,237 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Wed, 30 Nov 2022 21:51:16 +0100 +Subject: [PATCH] Faster chunk serialization + +License: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html) +Gale - https://galemc.org + +This patch is based on the following mixins and classes: +* "net/caffeinemc/mods/lithium/common/world/chunk/CompactingPackedIntegerArray.java" +* "net/caffeinemc/mods/lithium/common/world/chunk/LithiumHashPalette.java" +* "net/caffeinemc/mods/lithium/mixin/chunk/serialization/PackedIntegerArrayMixin.java" +* "net/caffeinemc/mods/lithium/mixin/chunk/serialization/PalettedContainerMixin.java" +By: Angeline +As part of: Lithium (https://github.com/CaffeineMC/lithium-fabric) +Licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html) + +diff --git a/net/minecraft/util/BitStorage.java b/net/minecraft/util/BitStorage.java +index 02502d50f0255f5bbcc0ecb965abb48cc1a112da..e1f4ca261d106d176298b2afc016f5168abaa06b 100644 +--- a/net/minecraft/util/BitStorage.java ++++ b/net/minecraft/util/BitStorage.java +@@ -38,4 +38,6 @@ public interface BitStorage extends ca.spottedleaf.moonrise.patches.block_counti + return ret; + } + // Paper end - block counting ++ ++ void compact(net.minecraft.world.level.chunk.Palette srcPalette, net.minecraft.world.level.chunk.Palette dstPalette, short[] out); // Gale - Lithium - faster chunk serialization + } +diff --git a/net/minecraft/util/SimpleBitStorage.java b/net/minecraft/util/SimpleBitStorage.java +index e6306a68c8652d4c5d22d5ecb1416f5f931f76ee..8091f0c0a536047ead4966e70785962e87faad9a 100644 +--- a/net/minecraft/util/SimpleBitStorage.java ++++ b/net/minecraft/util/SimpleBitStorage.java +@@ -465,4 +465,45 @@ public class SimpleBitStorage implements BitStorage { + super(message); + } + } ++ ++ // Gale start - Lithium - faster chunk serialization ++ @Override ++ public void compact(net.minecraft.world.level.chunk.Palette srcPalette, net.minecraft.world.level.chunk.Palette dstPalette, short[] out) { ++ if (this.size >= Short.MAX_VALUE) { ++ throw new IllegalStateException("Array too large"); ++ } ++ ++ if (this.size != out.length) { ++ throw new IllegalStateException("Array size mismatch"); ++ } ++ ++ short[] mappings = new short[(int) (this.mask + 1)]; ++ ++ int idx = 0; ++ ++ for (long word : this.data) { ++ long bits = word; ++ ++ for (int elementIdx = 0; elementIdx < this.valuesPerLong; ++elementIdx) { ++ int value = (int) (bits & this.mask); ++ int remappedId = mappings[value]; ++ ++ if (remappedId == 0) { ++ remappedId = dstPalette.idFor(srcPalette.valueFor(value)) + 1; ++ mappings[value] = (short) remappedId; ++ } ++ ++ out[idx] = (short) (remappedId - 1); ++ bits >>= this.bits; ++ ++ ++idx; ++ ++ if (idx >= this.size) { ++ return; ++ } ++ } ++ } ++ } ++ // Gale end - Lithium - faster chunk serialization ++ + } +diff --git a/net/minecraft/util/ZeroBitStorage.java b/net/minecraft/util/ZeroBitStorage.java +index 5c1103ef028e5ffe6ce0eadc861dd3b2c8f3ed9f..828ced8aa5665c6f5d0b121947719c4e2ba591fe 100644 +--- a/net/minecraft/util/ZeroBitStorage.java ++++ b/net/minecraft/util/ZeroBitStorage.java +@@ -80,4 +80,6 @@ public class ZeroBitStorage implements BitStorage { + return ret; + } + // Paper end - block counting ++ ++ @Override public void compact(net.minecraft.world.level.chunk.Palette srcPalette, net.minecraft.world.level.chunk.Palette dstPalette, short[] out) {} // Gale - Lithium - faster chunk serialization + } +diff --git a/net/minecraft/world/level/chunk/PaletteResize.java b/net/minecraft/world/level/chunk/PaletteResize.java +index c723606fa0be811e580ba47de8c9c575583cc930..08d103577ec558e79fd0e5c53fbc4b0bc5526935 100644 +--- a/net/minecraft/world/level/chunk/PaletteResize.java ++++ b/net/minecraft/world/level/chunk/PaletteResize.java +@@ -1,5 +1,5 @@ + package net.minecraft.world.level.chunk; + +-interface PaletteResize { ++public interface PaletteResize { // Gale - Lithium - faster chunk serialization - package -> public + int onResize(int bits, T objectAdded); + } +diff --git a/net/minecraft/world/level/chunk/PalettedContainer.java b/net/minecraft/world/level/chunk/PalettedContainer.java +index f5da433050fd3060e0335d4002d520ebe8cd691f..82a5d45858067f8bd6d000d2eafc13fe2cb6f834 100644 +--- a/net/minecraft/world/level/chunk/PalettedContainer.java ++++ b/net/minecraft/world/level/chunk/PalettedContainer.java +@@ -25,6 +25,22 @@ import net.minecraft.util.ThreadingDetector; + import net.minecraft.util.ZeroBitStorage; + + public class PalettedContainer implements PaletteResize, PalettedContainerRO { ++ ++ // Gale start - Lithium - faster chunk serialization ++ private static final ThreadLocal CACHED_ARRAY_4096 = ThreadLocal.withInitial(() -> new short[4096]); ++ private static final ThreadLocal CACHED_ARRAY_64 = ThreadLocal.withInitial(() -> new short[64]); ++ private Optional asOptional(long[] data) { ++ return Optional.of(Arrays.stream(data)); ++ } ++ private short[] getOrCreate(int size) { ++ return switch (size) { ++ case 64 -> CACHED_ARRAY_64.get(); ++ case 4096 -> CACHED_ARRAY_4096.get(); ++ default -> new short[size]; ++ }; ++ } ++ // Gale end - Lithium - faster chunk serialization ++ + private static final int MIN_PALETTE_BITS = 0; + private final PaletteResize dummyPaletteResize = (bits, objectAdded) -> 0; + public final IdMap registry; +@@ -344,28 +360,54 @@ public class PalettedContainer implements PaletteResize, PalettedContainer + public synchronized PalettedContainerRO.PackedData pack(IdMap registry, PalettedContainer.Strategy strategy) { // Paper - synchronize + this.acquire(); + +- PalettedContainerRO.PackedData var12; ++ // Gale start - Lithium - faster chunk serialization ++ Optional data = Optional.empty(); ++ List elements = null; + try { +- HashMapPalette hashMapPalette = new HashMapPalette<>(registry, this.data.storage.getBits(), this.dummyPaletteResize); +- int size = strategy.size(); +- int[] ints = new int[size]; +- this.data.storage.unpack(ints); +- swapPalette(ints, id -> hashMapPalette.idFor(this.data.palette.valueFor(id))); +- int i = strategy.calculateBitsForSerialization(registry, hashMapPalette.getSize()); +- Optional optional; +- if (i != 0) { +- SimpleBitStorage simpleBitStorage = new SimpleBitStorage(i, size, ints); +- optional = Optional.of(Arrays.stream(simpleBitStorage.getRaw())); +- } else { +- optional = Optional.empty(); ++ // The palette that will be serialized ++ net.caffeinemc.mods.lithium.common.world.chunk.LithiumHashPalette hashPalette = null; ++ ++ final Palette palette = this.data.palette(); ++ final BitStorage storage = this.data.storage(); ++ if (storage instanceof ZeroBitStorage || palette.getSize() == 1) { ++ // If the palette only contains one entry, don't attempt to repack it. ++ elements = List.of(palette.valueFor(0)); ++ } else if (palette instanceof net.caffeinemc.mods.lithium.common.world.chunk.LithiumHashPalette lithiumHashPalette) { ++ hashPalette = lithiumHashPalette; + } + +- var12 = new PalettedContainerRO.PackedData<>(hashMapPalette.getEntries(), optional); ++ if (elements == null) { ++ net.caffeinemc.mods.lithium.common.world.chunk.LithiumHashPalette compactedPalette = new net.caffeinemc.mods.lithium.common.world.chunk.LithiumHashPalette<>(registry, storage.getBits(), this.dummyPaletteResize); ++ short[] array = this.getOrCreate(strategy.size()); ++ ++ storage.compact(this.data.palette(), compactedPalette, array); ++ ++ // If the palette didn't change during compaction, do a simple copy of the data array ++ if (hashPalette != null && hashPalette.getSize() == compactedPalette.getSize() && storage.getBits() == strategy.calculateBitsForSerialization(registry, hashPalette.getSize())) { // paletteSize can de-sync from palette - see https://github.com/CaffeineMC/lithium-fabric/issues/279 ++ data = this.asOptional(storage.getRaw().clone()); ++ elements = hashPalette.getElements(); ++ } else { ++ int bits = strategy.calculateBitsForSerialization(registry, compactedPalette.getSize()); ++ if (bits != 0) { ++ // Re-pack the integer array as the palette has changed size ++ SimpleBitStorage copy = new SimpleBitStorage(bits, array.length); ++ for (int i = 0; i < array.length; ++i) { ++ copy.set(i, array[i]); ++ } ++ ++ // We don't need to clone the data array as we are the sole owner of it ++ data = this.asOptional(copy.getRaw()); ++ } ++ ++ elements = compactedPalette.getElements(); ++ } ++ } + } finally { + this.release(); + } + +- return var12; ++ return new PalettedContainerRO.PackedData<>(elements, data); ++ // Gale end - Lithium - faster chunk serialization + } + + private static void swapPalette(int[] bits, IntUnaryOperator operator) { +@@ -405,13 +447,33 @@ public class PalettedContainer implements PaletteResize, PalettedContainer + + @Override + public void count(PalettedContainer.CountConsumer countConsumer) { +- if (this.data.palette.getSize() == 1) { +- countConsumer.accept(this.data.palette.valueFor(0), this.data.storage.getSize()); +- } else { +- Int2IntOpenHashMap map = new Int2IntOpenHashMap(); +- this.data.storage.getAll(id -> map.addTo(id, 1)); +- map.int2IntEntrySet().forEach(idEntry -> countConsumer.accept(this.data.palette.valueFor(idEntry.getIntKey()), idEntry.getIntValue())); ++ // Gale start - Lithium - faster chunk serialization ++ int len = this.data.palette().getSize(); ++ ++ // Do not allocate huge arrays if we're using a large palette ++ if (len > 4096) { ++ // VanillaCopy ++ if (this.data.palette.getSize() == 1) { ++ countConsumer.accept(this.data.palette.valueFor(0), this.data.storage.getSize()); ++ } else { ++ Int2IntOpenHashMap map = new Int2IntOpenHashMap(); ++ this.data.storage.getAll(id -> map.addTo(id, 1)); ++ map.int2IntEntrySet().forEach(idEntry -> countConsumer.accept(this.data.palette.valueFor(idEntry.getIntKey()), idEntry.getIntValue())); ++ } ++ } ++ ++ short[] counts = new short[len]; ++ ++ this.data.storage().getAll(i -> counts[i]++); ++ ++ for (int i = 0; i < counts.length; i++) { ++ T obj = this.data.palette().valueFor(i); ++ ++ if (obj != null) { ++ countConsumer.accept(obj, counts[i]); ++ } + } ++ // Gale end - Lithium - faster chunk serialization + } + + record Configuration(Palette.Factory factory, int bits) { diff --git a/patches/server/0076-Update-boss-bar-within-tick.patch b/gale-server/minecraft-patches/features/0063-Update-boss-bar-within-tick.patch similarity index 73% rename from patches/server/0076-Update-boss-bar-within-tick.patch rename to gale-server/minecraft-patches/features/0063-Update-boss-bar-within-tick.patch index 4b3308d..69e8f09 100644 --- a/patches/server/0076-Update-boss-bar-within-tick.patch +++ b/gale-server/minecraft-patches/features/0063-Update-boss-bar-within-tick.patch @@ -12,19 +12,19 @@ By: Angeline As part of: Lithium (https://github.com/CaffeineMC/lithium-fabric) Licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html) -diff --git a/src/main/java/net/minecraft/world/entity/raid/Raid.java b/src/main/java/net/minecraft/world/entity/raid/Raid.java -index 11cf2d9def087b0898c828eaa21eb5f7b8811d5f..4ce08edf6e7a59238b1c4e85acc04eab21b21ee9 100644 ---- a/src/main/java/net/minecraft/world/entity/raid/Raid.java -+++ b/src/main/java/net/minecraft/world/entity/raid/Raid.java -@@ -112,6 +112,7 @@ public class Raid { +diff --git a/net/minecraft/world/entity/raid/Raid.java b/net/minecraft/world/entity/raid/Raid.java +index 6e8c1a2863ac6e5137a26815ecf5142f0fcc9893..27234627933ccaa70b2c51a792efb2e68104a84f 100644 +--- a/net/minecraft/world/entity/raid/Raid.java ++++ b/net/minecraft/world/entity/raid/Raid.java +@@ -109,6 +109,7 @@ public class Raid { private static final org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry PDC_TYPE_REGISTRY = new org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry(); public final org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer persistentDataContainer = new org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer(PDC_TYPE_REGISTRY); // Paper end + private boolean isBarDirty; // Gale - Lithium - update boss bar within tick - public Raid(int id, ServerLevel world, BlockPos pos) { - this.raidEvent = new ServerBossEvent(Raid.RAID_NAME_COMPONENT, BossEvent.BossBarColor.RED, BossEvent.BossBarOverlay.NOTCHED_10); -@@ -291,6 +292,12 @@ public class Raid { + public Raid(int id, ServerLevel level, BlockPos center) { + this.id = id; +@@ -263,6 +264,12 @@ public class Raid { } public void tick() { @@ -37,7 +37,7 @@ index 11cf2d9def087b0898c828eaa21eb5f7b8811d5f..4ce08edf6e7a59238b1c4e85acc04eab if (!this.isStopped()) { if (this.status == Raid.RaidStatus.ONGOING) { boolean flag = this.active; -@@ -652,6 +659,12 @@ public class Raid { +@@ -588,6 +595,12 @@ public class Raid { } public void updateBossbar() { diff --git a/patches/server/0077-Cache-world-generator-sea-level.patch b/gale-server/minecraft-patches/features/0064-Cache-world-generator-sea-level.patch similarity index 54% rename from patches/server/0077-Cache-world-generator-sea-level.patch rename to gale-server/minecraft-patches/features/0064-Cache-world-generator-sea-level.patch index fb3d4da..ab7f653 100644 --- a/patches/server/0077-Cache-world-generator-sea-level.patch +++ b/gale-server/minecraft-patches/features/0064-Cache-world-generator-sea-level.patch @@ -7,16 +7,16 @@ License: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html) Gale - https://galemc.org This patch is based on the following mixin: -"net/caffeinemc/mods/lithium/mixin/gen/cached_generator_settings/NoiseChunkGeneratorMixin.java" +"net/caffeinemc/mods/lithium/mixin/gen/cached_generator_settings/NoiseBasedChunkGeneratorMixin.java" By: SuperCoder7979 As part of: Lithium (https://github.com/CaffeineMC/lithium-fabric) Licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html) -diff --git a/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java b/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java -index 3f39d6c786d9dfdd9ad591e08ff05fcbb41a1df6..aa63b49738ef42122e7cd0f9dbec0d019c9b97b0 100644 ---- a/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java -+++ b/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java -@@ -61,12 +61,17 @@ public final class NoiseBasedChunkGenerator extends ChunkGenerator { +diff --git a/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java b/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java +index 65728ef17e63d71833677fdcbd5bb90794b4822b..de0f33fd008d8cd08b6da9ab37e98bd7f51ce0ca 100644 +--- a/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java ++++ b/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java +@@ -57,11 +57,19 @@ public final class NoiseBasedChunkGenerator extends ChunkGenerator { private static final BlockState AIR = Blocks.AIR.defaultBlockState(); public final Holder settings; private final Supplier globalFluidPicker; @@ -25,21 +25,23 @@ index 3f39d6c786d9dfdd9ad591e08ff05fcbb41a1df6..aa63b49738ef42122e7cd0f9dbec0d01 public NoiseBasedChunkGenerator(BiomeSource biomeSource, Holder settings) { super(biomeSource); this.settings = settings; - this.globalFluidPicker = Suppliers.memoize(() -> { -- return NoiseBasedChunkGenerator.createFluidPicker((NoiseGeneratorSettings) settings.value()); -+ // Gale start - Lithium - cache world generator sea level -+ var fluidPicker = NoiseBasedChunkGenerator.createFluidPicker((NoiseGeneratorSettings) settings.value()); +- this.globalFluidPicker = Suppliers.memoize(() -> createFluidPicker(settings.value())); ++ // Gale start - Lithium - cache world generator sea level ++ this.globalFluidPicker = Suppliers.memoize(() -> { ++ var fluidPicker = createFluidPicker(settings.value()); + this.cachedSeaLevel = settings.value().seaLevel(); + return fluidPicker; -+ // Gale end - Lithium - cache world generator sea level - }); ++ ++ }); ++ // Gale end - Lithium - cache world generator sea level } -@@ -409,7 +414,7 @@ public final class NoiseBasedChunkGenerator extends ChunkGenerator { + private static Aquifer.FluidPicker createFluidPicker(NoiseGeneratorSettings settings) { +@@ -407,7 +415,7 @@ public final class NoiseBasedChunkGenerator extends ChunkGenerator { @Override public int getSeaLevel() { -- return ((NoiseGeneratorSettings) this.settings.value()).seaLevel(); +- return this.settings.value().seaLevel(); + return this.cachedSeaLevel; // Gale - Lithium - cache world generator sea level } diff --git a/patches/server/0078-Skip-secondary-POI-sensor-if-absent.patch b/gale-server/minecraft-patches/features/0065-Skip-secondary-POI-sensor-if-absent.patch similarity index 68% rename from patches/server/0078-Skip-secondary-POI-sensor-if-absent.patch rename to gale-server/minecraft-patches/features/0065-Skip-secondary-POI-sensor-if-absent.patch index e5d1c81..172452d 100644 --- a/patches/server/0078-Skip-secondary-POI-sensor-if-absent.patch +++ b/gale-server/minecraft-patches/features/0065-Skip-secondary-POI-sensor-if-absent.patch @@ -7,7 +7,7 @@ License: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html) Gale - https://galemc.org This patch is based on the following mixin: -"net/caffeinemc/mods/lithium/mixin/ai/sensor/secondary_poi/SecondaryPointsOfInterestSensorMixin.java" +"net/caffeinemc/mods/lithium/mixin/ai/sensor/secondary_poi/SecondaryPoiSensorMixin.java" By: 2No2Name <2No2Name@web.de> As part of: Lithium (https://github.com/CaffeineMC/lithium-fabric) Licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html) @@ -16,14 +16,14 @@ Licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html) villagers that have no secondary POI (farmland) do not search for it -diff --git a/src/main/java/net/minecraft/world/entity/ai/sensing/SecondaryPoiSensor.java b/src/main/java/net/minecraft/world/entity/ai/sensing/SecondaryPoiSensor.java -index a0e0692d17760f440fe81d52887284c787e562db..1595568f3140a62b0f2236644ac2da11db12af05 100644 ---- a/src/main/java/net/minecraft/world/entity/ai/sensing/SecondaryPoiSensor.java -+++ b/src/main/java/net/minecraft/world/entity/ai/sensing/SecondaryPoiSensor.java +diff --git a/net/minecraft/world/entity/ai/sensing/SecondaryPoiSensor.java b/net/minecraft/world/entity/ai/sensing/SecondaryPoiSensor.java +index 6b99afb4f237b5d6def98f3e03492975b795bc95..05c664732adfca7d18bfcbebae9bb455f001aa93 100644 +--- a/net/minecraft/world/entity/ai/sensing/SecondaryPoiSensor.java ++++ b/net/minecraft/world/entity/ai/sensing/SecondaryPoiSensor.java @@ -22,6 +22,13 @@ public class SecondaryPoiSensor extends Sensor { @Override - protected void doTick(ServerLevel world, Villager entity) { + protected void doTick(ServerLevel level, Villager entity) { + // Gale start - Lithium - skip secondary POI sensor if absent + var secondaryPoi = entity.getVillagerData().getProfession().secondaryPoi(); + if (secondaryPoi.isEmpty()) { @@ -31,6 +31,6 @@ index a0e0692d17760f440fe81d52887284c787e562db..1595568f3140a62b0f2236644ac2da11 + return; + } + // Gale end - Lithium - skip secondary POI sensor if absent - ResourceKey resourceKey = world.dimension(); + ResourceKey resourceKey = level.dimension(); BlockPos blockPos = entity.blockPosition(); List list = Lists.newArrayList(); diff --git a/patches/server/0079-Skip-entity-move-if-movement-is-zero.patch b/gale-server/minecraft-patches/features/0066-Skip-entity-move-if-movement-is-zero.patch similarity index 70% rename from patches/server/0079-Skip-entity-move-if-movement-is-zero.patch rename to gale-server/minecraft-patches/features/0066-Skip-entity-move-if-movement-is-zero.patch index 99a90fb..edddb1e 100644 --- a/patches/server/0079-Skip-entity-move-if-movement-is-zero.patch +++ b/gale-server/minecraft-patches/features/0066-Skip-entity-move-if-movement-is-zero.patch @@ -12,19 +12,19 @@ By: ishland As part of: VMP (https://github.com/RelativityMC/VMP-fabric) Licensed under: MIT (https://opensource.org/licenses/MIT) -diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 1a03a415d17fec083beaaafb0fc9da1f00f514de..6604efeaf2eddfc109d05b45b4e36378862054c0 100644 ---- a/src/main/java/net/minecraft/world/entity/Entity.java -+++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -280,6 +280,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java +index b68013f83db13f4aeb94be4777c5341ce8ebfde4..9f674f579a3a0f6fe9eb71fa2cace7f0a93d5702 100644 +--- a/net/minecraft/world/entity/Entity.java ++++ b/net/minecraft/world/entity/Entity.java +@@ -233,6 +233,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess public float yRotO; public float xRotO; - private AABB bb; + private AABB bb = INITIAL_AABB; + private boolean boundingBoxChanged = false; // Gale - VMP - skip entity move if movement is zero public boolean onGround; public boolean horizontalCollision; public boolean verticalCollision; -@@ -1156,6 +1157,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -1083,6 +1084,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess // Paper end - detailed watchdog information public void move(MoverType type, Vec3 movement) { @@ -36,15 +36,15 @@ index 1a03a415d17fec083beaaafb0fc9da1f00f514de..6604efeaf2eddfc109d05b45b4e36378 final Vec3 originalMovement = movement; // Paper - Expose pre-collision velocity // Paper start - detailed watchdog information ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread("Cannot move an entity off-main"); -@@ -4375,6 +4381,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -4174,6 +4180,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess } - public final void setBoundingBox(AABB boundingBox) { + public final void setBoundingBox(AABB bb) { + // Gale start - VMP - skip entity move if movement is zero -+ if (!this.bb.equals(boundingBox)) { ++ if (!this.bb.equals(bb)) { + this.boundingBoxChanged = true; + } + // Gale end - VMP - skip entity move if movement is zero // CraftBukkit start - block invalid bounding boxes - double minX = boundingBox.minX, - minY = boundingBox.minY, + double minX = bb.minX, + minY = bb.minY, diff --git a/gale-server/minecraft-patches/features/0067-Store-mob-counts-in-an-array.patch b/gale-server/minecraft-patches/features/0067-Store-mob-counts-in-an-array.patch new file mode 100644 index 0000000..2ca79d8 --- /dev/null +++ b/gale-server/minecraft-patches/features/0067-Store-mob-counts-in-an-array.patch @@ -0,0 +1,36 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Wed, 30 Nov 2022 17:46:23 +0100 +Subject: [PATCH] Store mob counts in an array + +License: MIT (https://opensource.org/licenses/MIT) +Gale - https://galemc.org + +This patch is based on the following mixin: +"com/ishland/vmp/mixins/general/spawn_density_cap/MixinSpawnDensityCapperDensityCap.java" +By: ishland +As part of: VMP (https://github.com/RelativityMC/VMP-fabric) +Licensed under: MIT (https://opensource.org/licenses/MIT) + +diff --git a/net/minecraft/world/level/LocalMobCapCalculator.java b/net/minecraft/world/level/LocalMobCapCalculator.java +index 9641219c190261dea0db5f95f040a705ba0a3ff9..635afc61ee441924e1d64dbcf6dbab057d80c740 100644 +--- a/net/minecraft/world/level/LocalMobCapCalculator.java ++++ b/net/minecraft/world/level/LocalMobCapCalculator.java +@@ -42,14 +42,14 @@ public class LocalMobCapCalculator { + } + + static class MobCounts { +- private final Object2IntMap counts = new Object2IntOpenHashMap<>(MobCategory.values().length); ++ private final int[] counts = new int[MobCategory.values().length]; // Gale - VMP - store mob counts in an array + + public void add(MobCategory category) { +- this.counts.computeInt(category, (key, value) -> value == null ? 1 : value + 1); ++ this.counts[category.ordinal()]++; // Gale - VMP - store mob counts in an array + } + + public boolean canSpawn(MobCategory category) { +- return this.counts.getOrDefault(category, 0) < category.getMaxInstancesPerChunk(); ++ return this.counts[category.ordinal()] < category.getMaxInstancesPerChunk(); // Gale - VMP - store mob counts in an array + } + } + } diff --git a/gale-server/minecraft-patches/features/0068-Use-linked-map-for-entity-trackers.patch b/gale-server/minecraft-patches/features/0068-Use-linked-map-for-entity-trackers.patch new file mode 100644 index 0000000..cb9df0a --- /dev/null +++ b/gale-server/minecraft-patches/features/0068-Use-linked-map-for-entity-trackers.patch @@ -0,0 +1,27 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Thu, 1 Dec 2022 14:40:03 +0100 +Subject: [PATCH] Use linked map for entity trackers + +License: MIT (https://opensource.org/licenses/MIT) +Gale - https://galemc.org + +This patch is based on the following mixin: +"com/ishland/vmp/mixins/entitytracker/MixinThreadedAnvilChunkStorage.java" +By: ishland +As part of: VMP (https://github.com/RelativityMC/VMP-fabric) +Licensed under: MIT (https://opensource.org/licenses/MIT) + +diff --git a/net/minecraft/server/level/ChunkMap.java b/net/minecraft/server/level/ChunkMap.java +index d3d9926d504fa6b3384be5ae06b2843ebb7f807c..6a9fdb6329f177aca1274336a8e5be70ca3ce931 100644 +--- a/net/minecraft/server/level/ChunkMap.java ++++ b/net/minecraft/server/level/ChunkMap.java +@@ -127,7 +127,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider + public final AtomicInteger tickingGenerated = new AtomicInteger(); // Paper - public + private final String storageName; + private final PlayerMap playerMap = new PlayerMap(); +- public final Int2ObjectMap entityMap = new Int2ObjectOpenHashMap<>(); ++ public final Int2ObjectMap entityMap = new it.unimi.dsi.fastutil.ints.Int2ObjectLinkedOpenHashMap<>(); // Gale - VMP - use linked map for entity trackers - provides faster iteration + private final Long2ByteMap chunkTypeCache = new Long2ByteOpenHashMap(); + // Paper - rewrite chunk system + public int serverViewDistance; diff --git a/gale-server/minecraft-patches/features/0069-Optimize-noise-generation.patch b/gale-server/minecraft-patches/features/0069-Optimize-noise-generation.patch new file mode 100644 index 0000000..190040e --- /dev/null +++ b/gale-server/minecraft-patches/features/0069-Optimize-noise-generation.patch @@ -0,0 +1,239 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Wed, 30 Nov 2022 19:49:14 +0100 +Subject: [PATCH] Optimize noise generation + +License: MIT (https://opensource.org/licenses/MIT) +Gale - https://galemc.org + +This patch is based on the following mixins: +* "com/ishland/c2me/opts/math/mixin/MixinOctavePerlinNoiseSampler.java" +* "com/ishland/c2me/opts/math/mixin/MixinPerlinNoiseSampler.java" +By: ishland +As part of: C2ME (https://github.com/RelativityMC/C2ME-fabric) +Licensed under: MIT (https://opensource.org/licenses/MIT) + +diff --git a/net/minecraft/world/level/levelgen/synth/ImprovedNoise.java b/net/minecraft/world/level/levelgen/synth/ImprovedNoise.java +index fb11a2eea540d55e50eab59f9857ca5d99f556f8..dcc1a3f8b611c9f103b848db90b077b984b60ada 100644 +--- a/net/minecraft/world/level/levelgen/synth/ImprovedNoise.java ++++ b/net/minecraft/world/level/levelgen/synth/ImprovedNoise.java +@@ -11,6 +11,27 @@ public final class ImprovedNoise { + public final double yo; + public final double zo; + ++ // Gale start - C2ME - optimize noise generation ++ private static final double[] FLAT_SIMPLEX_GRAD = new double[]{ ++ 1, 1, 0, 0, ++ -1, 1, 0, 0, ++ 1, -1, 0, 0, ++ -1, -1, 0, 0, ++ 1, 0, 1, 0, ++ -1, 0, 1, 0, ++ 1, 0, -1, 0, ++ -1, 0, -1, 0, ++ 0, 1, 1, 0, ++ 0, -1, 1, 0, ++ 0, 1, -1, 0, ++ 0, -1, -1, 0, ++ 1, 1, 0, 0, ++ 0, -1, 1, 0, ++ -1, 1, 0, 0, ++ 0, -1, -1, 0, ++ }; ++ // Gale end - C2ME - optimize noise generation ++ + public ImprovedNoise(RandomSource random) { + this.xo = random.nextDouble() * 256.0; + this.yo = random.nextDouble() * 256.0; +@@ -38,9 +59,11 @@ public final class ImprovedNoise { + double d = x + this.xo; + double d1 = y + this.yo; + double d2 = z + this.zo; +- int floor = Mth.floor(d); +- int floor1 = Mth.floor(d1); +- int floor2 = Mth.floor(d2); ++ // Gale start - C2ME - optimize noise generation - optimize: remove frequent type conversions ++ double floor = Math.floor(d); ++ double floor1 = Math.floor(d1); ++ double floor2 = Math.floor(d2); ++ // Gale end - C2ME - optimize noise generation - optimize: remove frequent type conversions + double d3 = d - floor; + double d4 = d1 - floor1; + double d5 = d2 - floor2; +@@ -53,25 +76,27 @@ public final class ImprovedNoise { + d6 = d4; + } + +- d7 = Mth.floor(d6 / yScale + 1.0E-7F) * yScale; ++ d7 = Math.floor(d6 / yScale + 1.0E-7F) * yScale; // Gale - C2ME - optimize noise generation - optimize: remove frequent type conversions + } else { + d7 = 0.0; + } + +- return this.sampleAndLerp(floor, floor1, floor2, d3, d4 - d7, d5, d4); ++ return this.sampleAndLerp((int) floor, (int) floor1, (int) floor2, d3, d4 - d7, d5, d4); // Gale - C2ME - optimize noise generation - optimize: remove frequent type conversions + } + + public double noiseWithDerivative(double x, double y, double z, double[] values) { + double d = x + this.xo; + double d1 = y + this.yo; + double d2 = z + this.zo; +- int floor = Mth.floor(d); +- int floor1 = Mth.floor(d1); +- int floor2 = Mth.floor(d2); ++ // Gale start - C2ME - optimize noise generation - optimize: remove frequent type conversions ++ double floor = Math.floor(d); ++ double floor1 = Math.floor(d1); ++ double floor2 = Math.floor(d2); ++ // Gale end - C2ME - optimize noise generation - optimize: remove frequent type conversions + double d3 = d - floor; + double d4 = d1 - floor1; + double d5 = d2 - floor2; +- return this.sampleWithDerivative(floor, floor1, floor2, d3, d4, d5, values); ++ return this.sampleWithDerivative((int) floor, (int) floor1, (int) floor2, d3, d4, d5, values); // Gale - C2ME - optimize noise generation - optimize: remove frequent type conversions + } + + private static double gradDot(int gradIndex, double xFactor, double yFactor, double zFactor) { +@@ -83,24 +108,69 @@ public final class ImprovedNoise { + } + + private double sampleAndLerp(int gridX, int gridY, int gridZ, double deltaX, double weirdDeltaY, double deltaZ, double deltaY) { +- int i = this.p(gridX); +- int i1 = this.p(gridX + 1); +- int i2 = this.p(i + gridY); +- int i3 = this.p(i + gridY + 1); +- int i4 = this.p(i1 + gridY); +- int i5 = this.p(i1 + gridY + 1); +- double d = gradDot(this.p(i2 + gridZ), deltaX, weirdDeltaY, deltaZ); +- double d1 = gradDot(this.p(i4 + gridZ), deltaX - 1.0, weirdDeltaY, deltaZ); +- double d2 = gradDot(this.p(i3 + gridZ), deltaX, weirdDeltaY - 1.0, deltaZ); +- double d3 = gradDot(this.p(i5 + gridZ), deltaX - 1.0, weirdDeltaY - 1.0, deltaZ); +- double d4 = gradDot(this.p(i2 + gridZ + 1), deltaX, weirdDeltaY, deltaZ - 1.0); +- double d5 = gradDot(this.p(i4 + gridZ + 1), deltaX - 1.0, weirdDeltaY, deltaZ - 1.0); +- double d6 = gradDot(this.p(i3 + gridZ + 1), deltaX, weirdDeltaY - 1.0, deltaZ - 1.0); +- double d7 = gradDot(this.p(i5 + gridZ + 1), deltaX - 1.0, weirdDeltaY - 1.0, deltaZ - 1.0); +- double d8 = Mth.smoothstep(deltaX); +- double d9 = Mth.smoothstep(deltaY); +- double d10 = Mth.smoothstep(deltaZ); +- return Mth.lerp3(d8, d9, d10, d, d1, d2, d3, d4, d5, d6, d7); ++ // Gale start - C2ME - optimize noise generation - inline math & small optimization: remove frequent type conversions and redundant ops ++ final int var0 = gridX & 0xFF; ++ final int var1 = (gridX + 1) & 0xFF; ++ final int var2 = this.p[var0] & 0xFF; ++ final int var3 = this.p[var1] & 0xFF; ++ final int var4 = (var2 + gridY) & 0xFF; ++ final int var5 = (var3 + gridY) & 0xFF; ++ final int var6 = (var2 + gridY + 1) & 0xFF; ++ final int var7 = (var3 + gridY + 1) & 0xFF; ++ final int var8 = this.p[var4] & 0xFF; ++ final int var9 = this.p[var5] & 0xFF; ++ final int var10 = this.p[var6] & 0xFF; ++ final int var11 = this.p[var7] & 0xFF; ++ ++ final int var12 = (var8 + gridZ) & 0xFF; ++ final int var13 = (var9 + gridZ) & 0xFF; ++ final int var14 = (var10 + gridZ) & 0xFF; ++ final int var15 = (var11 + gridZ) & 0xFF; ++ final int var16 = (var8 + gridZ + 1) & 0xFF; ++ final int var17 = (var9 + gridZ + 1) & 0xFF; ++ final int var18 = (var10 + gridZ + 1) & 0xFF; ++ final int var19 = (var11 + gridZ + 1) & 0xFF; ++ final int var20 = (this.p[var12] & 15) << 2; ++ final int var21 = (this.p[var13] & 15) << 2; ++ final int var22 = (this.p[var14] & 15) << 2; ++ final int var23 = (this.p[var15] & 15) << 2; ++ final int var24 = (this.p[var16] & 15) << 2; ++ final int var25 = (this.p[var17] & 15) << 2; ++ final int var26 = (this.p[var18] & 15) << 2; ++ final int var27 = (this.p[var19] & 15) << 2; ++ final double var60 = deltaX - 1.0; ++ final double var61 = weirdDeltaY - 1.0; ++ final double var62 = deltaZ - 1.0; ++ final double var87 = FLAT_SIMPLEX_GRAD[(var20) | 0] * deltaX + FLAT_SIMPLEX_GRAD[(var20) | 1] * weirdDeltaY + FLAT_SIMPLEX_GRAD[(var20) | 2] * deltaZ; ++ final double var88 = FLAT_SIMPLEX_GRAD[(var21) | 0] * var60 + FLAT_SIMPLEX_GRAD[(var21) | 1] * weirdDeltaY + FLAT_SIMPLEX_GRAD[(var21) | 2] * deltaZ; ++ final double var89 = FLAT_SIMPLEX_GRAD[(var22) | 0] * deltaX + FLAT_SIMPLEX_GRAD[(var22) | 1] * var61 + FLAT_SIMPLEX_GRAD[(var22) | 2] * deltaZ; ++ final double var90 = FLAT_SIMPLEX_GRAD[(var23) | 0] * var60 + FLAT_SIMPLEX_GRAD[(var23) | 1] * var61 + FLAT_SIMPLEX_GRAD[(var23) | 2] * deltaZ; ++ final double var91 = FLAT_SIMPLEX_GRAD[(var24) | 0] * deltaX + FLAT_SIMPLEX_GRAD[(var24) | 1] * weirdDeltaY + FLAT_SIMPLEX_GRAD[(var24) | 2] * var62; ++ final double var92 = FLAT_SIMPLEX_GRAD[(var25) | 0] * var60 + FLAT_SIMPLEX_GRAD[(var25) | 1] * weirdDeltaY + FLAT_SIMPLEX_GRAD[(var25) | 2] * var62; ++ final double var93 = FLAT_SIMPLEX_GRAD[(var26) | 0] * deltaX + FLAT_SIMPLEX_GRAD[(var26) | 1] * var61 + FLAT_SIMPLEX_GRAD[(var26) | 2] * var62; ++ final double var94 = FLAT_SIMPLEX_GRAD[(var27) | 0] * var60 + FLAT_SIMPLEX_GRAD[(var27) | 1] * var61 + FLAT_SIMPLEX_GRAD[(var27) | 2] * var62; ++ ++ final double var95 = deltaX * 6.0 - 15.0; ++ final double var96 = deltaY * 6.0 - 15.0; ++ final double var97 = deltaZ * 6.0 - 15.0; ++ final double var98 = deltaX * var95 + 10.0; ++ final double var99 = deltaY * var96 + 10.0; ++ final double var100 = deltaZ * var97 + 10.0; ++ final double var101 = deltaX * deltaX * deltaX * var98; ++ final double var102 = deltaY * deltaY * deltaY * var99; ++ final double var103 = deltaZ * deltaZ * deltaZ * var100; ++ ++ final double var113 = var87 + var101 * (var88 - var87); ++ final double var114 = var93 + var101 * (var94 - var93); ++ final double var115 = var91 + var101 * (var92 - var91); ++ final double var116 = var89 + var101 * (var90 - var89); ++ final double var117 = var114 - var115; ++ final double var118 = var102 * (var116 - var113); ++ final double var119 = var102 * var117; ++ final double var120 = var113 + var118; ++ final double var121 = var115 + var119; ++ return var120 + (var103 * (var121 - var120)); ++ // Gale end - C2ME - optimize noise generation - inline math & small optimization: remove frequent type conversions and redundant ops + } + + private double sampleWithDerivative(int gridX, int gridY, int gridZ, double deltaX, double deltaY, double deltaZ, double[] noiseValues) { +diff --git a/net/minecraft/world/level/levelgen/synth/PerlinNoise.java b/net/minecraft/world/level/levelgen/synth/PerlinNoise.java +index da3c26fbad32d75d71f7e59c8c3341316a754756..2c28bb2fed04542a2ee126fe0c1c1f0253a3e2eb 100644 +--- a/net/minecraft/world/level/levelgen/synth/PerlinNoise.java ++++ b/net/minecraft/world/level/levelgen/synth/PerlinNoise.java +@@ -26,6 +26,10 @@ public class PerlinNoise { + private final double lowestFreqValueFactor; + private final double lowestFreqInputFactor; + private final double maxValue; ++ // Gale start - C2ME - optimize noise generation ++ private final int octaveSamplersCount; ++ private final double [] amplitudesArray; ++ // Gale end - C2ME - optimize noise generation + + @Deprecated + public static PerlinNoise createLegacyForBlendedNoise(RandomSource random, IntStream octaves) { +@@ -127,6 +131,10 @@ public class PerlinNoise { + this.lowestFreqInputFactor = Math.pow(2.0, -i); + this.lowestFreqValueFactor = Math.pow(2.0, size - 1) / (Math.pow(2.0, size) - 1.0); + this.maxValue = this.edgeValue(2.0); ++ // Gale start - C2ME - optimize noise generation ++ this.octaveSamplersCount = this.noiseLevels.length; ++ this.amplitudesArray = this.amplitudes.toDoubleArray(); ++ // Gale end - C2ME - optimize noise generation + } + + protected double maxValue() { +@@ -138,7 +146,27 @@ public class PerlinNoise { + } + + public double getValue(double x, double y, double z) { +- return this.getValue(x, y, z, 0.0, 0.0, false); ++ // Gale start - C2ME - optimize noise generation - optimize for common cases ++ double d = 0.0; ++ double e = this.lowestFreqInputFactor; ++ double f = this.lowestFreqValueFactor; ++ ++ for (int i = 0; i < this.octaveSamplersCount; ++i) { ++ ImprovedNoise perlinNoiseSampler = this.noiseLevels[i]; ++ if (perlinNoiseSampler != null) { ++ @SuppressWarnings("deprecation") ++ double g = perlinNoiseSampler.noise( ++ wrap(x * e), wrap(y * e), wrap(z * e), 0.0, 0.0 ++ ); ++ d += this.amplitudesArray[i] * g * f; ++ } ++ ++ e *= 2.0; ++ f /= 2.0; ++ } ++ ++ return d; ++ // Gale end - C2ME - optimize noise generation - optimize for common cases + } + + @Deprecated diff --git a/patches/server/0083-Optimize-sheep-offspring-color.patch b/gale-server/minecraft-patches/features/0070-Optimize-sheep-offspring-color.patch similarity index 71% rename from patches/server/0083-Optimize-sheep-offspring-color.patch rename to gale-server/minecraft-patches/features/0070-Optimize-sheep-offspring-color.patch index d652f76..30261ad 100644 --- a/patches/server/0083-Optimize-sheep-offspring-color.patch +++ b/gale-server/minecraft-patches/features/0070-Optimize-sheep-offspring-color.patch @@ -45,12 +45,12 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -diff --git a/src/main/java/net/minecraft/world/entity/animal/Sheep.java b/src/main/java/net/minecraft/world/entity/animal/Sheep.java -index 0b7f8b8d8cd119d83e67a2cee389bd6117ac4cf7..a021252871fd93d4fb3f23598d6008f25a350150 100644 ---- a/src/main/java/net/minecraft/world/entity/animal/Sheep.java -+++ b/src/main/java/net/minecraft/world/entity/animal/Sheep.java -@@ -337,7 +337,99 @@ public class Sheep extends Animal implements Shearable { - return super.finalizeSpawn(world, difficulty, spawnReason, entityData); +diff --git a/net/minecraft/world/item/DyeColor.java b/net/minecraft/world/item/DyeColor.java +index f1b9fa4b39c7e13a4cf3e7947bda96c3cf523e82..028bb51c6753d44cbae76890412aa55b070f8054 100644 +--- a/net/minecraft/world/item/DyeColor.java ++++ b/net/minecraft/world/item/DyeColor.java +@@ -108,7 +108,97 @@ public enum DyeColor implements StringRepresentable { + return this.name; } + // Gale start - carpet-fixes - optimize sheep offspring color @@ -134,30 +134,16 @@ index 0b7f8b8d8cd119d83e67a2cee389bd6117ac4cf7..a021252871fd93d4fb3f23598d6008f2 + } + // Gale end - carpet-fixes - optimize sheep offspring color + - private DyeColor getOffspringColor(ServerLevel world, Sheep firstParent, Sheep secondParent) { + public static DyeColor getMixedColor(ServerLevel level, DyeColor first, DyeColor second) { + // Gale start - carpet-fixes - optimize sheep offspring color -+ if (world.galeConfig().smallOptimizations.useOptimizedSheepOffspringColor) { -+ DyeColor firstColor = firstParent.getColor(); -+ DyeColor secondColor = secondParent.getColor(); -+ DyeColor col = properDye(firstColor, secondColor); ++ if (level.galeConfig().smallOptimizations.useOptimizedSheepOffspringColor) { ++ DyeColor col = properDye(first, second); + -+ if (col == null) col = world.random.nextBoolean() ? firstColor : secondColor; ++ if (col == null) col = level.random.nextBoolean() ? first : second; + + return col; + } + // Gale end - carpet-fixes - optimize sheep offspring color - DyeColor enumcolor = firstParent.getColor(); - DyeColor enumcolor1 = secondParent.getColor(); - CraftingInput craftinginput = Sheep.makeCraftInput(enumcolor, enumcolor1); -diff --git a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -index cc843de2d62bdaadb4efb7032162f8f04b10c286..1ba7cc5844236cfa75e7efcbf5a377f8e71fbaca 100644 ---- a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -+++ b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -@@ -34,6 +34,7 @@ public class GaleWorldConfiguration extends ConfigurationPart { - public class SmallOptimizations extends ConfigurationPart { - - public boolean saveFireworks = true; // Gale - EMC - make saving fireworks configurable -+ public boolean useOptimizedSheepOffspringColor = true; // Gale - carpet-fixes - optimize sheep offspring color - - // Gale start - Airplane - reduce projectile chunk loading - public MaxProjectileChunkLoads maxProjectileChunkLoads; + CraftingInput craftingInput = makeCraftColorInput(first, second); + return level.recipeAccess() + .getRecipeFor(RecipeType.CRAFTING, craftingInput, level) diff --git a/gale-server/minecraft-patches/features/0071-Hide-flames-on-entities-with-fire-resistance.patch b/gale-server/minecraft-patches/features/0071-Hide-flames-on-entities-with-fire-resistance.patch new file mode 100644 index 0000000..6ede64f --- /dev/null +++ b/gale-server/minecraft-patches/features/0071-Hide-flames-on-entities-with-fire-resistance.patch @@ -0,0 +1,32 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Wed, 30 Nov 2022 14:39:27 +0100 +Subject: [PATCH] Hide flames on entities with fire resistance + +License: MIT (https://opensource.org/licenses/MIT) +Gale - https://galemc.org + +This patch is based on the following patch: +"Don't send fire packets if player has Fire Resistance" +By: Cryptite +As part of: Slice (https://github.com/Cryptite/Slice) +Licensed under: MIT (https://opensource.org/licenses/MIT) + +diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java +index 9f674f579a3a0f6fe9eb71fa2cace7f0a93d5702..ec303fb52aee7a0bc1df42a628fac24276d059de 100644 +--- a/net/minecraft/world/entity/Entity.java ++++ b/net/minecraft/world/entity/Entity.java +@@ -884,7 +884,13 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess + + this.checkBelowWorld(); + if (!this.level().isClientSide) { ++ // Gale start - Slice - hide flames on entities with fire resistance ++ if (this instanceof net.minecraft.world.entity.LivingEntity livingEntity) { ++ this.setSharedFlagOnFire(this.remainingFireTicks > 0 && (!this.level.galeConfig().gameplayMechanics.hideFlamesOnEntitiesWithFireResistance || !livingEntity.hasEffect(net.minecraft.world.effect.MobEffects.FIRE_RESISTANCE))); ++ } else { ++ // Gale end - Slice - hide flames on entities with fire resistance + this.setSharedFlagOnFire(this.remainingFireTicks > 0); ++ } // Gale - Slice - hide flames on entities with fire resistance + } + + this.firstTick = false; diff --git a/patches/server/0085-Skip-cloning-advancement-criteria.patch b/gale-server/minecraft-patches/features/0072-Skip-cloning-advancement-criteria.patch similarity index 75% rename from patches/server/0085-Skip-cloning-advancement-criteria.patch rename to gale-server/minecraft-patches/features/0072-Skip-cloning-advancement-criteria.patch index dd18333..e355724 100644 --- a/patches/server/0085-Skip-cloning-advancement-criteria.patch +++ b/gale-server/minecraft-patches/features/0072-Skip-cloning-advancement-criteria.patch @@ -12,10 +12,10 @@ By: etil2jz <81570777+etil2jz@users.noreply.github.com> As part of: Mirai (https://github.com/etil2jz/Mirai) Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) -diff --git a/src/main/java/net/minecraft/advancements/Advancement.java b/src/main/java/net/minecraft/advancements/Advancement.java -index fb4b7652c386fa10783d71899615723a958ffd56..8045b17eed344e4bcdd02adba1d63904b6562cde 100644 ---- a/src/main/java/net/minecraft/advancements/Advancement.java -+++ b/src/main/java/net/minecraft/advancements/Advancement.java +diff --git a/net/minecraft/advancements/Advancement.java b/net/minecraft/advancements/Advancement.java +index d5c824eabf321a2c7600c7081b8d4f3057cfae2e..ccc9ca901fc8bec44f0e2717a51104caf759a1b4 100644 +--- a/net/minecraft/advancements/Advancement.java ++++ b/net/minecraft/advancements/Advancement.java @@ -60,7 +60,7 @@ public record Advancement( AdvancementRequirements requirements, boolean sendsTelemetryEvent diff --git a/gale-server/minecraft-patches/features/0073-Reduce-block-destruction-packet-allocations.patch b/gale-server/minecraft-patches/features/0073-Reduce-block-destruction-packet-allocations.patch new file mode 100644 index 0000000..2ace685 --- /dev/null +++ b/gale-server/minecraft-patches/features/0073-Reduce-block-destruction-packet-allocations.patch @@ -0,0 +1,51 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Fri, 23 Dec 2022 20:42:50 +0100 +Subject: [PATCH] Reduce block destruction packet allocations + +License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) +Gale - https://galemc.org + +This patch is based on the following patch: +"Cache block break animation packet" +By: VytskaLT +As part of: SportPaper (https://github.com/Electroid/SportPaper) +Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) + +diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java +index 2b9b683023943435a86c42e3a61e0b3329df19d8..8734feabddeb259249213f0084f072a3f12e7daf 100644 +--- a/net/minecraft/server/level/ServerLevel.java ++++ b/net/minecraft/server/level/ServerLevel.java +@@ -1559,6 +1559,14 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe + + @Override + public void destroyBlockProgress(int breakerId, BlockPos pos, int progress) { ++ // Gale start - SportPaper - reduce block destruction packet allocations ++ var players = this.server.getPlayerList().getPlayers(); ++ if (players.isEmpty()) { ++ return; ++ } ++ ++ ClientboundBlockDestructionPacket packet = new ClientboundBlockDestructionPacket(breakerId, pos, progress); ++ // Gale end - SportPaper - reduce block destruction packet allocations + // CraftBukkit start + Player breakerPlayer = null; + Entity entity = this.getEntity(breakerId); +@@ -1575,7 +1583,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe + .callEvent(); + } + // Paper end - Add BlockBreakProgressUpdateEvent +- for (ServerPlayer serverPlayer : this.server.getPlayerList().getPlayers()) { ++ for (ServerPlayer serverPlayer : players) { // Gale - SportPaper - reduce block destruction packet allocations + if (serverPlayer != null && serverPlayer.level() == this && serverPlayer.getId() != breakerId) { + double d = pos.getX() - serverPlayer.getX(); + double d1 = pos.getY() - serverPlayer.getY(); +@@ -1586,7 +1594,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe + } + // CraftBukkit end + if (d * d + d1 * d1 + d2 * d2 < 1024.0) { +- serverPlayer.connection.send(new ClientboundBlockDestructionPacket(breakerId, pos, progress)); ++ serverPlayer.connection.send(packet); // Gale - SportPaper - reduce block destruction packet allocations + } + } + } diff --git a/patches/server/0087-Spread-out-sending-all-player-info.patch b/gale-server/minecraft-patches/features/0074-Spread-out-sending-all-player-info.patch similarity index 60% rename from patches/server/0087-Spread-out-sending-all-player-info.patch rename to gale-server/minecraft-patches/features/0074-Spread-out-sending-all-player-info.patch index b357f3e..be2d046 100644 --- a/patches/server/0087-Spread-out-sending-all-player-info.patch +++ b/gale-server/minecraft-patches/features/0074-Spread-out-sending-all-player-info.patch @@ -36,11 +36,11 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index 2b6621b858961b8ec4ad73fb2db797306adf7251..843f09312888ab91ddd50fa2870ba4dc2236d54a 100644 ---- a/src/main/java/net/minecraft/server/players/PlayerList.java -+++ b/src/main/java/net/minecraft/server/players/PlayerList.java -@@ -133,10 +133,11 @@ public abstract class PlayerList { +diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java +index b4258db165b509d54b9c15a661c5b66ca984ffb3..af0f608e05262cbb118d92786bcdba9ae834a809 100644 +--- a/net/minecraft/server/players/PlayerList.java ++++ b/net/minecraft/server/players/PlayerList.java +@@ -109,11 +109,12 @@ public abstract class PlayerList { public static final Component CHAT_FILTERED_FULL = Component.translatable("chat.filtered_full"); public static final Component DUPLICATE_LOGIN_DISCONNECT_MESSAGE = Component.translatable("multiplayer.disconnect.duplicate_login"); private static final Logger LOGGER = LogUtils.getLogger(); @@ -49,53 +49,69 @@ index 2b6621b858961b8ec4ad73fb2db797306adf7251..843f09312888ab91ddd50fa2870ba4dc private static final SimpleDateFormat BAN_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z"); private final MinecraftServer server; public final List players = new java.util.concurrent.CopyOnWriteArrayList(); // CraftBukkit - ArrayList -> CopyOnWriteArrayList: Iterator safety -+ private final ServerPlayer[][] sendAllPlayerInfoBuckets = new ServerPlayer[SEND_PLAYER_INFO_INTERVAL][]; // Gale - Purpur - spread out sending all player info private final Map playersByUUID = Maps.newHashMap(); - private final UserBanList bans; - private final IpBanList ipBans; -@@ -329,6 +330,7 @@ public abstract class PlayerList { - - // entityplayer.connection.send(ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(this.players)); // CraftBukkit - replaced with loop below ++ private final ServerPlayer[][] sendAllPlayerInfoBuckets = new ServerPlayer[SEND_PLAYER_INFO_INTERVAL][]; // Gale - Purpur - spread out sending all player info + private final UserBanList bans = new UserBanList(USERBANLIST_FILE); + private final IpBanList ipBans = new IpBanList(IPBANLIST_FILE); + private final ServerOpList ops = new ServerOpList(OPLIST_FILE); +@@ -309,6 +310,7 @@ public abstract class PlayerList { this.players.add(player); -+ this.addToSendAllPlayerInfoBuckets(player); // Gale - Purpur - spread out sending all player info this.playersByName.put(player.getScoreboardName().toLowerCase(java.util.Locale.ROOT), player); // Spigot this.playersByUUID.put(player.getUUID(), player); - // this.broadcastAll(ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(List.of(entityplayer))); // CraftBukkit - replaced with loop below -@@ -623,6 +625,7 @@ public abstract class PlayerList { - entityplayer.retireScheduler(); // Paper - Folia schedulers - entityplayer.getAdvancements().stopListening(); - this.players.remove(entityplayer); -+ this.removeFromSendAllPlayerInfoBuckets(entityplayer); // Gale - Purpur - spread out sending all player info - this.playersByName.remove(entityplayer.getScoreboardName().toLowerCase(java.util.Locale.ROOT)); // Spigot - this.server.getCustomBossEvents().onPlayerDisconnect(entityplayer); - UUID uuid = entityplayer.getUUID(); -@@ -779,6 +782,7 @@ public abstract class PlayerList { - public ServerPlayer respawn(ServerPlayer entityplayer, boolean flag, Entity.RemovalReason entity_removalreason, RespawnReason reason, Location location) { - entityplayer.stopRiding(); // CraftBukkit - this.players.remove(entityplayer); -+ this.removeFromSendAllPlayerInfoBuckets(entityplayer); // Gale - Purpur - spread out sending all player info - this.playersByName.remove(entityplayer.getScoreboardName().toLowerCase(java.util.Locale.ROOT)); // Spigot - entityplayer.serverLevel().removePlayerImmediately(entityplayer, entity_removalreason); - /* CraftBukkit start -@@ -865,6 +869,7 @@ public abstract class PlayerList { - if (!entityplayer.connection.isDisconnected()) { - worldserver.addRespawnedPlayer(entityplayer1); - this.players.add(entityplayer1); -+ this.addToSendAllPlayerInfoBuckets(entityplayer1); // Gale - Purpur - spread out sending all player info - this.playersByName.put(entityplayer1.getScoreboardName().toLowerCase(java.util.Locale.ROOT), entityplayer1); // Spigot - this.playersByUUID.put(entityplayer1.getUUID(), entityplayer1); ++ this.addToSendAllPlayerInfoBuckets(player); // Gale - Purpur - spread out sending all player info + // this.broadcastAll(ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(List.of(player))); // CraftBukkit - replaced with loop below + // Paper start - Fire PlayerJoinEvent when Player is actually ready; correctly register player BEFORE PlayerJoinEvent, so the entity is valid and doesn't require tick delay hacks + player.supressTrackerForLogin = true; +@@ -578,6 +580,7 @@ public abstract class PlayerList { + player.getAdvancements().stopListening(); + this.players.remove(player); + this.playersByName.remove(player.getScoreboardName().toLowerCase(java.util.Locale.ROOT)); // Spigot ++ this.removeFromSendAllPlayerInfoBuckets(player); // Gale - Purpur - spread out sending all player info + this.server.getCustomBossEvents().onPlayerDisconnect(player); + UUID uuid = player.getUUID(); + ServerPlayer serverPlayer = this.playersByUUID.get(uuid); +@@ -725,6 +728,7 @@ public abstract class PlayerList { + player.stopRiding(); // CraftBukkit + this.players.remove(player); + this.playersByName.remove(player.getScoreboardName().toLowerCase(java.util.Locale.ROOT)); // Spigot ++ this.removeFromSendAllPlayerInfoBuckets(player); // Gale - Purpur - spread out sending all player info + player.serverLevel().removePlayerImmediately(player, reason); + // TeleportTransition teleportTransition = player.findRespawnPositionAndUseSpawnBlock(!keepInventory, TeleportTransition.DO_NOTHING); + // ServerLevel level = teleportTransition.newLevel(); +@@ -802,6 +806,7 @@ public abstract class PlayerList { + this.players.add(serverPlayer); + this.playersByName.put(serverPlayer.getScoreboardName().toLowerCase(java.util.Locale.ROOT), serverPlayer); // Spigot + this.playersByUUID.put(serverPlayer.getUUID(), serverPlayer); ++ this.addToSendAllPlayerInfoBuckets(serverPlayer); // Gale - Purpur - spread out sending all player info } -@@ -950,20 +955,55 @@ public abstract class PlayerList { - this.sendPlayerPermissionLevel(player, i, recalculatePermissions); // Paper - avoid recalculating permissions if possible + // serverPlayer.initInventoryMenu(); + serverPlayer.setHealth(serverPlayer.getHealth()); +@@ -890,18 +895,52 @@ public abstract class PlayerList { } -- public void tick() { + public void tick() { - if (++this.sendAllPlayerInfoIn > 600) { - // CraftBukkit start - for (int i = 0; i < this.players.size(); ++i) { -- final ServerPlayer target = (ServerPlayer) this.players.get(i); +- final ServerPlayer target = this.players.get(i); ++ // Gale start - Purpur - spread out sending all player info ++ ServerPlayer[] sendAllPlayerInfoBucket = this.sendAllPlayerInfoBuckets[this.sendAllPlayerInfoIn]; ++ if (sendAllPlayerInfoBucket != null) { ++ for (ServerPlayer target : sendAllPlayerInfoBucket) { ++ // Gale end - Purpur - spread out sending all player info + + target.connection.send(new ClientboundPlayerInfoUpdatePacket(EnumSet.of(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_LATENCY), com.google.common.collect.Collections2.filter(this.players, t -> target.getBukkitEntity().canSee(t.getBukkitEntity())))); + } +- // CraftBukkit end ++ // Gale start - Purpur - spread out sending all player info ++ } ++ if (++this.sendAllPlayerInfoIn >= SEND_PLAYER_INFO_INTERVAL) { ++ // Gale end - Purpur - spread out sending all player info + this.sendAllPlayerInfoIn = 0; + } + } + + // Gale start - Purpur - spread out sending all player info -+ + private void addToSendAllPlayerInfoBuckets(ServerPlayer player) { + ServerPlayer[] sendAllPlayerInfoBucket = this.sendAllPlayerInfoBuckets[player.sendAllPlayerInfoBucketIndex]; + if (sendAllPlayerInfoBucket == null) { @@ -123,47 +139,25 @@ index 2b6621b858961b8ec4ad73fb2db797306adf7251..843f09312888ab91ddd50fa2870ba4dc + } + } + } - + // Gale end - Purpur - spread out sending all player info + -+ public void tick() { -+ // Gale start - Purpur - spread out sending all player info -+ ServerPlayer[] sendAllPlayerInfoBucket = this.sendAllPlayerInfoBuckets[this.sendAllPlayerInfoIn]; -+ if (sendAllPlayerInfoBucket != null) { -+ for (ServerPlayer target : sendAllPlayerInfoBucket) { -+ // Gale end - Purpur - spread out sending all player info - target.connection.send(new ClientboundPlayerInfoUpdatePacket(EnumSet.of(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_LATENCY), this.players.stream().filter(new Predicate() { - @Override - public boolean test(ServerPlayer input) { - return target.getBukkitEntity().canSee(input.getBukkitEntity()); - } - }).collect(Collectors.toList()))); -+ // Gale start - Purpur - spread out sending all player info - } -- // CraftBukkit end -+ } -+ if (++this.sendAllPlayerInfoIn >= SEND_PLAYER_INFO_INTERVAL) { -+ // Gale end - Purpur - spread out sending all player info - this.sendAllPlayerInfoIn = 0; - } - -diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java -index 61d412c4f1ebd55661cc3f0260468e3ac0efe0bb..d6068324f7926741a490ead6277015b0e69517f8 100644 ---- a/src/main/java/net/minecraft/world/entity/player/Player.java -+++ b/src/main/java/net/minecraft/world/entity/player/Player.java -@@ -208,12 +208,15 @@ public abstract class Player extends LivingEntity { + // CraftBukkit start - add a world/entity limited version + public void broadcastAll(Packet packet, net.minecraft.world.entity.player.Player entityhuman) { + for (int i = 0; i < this.players.size(); ++i) { +diff --git a/net/minecraft/world/entity/player/Player.java b/net/minecraft/world/entity/player/Player.java +index 3ae542153bf1538d17e7c0fe6acc9e7f8605750c..57b11cd0eee3c2661070cc591b4bbef2f50ef009 100644 +--- a/net/minecraft/world/entity/player/Player.java ++++ b/net/minecraft/world/entity/player/Player.java +@@ -211,9 +211,12 @@ public abstract class Player extends LivingEntity { } // CraftBukkit end + public final int sendAllPlayerInfoBucketIndex; // Gale - Purpur - spread out sending all player info + - public Player(Level world, BlockPos pos, float yaw, GameProfile gameProfile) { - super(EntityType.PLAYER, world); - this.lastItemInMainHand = ItemStack.EMPTY; - this.cooldowns = this.createItemCooldowns(); - this.lastDeathLocation = Optional.empty(); + public Player(Level level, BlockPos pos, float yRot, GameProfile gameProfile) { + super(EntityType.PLAYER, level); this.setUUID(gameProfile.getId()); + this.sendAllPlayerInfoBucketIndex = Math.floorMod(this.uuid.hashCode(), net.minecraft.server.players.PlayerList.SEND_PLAYER_INFO_INTERVAL); // Gale - Purpur - spread out sending all player info this.gameProfile = gameProfile; - this.inventoryMenu = new InventoryMenu(this.inventory, !world.isClientSide, this); + this.inventoryMenu = new InventoryMenu(this.inventory, !level.isClientSide, this); this.containerMenu = this.inventoryMenu; diff --git a/patches/server/0088-Optimize-player-list-for-sending-player-info.patch b/gale-server/minecraft-patches/features/0075-Optimize-player-list-for-sending-player-info.patch similarity index 69% rename from patches/server/0088-Optimize-player-list-for-sending-player-info.patch rename to gale-server/minecraft-patches/features/0075-Optimize-player-list-for-sending-player-info.patch index 198ea8f..d67778c 100644 --- a/patches/server/0088-Optimize-player-list-for-sending-player-info.patch +++ b/gale-server/minecraft-patches/features/0075-Optimize-player-list-for-sending-player-info.patch @@ -36,32 +36,29 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index 843f09312888ab91ddd50fa2870ba4dc2236d54a..75a293b2b27231894fe996a42ff10a1462d640f3 100644 ---- a/src/main/java/net/minecraft/server/players/PlayerList.java -+++ b/src/main/java/net/minecraft/server/players/PlayerList.java -@@ -991,14 +991,18 @@ public abstract class PlayerList { +diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java +index af0f608e05262cbb118d92786bcdba9ae834a809..70f3dea61eca3639a4e0cc6a45c1d35fbc4e3e5a 100644 +--- a/net/minecraft/server/players/PlayerList.java ++++ b/net/minecraft/server/players/PlayerList.java +@@ -898,10 +898,19 @@ public abstract class PlayerList { // Gale start - Purpur - spread out sending all player info ServerPlayer[] sendAllPlayerInfoBucket = this.sendAllPlayerInfoBuckets[this.sendAllPlayerInfoIn]; if (sendAllPlayerInfoBucket != null) { - for (ServerPlayer target : sendAllPlayerInfoBucket) { -+ // Gale start - Purpur - optimize player list for sending player info -+ for (ServerPlayer targetPlayer : sendAllPlayerInfoBucket) { ++ for (ServerPlayer targetPlayer : sendAllPlayerInfoBucket) { // Gale - Purpur - optimize player list for sending player info // Gale end - Purpur - spread out sending all player info -- target.connection.send(new ClientboundPlayerInfoUpdatePacket(EnumSet.of(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_LATENCY), this.players.stream().filter(new Predicate() { -- @Override -- public boolean test(ServerPlayer input) { -- return target.getBukkitEntity().canSee(input.getBukkitEntity()); -+ var target = targetPlayer.getBukkitEntity();; ++ // Gale start - Purpur - optimize player list for sending player info ++ var target = targetPlayer.getBukkitEntity(); + final List list = new java.util.ArrayList<>(this.players.size()); + for (ServerPlayer player : this.players) { + if (target.canSeePlayer(player.getUUID())) { + list.add(player); - } -- }).collect(Collectors.toList()))); ++ } + } -+ target.getHandle().connection.send(new ClientboundPlayerInfoUpdatePacket(EnumSet.of(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_LATENCY), list)); + +- target.connection.send(new ClientboundPlayerInfoUpdatePacket(EnumSet.of(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_LATENCY), com.google.common.collect.Collections2.filter(this.players, t -> target.getBukkitEntity().canSee(t.getBukkitEntity())))); ++ targetPlayer.connection.send(new ClientboundPlayerInfoUpdatePacket(EnumSet.of(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_LATENCY), list)); + // Gale end - Purpur - optimize player list for sending player info - // Gale start - Purpur - spread out sending all player info } + // Gale start - Purpur - spread out sending all player info } diff --git a/patches/server/0089-Skip-PlayerCommandSendEvent-if-there-are-no-listener.patch b/gale-server/minecraft-patches/features/0076-Skip-PlayerCommandSendEvent-if-there-are-no-listener.patch similarity index 69% rename from patches/server/0089-Skip-PlayerCommandSendEvent-if-there-are-no-listener.patch rename to gale-server/minecraft-patches/features/0076-Skip-PlayerCommandSendEvent-if-there-are-no-listener.patch index 4200fd9..fd26249 100644 --- a/patches/server/0089-Skip-PlayerCommandSendEvent-if-there-are-no-listener.patch +++ b/gale-server/minecraft-patches/features/0076-Skip-PlayerCommandSendEvent-if-there-are-no-listener.patch @@ -36,23 +36,23 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java -index f584215a19cff134866ea6eb3015eacf4208a285..8f0162ffa1461e7444b51917001d8a27ca1f3dae 100644 ---- a/src/main/java/net/minecraft/commands/Commands.java -+++ b/src/main/java/net/minecraft/commands/Commands.java -@@ -507,6 +507,7 @@ public class Commands { - private void runSync(ServerPlayer player, Collection bukkit, RootCommandNode rootcommandnode) { +diff --git a/net/minecraft/commands/Commands.java b/net/minecraft/commands/Commands.java +index 22d5c733df234e8fac286809bfb724859a600963..f8677b15e7db4eae32c8604077c20ff693c4b744 100644 +--- a/net/minecraft/commands/Commands.java ++++ b/net/minecraft/commands/Commands.java +@@ -482,6 +482,7 @@ public class Commands { + private void runSync(ServerPlayer player, java.util.Collection bukkit, RootCommandNode rootCommandNode) { // Paper end - Perf: Async command map building - new com.destroystokyo.paper.event.brigadier.AsyncPlayerSendCommandsEvent(player.getBukkitEntity(), (RootCommandNode) rootcommandnode, true).callEvent(); // Paper - Brigadier API -+ if (PlayerCommandSendEvent.getHandlerList().getRegisteredListeners().length > 0) { // Gale - Purpur - skip PlayerCommandSendEvent if there are no listeners - PlayerCommandSendEvent event = new PlayerCommandSendEvent(player.getBukkitEntity(), new LinkedHashSet<>(bukkit)); + new com.destroystokyo.paper.event.brigadier.AsyncPlayerSendCommandsEvent(player.getBukkitEntity(), (RootCommandNode) rootCommandNode, true).callEvent(); // Paper - Brigadier API ++ if (org.bukkit.event.player.PlayerCommandSendEvent.getHandlerList().getRegisteredListeners().length > 0) { // Gale - Purpur - skip PlayerCommandSendEvent if there are no listeners + org.bukkit.event.player.PlayerCommandSendEvent event = new org.bukkit.event.player.PlayerCommandSendEvent(player.getBukkitEntity(), new java.util.LinkedHashSet<>(bukkit)); event.getPlayer().getServer().getPluginManager().callEvent(event); -@@ -517,6 +518,7 @@ public class Commands { +@@ -492,6 +493,7 @@ public class Commands { } } // CraftBukkit end + } // Gale - Purpur - skip PlayerCommandSendEvent if there are no listeners - player.connection.send(new ClientboundCommandsPacket(rootcommandnode)); - } + player.connection.send(new ClientboundCommandsPacket(rootCommandNode)); + } diff --git a/patches/server/0090-Send-multiple-keep-alive-packets.patch b/gale-server/minecraft-patches/features/0077-Send-multiple-keep-alive-packets.patch similarity index 57% rename from patches/server/0090-Send-multiple-keep-alive-packets.patch rename to gale-server/minecraft-patches/features/0077-Send-multiple-keep-alive-packets.patch index 53c3aa8..a8564c7 100644 --- a/patches/server/0090-Send-multiple-keep-alive-packets.patch +++ b/gale-server/minecraft-patches/features/0077-Send-multiple-keep-alive-packets.patch @@ -36,30 +36,34 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -diff --git a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java -index d777e5914148103dbdbfef7c8e4f8e012fa58b6d..92815589da3c2a1cb768ac8081660c9c2ccb2b14 100644 ---- a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java -+++ b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java -@@ -79,10 +79,14 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack +diff --git a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java +index 2b059bff0d24b52b106a0af4b7e79818f385596e..ea34bb4913e7357f5b76a64443f7e744abdf7b5e 100644 +--- a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java ++++ b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java +@@ -40,6 +40,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack private long keepAliveChallenge; private long closedListenerTime; private boolean closed = false; + private it.unimi.dsi.fastutil.longs.LongList keepAlives = new it.unimi.dsi.fastutil.longs.LongArrayList(); // Gale - Purpur - send multiple keep-alive packets private int latency; private volatile boolean suspendFlushingOnServerThread = false; + // CraftBukkit start +@@ -48,7 +49,10 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack + public boolean processedDisconnect; + // CraftBukkit end public final java.util.Map packCallbacks = new java.util.concurrent.ConcurrentHashMap<>(); // Paper - adventure resource pack callbacks - private static final long KEEPALIVE_LIMIT = Long.getLong("paper.playerconnection.keepalive", 30) * 1000; // Paper - provide property to set keepalive limit + // Gale start - Purpur - send multiple keep-alive packets + private static final long KEEPALIVE_LIMIT_IN_SECONDS = Long.getLong("paper.playerconnection.keepalive", 30); // Paper - provide property to set keepalive limit + private static final long KEEPALIVE_LIMIT = KEEPALIVE_LIMIT_IN_SECONDS * 1000; + // Gale end - Purpur - send multiple keep-alive packets - protected static final ResourceLocation MINECRAFT_BRAND = ResourceLocation.withDefaultNamespace("brand"); // Paper - Brand support + protected static final net.minecraft.resources.ResourceLocation MINECRAFT_BRAND = net.minecraft.resources.ResourceLocation.withDefaultNamespace("brand"); // Paper - Brand support + + public ServerCommonPacketListenerImpl(MinecraftServer server, Connection connection, CommonListenerCookie cookie, net.minecraft.server.level.ServerPlayer player) { // CraftBukkit +@@ -117,6 +121,16 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack - public ServerCommonPacketListenerImpl(MinecraftServer minecraftserver, Connection networkmanager, CommonListenerCookie commonlistenercookie, ServerPlayer player) { // CraftBukkit -@@ -136,6 +140,16 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack @Override public void handleKeepAlive(ServerboundKeepAlivePacket packet) { - //PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); // CraftBukkit // Paper - handle ServerboundKeepAlivePacket async + // Gale start - Purpur - send multiple keep-alive packets + if (org.galemc.gale.configuration.GaleGlobalConfiguration.get().misc.keepalive.sendMultiple) { + if (this.keepAlivePending && !keepAlives.isEmpty() && keepAlives.contains(packet.getId())) { @@ -71,60 +75,43 @@ index d777e5914148103dbdbfef7c8e4f8e012fa58b6d..92815589da3c2a1cb768ac8081660c9c + } else { + // Gale end - Purpur - send multiple keep-alive packets if (this.keepAlivePending && packet.getId() == this.keepAliveChallenge) { - int i = (int) (Util.getMillis() - this.keepAliveTime); - -@@ -144,6 +158,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack + int i = (int)(Util.getMillis() - this.keepAliveTime); + this.latency = (this.latency * 3 + i) / 4; +@@ -124,6 +138,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack } else if (!this.isSingleplayerOwner()) { - this.disconnectAsync(ServerCommonPacketListenerImpl.TIMEOUT_DISCONNECTION_MESSAGE, PlayerKickEvent.Cause.TIMEOUT); // Paper - add proper async disconnect + this.disconnectAsync(TIMEOUT_DISCONNECTION_MESSAGE, org.bukkit.event.player.PlayerKickEvent.Cause.TIMEOUT); // Paper - add proper async disconnect } + } // Gale - Purpur - send multiple keep-alive packets - } -@@ -259,6 +274,21 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack - long currentTime = Util.getMillis(); - long elapsedTime = currentTime - this.keepAliveTime; - + @Override +@@ -236,6 +251,21 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack + // Paper start - give clients a longer time to respond to pings as per pre 1.12.2 timings + // This should effectively place the keepalive handling back to "as it was" before 1.12.2 + final long elapsedTime = millis - this.keepAliveTime; + // Gale start - Purpur - send multiple keep-alive packets + if (org.galemc.gale.configuration.GaleGlobalConfiguration.get().misc.keepalive.sendMultiple) { + if (elapsedTime >= 1000L) { // 1 second + if (this.keepAlivePending && !this.processedDisconnect && this.keepAlives.size() >= KEEPALIVE_LIMIT_IN_SECONDS) { + LOGGER.warn("{} was kicked due to keepalive timeout!", this.player.getScoreboardName()); -+ this.disconnect(ServerCommonPacketListenerImpl.TIMEOUT_DISCONNECTION_MESSAGE, org.bukkit.event.player.PlayerKickEvent.Cause.TIMEOUT); -+ } else if (this.checkIfClosed(currentTime)) { ++ this.disconnect(TIMEOUT_DISCONNECTION_MESSAGE, org.bukkit.event.player.PlayerKickEvent.Cause.TIMEOUT); ++ } else if (this.checkIfClosed(millis)) { + this.keepAlivePending = true; -+ this.keepAliveTime = currentTime; // hijack this field for 1 second intervals -+ this.keepAlives.add(currentTime); // currentTime is ID -+ this.send(new ClientboundKeepAlivePacket(currentTime)); ++ this.keepAliveTime = millis; // hijack this field for 1 second intervals ++ this.keepAlives.add(millis); // millis is ID ++ this.send(new ClientboundKeepAlivePacket(millis)); + } + } + } else { + // Gale end - Purpur - send multiple keep-alive packets - if (!this.isSingleplayerOwner() && elapsedTime >= 15000L) { // Paper - use vanilla's 15000L between keep alive packets - if (this.keepAlivePending && !this.processedDisconnect && elapsedTime >= KEEPALIVE_LIMIT) { // Paper - check keepalive limit, don't fire if already disconnected - this.disconnect(ServerCommonPacketListenerImpl.TIMEOUT_DISCONNECTION_MESSAGE, PlayerKickEvent.Cause.TIMEOUT); // Paper - kick event cause -@@ -269,6 +299,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack + if (!this.isSingleplayerOwner() && elapsedTime >= 15000L) { // use vanilla's 15000L between keep alive packets + if (this.keepAlivePending) { + if (!this.processedDisconnect && elapsedTime >= KEEPALIVE_LIMIT) { // check keepalive limit, don't fire if already disconnected +@@ -249,6 +279,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack this.send(new ClientboundKeepAlivePacket(this.keepAliveChallenge)); } } + } // Gale - Purpur - send multiple keep-alive packets - // Paper end - give clients a longer time to respond to pings as per pre 1.12.2 timings } -diff --git a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -index b0da100cf972d4e39b130c99550ebcc763f055ee..b2ee56fa4be361e9151389787313594493dd7a2e 100644 ---- a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -+++ b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -@@ -52,6 +52,12 @@ public class GaleGlobalConfiguration extends ConfigurationPart { - public class Misc extends ConfigurationPart { - - public boolean verifyChatOrder = true; // Gale - Pufferfish - make chat order verification configurable -+ -+ public Keepalive keepalive; -+ public class Keepalive extends ConfigurationPart { -+ public boolean sendMultiple = true; // Gale - Purpur - send multiple keep-alive packets -+ } -+ - } - - public LogToConsole logToConsole; + private boolean checkIfClosed(long time) { diff --git a/gale-server/minecraft-patches/features/0078-Make-slow-login-timeout-configurable.patch b/gale-server/minecraft-patches/features/0078-Make-slow-login-timeout-configurable.patch new file mode 100644 index 0000000..39cdd4f --- /dev/null +++ b/gale-server/minecraft-patches/features/0078-Make-slow-login-timeout-configurable.patch @@ -0,0 +1,24 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Sat, 24 Dec 2022 22:50:13 +0100 +Subject: [PATCH] Make slow login timeout configurable + +License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) +Gale - https://galemc.org + +diff --git a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +index d9c0831dd58a5cdf1b23444489ac04629f8916f9..c3c85970a5d4bf85fa138a90a33a69f0336334a8 100644 +--- a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java ++++ b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +@@ -127,7 +127,10 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, + this.finishLoginAndWaitForClient(this.authenticatedProfile); + } + +- if (this.tick++ == 600) { ++ // Gale start - make slow login timeout configurable ++ int slowLoginTimeout = org.galemc.gale.configuration.GaleGlobalConfiguration.get().misc.premiumAccountSlowLoginTimeout; ++ if (this.tick++ >= (slowLoginTimeout < 1 ? MAX_TICKS_BEFORE_LOGIN : slowLoginTimeout)) { ++ // Gale end - make slow login timeout configurable + this.disconnect(Component.translatable("multiplayer.disconnect.slow_login")); + } + } diff --git a/gale-server/minecraft-patches/features/0079-Don-t-load-chunks-to-spawn-phantoms.patch b/gale-server/minecraft-patches/features/0079-Don-t-load-chunks-to-spawn-phantoms.patch new file mode 100644 index 0000000..bdabf44 --- /dev/null +++ b/gale-server/minecraft-patches/features/0079-Don-t-load-chunks-to-spawn-phantoms.patch @@ -0,0 +1,35 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Sun, 25 Dec 2022 19:31:09 +0100 +Subject: [PATCH] Don't load chunks to spawn phantoms + +License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) +Gale - https://galemc.org + +This patch is based on the following patch: +"Don't load chunks when spawning phantoms" +By: PureGero +As part of: MultiPaper (https://github.com/MultiPaper/MultiPaper) +Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) + +diff --git a/net/minecraft/world/level/levelgen/PhantomSpawner.java b/net/minecraft/world/level/levelgen/PhantomSpawner.java +index 11d25e64349b27bf54dc1620e4cce444c79f581c..c792483860d31ce663e7de34e9f79ff46de75b8c 100644 +--- a/net/minecraft/world/level/levelgen/PhantomSpawner.java ++++ b/net/minecraft/world/level/levelgen/PhantomSpawner.java +@@ -61,7 +61,15 @@ public class PhantomSpawner implements CustomSpawner { + BlockPos blockPos1 = blockPos.above(20 + randomSource.nextInt(15)) + .east(-10 + randomSource.nextInt(21)) + .south(-10 + randomSource.nextInt(21)); +- BlockState blockState = level.getBlockState(blockPos1); ++ // Gale start - MultiPaper - don't load chunks to spawn phantoms ++ BlockState blockState; ++ if (level.galeConfig().smallOptimizations.loadChunks.toSpawnPhantoms) { ++ blockState = level.getBlockState(blockPos1); ++ } else { ++ blockState = level.getBlockStateIfLoaded(blockPos1); ++ if (blockState == null) continue; ++ } ++ // Gale end - MultiPaper - don't load chunks to spawn phantoms + FluidState fluidState = level.getFluidState(blockPos1); + if (NaturalSpawner.isValidEmptySpawnBlock(level, blockPos1, blockState, fluidState, EntityType.PHANTOM)) { + SpawnGroupData spawnGroupData = null; diff --git a/patches/server/0093-Don-t-load-chunks-to-activate-climbing-entities.patch b/gale-server/minecraft-patches/features/0080-Don-t-load-chunks-to-activate-climbing-entities.patch similarity index 54% rename from patches/server/0093-Don-t-load-chunks-to-activate-climbing-entities.patch rename to gale-server/minecraft-patches/features/0080-Don-t-load-chunks-to-activate-climbing-entities.patch index d1d98e7..14878bb 100644 --- a/patches/server/0093-Don-t-load-chunks-to-activate-climbing-entities.patch +++ b/gale-server/minecraft-patches/features/0080-Don-t-load-chunks-to-activate-climbing-entities.patch @@ -6,11 +6,11 @@ Subject: [PATCH] Don't load chunks to activate climbing entities License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) Gale - https://galemc.org -diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index ce11e73e7a91c9d45f62552ab1cd7bec47b2a879..840534b87550d86b1d894ddd0916f9cbcaa688aa 100644 ---- a/src/main/java/net/minecraft/world/entity/Entity.java -+++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -4912,6 +4912,16 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java +index ec303fb52aee7a0bc1df42a628fac24276d059de..411c3829ac99b4a3673419d230e098ff05c272f3 100644 +--- a/net/minecraft/world/entity/Entity.java ++++ b/net/minecraft/world/entity/Entity.java +@@ -4679,6 +4679,16 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess return this.inBlockState; } @@ -27,11 +27,11 @@ index ce11e73e7a91c9d45f62552ab1cd7bec47b2a879..840534b87550d86b1d894ddd0916f9cb public ChunkPos chunkPosition() { return this.chunkPosition; } -diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index 887adb618a6eb158b53a96e57d785583a3ac322f..9551c2b75687bd036aaabd9593df7d96c062ab90 100644 ---- a/src/main/java/net/minecraft/world/entity/LivingEntity.java -+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -2132,19 +2132,43 @@ public abstract class LivingEntity extends Entity implements Attackable { +diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java +index d341bf76b4679470a7fb5ff081b79425e4bc1264..4e414a78a6acfb90d5e212398617580a3f34be9b 100644 +--- a/net/minecraft/world/entity/LivingEntity.java ++++ b/net/minecraft/world/entity/LivingEntity.java +@@ -2032,19 +2032,43 @@ public abstract class LivingEntity extends Entity implements Attackable { public boolean onClimbableCached() { if (!this.blockPosition().equals(this.lastClimbingPosition)) { @@ -62,31 +62,18 @@ index 887adb618a6eb158b53a96e57d785583a3ac322f..9551c2b75687bd036aaabd9593df7d96 if (this.isSpectator()) { return false; } else { - BlockPos blockposition = this.blockPosition(); -- BlockState iblockdata = this.getInBlockState(); + BlockPos blockPos = this.blockPosition(); + BlockState inBlockState = this.getInBlockState(); + // Gale start - don't load chunks to activate climbing entities -+ BlockState iblockdata; + if (loadChunk) { -+ iblockdata = this.getInBlockState(); ++ inBlockState = this.getInBlockState(); + } else { -+ iblockdata = this.getInBlockStateIfLoaded(); -+ if (iblockdata == null) { ++ inBlockState = this.getInBlockStateIfLoaded(); ++ if (inBlockState == null) { + return null; + } + } + // Gale end - don't load chunks to activate climbing entities - - if (iblockdata.is(BlockTags.CLIMBABLE)) { - this.lastClimbablePos = Optional.of(blockposition); -diff --git a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -index 61d6da8509837bfba30a139a84b0bc452ed4046b..e6ffd32986e587f4a8a6f98611ab6c02b96912e2 100644 ---- a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -+++ b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -@@ -95,6 +95,7 @@ public class GaleWorldConfiguration extends ConfigurationPart { - public LoadChunks loadChunks; - public class LoadChunks extends ConfigurationPart { - public boolean toSpawnPhantoms = false; // Gale - MultiPaper - don't load chunks to spawn phantoms -+ public boolean toActivateClimbingEntities = false; // Gale - don't load chunks to activate climbing entities - } - - } + if (inBlockState.is(BlockTags.CLIMBABLE)) { + this.lastClimbablePos = Optional.of(blockPos); + return true; diff --git a/gale-server/minecraft-patches/features/0081-Broadcast-crit-animations-as-the-entity-being-critte.patch b/gale-server/minecraft-patches/features/0081-Broadcast-crit-animations-as-the-entity-being-critte.patch new file mode 100644 index 0000000..97cd28b --- /dev/null +++ b/gale-server/minecraft-patches/features/0081-Broadcast-crit-animations-as-the-entity-being-critte.patch @@ -0,0 +1,39 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Sun, 25 Dec 2022 23:33:28 +0100 +Subject: [PATCH] Broadcast crit animations as the entity being critted + +License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) +Gale - https://galemc.org + +This patch is based on the following patch: +"Send crit animations as the entity being critted" +By: PureGero +As part of: MultiPaper (https://github.com/MultiPaper/MultiPaper) +Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) + +diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java +index 9c2f9bc5e5bef96fb7ad0f04aa1cb72db9d10638..e676e2082700a2bdc2a93b0a356e4f6b1000776e 100644 +--- a/net/minecraft/server/level/ServerPlayer.java ++++ b/net/minecraft/server/level/ServerPlayer.java +@@ -2150,12 +2150,18 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc + + @Override + public void crit(Entity entityHit) { +- this.serverLevel().getChunkSource().broadcastAndSend(this, new ClientboundAnimatePacket(entityHit, 4)); ++ // Gale start - MultiPaper - broadcast crit animations as the entity being critted ++ var level = this.serverLevel(); ++ level.getChunkSource().broadcastAndSend(level.galeConfig().gameplayMechanics.fixes.broadcastCritAnimationsAsTheEntityBeingCritted ? entityHit : this, new ClientboundAnimatePacket(entityHit, 4)); ++ // Gale end - MultiPaper - broadcast crit animations as the entity being critted + } + + @Override + public void magicCrit(Entity entityHit) { +- this.serverLevel().getChunkSource().broadcastAndSend(this, new ClientboundAnimatePacket(entityHit, 5)); ++ // Gale start - MultiPaper - broadcast crit animations as the entity being critted ++ var level = this.serverLevel(); ++ level.getChunkSource().broadcastAndSend(level.galeConfig().gameplayMechanics.fixes.broadcastCritAnimationsAsTheEntityBeingCritted ? entityHit : this, new ClientboundAnimatePacket(entityHit, 5)); ++ // Gale end - MultiPaper - broadcast crit animations as the entity being critted + } + + @Override diff --git a/gale-server/minecraft-patches/features/0082-Ignore-null-legacy-structure-data.patch b/gale-server/minecraft-patches/features/0082-Ignore-null-legacy-structure-data.patch new file mode 100644 index 0000000..b2f5676 --- /dev/null +++ b/gale-server/minecraft-patches/features/0082-Ignore-null-legacy-structure-data.patch @@ -0,0 +1,38 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Sun, 25 Dec 2022 23:39:05 +0100 +Subject: [PATCH] Ignore null legacy structure data + +License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) +Gale - https://galemc.org + +This patch is based on the following patch: +"Add null check in LegacyStructureDataHandler" +By: PureGero +As part of: MultiPaper (https://github.com/MultiPaper/MultiPaper) +Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) + +diff --git a/net/minecraft/world/level/levelgen/structure/LegacyStructureDataHandler.java b/net/minecraft/world/level/levelgen/structure/LegacyStructureDataHandler.java +index 28872f70ac27aacc8848cf5659cfd2c55e4cd19a..1f15e0f5e091117e2d7bd9c96e6b67b08fe25224 100644 +--- a/net/minecraft/world/level/levelgen/structure/LegacyStructureDataHandler.java ++++ b/net/minecraft/world/level/levelgen/structure/LegacyStructureDataHandler.java +@@ -171,13 +171,18 @@ public class LegacyStructureDataHandler { + + private void populateCaches(@Nullable DimensionDataStorage storage) { + if (storage != null) { ++ boolean ignoreNullLegacyStructureData = org.galemc.gale.configuration.GaleGlobalConfiguration.get().misc.ignoreNullLegacyStructureData; // Gale - MultiPaper - ignore null legacy structure data + for (String string : this.legacyKeys) { + CompoundTag compoundTag = new CompoundTag(); + + try { +- compoundTag = storage.readTagFromDisk(string, DataFixTypes.SAVED_DATA_STRUCTURE_FEATURE_INDICES, 1493) ++ // Gale start - MultiPaper - ignore null legacy structure data ++ CompoundTag tag = storage.readTagFromDisk(string, DataFixTypes.SAVED_DATA_STRUCTURE_FEATURE_INDICES, 1493); ++ if (ignoreNullLegacyStructureData && tag == null) continue; ++ compoundTag = tag + .getCompound("data") + .getCompound("Features"); ++ // Gale end - MultiPaper - ignore null legacy structure data + if (compoundTag.isEmpty()) { + continue; + } diff --git a/patches/server/0096-Skip-unnecessary-mob-spawning-computations.patch b/gale-server/minecraft-patches/features/0083-Skip-unnecessary-mob-spawning-computations.patch similarity index 59% rename from patches/server/0096-Skip-unnecessary-mob-spawning-computations.patch rename to gale-server/minecraft-patches/features/0083-Skip-unnecessary-mob-spawning-computations.patch index 3f9e819..3658f04 100644 --- a/patches/server/0096-Skip-unnecessary-mob-spawning-computations.patch +++ b/gale-server/minecraft-patches/features/0083-Skip-unnecessary-mob-spawning-computations.patch @@ -12,51 +12,49 @@ By: PureGero As part of: MultiPaper (https://github.com/MultiPaper/MultiPaper) Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) -diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index f6ed3936ebfe60e88160e1ca55589584354456bb..d6cfff8574567d0e3a77871c91be988ecfe31e25 100644 ---- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java -+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -@@ -527,10 +527,15 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon +diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java +index 5c8d76b80c6cefd87088282e59f5f0f72a4f1611..b6127fff62c49809cfa54e39a35c89f45f46c66c 100644 +--- a/net/minecraft/server/level/ServerChunkCache.java ++++ b/net/minecraft/server/level/ServerChunkCache.java +@@ -550,9 +550,14 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon } - private void tickChunks(long timeDelta, List chunks) { // Gale - Purpur - remove vanilla profiler + private void tickChunks(long timeInhabited, List chunks) { // Gale - Purpur - remove vanilla profiler + // Gale start - MultiPaper - skip unnecessary mob spawning computations -+ NaturalSpawner.SpawnState spawnercreature_d; // moved down -+ final boolean flag = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !this.level.players().isEmpty(); // CraftBukkit -+ boolean flagAndHasNaturalSpawn = flag && this.anySpawnCategoryIsSpawnedThisTick(); ++ NaturalSpawner.SpawnState spawnState; // moved down ++ final boolean _boolean = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !this.level.players().isEmpty(); // CraftBukkit ++ boolean flagAndHasNaturalSpawn = _boolean && this.anySpawnCategoryIsSpawnedThisTick(); + if (flagAndHasNaturalSpawn) { + // Gale end - MultiPaper - skip unnecessary mob spawning computations - int j = this.distanceManager.getNaturalSpawnChunkCount(); + int naturalSpawnChunkCount = this.distanceManager.getNaturalSpawnChunkCount(); // Paper start - Optional per player mob spawns - final int naturalSpawnChunkCount = j; -- NaturalSpawner.SpawnState spawnercreature_d; // moved down +- NaturalSpawner.SpawnState spawnState; if ((this.spawnFriendlies || this.spawnEnemies) && this.level.paperConfig().entities.spawning.perPlayerMobSpawns) { // don't count mobs when animals and monsters are disabled // re-set mob counts for (ServerPlayer player : this.level.players) { -@@ -553,11 +558,15 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon +@@ -574,10 +579,14 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon + } // Paper end - Optional per player mob spawns - - this.lastSpawnState = spawnercreature_d; -- boolean flag = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !this.level.players().isEmpty(); // CraftBukkit + this.lastSpawnState = spawnState; +- boolean _boolean = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !this.level.players().isEmpty(); // CraftBukkit + // Gale start - MultiPaper - skip unnecessary mob spawning computations + } else { -+ spawnercreature_d = null; ++ spawnState = null; + } + // Gale end - MultiPaper - skip unnecessary mob spawning computations - int k = this.level.getGameRules().getInt(GameRules.RULE_RANDOMTICKING); - List list1; - -- if (flag && (this.spawnEnemies || this.spawnFriendlies)) { + int _int = this.level.getGameRules().getInt(GameRules.RULE_RANDOMTICKING); + List filteredSpawningCategories; +- if (_boolean && (this.spawnEnemies || this.spawnFriendlies)) { + if (flagAndHasNaturalSpawn && (this.spawnEnemies || this.spawnFriendlies)) { // Gale - MultiPaper - skip unnecessary mob spawning computations // Paper start - PlayerNaturallySpawnCreaturesEvent for (ServerPlayer entityPlayer : this.level.players()) { int chunkRange = Math.min(level.spigotConfig.mobSpawnRange, entityPlayer.getBukkitEntity().getViewDistance()); -@@ -595,6 +604,20 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon - +@@ -609,6 +618,20 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon + } } + // Gale start - MultiPaper - skip unnecessary mob spawning computations -+ public boolean anySpawnCategoryIsSpawnedThisTick() { ++ private boolean anySpawnCategoryIsSpawnedThisTick() { + long gameTime = this.level.getLevelData().getGameTime(); + + for (long ticksForSpawnCategory : this.level.ticksPerSpawnCategory.values()) { @@ -69,6 +67,6 @@ index f6ed3936ebfe60e88160e1ca55589584354456bb..d6cfff8574567d0e3a77871c91be988e + } + // Gale end - MultiPaper - skip unnecessary mob spawning computations + - private void getFullChunk(long pos, Consumer chunkConsumer) { + private void getFullChunk(long chunkPos, Consumer fullChunkGetter) { // Paper start - rewrite chunk system // note: bypass currentlyLoaded from getChunkNow diff --git a/gale-server/minecraft-patches/features/0084-Prevent-entities-random-strolling-into-non-ticking-c.patch b/gale-server/minecraft-patches/features/0084-Prevent-entities-random-strolling-into-non-ticking-c.patch new file mode 100644 index 0000000..77c6146 --- /dev/null +++ b/gale-server/minecraft-patches/features/0084-Prevent-entities-random-strolling-into-non-ticking-c.patch @@ -0,0 +1,27 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Wed, 30 Nov 2022 20:38:15 +0100 +Subject: [PATCH] Prevent entities random strolling into non-ticking chunks + +License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) +Gale - https://galemc.org + +This patch is based on the following patch: +"Don't wander into non-ticking chunks" +By: PureGero +As part of: MultiPaper (https://github.com/MultiPaper/MultiPaper) +Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) + +diff --git a/net/minecraft/world/entity/ai/goal/RandomStrollGoal.java b/net/minecraft/world/entity/ai/goal/RandomStrollGoal.java +index bad57b0017c78d4d1d32c239fae5bc2ea20bc3c3..28f770d40f5ada6d547e91cd3147969702e1ae75 100644 +--- a/net/minecraft/world/entity/ai/goal/RandomStrollGoal.java ++++ b/net/minecraft/world/entity/ai/goal/RandomStrollGoal.java +@@ -49,7 +49,7 @@ public class RandomStrollGoal extends Goal { + } + + Vec3 position = this.getPosition(); +- if (position == null) { ++ if (position == null || (!this.mob.level().galeConfig().gameplayMechanics.entitiesCanRandomStrollIntoNonTickingChunks && !((net.minecraft.server.level.ServerLevel) this.mob.level()).isPositionEntityTicking(net.minecraft.core.BlockPos.containing(position)))) { // Gale - MultiPaper - prevent entities random strolling into non-ticking chunks + return false; + } else { + this.wantedX = position.x; diff --git a/patches/server/0098-Do-not-place-player-in-world-if-kicked-before-being-.patch b/gale-server/minecraft-patches/features/0085-Do-not-place-player-in-world-if-kicked-before-being-.patch similarity index 71% rename from patches/server/0098-Do-not-place-player-in-world-if-kicked-before-being-.patch rename to gale-server/minecraft-patches/features/0085-Do-not-place-player-in-world-if-kicked-before-being-.patch index db6f09d..44916f9 100644 --- a/patches/server/0098-Do-not-place-player-in-world-if-kicked-before-being-.patch +++ b/gale-server/minecraft-patches/features/0085-Do-not-place-player-in-world-if-kicked-before-being-.patch @@ -13,11 +13,11 @@ By: PureGero As part of: MultiPaper (https://github.com/MultiPaper/MultiPaper) Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) -diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index 75a293b2b27231894fe996a42ff10a1462d640f3..99521abc925e0c7754d9e5aaad52e4fa70383946 100644 ---- a/src/main/java/net/minecraft/server/players/PlayerList.java -+++ b/src/main/java/net/minecraft/server/players/PlayerList.java -@@ -272,6 +272,13 @@ public abstract class PlayerList { +diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java +index 70f3dea61eca3639a4e0cc6a45c1d35fbc4e3e5a..61d7d50d2a2e566d2f955b22c95908c6e4ef5274 100644 +--- a/net/minecraft/server/players/PlayerList.java ++++ b/net/minecraft/server/players/PlayerList.java +@@ -234,6 +234,13 @@ public abstract class PlayerList { org.spigotmc.event.player.PlayerSpawnLocationEvent ev = new org.spigotmc.event.player.PlayerSpawnLocationEvent(spawnPlayer, spawnPlayer.getLocation()); this.cserver.getPluginManager().callEvent(ev); @@ -28,6 +28,6 @@ index 75a293b2b27231894fe996a42ff10a1462d640f3..99521abc925e0c7754d9e5aaad52e4fa + } + // Gale end - MultiPaper - do not place player in world if kicked before being spawned in + - Location loc = ev.getSpawnLocation(); - worldserver1 = ((CraftWorld) loc.getWorld()).getHandle(); + org.bukkit.Location loc = ev.getSpawnLocation(); + serverLevel = ((org.bukkit.craftbukkit.CraftWorld) loc.getWorld()).getHandle(); diff --git a/patches/server/0100-Global-EULA-file.patch b/gale-server/minecraft-patches/features/0086-Global-EULA-file.patch similarity index 80% rename from patches/server/0100-Global-EULA-file.patch rename to gale-server/minecraft-patches/features/0086-Global-EULA-file.patch index 05db88f..1e7eba4 100644 --- a/patches/server/0100-Global-EULA-file.patch +++ b/gale-server/minecraft-patches/features/0086-Global-EULA-file.patch @@ -22,14 +22,14 @@ The above copyright notice and this permission notice shall be included in all c THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -diff --git a/src/main/java/net/minecraft/server/Eula.java b/src/main/java/net/minecraft/server/Eula.java -index 4f12ee62a381f87419c72f12a7c155a7b403d207..f8d6f9b165929961d23bc18a6044973405c1d633 100644 ---- a/src/main/java/net/minecraft/server/Eula.java -+++ b/src/main/java/net/minecraft/server/Eula.java -@@ -17,13 +17,30 @@ public class Eula { +diff --git a/net/minecraft/server/Eula.java b/net/minecraft/server/Eula.java +index 1f0413214f54e9a47f53c623484d6882c85f54c9..e7db86ad7b0991dcfab101e0a6bb7fb279af3258 100644 +--- a/net/minecraft/server/Eula.java ++++ b/net/minecraft/server/Eula.java +@@ -17,13 +17,29 @@ public class Eula { - public Eula(Path eulaFile) { - this.file = eulaFile; + public Eula(Path file) { + this.file = file; - this.agreed = SharedConstants.IS_RUNNING_IN_IDE || this.readFile(); + this.agreed = SharedConstants.IS_RUNNING_IN_IDE || this.readGlobalFile() || this.readFile(); // Gale - YAPFA - global EULA file } @@ -45,8 +45,7 @@ index 4f12ee62a381f87419c72f12a7c155a7b403d207..f8d6f9b165929961d23bc18a60449734 + if (globalFile.toFile().exists()) { + return readFile(globalFile); + } -+ } catch (Throwable ignored) { -+ } ++ } catch (Throwable ignored) {} + return false; + } + @@ -56,10 +55,10 @@ index 4f12ee62a381f87419c72f12a7c155a7b403d207..f8d6f9b165929961d23bc18a60449734 boolean var3; - try (InputStream inputStream = Files.newInputStream(this.file)) { + try (InputStream inputStream = Files.newInputStream(file)) { // Gale - YAPFA - global EULA file - Properties properties = new Properties(); - properties.load(inputStream); - var3 = Boolean.parseBoolean(properties.getProperty("eula", "false")); -@@ -31,8 +48,10 @@ public class Eula { + Properties map = new Properties(); + map.load(inputStream); + var3 = Boolean.parseBoolean(map.getProperty("eula", "false")); +@@ -31,8 +47,10 @@ public class Eula { return var3; } catch (Exception var6) { diff --git a/gale-server/minecraft-patches/features/0087-5-second-TPS-average.patch b/gale-server/minecraft-patches/features/0087-5-second-TPS-average.patch new file mode 100644 index 0000000..ace4fca --- /dev/null +++ b/gale-server/minecraft-patches/features/0087-5-second-TPS-average.patch @@ -0,0 +1,58 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Wed, 30 Nov 2022 12:42:32 +0100 +Subject: [PATCH] 5 second TPS average + +License: MIT (https://opensource.org/licenses/MIT) +Gale - https://galemc.org + +This patch is based on the following patch: +"Add 5 second tps average in /tps" +By: William Blake Galbreath +As part of: Purpur (https://github.com/PurpurMC/Purpur) +Licensed under: MIT (https://opensource.org/licenses/MIT) + +* Purpur copyright * + +MIT License + +Copyright (c) 2019-2022 PurpurMC + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java +index d69f6146ed653ec28eae67c0142867ac5d0e21ef..fc29bba496670dc19cbec3c441ee093545869e90 100644 +--- a/net/minecraft/server/MinecraftServer.java ++++ b/net/minecraft/server/MinecraftServer.java +@@ -1093,6 +1093,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { - return false; - } : this::haveTime); -+ lastTickProperTime = (System.nanoTime() - tickProperStart) / 1000000L; // Gale - YAPFA - last tick time - // Paper start - rewrite chunk system - final Throwable crash = this.chunkSystemCrash; - if (crash != null) { -@@ -1449,6 +1456,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop false : this::haveTime); ++ lastTickProperTime = (System.nanoTime() - tickProperStart) / 1000000L; // Gale - YAPFA - last tick time + // Paper start - rewrite chunk system + final Throwable crash = this.chunkSystemCrash; + if (crash != null) { +@@ -1353,11 +1360,13 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { -@@ -1456,6 +1464,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop !this.haveTime()); } finally { this.waitingForNextTick = false; + lastTickOversleepTime = (System.nanoTime() - tickOversleepStart) / 1000000L; // Gale - YAPFA - last tick time } - } + diff --git a/patches/server/0106-Increase-time-statistics-in-intervals.patch b/gale-server/minecraft-patches/features/0089-Increase-time-statistics-in-intervals.patch similarity index 65% rename from patches/server/0106-Increase-time-statistics-in-intervals.patch rename to gale-server/minecraft-patches/features/0089-Increase-time-statistics-in-intervals.patch index 341e641..bb085cf 100644 --- a/patches/server/0106-Increase-time-statistics-in-intervals.patch +++ b/gale-server/minecraft-patches/features/0089-Increase-time-statistics-in-intervals.patch @@ -44,29 +44,29 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java -index d6068324f7926741a490ead6277015b0e69517f8..7187652d038a5ea7b3555f5ad6f3671263947375 100644 ---- a/src/main/java/net/minecraft/world/entity/player/Player.java -+++ b/src/main/java/net/minecraft/world/entity/player/Player.java +diff --git a/net/minecraft/world/entity/player/Player.java b/net/minecraft/world/entity/player/Player.java +index 57b11cd0eee3c2661070cc591b4bbef2f50ef009..4a0f9626bb82ea885661b1827c99a4baf3892cf7 100644 +--- a/net/minecraft/world/entity/player/Player.java ++++ b/net/minecraft/world/entity/player/Player.java @@ -156,6 +156,7 @@ public abstract class Player extends LivingEntity { protected static final EntityDataAccessor DATA_PLAYER_MAIN_HAND = SynchedEntityData.defineId(Player.class, EntityDataSerializers.BYTE); protected static final EntityDataAccessor DATA_SHOULDER_LEFT = SynchedEntityData.defineId(Player.class, EntityDataSerializers.COMPOUND_TAG); protected static final EntityDataAccessor DATA_SHOULDER_RIGHT = SynchedEntityData.defineId(Player.class, EntityDataSerializers.COMPOUND_TAG); + public static int increaseTimeStatisticsInterval; // Gale - Hydrinity - increase time statistics in intervals - store as static field for fast access + public static final int CLIENT_LOADED_TIMEOUT_TIME = 60; private long timeEntitySatOnShoulder; final Inventory inventory = new Inventory(this); - protected PlayerEnderChestContainer enderChestInventory = new PlayerEnderChestContainer(this); // CraftBukkit - add "this" to constructor -@@ -297,19 +298,23 @@ public abstract class Player extends LivingEntity { +@@ -307,19 +308,23 @@ public abstract class Player extends LivingEntity { this.moveCloak(); - if (this instanceof ServerPlayer entityplayer) { - this.foodData.tick(entityplayer); + if (this instanceof ServerPlayer serverPlayer) { + this.foodData.tick(serverPlayer); - this.awardStat(Stats.PLAY_TIME); - this.awardStat(Stats.TOTAL_WORLD_TIME); + // Gale start - Hydrinity - increase time statistics in intervals + if (increaseTimeStatisticsInterval == 1 || this.tickCount % increaseTimeStatisticsInterval == 0) { -+ this.awardStat(Stats.PLAY_TIME, increaseTimeStatisticsInterval); -+ this.awardStat(Stats.TOTAL_WORLD_TIME, increaseTimeStatisticsInterval); -+ // Gale end - Hydrinity - increase time statistics in intervals ++ this.awardStat(Stats.PLAY_TIME, increaseTimeStatisticsInterval); ++ this.awardStat(Stats.TOTAL_WORLD_TIME, increaseTimeStatisticsInterval); ++ // Gale end - Hydrinity - increase time statistics in intervals if (this.isAlive()) { - this.awardStat(Stats.TIME_SINCE_DEATH); + this.awardStat(Stats.TIME_SINCE_DEATH, increaseTimeStatisticsInterval); // Gale - Hydrinity - increase time statistics in intervals @@ -85,26 +85,3 @@ index d6068324f7926741a490ead6277015b0e69517f8..7187652d038a5ea7b3555f5ad6f36712 } int i = 29999999; -diff --git a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -index 6f151a15b76827fb0e49c9bbe1d491b5d61516d2..3e5efa90180308cbfaaa063d96ad788985720b8c 100644 ---- a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -+++ b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -@@ -29,7 +29,17 @@ public class GaleGlobalConfiguration extends ConfigurationPart { - public SmallOptimizations smallOptimizations; - public class SmallOptimizations extends ConfigurationPart { - -- public int dummyValue = 0; -+ public ReducedIntervals reducedIntervals; -+ public class ReducedIntervals extends ConfigurationPart { -+ -+ public int increaseTimeStatistics = 20; // Gale - Hydrinity - increase time statistics in intervals -+ -+ @PostProcess -+ public void postProcess() { -+ net.minecraft.world.entity.player.Player.increaseTimeStatisticsInterval = Math.max(1, increaseTimeStatistics); // Gale - Hydrinity - increase time statistics in intervals - store as static field for fast access -+ } -+ -+ } - - // Gale start - Pufferfish - SIMD support - public Simd simd; diff --git a/patches/server/0107-For-collision-check-has-physics-before-same-vehicle.patch b/gale-server/minecraft-patches/features/0090-For-collision-check-has-physics-before-same-vehicle.patch similarity index 71% rename from patches/server/0107-For-collision-check-has-physics-before-same-vehicle.patch rename to gale-server/minecraft-patches/features/0090-For-collision-check-has-physics-before-same-vehicle.patch index a43d0c8..61cb2f2 100644 --- a/patches/server/0107-For-collision-check-has-physics-before-same-vehicle.patch +++ b/gale-server/minecraft-patches/features/0090-For-collision-check-has-physics-before-same-vehicle.patch @@ -15,17 +15,17 @@ By: ㄗㄠˋ ㄑㄧˊ As part of: Akarin (https://github.com/Akarin-project/Akarin) Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) -diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 840534b87550d86b1d894ddd0916f9cbcaa688aa..6bdcf5866b4ae4165b86268e2c4570e5abfaa26f 100644 ---- a/src/main/java/net/minecraft/world/entity/Entity.java -+++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -2290,8 +2290,8 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess - public void playerTouch(Player player) {} +diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java +index 411c3829ac99b4a3673419d230e098ff05c272f3..e0af617664641e27ffdee24309e340ede4cc6f73 100644 +--- a/net/minecraft/world/entity/Entity.java ++++ b/net/minecraft/world/entity/Entity.java +@@ -2168,8 +2168,8 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess + } public void push(Entity entity) { + if (!entity.noPhysics && !this.noPhysics) { // Gale - Akarin - collision physics check before vehicle check if (!this.isPassengerOfSameVehicle(entity)) { - if (!entity.noPhysics && !this.noPhysics) { if (this.level.paperConfig().collisions.onlyPlayersCollide && !(entity instanceof ServerPlayer || this instanceof ServerPlayer)) return; // Paper - Collision option for requiring a player participant - double d0 = entity.getX() - this.getX(); + double d = entity.getX() - this.getX(); double d1 = entity.getZ() - this.getZ(); diff --git a/patches/server/0108-Skip-negligible-planar-movement-multiplication.patch b/gale-server/minecraft-patches/features/0091-Skip-negligible-planar-movement-multiplication.patch similarity index 66% rename from patches/server/0108-Skip-negligible-planar-movement-multiplication.patch rename to gale-server/minecraft-patches/features/0091-Skip-negligible-planar-movement-multiplication.patch index 199f2db..a700f08 100644 --- a/patches/server/0108-Skip-negligible-planar-movement-multiplication.patch +++ b/gale-server/minecraft-patches/features/0091-Skip-negligible-planar-movement-multiplication.patch @@ -6,11 +6,11 @@ Subject: [PATCH] Skip negligible planar movement multiplication License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) Gale - https://galemc.org -diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 6bdcf5866b4ae4165b86268e2c4570e5abfaa26f..d9bd4116bd252e6df3b9c717c469cce0fb2e6fde 100644 ---- a/src/main/java/net/minecraft/world/entity/Entity.java -+++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -1286,9 +1286,17 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java +index e0af617664641e27ffdee24309e340ede4cc6f73..5fb13791f44ab27b6835b74f08c47807fb9ab58b 100644 +--- a/net/minecraft/world/entity/Entity.java ++++ b/net/minecraft/world/entity/Entity.java +@@ -1212,8 +1212,17 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess } } @@ -18,12 +18,11 @@ index 6bdcf5866b4ae4165b86268e2c4570e5abfaa26f..d9bd4116bd252e6df3b9c717c469cce0 + Vec3 oldDeltaMovement = this.getDeltaMovement(); + if (oldDeltaMovement.x < -1e-6 || oldDeltaMovement.x > 1e-6 || oldDeltaMovement.z < -1e-6 || oldDeltaMovement.z > 1e-6) { + // Gale end - skip negligible planar movement multiplication - float f = this.getBlockSpeedFactor(); -- -- this.setDeltaMovement(this.getDeltaMovement().multiply((double) f, 1.0D, (double) f)); + float blockSpeedFactor = this.getBlockSpeedFactor(); +- this.setDeltaMovement(this.getDeltaMovement().multiply(blockSpeedFactor, 1.0, blockSpeedFactor)); + // Gale start - skip negligible planar movement multiplication -+ if (f < 1 - 1e-6 || f > 1 + 1e-6) { -+ this.setDeltaMovement(oldDeltaMovement.multiply((double) f, 1.0D, (double) f)); ++ if (blockSpeedFactor < 1 - 1e-6 || blockSpeedFactor > 1 + 1e-6) { ++ this.setDeltaMovement(oldDeltaMovement.multiply(blockSpeedFactor, 1.0, blockSpeedFactor)); + } + } + // Gale end - skip negligible planar movement multiplication diff --git a/gale-server/minecraft-patches/features/0092-Optimize-matching-item-checks.patch b/gale-server/minecraft-patches/features/0092-Optimize-matching-item-checks.patch new file mode 100644 index 0000000..14beb72 --- /dev/null +++ b/gale-server/minecraft-patches/features/0092-Optimize-matching-item-checks.patch @@ -0,0 +1,26 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Sun, 25 Dec 2022 20:51:32 +0100 +Subject: [PATCH] Optimize matching item checks + +License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) +Gale - https://galemc.org + +diff --git a/net/minecraft/world/item/ItemStack.java b/net/minecraft/world/item/ItemStack.java +index badcb066ad66d9d4b17510fb1d633022c19d35d1..fba28a69b531a12a3d05b0c46d0d6efa5c999e6e 100644 +--- a/net/minecraft/world/item/ItemStack.java ++++ b/net/minecraft/world/item/ItemStack.java +@@ -865,11 +865,11 @@ public final class ItemStack implements DataComponentHolder { + } + + public static boolean isSameItem(ItemStack stack, ItemStack other) { +- return stack.is(other.getItem()); ++ return stack == other || stack.is(other.getItem()); // Gale - optimize identical item checks + } + + public static boolean isSameItemSameComponents(ItemStack stack, ItemStack other) { +- return stack.is(other.getItem()) && (stack.isEmpty() && other.isEmpty() || Objects.equals(stack.components, other.components)); ++ return stack == other || stack.is(other.getItem()) && (stack.isEmpty() && other.isEmpty() || Objects.equals(stack.components, other.components)); // Gale - optimize identical item checks + } + + public static MapCodec lenientOptionalFieldOf(String fieldName) { diff --git a/gale-server/minecraft-patches/features/0093-Pre-compute-VarLong-sizes.patch b/gale-server/minecraft-patches/features/0093-Pre-compute-VarLong-sizes.patch new file mode 100644 index 0000000..2acd225 --- /dev/null +++ b/gale-server/minecraft-patches/features/0093-Pre-compute-VarLong-sizes.patch @@ -0,0 +1,45 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Mon, 21 Aug 2023 21:46:10 +0200 +Subject: [PATCH] Pre-compute VarLong sizes + +License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) +Gale - https://galemc.org + +This patch is based on the following commit: +"Reapply "Optimize varint writing"" +By: Andrew Steinborn +As part of: Velocity (https://github.com/PaperMC/Velocity) +Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) + +* Velocity description * + +Inspired by the approach described at the bottom of https://richardstartin.github.io/posts/dont-use-protobuf-for-telemetry + +Given that we do a lot of varint writing as well, this should provide a small performance boost for larger/complex packets whilst not regressing hard on smaller packets. + +This includes a test to ensure that the behavior is as expected and fixes the initialization loop so that the correct results will be given. Much thanks to @octylFractal for acting as my duck while trying to figure this out. + +diff --git a/net/minecraft/network/VarLong.java b/net/minecraft/network/VarLong.java +index df9a85b19a9767c85f02837af6835f7ddb6c7dc3..ff9d84bf761797a8f695926c3cbb12c07609365d 100644 +--- a/net/minecraft/network/VarLong.java ++++ b/net/minecraft/network/VarLong.java +@@ -9,6 +9,18 @@ public class VarLong { + private static final int DATA_BITS_PER_BYTE = 7; + + public static int getByteSize(long data) { ++ // Gale start - Velocity - pre-compute VarInt and VarLong sizes ++ return VARLONG_EXACT_BYTE_LENGTHS[Long.numberOfLeadingZeros(data)]; ++ } ++ private static final int[] VARLONG_EXACT_BYTE_LENGTHS = new int[65]; ++ static { ++ for (int i = 0; i < 64; ++i) { ++ VARLONG_EXACT_BYTE_LENGTHS[i] = (int) Math.ceil((63d - (i - 1)) / 7d); ++ } ++ VARLONG_EXACT_BYTE_LENGTHS[64] = 1; // Special case for the number 0 ++ } ++ static int getByteSizeOld(long data) { // public -> package-private ++ // Gale end - Velocity - pre-compute VarInt and VarLong sizes + for (int i = 1; i < 10; i++) { + if ((data & -1L << i * 7) == 0L) { + return i; diff --git a/gale-server/minecraft-patches/features/0094-Optimize-VarInt-write-and-VarLong-write.patch b/gale-server/minecraft-patches/features/0094-Optimize-VarInt-write-and-VarLong-write.patch new file mode 100644 index 0000000..ca4c285 --- /dev/null +++ b/gale-server/minecraft-patches/features/0094-Optimize-VarInt-write-and-VarLong-write.patch @@ -0,0 +1,214 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Tue, 22 Aug 2023 21:38:37 +0200 +Subject: [PATCH] Optimize VarInt#write and VarLong#write + +License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) +Gale - https://galemc.org + +This patch is based on the following commit: +"Reapply "Optimize varint writing"" +By: Andrew Steinborn +As part of: Velocity (https://github.com/PaperMC/Velocity) +Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) + +* Velocity description * + +Inspired by the approach described at the bottom of https://richardstartin.github.io/posts/dont-use-protobuf-for-telemetry + +Given that we do a lot of varint writing as well, this should provide a small performance boost for larger/complex packets whilst not regressing hard on smaller packets. + +This includes a test to ensure that the behavior is as expected and fixes the initialization loop so that the correct results will be given. Much thanks to @octylFractal for acting as my duck while trying to figure this out. + +diff --git a/net/minecraft/network/VarInt.java b/net/minecraft/network/VarInt.java +index 4897ff4648083ebe737ae5b32bae344af27357e4..6f8dd31582f0e1d3a71acc7a142c1f4ec0539d9e 100644 +--- a/net/minecraft/network/VarInt.java ++++ b/net/minecraft/network/VarInt.java +@@ -51,6 +51,41 @@ public class VarInt { + } + + public static ByteBuf write(ByteBuf buffer, int value) { ++ // Gale start - Velocity - optimized VarInt#write ++ if ((value & 0xFFFFFF80) == 0) { ++ buffer.writeByte(value); ++ } else if ((value & 0xFFFFC000) == 0) { ++ int w = (value & 0x7F) << 8 ++ | (value >>> 7) ++ | 0x00008000; ++ buffer.writeShort(w); ++ } else if ((value & 0xFFE00000) == 0) { ++ int w = (value & 0x7F) << 16 ++ | (value & 0x3F80) << 1 ++ | (value >>> 14) ++ | 0x00808000; ++ buffer.writeMedium(w); ++ } else if ((value & 0xF0000000) == 0) { ++ int w = (value & 0x7F) << 24 ++ | ((value & 0x3F80) << 9) ++ | (value & 0x1FC000) >> 6 ++ | (value >>> 21) ++ | 0x80808000; ++ buffer.writeInt(w); ++ } else { ++ int w = (value & 0x7F) << 24 ++ | (value & 0x3F80) << 9 ++ | (value & 0x1FC000) >> 6 ++ | ((value >>> 21) & 0x7F) ++ | 0x80808080; ++ buffer.writeInt(w); ++ buffer.writeByte(value >>> 28); ++ } ++ return buffer; ++ } ++ ++ static ByteBuf writeOld(ByteBuf buffer, int value) { // public -> package-private ++ // Gale end - Velocity - optimized VarInt#write + // Paper start - Optimize VarInts + // Peel the one and two byte count cases explicitly as they are the most common VarInt sizes + // that the proxy will write, to improve inlining. +@@ -60,11 +95,11 @@ public class VarInt { + int w = (value & 0x7F | 0x80) << 8 | (value >>> 7); + buffer.writeShort(w); + } else { +- writeOld(buffer, value); ++ writeOld2(buffer, value); // rename + } + return buffer; + } +- public static ByteBuf writeOld(ByteBuf buffer, int value) { ++ public static ByteBuf writeOld2(ByteBuf buffer, int value) { // rename + // Paper end - Optimize VarInts + while ((value & -128) != 0) { + buffer.writeByte(value & 127 | 128); +diff --git a/net/minecraft/network/VarLong.java b/net/minecraft/network/VarLong.java +index ff9d84bf761797a8f695926c3cbb12c07609365d..244f8c06c6410541056a989815faf43f0fee9111 100644 +--- a/net/minecraft/network/VarLong.java ++++ b/net/minecraft/network/VarLong.java +@@ -51,6 +51,127 @@ public class VarLong { + } + + public static ByteBuf write(ByteBuf buffer, long value) { ++ // Gale start - Velocity - optimized VarLong#write ++ if ((value & 0xFFFFFFFFFFFFFF80L) == 0) { ++ buffer.writeByte((int) value); ++ } else if (value < 0) { ++ // The case of writing arbitrary longs is common ++ // Here, the number is negative, which has probability 1/2 for arbitrary numbers ++ int least7bits = (int) (value & 0xFFFFFFFL); ++ int w = (least7bits & 0x7F) << 24 ++ | (least7bits & 0x3F80) << 9 ++ | (least7bits & 0x1FC000) >> 6 ++ | ((least7bits >>> 21) & 0x7F) ++ | 0x80808080; ++ long nonLeast7Bits = value >>> 28; ++ int secondLeast7bits = (int) (nonLeast7Bits & 0xFFFFFFFL); ++ int w2 = (secondLeast7bits & 0x7F) << 24 ++ | ((secondLeast7bits & 0x3F80) << 9) ++ | (secondLeast7bits & 0x1FC000) >> 6 ++ | (secondLeast7bits >>> 21) ++ | 0x80808080; ++ int thirdLeast7Bits = (int) (nonLeast7Bits >>> 28); ++ int w3 = (thirdLeast7Bits & 0x7F) << 8 ++ | (thirdLeast7Bits >>> 7) ++ | 0x00008000; ++ buffer.writeInt(w); ++ buffer.writeInt(w2); ++ buffer.writeShort(w3); ++ } else if ((value & 0xFFFFFFFFFFFFC000L) == 0) { ++ int least7bits = (int) value; ++ int w = (least7bits & 0x7F) << 8 ++ | (least7bits >>> 7) ++ | 0x00008000; ++ buffer.writeShort(w); ++ } else if ((value & 0xFFFFFFFFFFE00000L) == 0) { ++ int least7bits = (int) value; ++ int w = (least7bits & 0x7F) << 16 ++ | (least7bits & 0x3F80) << 1 ++ | (least7bits >>> 14) ++ | 0x00808000; ++ buffer.writeMedium(w); ++ } else if ((value & 0xFFFFFFFFF0000000L) == 0) { ++ int least7bits = (int) value; ++ int w = (least7bits & 0x7F) << 24 ++ | ((least7bits & 0x3F80) << 9) ++ | (least7bits & 0x1FC000) >> 6 ++ | (least7bits >>> 21) ++ | 0x80808000; ++ buffer.writeInt(w); ++ } else if ((value & 0xFFFFFFF800000000L) == 0) { ++ int least7bits = (int) (value & 0xFFFFFFFL); ++ int w = (least7bits & 0x7F) << 24 ++ | (least7bits & 0x3F80) << 9 ++ | (least7bits & 0x1FC000) >> 6 ++ | ((least7bits >>> 21) & 0x7F) ++ | 0x80808080; ++ buffer.writeInt(w); ++ buffer.writeByte((int) (value >>> 28)); ++ } else if ((value & 0xFFFFFC0000000000L) == 0) { ++ int least7bits = (int) (value & 0xFFFFFFFL); ++ int w = (least7bits & 0x7F) << 24 ++ | (least7bits & 0x3F80) << 9 ++ | (least7bits & 0x1FC000) >> 6 ++ | ((least7bits >>> 21) & 0x7F) ++ | 0x80808080; ++ int secondLeast7bits = (int) (value >>> 28); ++ int w2 = (secondLeast7bits & 0x7F) << 8 ++ | (secondLeast7bits >>> 7) ++ | 0x00008000; ++ buffer.writeInt(w); ++ buffer.writeShort(w2); ++ } else if ((value & 0xFFFE000000000000L) == 0) { ++ int least7bits = (int) (value & 0xFFFFFFFL); ++ int w = (least7bits & 0x7F) << 24 ++ | (least7bits & 0x3F80) << 9 ++ | (least7bits & 0x1FC000) >> 6 ++ | ((least7bits >>> 21) & 0x7F) ++ | 0x80808080; ++ int secondLeast7bits = (int) (value >>> 28); ++ int w2 = (secondLeast7bits & 0x7F) << 16 ++ | (secondLeast7bits & 0x3F80) << 1 ++ | (secondLeast7bits >>> 14) ++ | 0x00808000; ++ buffer.writeInt(w); ++ buffer.writeMedium(w2); ++ } else if ((value & 0xFF00000000000000L) == 0) { ++ int least7bits = (int) (value & 0xFFFFFFFL); ++ int w = (least7bits & 0x7F) << 24 ++ | (least7bits & 0x3F80) << 9 ++ | (least7bits & 0x1FC000) >> 6 ++ | ((least7bits >>> 21) & 0x7F) ++ | 0x80808080; ++ int secondLeast7bits = (int) (value >>> 28); ++ int w2 = (secondLeast7bits & 0x7F) << 24 ++ | ((secondLeast7bits & 0x3F80) << 9) ++ | (secondLeast7bits & 0x1FC000) >> 6 ++ | (secondLeast7bits >>> 21) ++ | 0x80808000; ++ buffer.writeInt(w); ++ buffer.writeInt(w2); ++ } else { ++ int least7bits = (int) (value & 0xFFFFFFFL); ++ int w = (least7bits & 0x7F) << 24 ++ | (least7bits & 0x3F80) << 9 ++ | (least7bits & 0x1FC000) >> 6 ++ | ((least7bits >>> 21) & 0x7F) ++ | 0x80808080; ++ long nonLeast7Bits = value >>> 28; ++ int secondLeast7bits = (int) (nonLeast7Bits & 0xFFFFFFFL); ++ int w2 = (secondLeast7bits & 0x7F) << 24 ++ | ((secondLeast7bits & 0x3F80) << 9) ++ | (secondLeast7bits & 0x1FC000) >> 6 ++ | (secondLeast7bits >>> 21) ++ | 0x80808080; ++ buffer.writeInt(w); ++ buffer.writeInt(w2); ++ buffer.writeByte((int) (nonLeast7Bits >>> 28)); ++ } ++ return buffer; ++ } ++ ++ static ByteBuf writeOld(ByteBuf buffer, long value) { // public -> package-private ++ // Gale end - Velocity - optimized VarLong#write + while ((value & -128L) != 0L) { + buffer.writeByte((int)(value & 127L) | 128); + value >>>= 7; diff --git a/gale-server/minecraft-patches/features/0095-Reduce-RandomSource-instances.patch b/gale-server/minecraft-patches/features/0095-Reduce-RandomSource-instances.patch new file mode 100644 index 0000000..f4a9085 --- /dev/null +++ b/gale-server/minecraft-patches/features/0095-Reduce-RandomSource-instances.patch @@ -0,0 +1,138 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Tue, 29 Nov 2022 00:45:45 +0100 +Subject: [PATCH] Reduce RandomSource instances + +License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) +Gale - https://galemc.org + +This patch is based on the following patch: +"don't create new random instance" +By: foss-mc <69294560+foss-mc@users.noreply.github.com> +As part of: Patina (https://github.com/PatinaMC/Patina) +Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) + +diff --git a/net/minecraft/server/commands/SpreadPlayersCommand.java b/net/minecraft/server/commands/SpreadPlayersCommand.java +index d381800ad054be6b054dcca43fbe80d3f0c0c771..5904b9d985487ff8bd1f330667c43096aa298b98 100644 +--- a/net/minecraft/server/commands/SpreadPlayersCommand.java ++++ b/net/minecraft/server/commands/SpreadPlayersCommand.java +@@ -107,7 +107,7 @@ public class SpreadPlayersCommand { + if (maxHeight < minY) { + throw ERROR_INVALID_MAX_HEIGHT.create(maxHeight, minY); + } else { +- RandomSource randomSource = RandomSource.create(); ++ RandomSource randomSource = source.getLevel().random; // Gale - Patina - reduce RandomSource instances + double d = center.x - maxRange; + double d1 = center.y - maxRange; + double d2 = center.x + maxRange; +diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java +index e676e2082700a2bdc2a93b0a356e4f6b1000776e..e56e930df980613a13f92d771f1036eba82b1d19 100644 +--- a/net/minecraft/server/level/ServerPlayer.java ++++ b/net/minecraft/server/level/ServerPlayer.java +@@ -461,7 +461,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc + long l1 = l * l; + int i = l1 > 2147483647L ? Integer.MAX_VALUE : (int)l1; + int coprime = this.getCoprime(i); +- int randomInt = RandomSource.create().nextInt(i); ++ int randomInt = level.random.nextInt(i); // Gale - Patina - reduce RandomSource instances + + for (int i1 = 0; i1 < i; i1++) { + int i2 = (randomInt + coprime * i1) % i; +diff --git a/net/minecraft/server/rcon/thread/QueryThreadGs4.java b/net/minecraft/server/rcon/thread/QueryThreadGs4.java +index 0b8d279a53196f3998b1f6901738ca8e02ef7311..9add567d2ec2f5e9cd5bee84423c5a44433fe188 100644 +--- a/net/minecraft/server/rcon/thread/QueryThreadGs4.java ++++ b/net/minecraft/server/rcon/thread/QueryThreadGs4.java +@@ -341,7 +341,7 @@ public class QueryThreadGs4 extends GenericThread { + this.identBytes[2] = data[5]; + this.identBytes[3] = data[6]; + this.ident = new String(this.identBytes, StandardCharsets.UTF_8); +- this.challenge = RandomSource.create().nextInt(16777216); ++ this.challenge = java.util.concurrent.ThreadLocalRandom.current().nextInt(16777216); // Gale - Patina - reduce RandomSource instances + this.challengeBytes = String.format(Locale.ROOT, "\t%s%d\u0000", this.ident, this.challenge).getBytes(StandardCharsets.UTF_8); + } + +diff --git a/net/minecraft/world/entity/projectile/FishingHook.java b/net/minecraft/world/entity/projectile/FishingHook.java +index 1e012c7ef699a64ff3f1b00f897bb893ab25ecbd..800db05c1d2f2452a9e8ab7532f5ec10a924b0ce 100644 +--- a/net/minecraft/world/entity/projectile/FishingHook.java ++++ b/net/minecraft/world/entity/projectile/FishingHook.java +@@ -48,7 +48,7 @@ import org.slf4j.Logger; + + public class FishingHook extends Projectile { + private static final Logger LOGGER = LogUtils.getLogger(); +- private final RandomSource syncronizedRandom = RandomSource.create(); ++ private final RandomSource syncronizedRandom; // Gale - Patina - reduce RandomSource instances + private boolean biting; + public int outOfWaterTime; + private static final int MAX_OUT_OF_WATER_TIME = 10; +@@ -86,6 +86,7 @@ public class FishingHook extends Projectile { + this.minWaitTime = level.paperConfig().fishingTimeRange.minimum; + this.maxWaitTime = level.paperConfig().fishingTimeRange.maximum; + // Paper end - Configurable fishing time ranges ++ this.syncronizedRandom = level.random; // Gale - Patina - reduce RandomSource instances + } + + public FishingHook(EntityType entityType, Level level) { +diff --git a/net/minecraft/world/entity/raid/Raid.java b/net/minecraft/world/entity/raid/Raid.java +index 27234627933ccaa70b2c51a792efb2e68104a84f..7b0de83f1eb79007c6fe0ecf00660143781d1aa6 100644 +--- a/net/minecraft/world/entity/raid/Raid.java ++++ b/net/minecraft/world/entity/raid/Raid.java +@@ -99,7 +99,7 @@ public class Raid { + public final ServerBossEvent raidEvent = new ServerBossEvent(RAID_NAME_COMPONENT, BossEvent.BossBarColor.RED, BossEvent.BossBarOverlay.NOTCHED_10); + private int postRaidTicks; + private int raidCooldownTicks; +- private final RandomSource random = RandomSource.create(); ++ private final RandomSource random; // Gale - Patina - reduce RandomSource instances + public final int numGroups; + private Raid.RaidStatus status; + private int celebrationTicks; +@@ -120,6 +120,7 @@ public class Raid { + this.center = center; + this.numGroups = this.getNumGroups(level.getDifficulty()); + this.status = Raid.RaidStatus.ONGOING; ++ this.random = level.random; // Gale - Patina - reduce RandomSource instances + } + + public Raid(ServerLevel level, CompoundTag compound) { +@@ -147,6 +148,7 @@ public class Raid { + this.persistentDataContainer.putAll(compound.getCompound(PDC_NBT_KEY)); + } + // Paper end ++ this.random = level.random; // Gale - Patina - reduce RandomSource instances + } + + public boolean isOver() { +diff --git a/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java b/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java +index 5bf39c542757bf97da8909b65c22786a8a30385a..9333db899f86f91a667273f23f24a1c2eca9ad64 100644 +--- a/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java ++++ b/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java +@@ -248,7 +248,7 @@ public class TheEndGatewayBlockEntity extends TheEndPortalBlockEntity { + } + + private static void spawnGatewayPortal(ServerLevel level, BlockPos pos, EndGatewayConfiguration config) { +- Feature.END_GATEWAY.place(config, level, level.getChunkSource().getGenerator(), RandomSource.create(), pos); ++ Feature.END_GATEWAY.place(config, level, level.getChunkSource().getGenerator(), level.random, pos); // Gale - Patina - reduce RandomSource instances + } + + @Override +diff --git a/net/minecraft/world/level/dimension/end/EndDragonFight.java b/net/minecraft/world/level/dimension/end/EndDragonFight.java +index 6e7e87c32734b3aae354bc34459e5f207da5c78f..b933038ce88cdf285c8b4a901c3493ae7605f57e 100644 +--- a/net/minecraft/world/level/dimension/end/EndDragonFight.java ++++ b/net/minecraft/world/level/dimension/end/EndDragonFight.java +@@ -434,7 +434,7 @@ public class EndDragonFight { + .registryAccess() + .lookup(Registries.CONFIGURED_FEATURE) + .flatMap(registry -> registry.get(EndFeatures.END_GATEWAY_DELAYED)) +- .ifPresent(endGatewayFeature -> endGatewayFeature.value().place(this.level, this.level.getChunkSource().getGenerator(), RandomSource.create(), pos)); ++ .ifPresent(endGatewayFeature -> endGatewayFeature.value().place(this.level, this.level.getChunkSource().getGenerator(), this.level.random, pos)); // Gale - Patina - reduce RandomSource instances + } + + public void spawnExitPortal(boolean active) { +@@ -453,7 +453,7 @@ public class EndDragonFight { + } + // Paper end - Prevent "softlocked" exit portal generation + if (endPodiumFeature.place( +- FeatureConfiguration.NONE, this.level, this.level.getChunkSource().getGenerator(), RandomSource.create(), this.portalLocation ++ FeatureConfiguration.NONE, this.level, this.level.getChunkSource().getGenerator(), this.level.random, this.portalLocation // Gale - Patina - reduce RandomSource instances + )) { + int i = Mth.positiveCeilDiv(4, 16); + this.level.getChunkSource().chunkMap.waitForLightBeforeSending(new ChunkPos(this.portalLocation), i); diff --git a/gale-server/minecraft-patches/features/0096-Add-xor-shift-random.patch b/gale-server/minecraft-patches/features/0096-Add-xor-shift-random.patch new file mode 100644 index 0000000..43086c8 --- /dev/null +++ b/gale-server/minecraft-patches/features/0096-Add-xor-shift-random.patch @@ -0,0 +1,69 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Tue, 8 Aug 2023 21:12:58 +0200 +Subject: [PATCH] Add xor-shift random +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +License: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html) +Gale - https://galemc.org + +This patch is based on the following patch: +"Apply faster random" +By: AlphaKR93 +As part of: Plazma (https://github.com/PlazmaMC/Plazma) +Class `org.plazmamc.plazma.Random` licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html) +Other changes licensed under: MIT (https://opensource.org/licenses/MIT) + +* Plazma copyright * + +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +diff --git a/io/papermc/paper/entity/activation/ActivationRange.java b/io/papermc/paper/entity/activation/ActivationRange.java +index b9c8bcf3136939a1c8f215af53c4fa343b344e38..a04302728819f28ab724d474a3d06a916f3d1d99 100644 +--- a/io/papermc/paper/entity/activation/ActivationRange.java ++++ b/io/papermc/paper/entity/activation/ActivationRange.java +@@ -75,7 +75,7 @@ public final class ActivationRange { + } + + // Gale start - variable entity wake-up duration +- private static final java.util.Random wakeUpDurationRandom = new java.util.Random(); ++ public static java.util.Random wakeUpDurationRandom; // Gale - xor-shift random - set in GaleGlobalConfiguration + + private static int getWakeUpDurationWithVariance(Entity entity, int wakeUpDuration) { + double deviation = entity.level().galeConfig().gameplayMechanics.entityWakeUpDurationRatioStandardDeviation; +diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java +index 95972e7d5e0357ff5884f1cb2f7596c5029f999d..a5f76c81dfb148fc184d137395d5961229cb799b 100644 +--- a/net/minecraft/world/level/chunk/LevelChunk.java ++++ b/net/minecraft/world/level/chunk/LevelChunk.java +@@ -174,7 +174,9 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p + this.defaultBlockState = empty ? VOID_AIR_BLOCKSTATE : AIR_BLOCKSTATE; + // Paper end - get block chunk optimisation + +- this.lightningTick = this.level.simpleRandom.nextInt(100000) << 1; // Gale - Airplane - optimize random calls in chunk ticking - initialize lightning tick ++ this.lightningTick = org.galemc.gale.configuration.GaleGlobalConfiguration.get().smallOptimizations.useXorShiftRandom.lightningRandomTick ++ ? new org.galemc.gale.random.XorShiftRandom().nextInt(100000) << 1 ++ : this.level.simpleRandom.nextInt(100000) << 1; // Gale - Airplane - optimize random calls in chunk ticking - initialize lightning tick // Gale - xor-shift random + } + + public LevelChunk(ServerLevel level, ProtoChunk chunk, @Nullable LevelChunk.PostLoadProcessor postLoad) { +diff --git a/net/minecraft/world/level/chunk/storage/RegionFile.java b/net/minecraft/world/level/chunk/storage/RegionFile.java +index 0c41177462cca5c4bbab6490e323b9535fd6300f..231d1905092532acf7e632197ba0e727adc4b1d7 100644 +--- a/net/minecraft/world/level/chunk/storage/RegionFile.java ++++ b/net/minecraft/world/level/chunk/storage/RegionFile.java +@@ -104,7 +104,7 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche + } + + private void backupRegionFile() { +- Path backup = this.path.getParent().resolve(this.path.getFileName() + "." + new java.util.Random().nextLong() + ".backup"); ++ Path backup = this.path.getParent().resolve(this.path.getFileName() + "." + new org.galemc.gale.random.XorShiftRandom().nextLong() + ".backup"); // Gale - xor-shift random + this.backupRegionFile(backup); + } + diff --git a/gale-server/minecraft-patches/features/0097-Reduce-skull-ItemStack-lookups-for-reduced-visibilit.patch b/gale-server/minecraft-patches/features/0097-Reduce-skull-ItemStack-lookups-for-reduced-visibilit.patch new file mode 100644 index 0000000..ae6242c --- /dev/null +++ b/gale-server/minecraft-patches/features/0097-Reduce-skull-ItemStack-lookups-for-reduced-visibilit.patch @@ -0,0 +1,65 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Wed, 30 Aug 2023 20:17:20 +0200 +Subject: [PATCH] Reduce skull ItemStack lookups for reduced visibility + +License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) +Gale - https://galemc.org + +This patch is based on the following patch: +"feat: reduce sensor work" +By: peaches94 +As part of: Petal (https://github.com/Bloom-host/Petal) +Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) + +* Petal description * + +this patch is focused around the sensors used for ai +delete the line of sight cache less often and use a faster nearby comparison + +diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java +index 4e414a78a6acfb90d5e212398617580a3f34be9b..883a47a9ccd75ea124d45beb1645b3f011962c48 100644 +--- a/net/minecraft/world/entity/LivingEntity.java ++++ b/net/minecraft/world/entity/LivingEntity.java +@@ -1003,15 +1003,16 @@ public abstract class LivingEntity extends Entity implements Attackable { + } + + if (lookingEntity != null) { +- ItemStack itemBySlot = this.getItemBySlot(EquipmentSlot.HEAD); ++ // Gale start - Petal - reduce skull ItemStack lookups for reduced visibility + EntityType type = lookingEntity.getType(); +- if (type == EntityType.SKELETON && itemBySlot.is(Items.SKELETON_SKULL) +- || type == EntityType.ZOMBIE && itemBySlot.is(Items.ZOMBIE_HEAD) +- || type == EntityType.PIGLIN && itemBySlot.is(Items.PIGLIN_HEAD) +- || type == EntityType.PIGLIN_BRUTE && itemBySlot.is(Items.PIGLIN_HEAD) +- || type == EntityType.CREEPER && itemBySlot.is(Items.CREEPER_HEAD)) { ++ if (type == EntityType.SKELETON && this.getItemBySlot(EquipmentSlot.HEAD).is(Items.SKELETON_SKULL) ++ || type == EntityType.ZOMBIE && this.getItemBySlot(EquipmentSlot.HEAD).is(Items.ZOMBIE_HEAD) ++ || type == EntityType.PIGLIN && this.getItemBySlot(EquipmentSlot.HEAD).is(Items.PIGLIN_HEAD) ++ || type == EntityType.PIGLIN_BRUTE && this.getItemBySlot(EquipmentSlot.HEAD).is(Items.PIGLIN_HEAD) ++ || type == EntityType.CREEPER && this.getItemBySlot(EquipmentSlot.HEAD).is(Items.CREEPER_HEAD)) { + d *= 0.5; + } ++ // Gale end - Petal - reduce skull ItemStack lookups for reduced visibility + } + + return d; +diff --git a/net/minecraft/world/entity/LivingEntity.java.rej b/net/minecraft/world/entity/LivingEntity.java.rej +new file mode 100644 +index 0000000000000000000000000000000000000000..a1acc8d7b32caf3eebbbfc1a3058157b69dd74f4 +--- /dev/null ++++ b/net/minecraft/world/entity/LivingEntity.java.rej +@@ -0,0 +1,13 @@ ++diff a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java (rejected hunks) ++@@ -1050,10 +1050,9 @@ public abstract class LivingEntity extends Entity implements Attackable { ++ } ++ ++ if (entity != null) { ++- ItemStack itemstack = this.getItemBySlot(EquipmentSlot.HEAD); ++ EntityType entitytypes = entity.getType(); ++ ++- if (entitytypes == EntityType.SKELETON && itemstack.is(Items.SKELETON_SKULL) || entitytypes == EntityType.ZOMBIE && itemstack.is(Items.ZOMBIE_HEAD) || entitytypes == EntityType.PIGLIN && itemstack.is(Items.PIGLIN_HEAD) || entitytypes == EntityType.PIGLIN_BRUTE && itemstack.is(Items.PIGLIN_HEAD) || entitytypes == EntityType.CREEPER && itemstack.is(Items.CREEPER_HEAD)) { +++ if (entitytypes == EntityType.SKELETON && this.getItemBySlot(EquipmentSlot.HEAD).is(Items.SKELETON_SKULL) || entitytypes == EntityType.ZOMBIE && this.getItemBySlot(EquipmentSlot.HEAD).is(Items.ZOMBIE_HEAD) || entitytypes == EntityType.PIGLIN && this.getItemBySlot(EquipmentSlot.HEAD).is(Items.PIGLIN_HEAD) || entitytypes == EntityType.PIGLIN_BRUTE && this.getItemBySlot(EquipmentSlot.HEAD).is(Items.PIGLIN_HEAD) || entitytypes == EntityType.CREEPER && this.getItemBySlot(EquipmentSlot.HEAD).is(Items.CREEPER_HEAD)) { // Gale - Petal - reduce skull ItemStack lookups for reduced visibility ++ d0 *= 0.5D; ++ } ++ } diff --git a/patches/server/0115-Initialize-line-of-sight-cache-with-low-capacity.patch b/gale-server/minecraft-patches/features/0098-Initialize-line-of-sight-cache-with-low-capacity.patch similarity index 64% rename from patches/server/0115-Initialize-line-of-sight-cache-with-low-capacity.patch rename to gale-server/minecraft-patches/features/0098-Initialize-line-of-sight-cache-with-low-capacity.patch index 20ea401..d64d4c8 100644 --- a/patches/server/0115-Initialize-line-of-sight-cache-with-low-capacity.patch +++ b/gale-server/minecraft-patches/features/0098-Initialize-line-of-sight-cache-with-low-capacity.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Initialize line of sight cache with low capacity License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) Gale - https://galemc.org -diff --git a/src/main/java/net/minecraft/world/entity/ai/sensing/Sensing.java b/src/main/java/net/minecraft/world/entity/ai/sensing/Sensing.java -index ed440b9a84ac0e4619c075491515fa072d6aebec..57472cb54e9fd83e980e3c57f28d6e6643f422e8 100644 ---- a/src/main/java/net/minecraft/world/entity/ai/sensing/Sensing.java -+++ b/src/main/java/net/minecraft/world/entity/ai/sensing/Sensing.java +diff --git a/net/minecraft/world/entity/ai/sensing/Sensing.java b/net/minecraft/world/entity/ai/sensing/Sensing.java +index b1aa7294f9479f45fcde77c5ea46db9f62370abf..e17b1a2a95975d1eae5adaa679e027b9181dddbd 100644 +--- a/net/minecraft/world/entity/ai/sensing/Sensing.java ++++ b/net/minecraft/world/entity/ai/sensing/Sensing.java @@ -7,8 +7,10 @@ import net.minecraft.world.entity.Mob; public class Sensing { @@ -21,5 +21,5 @@ index ed440b9a84ac0e4619c075491515fa072d6aebec..57472cb54e9fd83e980e3c57f28d6e66 + private final IntSet unseen = new IntOpenHashSet(2); + // Gale end - initialize line of sight cache with low capacity - public Sensing(Mob owner) { - this.mob = owner; + public Sensing(Mob mob) { + this.mob = mob; diff --git a/patches/server/0116-Reduce-line-of-sight-updates-and-cache-lookups.patch b/gale-server/minecraft-patches/features/0099-Reduce-line-of-sight-updates-and-cache-lookups.patch similarity index 66% rename from patches/server/0116-Reduce-line-of-sight-updates-and-cache-lookups.patch rename to gale-server/minecraft-patches/features/0099-Reduce-line-of-sight-updates-and-cache-lookups.patch index d40fd15..82a1a0c 100644 --- a/patches/server/0116-Reduce-line-of-sight-updates-and-cache-lookups.patch +++ b/gale-server/minecraft-patches/features/0099-Reduce-line-of-sight-updates-and-cache-lookups.patch @@ -17,10 +17,10 @@ Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) this patch is focused around the sensors used for ai delete the line of sight cache less often and use a faster nearby comparison -diff --git a/src/main/java/net/minecraft/world/entity/ai/sensing/Sensing.java b/src/main/java/net/minecraft/world/entity/ai/sensing/Sensing.java -index 57472cb54e9fd83e980e3c57f28d6e6643f422e8..aa5fb4288057e97a41ce41df5009ad4d887e6e64 100644 ---- a/src/main/java/net/minecraft/world/entity/ai/sensing/Sensing.java -+++ b/src/main/java/net/minecraft/world/entity/ai/sensing/Sensing.java +diff --git a/net/minecraft/world/entity/ai/sensing/Sensing.java b/net/minecraft/world/entity/ai/sensing/Sensing.java +index e17b1a2a95975d1eae5adaa679e027b9181dddbd..9a2c3a8ee9b0f863bf2761901a7550ff71b58acc 100644 +--- a/net/minecraft/world/entity/ai/sensing/Sensing.java ++++ b/net/minecraft/world/entity/ai/sensing/Sensing.java @@ -7,33 +7,70 @@ import net.minecraft.world.entity.Mob; public class Sensing { @@ -37,8 +37,8 @@ index 57472cb54e9fd83e980e3c57f28d6e6643f422e8..aa5fb4288057e97a41ce41df5009ad4d + private int nextToExpireIndex = 1; + // Gale end - Petal - reduce line of sight updates - expiring entity id lists - public Sensing(Mob owner) { - this.mob = owner; + public Sensing(Mob mob) { + this.mob = mob; + // Gale start - Petal - reduce line of sight updates - expiring entity id lists + int updateLineOfSightInterval = org.galemc.gale.configuration.GaleGlobalConfiguration.get().smallOptimizations.reducedIntervals.updateEntityLineOfSight; + if (updateLineOfSightInterval <= 1) { @@ -56,7 +56,7 @@ index 57472cb54e9fd83e980e3c57f28d6e6643f422e8..aa5fb4288057e97a41ce41df5009ad4d + if (this.expiring == null) { // Gale - Petal - reduce line of sight updates this.seen.clear(); - this.unseen.clear(); -+ // Gale start - Petal - reduce line of sight updates ++ // Gale start - Petal - reduce line of sight updates + } else { + var expiringNow = this.expiring[this.nextToExpireIndex]; + expiringNow.forEach(this.seen::remove); @@ -74,42 +74,30 @@ index 57472cb54e9fd83e980e3c57f28d6e6643f422e8..aa5fb4288057e97a41ce41df5009ad4d } public boolean hasLineOfSight(Entity entity) { - int i = entity.getId(); -- if (this.seen.contains(i)) { + int id = entity.getId(); +- if (this.seen.contains(id)) { + // Gale start - Petal - reduce line of sight cache lookups - merge sets -+ int cached = this.seen.get(i); ++ int cached = this.seen.get(id); + if (cached == 1) { + // Gale end - Petal - reduce line of sight cache lookups - merge sets return true; -- } else if (this.unseen.contains(i)) { +- } else if (this.unseen.contains(id)) { + } else if (cached == 2) { // Gale - Petal - reduce line of sight cache lookups - merge sets return false; } else { - boolean bl = this.mob.hasLineOfSight(entity); - if (bl) { -- this.seen.add(i); -+ this.seen.put(i, 1); // Gale - Petal - reduce line of sight cache lookups - merge sets + boolean hasLineOfSight = this.mob.hasLineOfSight(entity); + if (hasLineOfSight) { +- this.seen.add(id); ++ this.seen.put(id, 1); // Gale - Petal - reduce line of sight cache lookups - merge sets } else { -- this.unseen.add(i); -+ this.seen.put(i, 2); // Gale - Petal - reduce line of sight cache lookups - merge sets +- this.unseen.add(id); ++ this.seen.put(id, 2); // Gale - Petal - reduce line of sight cache lookups - merge sets + } + // Gale start - Petal - reduce line of sight updates + if (this.expiring != null) { -+ this.expiring[this.currentCacheAddIndex].add(i); ++ this.expiring[this.currentCacheAddIndex].add(id); } + // Gale end - Petal - reduce line of sight updates - return bl; + return hasLineOfSight; } -diff --git a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -index c57ebf0f37aba2d118e54f3c71697f29bb9a57a0..417dda8dc61af144fe07963b66080e5c9f2750b4 100644 ---- a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -+++ b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -@@ -34,6 +34,7 @@ public class GaleGlobalConfiguration extends ConfigurationPart { - public class ReducedIntervals extends ConfigurationPart { - - public int increaseTimeStatistics = 20; // Gale - Hydrinity - increase time statistics in intervals -+ public int updateEntityLineOfSight = 4; // Gale - Petal - reduce line of sight updates - - @PostProcess - public void postProcess() { diff --git a/patches/server/0117-Server-thread-priority-environment-variable.patch b/gale-server/minecraft-patches/features/0100-Server-thread-priority-environment-variable.patch similarity index 68% rename from patches/server/0117-Server-thread-priority-environment-variable.patch rename to gale-server/minecraft-patches/features/0100-Server-thread-priority-environment-variable.patch index 4025b2f..0352379 100644 --- a/patches/server/0117-Server-thread-priority-environment-variable.patch +++ b/gale-server/minecraft-patches/features/0100-Server-thread-priority-environment-variable.patch @@ -6,28 +6,27 @@ Subject: [PATCH] Server thread priority environment variable License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) Gale - https://galemc.org -diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 1f299e98a9efd0f51bace264b0cbb7cbc4845907..24b9711dca7223dd12b24c36cd76f50fbd96fc68 100644 ---- a/src/main/java/net/minecraft/server/MinecraftServer.java -+++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -195,6 +195,8 @@ import org.bukkit.event.server.ServerLoadEvent; +diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java +index 6ad3cdfd10daebd1920ef54481ce07e3d03f6829..6be2931adb464598e3f3228b647190599c9bca63 100644 +--- a/net/minecraft/server/MinecraftServer.java ++++ b/net/minecraft/server/MinecraftServer.java +@@ -163,6 +163,7 @@ import net.minecraft.world.phys.Vec3; + import org.slf4j.Logger; public abstract class MinecraftServer extends ReentrantBlockableEventLoop implements ServerInfo, ChunkIOErrorReporter, CommandSource, ca.spottedleaf.moonrise.patches.chunk_system.server.ChunkSystemMinecraftServer { // Paper - rewrite chunk system - + public static final int SERVER_THREAD_PRIORITY = Integer.getInteger("gale.thread.priority.server", -1); // Gale - server thread priority environment variable -+ private static MinecraftServer SERVER; // Paper public static final Logger LOGGER = LogUtils.getLogger(); public static final net.kyori.adventure.text.logger.slf4j.ComponentLogger COMPONENT_LOGGER = net.kyori.adventure.text.logger.slf4j.ComponentLogger.logger(LOGGER.getName()); // Paper -@@ -334,6 +336,11 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 0) { + thread.setPriority(SERVER_THREAD_PRIORITY); + } + // Gale end - server thread priority environment variable thread.start(); - return s0; + return minecraftServer; } diff --git a/patches/server/0005-Gale-branding-changes.patch b/gale-server/paper-patches/features/0001-Gale-branding-changes.patch similarity index 75% rename from patches/server/0005-Gale-branding-changes.patch rename to gale-server/paper-patches/features/0001-Gale-branding-changes.patch index f6f41d2..5abe2fc 100644 --- a/patches/server/0005-Gale-branding-changes.patch +++ b/gale-server/paper-patches/features/0001-Gale-branding-changes.patch @@ -220,53 +220,6 @@ index 94a9ed024d3859793618152ea559a168bbcbb5e2..e60008693e017bec1b4eb49c84be3898 Public License instead of this License. But first, please read -. +. -diff --git a/build.gradle.kts b/build.gradle.kts -index 1bbd7458f6031cedde5c7efa652481bf4c66b5d6..e3bed8a7f6a9b985c28551b2dfb03456b802380d 100644 ---- a/build.gradle.kts -+++ b/build.gradle.kts -@@ -108,14 +108,14 @@ tasks.jar { - val gitBranch = git("rev-parse", "--abbrev-ref", "HEAD").getText().trim() // Paper - attributes( - "Main-Class" to "org.bukkit.craftbukkit.Main", -- "Implementation-Title" to "Paper", -+ "Implementation-Title" to "Gale", // Gale - branding changes - "Implementation-Version" to implementationVersion, - "Implementation-Vendor" to date, // Paper -- "Specification-Title" to "Paper", -+ "Specification-Title" to "Gale", // Gale - branding changes - "Specification-Version" to project.version, -- "Specification-Vendor" to "Paper Team", -- "Brand-Id" to "papermc:paper", -- "Brand-Name" to "Paper", -+ "Specification-Vendor" to "GaleMC Team", // Gale - branding changes -+ "Brand-Id" to "galemc:gale", // Gale - branding changes -+ "Brand-Name" to "Gale", // Gale - branding changes - "Build-Number" to (build ?: ""), - "Build-Time" to Instant.now().toString(), - "Git-Branch" to gitBranch, // Paper -@@ -261,3 +261,22 @@ tasks.registerRunTask("runReobfPaperclip") { - classpath(rootProject.tasks.named("createReobfPaperclipJar").flatMap { it.outputZip }) - mainClass.set(null as String?) - } -+ -+// Gale start - package license into jar -+tasks.register("copyLicense") { -+ from(layout.projectDirectory.file("LICENSE.txt")) -+ into(layout.buildDirectory.dir("tmp/copiedlicense")) -+} -+ -+tasks.processResources { -+ dependsOn("copyLicense") -+} -+ -+sourceSets { -+ main { -+ resources { -+ srcDir(layout.buildDirectory.dir("tmp/copiedlicense")) -+ } -+ } -+} -+// Gale end - package license into jar diff --git a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java index 532306cacd52579cdf37e4aca25887b1ed3ba6a1..2beea17d87464683faaefa835206f2654df9bde0 100644 --- a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java @@ -440,38 +393,6 @@ index 790bad0494454ca12ee152e3de6da3da634d9b20..2596e0ee4df5b96f181e28a742ef3459 } @Override -diff --git a/src/main/java/net/minecraft/world/damagesource/DamageSource.java b/src/main/java/net/minecraft/world/damagesource/DamageSource.java -index bb1a60180e58c1333e7bb33e8acf1b0225eda8a8..4d037e899e0b5548be406ad55acd2062603b7da1 100644 ---- a/src/main/java/net/minecraft/world/damagesource/DamageSource.java -+++ b/src/main/java/net/minecraft/world/damagesource/DamageSource.java -@@ -67,7 +67,7 @@ public class DamageSource { - - public DamageSource customEventDamager(Entity entity) { - if (this.directEntity != null) { -- throw new IllegalStateException("Cannot set custom event damager when direct entity is already set (report a bug to Paper)"); -+ throw new IllegalStateException("Cannot set custom event damager when direct entity is already set (report a bug to Paper, if you think this is a Gale bug, please report it at https://github.com/GaleMC/Gale/issues)"); // Gale - branding changes - } - DamageSource damageSource = this.cloneInstance(); - damageSource.customEventDamager = entity; -diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java -index e40665cead218502b44dd49051a53326ed94f061..cbeebb98622025d35557125e784cd8f0b4fbb751 100644 ---- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java -+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java -@@ -289,7 +289,13 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise - - // Paper start - private static void printOversizedLog(String msg, Path file, int x, int z) { -- org.apache.logging.log4j.LogManager.getLogger().fatal(msg + " (" + file.toString().replaceAll(".+[\\\\/]", "") + " - " + x + "," + z + ") Go clean it up to remove this message. /minecraft:tp " + (x<<4)+" 128 "+(z<<4) + " - DO NOT REPORT THIS TO PAPER - You may ask for help on Discord, but do not file an issue. These error messages can not be removed."); -+ // Gale start - branding changes -+ /* -+ We do not want people to report thread issues to Paper, -+ but we do want people to report thread issues to Gale. -+ */ -+ org.apache.logging.log4j.LogManager.getLogger().fatal(msg + " (" + file.toString().replaceAll(".+[\\\\/]", "") + " - " + x + "," + z + ") Go clean it up to remove this message. /minecraft:tp " + (x<<4)+" 128 "+(z<<4) + " - DO NOT REPORT THIS TO PAPER OR GALE - You may ask for help on Discord, but do not file an issue. These error messages can not be removed. - If you think this is a Gale bug, please report it at https://github.com/GaleMC/Gale/issues)"); -+ // Gale end - branding changes - } - - private static CompoundTag readOversizedChunk(RegionFile regionfile, ChunkPos chunkCoordinate) throws IOException { diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java index 1354ccfbf525e5e64483ac5f443cc2325ba63850..f6bc955c3496b52cda1a20aabd78769803ef471f 100644 --- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java @@ -486,10 +407,10 @@ index 1354ccfbf525e5e64483ac5f443cc2325ba63850..f6bc955c3496b52cda1a20aabd787698 // (async tasks must live with race-conditions if they attempt to cancel between these few lines of code) } diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -index 507f908916cbeb592496f963b46e4c2121a7b5e3..e57be8cbe35fdc2ae41b3a0278d244672a303059 100644 +index 32750451421fc559e9be1d98e6e328ede0049263..ff61452021ac624b481ef1747cfbf3e260eec37a 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -@@ -505,7 +505,7 @@ public final class CraftMagicNumbers implements UnsafeValues { +@@ -513,7 +513,7 @@ public final class CraftMagicNumbers implements UnsafeValues { // Paper start @Override public com.destroystokyo.paper.util.VersionFetcher getVersionFetcher() { @@ -511,253 +432,70 @@ index 774556a62eb240da42e84db4502e2ed43495be17..0b5979723bb30f9011ac64c36d894aa4 Properties properties = new Properties(); if (stream != null) { -diff --git a/src/main/java/org/galemc/gale/version/AbstractPaperVersionFetcher.java b/src/main/java/org/galemc/gale/version/AbstractPaperVersionFetcher.java -new file mode 100644 -index 0000000000000000000000000000000000000000..fab5d5af9ec6a20810ce5e437dd617684cc5768f ---- /dev/null -+++ b/src/main/java/org/galemc/gale/version/AbstractPaperVersionFetcher.java -@@ -0,0 +1,154 @@ -+// Gale - branding changes - version fetcher -+ -+package org.galemc.gale.version; -+ -+import com.destroystokyo.paper.PaperVersionFetcher; -+import com.destroystokyo.paper.VersionHistoryManager; -+import com.destroystokyo.paper.util.VersionFetcher; -+import com.google.common.base.Charsets; -+import com.google.gson.Gson; -+import com.google.gson.JsonObject; -+import com.google.gson.JsonSyntaxException; -+import com.mojang.logging.LogUtils; -+import io.papermc.paper.ServerBuildInfo; -+import net.kyori.adventure.text.Component; -+import net.kyori.adventure.text.event.ClickEvent; -+import net.kyori.adventure.text.format.NamedTextColor; -+import net.kyori.adventure.text.format.TextDecoration; -+import org.jetbrains.annotations.NotNull; -+import org.slf4j.Logger; -+ -+import javax.annotation.Nullable; -+import java.io.BufferedReader; -+import java.io.IOException; -+import java.io.InputStreamReader; -+import java.net.HttpURLConnection; -+import java.net.URI; -+import java.util.Optional; -+ -+import static net.kyori.adventure.text.Component.text; -+import static net.kyori.adventure.text.format.TextColor.color; -+ -+/** -+ * An abstract version fetcher, derived from {@link PaperVersionFetcher}. -+ * This class was then made to be a superclass of both {@link PaperVersionFetcher} -+ * and {@link GaleVersionFetcher}. -+ *
-+ * Changes to {@link PaperVersionFetcher} are indicated by Gale marker comments. -+ */ -+public abstract class AbstractPaperVersionFetcher implements VersionFetcher { -+ protected static final Logger LOGGER = LogUtils.getClassLogger(); -+ protected static final int DISTANCE_ERROR = -1; -+ protected static final int DISTANCE_UNKNOWN = -2; -+ protected static final ServerBuildInfo BUILD_INFO = ServerBuildInfo.buildInfo(); -+ -+ // Gale start - branding changes - version fetcher -+ protected final String gitHubBranchName; -+ protected final String downloadPage; -+ protected final String organizationDisplayName; -+ protected final String projectDisplayName; -+ protected final String gitHubOrganizationName; -+ protected final String gitHubRepoName; -+ -+ protected AbstractPaperVersionFetcher(String githubBranchName, String downloadPage, String organizationDisplayName, String projectDisplayName, String gitHubOrganizationName, String gitHubRepoName) { -+ this.gitHubBranchName = githubBranchName; -+ this.downloadPage = downloadPage; -+ this.organizationDisplayName = organizationDisplayName; -+ this.projectDisplayName = projectDisplayName; -+ this.gitHubOrganizationName = gitHubOrganizationName; -+ this.gitHubRepoName = gitHubRepoName; -+ } -+ // Gale end - branding changes - version fetcher -+ -+ @Override -+ public long getCacheTime() { -+ return 720000; -+ } -+ -+ @Override -+ public @NotNull Component getVersionMessage(final @NotNull String serverVersion) { -+ final Component updateMessage; -+ final ServerBuildInfo build = ServerBuildInfo.buildInfo(); -+ if (build.buildNumber().isEmpty() && build.gitCommit().isEmpty()) { -+ updateMessage = text("You are running a development version without access to version information", color(0xFF5300)); -+ } else { -+ updateMessage = getUpdateStatusMessage(this.gitHubOrganizationName + "/" + this.gitHubRepoName, build); // Gale - branding changes - version fetcher -+ } -+ final @Nullable Component history = this.getHistory(); -+ -+ return history != null ? Component.textOfChildren(updateMessage, Component.newline(), history) : updateMessage; -+ } -+ -+ // Gale start - branding changes - version fetcher -+ protected boolean canFetchDistanceFromSiteApi() { -+ return false; -+ } -+ -+ protected int fetchDistanceFromSiteApi(int jenkinsBuild) { -+ return -1; -+ } -+ // Gale end - branding changes - version fetcher -+ -+ private Component getUpdateStatusMessage(final String repo, final ServerBuildInfo build) { -+ int distance = DISTANCE_ERROR; -+ -+ // Gale start - branding changes - version fetcher -+ final Optional gitBranch = build.gitBranch(); -+ final Optional gitCommit = build.gitCommit(); -+ if (gitBranch.isPresent() && gitCommit.isPresent()) { -+ distance = fetchDistanceFromGitHub(repo, gitBranch.get(), gitCommit.get()); -+ } -+ // Gale end - branding changes - version fetcher -+ -+ return switch (distance) { -+ case DISTANCE_ERROR -> text("Error obtaining version information", NamedTextColor.YELLOW); -+ case 0 -> text("You are running the latest version", NamedTextColor.GREEN); -+ case DISTANCE_UNKNOWN -> text("Unknown version", NamedTextColor.YELLOW); -+ default -> text("You are " + distance + " version(s) behind", NamedTextColor.YELLOW) -+ .append(Component.newline()) -+ .append(text("Download the new version at: ") -+ .append(text(this.downloadPage, NamedTextColor.GOLD) // Gale - branding changes - version fetcher -+ .hoverEvent(text("Click to open", NamedTextColor.WHITE)) -+ .clickEvent(ClickEvent.openUrl(this.downloadPage)))); // Gale - branding changes - version fetcher -+ }; -+ } -+ -+ // Contributed by Techcable in GH-65 -+ private static int fetchDistanceFromGitHub(final String repo, final String branch, final String hash) { -+ try { -+ final HttpURLConnection connection = (HttpURLConnection) URI.create("https://api.github.com/repos/%s/compare/%s...%s".formatted(repo, branch, hash)).toURL().openConnection(); -+ connection.connect(); -+ if (connection.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) -+ return DISTANCE_UNKNOWN; // Unknown commit -+ try (final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), Charsets.UTF_8))) { -+ final JsonObject obj = new Gson().fromJson(reader, JsonObject.class); -+ final String status = obj.get("status").getAsString(); -+ return switch (status) { -+ case "identical" -> 0; -+ case "behind" -> obj.get("behind_by").getAsInt(); -+ default -> DISTANCE_ERROR; -+ }; -+ } catch (final JsonSyntaxException | NumberFormatException e) { -+ LOGGER.error("Error parsing json from GitHub's API", e); -+ return DISTANCE_ERROR; -+ } -+ } catch (final IOException e) { -+ LOGGER.error("Error while parsing version", e); -+ return DISTANCE_ERROR; -+ } -+ } -+ -+ private @Nullable Component getHistory() { -+ final VersionHistoryManager.VersionData data = VersionHistoryManager.INSTANCE.getVersionData(); -+ if (data == null) { -+ return null; -+ } -+ -+ final @Nullable String oldVersion = data.getOldVersion(); -+ if (oldVersion == null) { -+ return null; -+ } -+ -+ return text("Previous version: " + oldVersion, NamedTextColor.GRAY, TextDecoration.ITALIC); -+ } -+} -diff --git a/src/main/java/org/galemc/gale/version/GaleVersionFetcher.java b/src/main/java/org/galemc/gale/version/GaleVersionFetcher.java -new file mode 100644 -index 0000000000000000000000000000000000000000..9a03014be5b95b9f24576e08d533b0b2c4a44fe6 ---- /dev/null -+++ b/src/main/java/org/galemc/gale/version/GaleVersionFetcher.java -@@ -0,0 +1,17 @@ -+// Gale - branding changes - version fetcher -+ -+package org.galemc.gale.version; -+ -+public class GaleVersionFetcher extends AbstractPaperVersionFetcher { -+ -+ public GaleVersionFetcher() { -+ super( -+ "ver/1.21.3", -+ "https://github.com/Dreeam-qwq/Gale", -+ "GaleMC", -+ "Gale", -+ "GaleMC", -+ "Gale"); -+ } -+ -+} diff --git a/src/main/java/org/spigotmc/WatchdogThread.java b/src/main/java/org/spigotmc/WatchdogThread.java -index f7a4fee9bb25ff256dc2e5ea26bfbceca6a49167..08fa6018bcab38d8c9ca05c84e229d69184ce01b 100644 +index a9339f59f81dff307317ae4afdff0dc296febcc9..64e3c7bd0a1ff93dd87e688f9e49e213c8f6670e 100644 --- a/src/main/java/org/spigotmc/WatchdogThread.java +++ b/src/main/java/org/spigotmc/WatchdogThread.java -@@ -155,14 +155,20 @@ public class WatchdogThread extends ca.spottedleaf.moonrise.common.util.TickThre +@@ -77,14 +77,20 @@ public class WatchdogThread extends Thread { if (isLongTimeout) { - // Paper end - log.log( Level.SEVERE, "------------------------------" ); -- log.log( Level.SEVERE, "The server has stopped responding! This is (probably) not a Paper bug." ); // Paper -+ // Gale start - branding changes -+ /* -+ We do not want people to report thread issues to Paper, -+ but we do want people to report thread issues to Gale. -+ */ -+ log.log( Level.SEVERE, "The server has stopped responding! This is (probably) not a Paper bug. This could be a Gale bug." ); // Paper -+ // Gale end - branding changes - log.log( Level.SEVERE, "If you see a plugin in the Server thread dump below, then please report it to that author" ); - log.log( Level.SEVERE, "\t *Especially* if it looks like HTTP or MySQL operations are occurring" ); - log.log( Level.SEVERE, "If you see a world save or edit, then it means you did far more than your server can handle at once" ); - log.log( Level.SEVERE, "\t If this is the case, consider increasing timeout-time in spigot.yml but note that this will replace the crash with LARGE lag spikes" ); -- log.log( Level.SEVERE, "If you are unsure or still think this is a Paper bug, please report this to https://github.com/PaperMC/Paper/issues" ); -+ log.log( Level.SEVERE, "If you are unsure or think this is a Gale bug, please report this to https://github.com/GaleMC/Gale/issues - and if you think this is a Paper bug, please report this to https://github.com/PaperMC/Paper/issues" ); // Gale - branding changes - log.log( Level.SEVERE, "Be sure to include ALL relevant console errors and Minecraft crash reports" ); -- log.log( Level.SEVERE, "Paper version: " + Bukkit.getServer().getVersion() ); -+ log.log( Level.SEVERE, "Gale version: " + Bukkit.getServer().getVersion() ); // Gale - branding changes - // - if ( net.minecraft.world.level.Level.lastPhysicsProblem != null ) - { -@@ -184,12 +190,18 @@ public class WatchdogThread extends ca.spottedleaf.moonrise.common.util.TickThre - // Paper end - } else - { -- log.log(Level.SEVERE, "--- DO NOT REPORT THIS TO PAPER - THIS IS NOT A BUG OR A CRASH - " + Bukkit.getServer().getVersion() + " ---"); + // Paper end + logger.log(Level.SEVERE, "------------------------------"); +- logger.log(Level.SEVERE, "The server has stopped responding! This is (probably) not a Paper bug."); // Paper + // Gale start - branding changes + /* + We do not want people to report thread issues to Paper, + but we do want people to report thread issues to Gale. + */ -+ log.log(Level.SEVERE, "--- DO NOT REPORT THIS TO PAPER - If you think this is a Gale bug, please report it at https://github.com/GaleMC/Gale/issues - THIS IS NOT A PAPER BUG OR CRASH - " + Bukkit.getServer().getVersion() + " ---"); ++ logger.log(Level.SEVERE, "The server has stopped responding! This is (probably) not a Paper bug. This could be a Gale bug."); // Paper + // Gale end - branding changes - log.log(Level.SEVERE, "The server has not responded for " + (currentTime - lastTick) / 1000 + " seconds! Creating thread dump"); - } - // Paper end - Different message for short timeout - log.log( Level.SEVERE, "------------------------------" ); -- log.log( Level.SEVERE, "Server thread dump (Look for plugins here before reporting to Paper!):" ); // Paper -+ log.log( Level.SEVERE, "Server thread dump (Look for plugins here before reporting to Gale!):" ); // Paper // Gale - branding changes - ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ChunkTaskScheduler.dumpAllChunkLoadInfo(MinecraftServer.getServer(), isLongTimeout); // Paper - rewrite chunk system - this.dumpTickingInfo(); // Paper - log detailed tick information - WatchdogThread.dumpThread( ManagementFactory.getThreadMXBean().getThreadInfo( MinecraftServer.getServer().serverThread.getId(), Integer.MAX_VALUE ), log ); -@@ -205,7 +217,13 @@ public class WatchdogThread extends ca.spottedleaf.moonrise.common.util.TickThre - WatchdogThread.dumpThread( thread, log ); - } + logger.log(Level.SEVERE, "If you see a plugin in the Server thread dump below, then please report it to that author"); + logger.log(Level.SEVERE, "\t *Especially* if it looks like HTTP or MySQL operations are occurring"); + logger.log(Level.SEVERE, "If you see a world save or edit, then it means you did far more than your server can handle at once"); + logger.log(Level.SEVERE, "\t If this is the case, consider increasing timeout-time in spigot.yml but note that this will replace the crash with LARGE lag spikes"); +- logger.log(Level.SEVERE, "If you are unsure or still think this is a Paper bug, please report this to https://github.com/PaperMC/Paper/issues"); ++ logger.log(Level.SEVERE, "If you are unsure or think this is a Gale bug, please report this to https://github.com/GaleMC/Gale/issues - and if you think this is a Paper bug, please report this to https://github.com/PaperMC/Paper/issues"); // Gale - branding changes + logger.log(Level.SEVERE, "Be sure to include ALL relevant console errors and Minecraft crash reports"); +- logger.log(Level.SEVERE, "Paper version: " + Bukkit.getServer().getVersion()); ++ logger.log(Level.SEVERE, "Gale version: " + Bukkit.getServer().getVersion()); // Gale - branding changes + + if (net.minecraft.world.level.Level.lastPhysicsProblem != null) { + logger.log(Level.SEVERE, "------------------------------"); +@@ -104,12 +110,18 @@ public class WatchdogThread extends Thread { + } + // Paper end } else { -- log.log(Level.SEVERE, "--- DO NOT REPORT THIS TO PAPER - THIS IS NOT A BUG OR A CRASH ---"); +- logger.log(Level.SEVERE, "--- DO NOT REPORT THIS TO PAPER - THIS IS NOT A BUG OR A CRASH - " + Bukkit.getServer().getVersion() + " ---"); + // Gale start - branding changes + /* + We do not want people to report thread issues to Paper, + but we do want people to report thread issues to Gale. -+ */ -+ log.log(Level.SEVERE, "--- DO NOT REPORT THIS TO PAPER - If you think this is a Gale bug, please report it at https://github.com/GaleMC/Gale/issues - THIS IS NOT A PAPER BUG OR CRASH ---"); ++ */ ++ logger.log(Level.SEVERE, "--- DO NOT REPORT THIS TO PAPER - If you think this is a Gale bug, please report it at https://github.com/GaleMC/Gale/issues - THIS IS NOT A PAPER BUG OR CRASH - " + Bukkit.getServer().getVersion() + " ---"); ++ // Gale end - branding changes + logger.log(Level.SEVERE, "The server has not responded for " + (currentTime - lastTick) / 1000 + " seconds! Creating thread dump"); + } + // Paper end - Different message for short timeout + logger.log(Level.SEVERE, "------------------------------"); +- logger.log(Level.SEVERE, "Server thread dump (Look for plugins here before reporting to Paper!):"); // Paper ++ logger.log(Level.SEVERE, "Server thread dump (Look for plugins here before reporting to Gale!):"); // Paper // Gale - branding changes + FeatureHooks.dumpAllChunkLoadInfo(MinecraftServer.getServer(), isLongTimeout); // Paper - log detailed tick information + WatchdogThread.dumpThread(ManagementFactory.getThreadMXBean().getThreadInfo(MinecraftServer.getServer().serverThread.getId(), Integer.MAX_VALUE), logger); + logger.log(Level.SEVERE, "------------------------------"); +@@ -122,7 +134,13 @@ public class WatchdogThread extends Thread { + WatchdogThread.dumpThread(thread, logger); + } + } else { +- logger.log(Level.SEVERE, "--- DO NOT REPORT THIS TO PAPER - THIS IS NOT A BUG OR A CRASH ---"); ++ // Gale start - branding changes ++ /* ++ We do not want people to report thread issues to Paper, ++ but we do want people to report thread issues to Gale. ++ */ ++ logger.log(Level.SEVERE, "--- DO NOT REPORT THIS TO PAPER - If you think this is a Gale bug, please report it at https://github.com/GaleMC/Gale/issues - THIS IS NOT A PAPER BUG OR CRASH ---"); + // Gale end - branding changes } - log.log( Level.SEVERE, "------------------------------" ); + logger.log(Level.SEVERE, "------------------------------"); diff --git a/src/main/resources/logo.png b/src/main/resources/logo.png index 8b924977b7886df9ab8790b1e4ff9b1c04a2af45..e7e9fd9a6077535b89c6c9d7b0164e8b87c54bed 100644 GIT binary patch diff --git a/patches/server/0006-Gale-metrics.patch b/gale-server/paper-patches/features/0002-Gale-metrics.patch similarity index 98% rename from patches/server/0006-Gale-metrics.patch rename to gale-server/paper-patches/features/0002-Gale-metrics.patch index 29126e8..be909e8 100644 --- a/patches/server/0006-Gale-metrics.patch +++ b/gale-server/paper-patches/features/0002-Gale-metrics.patch @@ -34,10 +34,10 @@ index 632920e04686d8a0fd0a60e87348be1fe7862a3c..ba0dd850f90564fab3a5b922bb28d244 IO_POOL.adjustThreadCount(ioThreads); diff --git a/src/main/java/com/destroystokyo/paper/Metrics.java b/src/main/java/com/destroystokyo/paper/Metrics.java -index 4b002e8b75d117b726b0de274a76d3596fce015b..e848529892c07cad638090a39ef738b4a068db3e 100644 +index 8f62879582195d8ae4f64bd23f752fa133b1c973..8f50cbe29b36e7b73c8c9db491f4dd21a886f45d 100644 --- a/src/main/java/com/destroystokyo/paper/Metrics.java +++ b/src/main/java/com/destroystokyo/paper/Metrics.java -@@ -593,7 +593,7 @@ public class Metrics { +@@ -592,7 +592,7 @@ public class Metrics { boolean logFailedRequests = config.getBoolean("logFailedRequests", false); // Only start Metrics, if it's enabled in the config if (config.getBoolean("enabled", true)) { @@ -46,7 +46,7 @@ index 4b002e8b75d117b726b0de274a76d3596fce015b..e848529892c07cad638090a39ef738b4 metrics.addCustomChart(new Metrics.SimplePie("minecraft_version", () -> { String minecraftVersion = Bukkit.getVersion(); -@@ -603,20 +603,20 @@ public class Metrics { +@@ -602,20 +602,20 @@ public class Metrics { metrics.addCustomChart(new Metrics.SingleLineChart("players", () -> Bukkit.getOnlinePlayers().size())); metrics.addCustomChart(new Metrics.SimplePie("online_mode", () -> Bukkit.getOnlineMode() ? "online" : "offline")); @@ -73,7 +73,7 @@ index 4b002e8b75d117b726b0de274a76d3596fce015b..e848529892c07cad638090a39ef738b4 entry.put(javaVersion, 1); // http://openjdk.java.net/jeps/223 -@@ -645,7 +645,7 @@ public class Metrics { +@@ -644,7 +644,7 @@ public class Metrics { })); metrics.addCustomChart(new Metrics.DrilldownPie("legacy_plugins", () -> { @@ -82,7 +82,7 @@ index 4b002e8b75d117b726b0de274a76d3596fce015b..e848529892c07cad638090a39ef738b4 // count legacy plugins int legacy = 0; -@@ -656,7 +656,7 @@ public class Metrics { +@@ -655,7 +655,7 @@ public class Metrics { } // insert real value as lower dimension @@ -91,7 +91,7 @@ index 4b002e8b75d117b726b0de274a76d3596fce015b..e848529892c07cad638090a39ef738b4 entry.put(String.valueOf(legacy), 1); // create buckets as higher dimension -@@ -676,6 +676,256 @@ public class Metrics { +@@ -675,6 +675,256 @@ public class Metrics { return map; })); diff --git a/gale-server/paper-patches/features/0003-Gale-semantic-version.patch b/gale-server/paper-patches/features/0003-Gale-semantic-version.patch new file mode 100644 index 0000000..8862cba --- /dev/null +++ b/gale-server/paper-patches/features/0003-Gale-semantic-version.patch @@ -0,0 +1,29 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Wed, 9 Aug 2023 19:04:22 +0200 +Subject: [PATCH] Gale semantic version + +License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) +Gale - https://galemc.org + +diff --git a/src/main/java/com/destroystokyo/paper/Metrics.java b/src/main/java/com/destroystokyo/paper/Metrics.java +index 8f50cbe29b36e7b73c8c9db491f4dd21a886f45d..59e4ea913ee34d133e74be50ad3f35606354db43 100644 +--- a/src/main/java/com/destroystokyo/paper/Metrics.java ++++ b/src/main/java/com/destroystokyo/paper/Metrics.java +@@ -925,6 +925,16 @@ public class Metrics { + })); + // Gale end - metrics - runtime max memory + ++ // Gale start - semantic version - include in metrics ++ Map> semanticVersionMap = new HashMap<>(2); ++ { ++ Map entry = new HashMap<>(2); ++ entry.put(org.galemc.gale.version.GaleSemanticVersion.version, 1); ++ semanticVersionMap.put(org.galemc.gale.version.GaleSemanticVersion.majorMinorVersion, entry); ++ } ++ metrics.addCustomChart(new Metrics.DrilldownPie("gale_semantic_version", () -> semanticVersionMap)); ++ // Gale end - semantic version - include in metrics ++ + } + + } diff --git a/gale-server/paper-patches/features/0004-Gale-configuration.patch b/gale-server/paper-patches/features/0004-Gale-configuration.patch new file mode 100644 index 0000000..07fd31a --- /dev/null +++ b/gale-server/paper-patches/features/0004-Gale-configuration.patch @@ -0,0 +1,172 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Wed, 23 Nov 2022 21:05:47 +0100 +Subject: [PATCH] Gale configuration + +License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) +Gale - https://galemc.org + +This patch is based on the following patch: +"Paper config files" +By: Jake Potrebic +As part of: Paper (https://github.com/PaperMC/Paper) +Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) + +diff --git a/src/main/java/io/papermc/paper/configuration/Configurations.java b/src/main/java/io/papermc/paper/configuration/Configurations.java +index 109e569b7ba6419d60c6490b588937579b4f6878..6b453e3f97629f52c491a0caf79c27a3078aefb7 100644 +--- a/src/main/java/io/papermc/paper/configuration/Configurations.java ++++ b/src/main/java/io/papermc/paper/configuration/Configurations.java +@@ -94,7 +94,7 @@ public abstract class Configurations { + }; + } + +- static CheckedFunction reloader(Class type, T instance) { ++ public static CheckedFunction reloader(Class type, T instance) { // Gale - Gale configuration + return node -> { + ObjectMapper.Factory factory = (ObjectMapper.Factory) Objects.requireNonNull(node.options().serializers().get(type)); + ObjectMapper.Mutable mutable = (ObjectMapper.Mutable) factory.get(type); +@@ -168,7 +168,7 @@ public abstract class Configurations { + final YamlConfigurationLoader loader = result.loader(); + final ConfigurationNode node = loader.load(); + if (result.isNewFile()) { // add version to new files +- node.node(Configuration.VERSION_FIELD).raw(this.worldConfigVersion()); ++ node.node(Configuration.VERSION_FIELD).raw(getWorldConfigurationCurrentVersion()); // Gale - Gale configuration + } else { + this.verifyWorldConfigVersion(contextMap, node); + } +@@ -230,7 +230,7 @@ public abstract class Configurations { + .build(); + final ConfigurationNode worldNode = worldLoader.load(); + if (newFile) { // set the version field if new file +- worldNode.node(Configuration.VERSION_FIELD).set(this.worldConfigVersion()); ++ worldNode.node(Configuration.VERSION_FIELD).set(getWorldConfigurationCurrentVersion()); // Gale - Gale configuration + } else { + this.verifyWorldConfigVersion(contextMap, worldNode); + } +@@ -356,4 +356,25 @@ public abstract class Configurations { + return "ContextKey{" + this.name + "}"; + } + } ++ ++ // Gale start - Gale configuration ++ ++ public static final String legacyWorldsSectionKey = "__________WORLDS__________"; ++ public static final String legacyWorldDefaultsSectionKey = "__defaults__"; ++ ++ @Deprecated ++ public org.bukkit.configuration.file.YamlConfiguration createLegacyObject(final net.minecraft.server.MinecraftServer server) { ++ org.bukkit.configuration.file.YamlConfiguration global = org.bukkit.configuration.file.YamlConfiguration.loadConfiguration(this.globalFolder.resolve(this.globalConfigFileName).toFile()); ++ org.bukkit.configuration.ConfigurationSection worlds = global.createSection(legacyWorldsSectionKey); ++ worlds.set(legacyWorldDefaultsSectionKey, org.bukkit.configuration.file.YamlConfiguration.loadConfiguration(this.globalFolder.resolve(this.defaultWorldConfigFileName).toFile())); ++ for (ServerLevel level : server.getAllLevels()) { ++ worlds.set(level.getWorld().getName(), org.bukkit.configuration.file.YamlConfiguration.loadConfiguration(getWorldConfigFile(level).toFile())); ++ } ++ return global; ++ } ++ ++ public abstract int getWorldConfigurationCurrentVersion(); ++ ++ // Gale end - Gale configuration ++ + } +diff --git a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java +index 098ab351de4f84cdc943ebe855dd0022174e1e67..7a67e244cb1cd508a703ecdff5a6ab6ab07ac32b 100644 +--- a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java ++++ b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java +@@ -326,7 +326,7 @@ public class PaperConfigurations extends Configurations globalConfig() { ++ // Gale start - Gale configuration ++ public static FieldDiscoverer galeWorldConfig(io.papermc.paper.configuration.Configurations.ContextMap contextMap) { ++ final Map, Object> overrides = Map.of( ++ org.galemc.gale.configuration.GaleWorldConfiguration.class, new org.galemc.gale.configuration.GaleWorldConfiguration( ++ contextMap.require(io.papermc.paper.configuration.PaperConfigurations.SPIGOT_WORLD_CONFIG_CONTEXT_KEY).get(), ++ contextMap.require(io.papermc.paper.configuration.Configurations.WORLD_KEY) ++ ) ++ ); ++ return new InnerClassFieldDiscoverer(overrides); ++ } ++ // Gale end - Gale configuration ++ ++ public static FieldDiscoverer globalConfig() { // Gale - Gale configuration + return new InnerClassFieldDiscoverer(Collections.emptyMap()); + } + } +diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java +index 381448d8ebd7beaae4be45cd18509042d39fb047..c8a3733d4a964ee10eaafd90657a11d91ef8bca4 100644 +--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java ++++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java +@@ -1086,6 +1086,7 @@ public final class CraftServer implements Server { + + org.spigotmc.SpigotConfig.init((File) this.console.options.valueOf("spigot-settings")); // Spigot + this.console.paperConfigurations.reloadConfigs(this.console); ++ this.console.galeConfigurations.reloadConfigs(this.console); // Gale - Gale configuration + for (ServerLevel world : this.console.getAllLevels()) { + // world.serverLevelData.setDifficulty(config.difficulty); // Paper - per level difficulty + world.setSpawnSettings(world.serverLevelData.getDifficulty() != Difficulty.PEACEFUL && config.spawnMonsters); // Paper - per level difficulty (from MinecraftServer#setDifficulty(ServerLevel, Difficulty, boolean)) +@@ -3049,6 +3050,14 @@ public final class CraftServer implements Server { + return CraftServer.this.console.paperConfigurations.createLegacyObject(CraftServer.this.console); + } + ++ // Gale start - Gale configuration - API ++ @Override ++ public YamlConfiguration getGaleConfig() ++ { ++ return CraftServer.this.console.galeConfigurations.createLegacyObject(CraftServer.this.console); ++ } ++ // Gale end - Gale configuration - API ++ + @Override + public void restart() { + org.spigotmc.RestartCommand.restart(); diff --git a/patches/server/0009-Set-Gale-permissions-root.patch b/gale-server/paper-patches/features/0005-Set-Gale-permissions-root.patch similarity index 90% rename from patches/server/0009-Set-Gale-permissions-root.patch rename to gale-server/paper-patches/features/0005-Set-Gale-permissions-root.patch index 5d6fcb6..fa854b1 100644 --- a/patches/server/0009-Set-Gale-permissions-root.patch +++ b/gale-server/paper-patches/features/0005-Set-Gale-permissions-root.patch @@ -7,7 +7,7 @@ License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) Gale - https://galemc.org diff --git a/src/main/java/org/bukkit/craftbukkit/util/permissions/CraftDefaultPermissions.java b/src/main/java/org/bukkit/craftbukkit/util/permissions/CraftDefaultPermissions.java -index 8e06bc11fb28baee3407bbfe9d7b3689d6f85ff2..2e23147f807c6620b54d3047fe24a3847900712c 100644 +index e0e61115ada9a49d4c528c5d4e02a1ca571d9531..0a808c5d242b2d9bea82d9d219227fbaf5741bf4 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/permissions/CraftDefaultPermissions.java +++ b/src/main/java/org/bukkit/craftbukkit/util/permissions/CraftDefaultPermissions.java @@ -5,6 +5,7 @@ import org.bukkit.util.permissions.DefaultPermissions; diff --git a/gale-server/paper-patches/features/0006-Simpler-ShapelessRecipe-comparison-for-vanilla.patch b/gale-server/paper-patches/features/0006-Simpler-ShapelessRecipe-comparison-for-vanilla.patch new file mode 100644 index 0000000..7677a7c --- /dev/null +++ b/gale-server/paper-patches/features/0006-Simpler-ShapelessRecipe-comparison-for-vanilla.patch @@ -0,0 +1,50 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Wed, 23 Nov 2022 16:22:47 +0100 +Subject: [PATCH] Simpler ShapelessRecipe comparison for vanilla + +License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) +Gale - https://galemc.org + +This patch is based on the following patch: +"Simpler ShapelessRecipes comparison for Vanilla" +By: Paul Sauve +As part of: Airplane (https://github.com/TECHNOVE/Airplane) +Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) + +* Airplane description * + +Paper added a fancy sorting comparison due to Bukkit recipes breaking +the vanilla one, however this is far more advanced than what you need +for all the vanilla recipes. + +* Airplane copyright * + +Airplane +Copyright (C) 2020 Technove LLC + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . + +diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java +index 7c989318dc7ad89bb0d9143fcaac1e4bba6f5907..a90b294a99072ab576e61ddacb60a036cb7f0f5a 100644 +--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java ++++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java +@@ -44,6 +44,6 @@ public class CraftShapelessRecipe extends ShapelessRecipe implements CraftRecipe + data.add(this.toNMS(i, true)); + } + +- MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftRecipe.toMinecraft(this.getKey()), new net.minecraft.world.item.crafting.ShapelessRecipe(this.getGroup(), CraftRecipe.getCategory(this.getCategory()), CraftItemStack.asNMSCopy(this.getResult()), data))); ++ MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftRecipe.toMinecraft(this.getKey()), new net.minecraft.world.item.crafting.ShapelessRecipe(this.getGroup(), CraftRecipe.getCategory(this.getCategory()), CraftItemStack.asNMSCopy(this.getResult()), data, true))); // Gale - Airplane - simpler ShapelessRecipe comparison for vanilla + } + } diff --git a/patches/server/0023-Print-stack-trace-for-plugins-not-shutting-down-task.patch b/gale-server/paper-patches/features/0007-Print-stack-trace-for-plugins-not-shutting-down-task.patch similarity index 96% rename from patches/server/0023-Print-stack-trace-for-plugins-not-shutting-down-task.patch rename to gale-server/paper-patches/features/0007-Print-stack-trace-for-plugins-not-shutting-down-task.patch index d1f23f1..7175d65 100644 --- a/patches/server/0023-Print-stack-trace-for-plugins-not-shutting-down-task.patch +++ b/gale-server/paper-patches/features/0007-Print-stack-trace-for-plugins-not-shutting-down-task.patch @@ -31,7 +31,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 269e3937b4ad1bdf04faa214245a2accbdc3a225..50ca138f183529b71790c6c458e1b815c04d4971 100644 +index c8a3733d4a964ee10eaafd90657a11d91ef8bca4..153ed5bbd2142ea5b36c7d8b1147ec464545d4be 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -1180,6 +1180,13 @@ public final class CraftServer implements Server { diff --git a/patches/server/0030-SIMD-support.patch b/gale-server/paper-patches/features/0008-SIMD-support.patch similarity index 53% rename from patches/server/0030-SIMD-support.patch rename to gale-server/paper-patches/features/0008-SIMD-support.patch index fb71054..42b5f9c 100644 --- a/patches/server/0030-SIMD-support.patch +++ b/gale-server/paper-patches/features/0008-SIMD-support.patch @@ -12,31 +12,11 @@ By: Kevin Raneri As part of: Pufferfish (https://github.com/pufferfish-gg/Pufferfish) Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) -diff --git a/build.gradle.kts b/build.gradle.kts -index e3bed8a7f6a9b985c28551b2dfb03456b802380d..579877ba9bf17f40313c05ad5b1b219cf4b59ab3 100644 ---- a/build.gradle.kts -+++ b/build.gradle.kts -@@ -92,6 +92,7 @@ tasks.withType { - compilerArgs.add("-Xlint:-module") - compilerArgs.add("-Xlint:-removal") - compilerArgs.add("-Xlint:-dep-ann") -+ compilerArgs.add("--add-modules=jdk.incubator.vector") // Gale - Pufferfish - SIMD support - } - // Gale end - hide irrelevant compilation warnings - -@@ -210,6 +211,7 @@ fun TaskContainer.registerRunTask( - minHeapSize = "${memoryGb}G" - maxHeapSize = "${memoryGb}G" - jvmArgs("--enable-preview") // Gale - enable preview features for development runs -+ jvmArgs("--add-modules=jdk.incubator.vector") // Gale - Pufferfish - SIMD support - - doFirst { - workingDir.mkdirs() diff --git a/src/main/java/com/destroystokyo/paper/Metrics.java b/src/main/java/com/destroystokyo/paper/Metrics.java -index cb9e42fea57856f9ab649e33df26071db1b7790f..1f158ed7ed5c115e892311d5f72a9131659f9d65 100644 +index 59e4ea913ee34d133e74be50ad3f35606354db43..dbe3d8748c1e6fbad7ee4ccf39dfc0422b0ce50b 100644 --- a/src/main/java/com/destroystokyo/paper/Metrics.java +++ b/src/main/java/com/destroystokyo/paper/Metrics.java -@@ -936,6 +936,46 @@ public class Metrics { +@@ -935,6 +935,46 @@ public class Metrics { metrics.addCustomChart(new Metrics.DrilldownPie("gale_semantic_version", () -> semanticVersionMap)); // Gale end - semantic version - include in metrics @@ -83,40 +63,3 @@ index cb9e42fea57856f9ab649e33df26071db1b7790f..1f158ed7ed5c115e892311d5f72a9131 } } -diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -index bd3a4bb0192d2af4868bcd96b1b6205c4b05fe20..d0da1451d41a6b4eee0abc54d93912d432aa05d1 100644 ---- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -@@ -242,6 +242,13 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface - com.destroystokyo.paper.Metrics.PaperMetrics.startMetrics(); // Paper - start metrics - com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // Paper - load version history now - -+ // Gale start - Pufferfish - SIMD support -+ // Initialize vectorization -+ try { -+ gg.pufferfish.pufferfish.simd.SIMDDetection.initialize(); -+ } catch (Throwable ignored) {} -+ // Gale end - Pufferfish - SIMD support -+ - this.setPvpAllowed(dedicatedserverproperties.pvp); - this.setFlightAllowed(dedicatedserverproperties.allowFlight); - this.setMotd(dedicatedserverproperties.motd); -diff --git a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -index 8f8fd98f96cd390ba43033521982a13044df91cf..d46f952e5e425eb90f8c435276bfc4542e85f6a7 100644 ---- a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -+++ b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -@@ -25,6 +25,14 @@ public class GaleGlobalConfiguration extends ConfigurationPart { - - public int dummyValue = 0; - -+ // Gale start - Pufferfish - SIMD support -+ public Simd simd; -+ public class Simd extends ConfigurationPart { -+ public boolean warnIfDisabled = true; -+ public boolean logVectorSizesToConsole = false; -+ } -+ // Gale end - Pufferfish - SIMD support -+ - } - - } diff --git a/patches/server/0031-Make-book-writing-configurable.patch b/gale-server/paper-patches/features/0009-Make-book-writing-configurable.patch similarity index 56% rename from patches/server/0031-Make-book-writing-configurable.patch rename to gale-server/paper-patches/features/0009-Make-book-writing-configurable.patch index 82e5e0d..51f555b 100644 --- a/patches/server/0031-Make-book-writing-configurable.patch +++ b/gale-server/paper-patches/features/0009-Make-book-writing-configurable.patch @@ -21,22 +21,6 @@ the ability for non-privileged players to edit books. This patch allows you to easily disable books, should you want to preemptively remove this functionality before additional exploits are found. -diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index b5d5dbc50a7b8c40739a15f164ffd08fdc534f9c..c13aadf03462faf04bf0fc50525a130112debdff 100644 ---- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -1172,6 +1172,11 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl - - @Override - public void handleEditBook(ServerboundEditBookPacket packet) { -+ // Gale start - Pufferfish - make book writing configurable -+ if (!(org.galemc.gale.configuration.GaleGlobalConfiguration.get().gameplayMechanics.enableBookWriting || this.player.getBukkitEntity().hasPermission(org.bukkit.craftbukkit.util.permissions.CraftDefaultPermissions.writeBooks) || this.player.getBukkitEntity().hasPermission("pufferfish.usebooks"))) { -+ return; -+ } -+ // Gale end - Pufferfish - make book writing configurable - // Paper start - Book size limits - final io.papermc.paper.configuration.type.number.IntOr.Disabled pageMax = io.papermc.paper.configuration.GlobalConfiguration.get().itemValidation.bookSize.pageMax; - if (!this.cserver.isPrimaryThread() && pageMax.enabled()) { diff --git a/src/main/java/org/bukkit/craftbukkit/util/permissions/CraftDefaultPermissions.java b/src/main/java/org/bukkit/craftbukkit/util/permissions/CraftDefaultPermissions.java index 0a808c5d242b2d9bea82d9d219227fbaf5741bf4..7d66126c1f5957c109a2426d53f5d0072886309b 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/permissions/CraftDefaultPermissions.java @@ -58,18 +42,3 @@ index 0a808c5d242b2d9bea82d9d219227fbaf5741bf4..7d66126c1f5957c109a2426d53f5d007 parent.recalculatePermissibles(); } } -diff --git a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -index d46f952e5e425eb90f8c435276bfc4542e85f6a7..d180ea6099d8fed3cf19f0f32bbfced7df57c9d7 100644 ---- a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -+++ b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -@@ -35,4 +35,10 @@ public class GaleGlobalConfiguration extends ConfigurationPart { - - } - -+ public GameplayMechanics gameplayMechanics; -+ public class GameplayMechanics extends ConfigurationPart { -+ -+ public boolean enableBookWriting = true; // Gale - Pufferfish - make book writing configurable -+ -+ } - } diff --git a/patches/server/0032-Optimize-entity-coordinate-key.patch b/gale-server/paper-patches/features/0010-Optimize-entity-coordinate-key.patch similarity index 71% rename from patches/server/0032-Optimize-entity-coordinate-key.patch rename to gale-server/paper-patches/features/0010-Optimize-entity-coordinate-key.patch index d2ee24a..34ed20f 100644 --- a/patches/server/0032-Optimize-entity-coordinate-key.patch +++ b/gale-server/paper-patches/features/0010-Optimize-entity-coordinate-key.patch @@ -34,16 +34,3 @@ index 31b92bd48828cbea25b44a9f0f96886347aa1ae6..036c1a287db04c0191e5f84b027ea68d } public static long getChunkKey(final ChunkPos pos) { -diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 44028368322ac91a4f6848f632d51d34269cb64a..d7c0a78c17de70037cca43bea758edcbe457cd73 100644 ---- a/src/main/java/net/minecraft/world/entity/Entity.java -+++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -272,7 +272,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess - public double yo; - public double zo; - private Vec3 position; -- private BlockPos blockPosition; -+ public BlockPos blockPosition; // Gale - Pufferfish - optimize entity coordinate key - private -> public - private ChunkPos chunkPosition; - private Vec3 deltaMovement; - private float yRot; diff --git a/patches/server/0046-Do-not-log-legacy-Material-initialization.patch b/gale-server/paper-patches/features/0011-Do-not-log-legacy-Material-initialization.patch similarity index 73% rename from patches/server/0046-Do-not-log-legacy-Material-initialization.patch rename to gale-server/paper-patches/features/0011-Do-not-log-legacy-Material-initialization.patch index 2a7ca8d..e243b5d 100644 --- a/patches/server/0046-Do-not-log-legacy-Material-initialization.patch +++ b/gale-server/paper-patches/features/0011-Do-not-log-legacy-Material-initialization.patch @@ -49,15 +49,3 @@ index 51ae8eddadc87b143b93521a3cef374f1e3a24dc..eed2d01c4f884c3aafdef21741fc1a2e if (MinecraftServer.getServer() != null && MinecraftServer.getServer().isDebugging()) { new Exception().printStackTrace(); } -diff --git a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -index 360c48ce9f64e7bbfadd56ce4fa2b78c4787734d..3ad96a516ef51858b91e2c95fd4e923522a93246 100644 ---- a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -+++ b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -@@ -55,6 +55,7 @@ public class GaleGlobalConfiguration extends ConfigurationPart { - public boolean ignoredAdvancements = true; // Gale - Purpur - do not log ignored advancements - public boolean setBlockInFarChunk = true; // Gale - Purpur - do not log setBlock in far chunks - public boolean unrecognizedRecipes = false; // Gale - Purpur - do not log unrecognized recipes -+ public boolean legacyMaterialInitialization = false; // Gale - Purpur - do not log legacy Material initialization - - public Chat chat; - public class Chat extends ConfigurationPart { diff --git a/gale-server/paper-patches/features/0012-Do-not-log-Not-Secure-marker.patch b/gale-server/paper-patches/features/0012-Do-not-log-Not-Secure-marker.patch new file mode 100644 index 0000000..dd6abc0 --- /dev/null +++ b/gale-server/paper-patches/features/0012-Do-not-log-Not-Secure-marker.patch @@ -0,0 +1,21 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Fri, 25 Nov 2022 15:13:38 +0100 +Subject: [PATCH] Do not log Not Secure marker + +License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) +Gale - https://galemc.org + +diff --git a/src/main/java/io/papermc/paper/adventure/ChatProcessor.java b/src/main/java/io/papermc/paper/adventure/ChatProcessor.java +index 14e412ebf75b0e06ab53a1c8f9dd1be6ad1e2680..506c746980cfca170efd249d035a572361b667c4 100644 +--- a/src/main/java/io/papermc/paper/adventure/ChatProcessor.java ++++ b/src/main/java/io/papermc/paper/adventure/ChatProcessor.java +@@ -317,7 +317,7 @@ public final class ChatProcessor { + + private void sendToServer(final ChatType.Bound chatType, final @Nullable Function msgFunction) { + final PlayerChatMessage toConsoleMessage = msgFunction == null ? ChatProcessor.this.message : ChatProcessor.this.message.withUnsignedContent(msgFunction.apply(ChatProcessor.this.server.console)); +- ChatProcessor.this.server.logChatMessage(toConsoleMessage.decoratedContent(), chatType, ChatProcessor.this.server.getPlayerList().verifyChatTrusted(toConsoleMessage) ? null : "Not Secure"); ++ ChatProcessor.this.server.logChatMessage(toConsoleMessage.decoratedContent(), chatType, !org.galemc.gale.configuration.GaleGlobalConfiguration.get().logToConsole.chat.notSecureMarker || ChatProcessor.this.server.getPlayerList().verifyChatTrusted(toConsoleMessage) ? null : "Not Secure"); // Gale - do not log Not Secure marker + } + } + diff --git a/gale-server/paper-patches/features/0013-Reduce-array-allocations.patch b/gale-server/paper-patches/features/0013-Reduce-array-allocations.patch new file mode 100644 index 0000000..a0f7197 --- /dev/null +++ b/gale-server/paper-patches/features/0013-Reduce-array-allocations.patch @@ -0,0 +1,168 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Sat, 26 Nov 2022 11:25:45 +0100 +Subject: [PATCH] Reduce array allocations + +License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) +Gale - https://galemc.org + +This patch is based on the following patch: +"reduce allocs" +By: Simon Gardling +As part of: JettPack (https://gitlab.com/Titaniumtown/JettPack) +Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) + +diff --git a/src/main/java/ca/spottedleaf/moonrise/common/list/EntityList.java b/src/main/java/ca/spottedleaf/moonrise/common/list/EntityList.java +index 7fed43a1e7bcf35c4d7fd3224837a47fedd59860..adc47f1ca3580a6968d145239ae830734a0ebe4a 100644 +--- a/src/main/java/ca/spottedleaf/moonrise/common/list/EntityList.java ++++ b/src/main/java/ca/spottedleaf/moonrise/common/list/EntityList.java +@@ -18,9 +18,7 @@ public final class EntityList implements Iterable { + this.entityToIndex.defaultReturnValue(Integer.MIN_VALUE); + } + +- private static final Entity[] EMPTY_LIST = new Entity[0]; +- +- private Entity[] entities = EMPTY_LIST; ++ private Entity[] entities = me.titaniumtown.ArrayConstants.emptyEntityArray; // Gale - JettPack - reduce array allocations + private int count; + + public int size() { +diff --git a/src/main/java/ca/spottedleaf/moonrise/common/list/IntList.java b/src/main/java/ca/spottedleaf/moonrise/common/list/IntList.java +index 9f3b25bb2439f283f878db93973a02fcdcd14eed..4eb7bf187276f07f807fe181b303dda8e1b9196d 100644 +--- a/src/main/java/ca/spottedleaf/moonrise/common/list/IntList.java ++++ b/src/main/java/ca/spottedleaf/moonrise/common/list/IntList.java +@@ -10,9 +10,7 @@ public final class IntList { + this.map.defaultReturnValue(Integer.MIN_VALUE); + } + +- private static final int[] EMPTY_LIST = new int[0]; +- +- private int[] byIndex = EMPTY_LIST; ++ private int[] byIndex = me.titaniumtown.ArrayConstants.emptyIntArray; // Gale - JettPack - reduce array allocations + private int count; + + public int size() { +diff --git a/src/main/java/ca/spottedleaf/moonrise/common/list/ReferenceList.java b/src/main/java/ca/spottedleaf/moonrise/common/list/ReferenceList.java +index 2e876b918672e8ef3b5197b7e6b1597247fdeaa1..8df9406b77eb3c225ebf88bf76a7adb666452f3b 100644 +--- a/src/main/java/ca/spottedleaf/moonrise/common/list/ReferenceList.java ++++ b/src/main/java/ca/spottedleaf/moonrise/common/list/ReferenceList.java +@@ -7,14 +7,12 @@ import java.util.NoSuchElementException; + + public final class ReferenceList implements Iterable { + +- private static final Object[] EMPTY_LIST = new Object[0]; +- + private final Reference2IntOpenHashMap referenceToIndex; + private E[] references; + private int count; + + public ReferenceList() { +- this((E[])EMPTY_LIST); ++ this((E[]) me.titaniumtown.ArrayConstants.emptyObjectArray); // Gale - JettPack - reduce array allocations + } + + public ReferenceList(final E[] referenceArray) { +diff --git a/src/main/java/ca/spottedleaf/moonrise/common/list/ShortList.java b/src/main/java/ca/spottedleaf/moonrise/common/list/ShortList.java +index 2bae9949ef325d0001aa638150fbbdf968367e75..a72d5db6f6a8667c5c839016033bba4d0f16cf13 100644 +--- a/src/main/java/ca/spottedleaf/moonrise/common/list/ShortList.java ++++ b/src/main/java/ca/spottedleaf/moonrise/common/list/ShortList.java +@@ -10,9 +10,7 @@ public final class ShortList { + this.map.defaultReturnValue(Short.MIN_VALUE); + } + +- private static final short[] EMPTY_LIST = new short[0]; +- +- private short[] byIndex = EMPTY_LIST; ++ private short[] byIndex = me.titaniumtown.ArrayConstants.emptyShortArray; // Gale - JettPack - reduce array allocations + private short count; + + public int size() { +diff --git a/src/main/java/ca/spottedleaf/moonrise/common/list/SortedList.java b/src/main/java/ca/spottedleaf/moonrise/common/list/SortedList.java +index db92261a6cb3758391108361096417c61bc82cdc..1a14fddb36ca3c14d243304db629d0c5aac3906c 100644 +--- a/src/main/java/ca/spottedleaf/moonrise/common/list/SortedList.java ++++ b/src/main/java/ca/spottedleaf/moonrise/common/list/SortedList.java +@@ -6,14 +6,12 @@ import java.util.Comparator; + + public final class SortedList { + +- private static final Object[] EMPTY_LIST = new Object[0]; +- + private Comparator comparator; + private E[] elements; + private int count; + + public SortedList(final Comparator comparator) { +- this((E[])EMPTY_LIST, comparator); ++ this((E[]) me.titaniumtown.ArrayConstants.emptyObjectArray, comparator); // Gale - JettPack - reduce array allocations + } + + public SortedList(final E[] elements, final Comparator comparator) { +diff --git a/src/main/java/io/papermc/paper/command/brigadier/PaperCommands.java b/src/main/java/io/papermc/paper/command/brigadier/PaperCommands.java +index 95d3b42cbe2184b0a04d941f27f7a6e643ef59be..e0dad3b61402b309084a464bc3dfdb80043e69eb 100644 +--- a/src/main/java/io/papermc/paper/command/brigadier/PaperCommands.java ++++ b/src/main/java/io/papermc/paper/command/brigadier/PaperCommands.java +@@ -195,7 +195,7 @@ public class PaperCommands implements Commands, PaperRegistrar { +- basicCommand.execute(stack.getSource(), new String[0]); ++ basicCommand.execute(stack.getSource(), me.titaniumtown.ArrayConstants.emptyStringArray); // Gale - JettPack - reduce array allocations + return com.mojang.brigadier.Command.SINGLE_SUCCESS; + }); + +diff --git a/src/main/java/io/papermc/paper/command/subcommands/VersionCommand.java b/src/main/java/io/papermc/paper/command/subcommands/VersionCommand.java +index ae60bd96b5284d54676d8e7e4dd5d170b526ec1e..89562a86cd33ea2b55b284f77dc5d903ee21a49b 100644 +--- a/src/main/java/io/papermc/paper/command/subcommands/VersionCommand.java ++++ b/src/main/java/io/papermc/paper/command/subcommands/VersionCommand.java +@@ -14,7 +14,7 @@ public final class VersionCommand implements PaperSubcommand { + public boolean execute(final CommandSender sender, final String subCommand, final String[] args) { + final @Nullable Command ver = MinecraftServer.getServer().server.getCommandMap().getCommand("version"); + if (ver != null) { +- ver.execute(sender, "paper", new String[0]); ++ ver.execute(sender, "paper", me.titaniumtown.ArrayConstants.emptyStringArray); // Gale - JettPack - reduce array allocations + } + return true; + } +diff --git a/src/main/java/org/bukkit/craftbukkit/CraftEquipmentSlot.java b/src/main/java/org/bukkit/craftbukkit/CraftEquipmentSlot.java +index ae86c45c1d49c7646c721991910592091e7333f8..1368191d6f76d1b4246b1bae7d5afdda44050965 100644 +--- a/src/main/java/org/bukkit/craftbukkit/CraftEquipmentSlot.java ++++ b/src/main/java/org/bukkit/craftbukkit/CraftEquipmentSlot.java +@@ -7,8 +7,10 @@ import org.bukkit.inventory.EquipmentSlot; + + public class CraftEquipmentSlot { + +- private static final net.minecraft.world.entity.EquipmentSlot[] slots = new net.minecraft.world.entity.EquipmentSlot[EquipmentSlot.values().length]; +- private static final EquipmentSlot[] enums = new EquipmentSlot[net.minecraft.world.entity.EquipmentSlot.values().length]; ++ // Gale start - JettPack - reduce array allocations ++ private static final net.minecraft.world.entity.EquipmentSlot[] slots = net.minecraft.world.entity.EquipmentSlot.VALUES_ARRAY; ++ private static final EquipmentSlot[] enums = new EquipmentSlot[net.minecraft.world.entity.EquipmentSlot.VALUES.size()]; ++ // Gale end - JettPack - reduce array allocations + + static { + set(EquipmentSlot.HAND, net.minecraft.world.entity.EquipmentSlot.MAINHAND); +diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftEntityEquipment.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftEntityEquipment.java +index fdcc414f4fa246082ad0732133c870d915ae3084..33ed515d6e79c4135f3e7bbc25fd0e3d83d08540 100644 +--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftEntityEquipment.java ++++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftEntityEquipment.java +@@ -165,7 +165,7 @@ public class CraftEntityEquipment implements EntityEquipment { + + @Override + public void clear() { +- for (net.minecraft.world.entity.EquipmentSlot slot : net.minecraft.world.entity.EquipmentSlot.values()) { ++ for (net.minecraft.world.entity.EquipmentSlot slot : net.minecraft.world.entity.EquipmentSlot.VALUES) { // Gale - JettPack - reduce array allocations + this.setEquipment(slot, null, false); + } + } +diff --git a/src/main/java/org/bukkit/craftbukkit/util/WeakCollection.java b/src/main/java/org/bukkit/craftbukkit/util/WeakCollection.java +index b25dc23b81687dd4d4e70b3615ffb91f8c03c68b..59ff2801592c98e7471404c70dbbdf3db1b7716b 100644 +--- a/src/main/java/org/bukkit/craftbukkit/util/WeakCollection.java ++++ b/src/main/java/org/bukkit/craftbukkit/util/WeakCollection.java +@@ -164,7 +164,7 @@ public final class WeakCollection implements Collection { + + @Override + public Object[] toArray() { +- return this.toArray(new Object[0]); ++ return this.toArray(me.titaniumtown.ArrayConstants.emptyObjectArray); // Gale - JettPack - reduce array allocations + } + + @Override diff --git a/patches/server/0099-CraftBukkit-UUID-to-world-map.patch b/gale-server/paper-patches/features/0014-CraftBukkit-UUID-to-world-map.patch similarity index 90% rename from patches/server/0099-CraftBukkit-UUID-to-world-map.patch rename to gale-server/paper-patches/features/0014-CraftBukkit-UUID-to-world-map.patch index da0bd06..fa4a2be 100644 --- a/patches/server/0099-CraftBukkit-UUID-to-world-map.patch +++ b/gale-server/paper-patches/features/0014-CraftBukkit-UUID-to-world-map.patch @@ -13,7 +13,7 @@ As part of: MultiPaper (https://github.com/MultiPaper/MultiPaper) Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 50ca138f183529b71790c6c458e1b815c04d4971..6f3ab640cbebce1b0b3b8dfedc59a426b293f462 100644 +index 153ed5bbd2142ea5b36c7d8b1147ec464545d4be..d3363282251a111d8e53b49decb734ffc21cd42b 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -284,6 +284,7 @@ public final class CraftServer implements Server { @@ -24,7 +24,7 @@ index 50ca138f183529b71790c6c458e1b815c04d4971..6f3ab640cbebce1b0b3b8dfedc59a426 // private final Map, Registry> registries = new HashMap<>(); // Paper - replace with RegistryAccess private YamlConfiguration configuration; private YamlConfiguration commandsConfiguration; -@@ -1507,6 +1508,7 @@ public final class CraftServer implements Server { +@@ -1526,6 +1527,7 @@ public final class CraftServer implements Server { this.getLogger().log(Level.SEVERE, null, ex); } @@ -32,7 +32,7 @@ index 50ca138f183529b71790c6c458e1b815c04d4971..6f3ab640cbebce1b0b3b8dfedc59a426 this.worlds.remove(world.getName().toLowerCase(Locale.ROOT)); this.console.removeLevel(handle); return true; -@@ -1525,12 +1527,7 @@ public final class CraftServer implements Server { +@@ -1544,12 +1546,7 @@ public final class CraftServer implements Server { @Override public World getWorld(UUID uid) { @@ -46,7 +46,7 @@ index 50ca138f183529b71790c6c458e1b815c04d4971..6f3ab640cbebce1b0b3b8dfedc59a426 } // Paper start -@@ -1548,6 +1545,7 @@ public final class CraftServer implements Server { +@@ -1567,6 +1564,7 @@ public final class CraftServer implements Server { System.out.println("World " + world.getName() + " is a duplicate of another world and has been prevented from loading. Please delete the uid.dat file from " + world.getName() + "'s world directory if you want to be able to load the duplicate world."); return; } diff --git a/patches/server/0101-Specific-interval-TPS-API.patch b/gale-server/paper-patches/features/0015-Specific-interval-TPS-API.patch similarity index 88% rename from patches/server/0101-Specific-interval-TPS-API.patch rename to gale-server/paper-patches/features/0015-Specific-interval-TPS-API.patch index b846094..00ad276 100644 --- a/patches/server/0101-Specific-interval-TPS-API.patch +++ b/gale-server/paper-patches/features/0015-Specific-interval-TPS-API.patch @@ -7,10 +7,10 @@ License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) Gale - https://galemc.org diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 6f3ab640cbebce1b0b3b8dfedc59a426b293f462..c89181402150c0ccaec9df08513b9f9b98be5fa2 100644 +index d3363282251a111d8e53b49decb734ffc21cd42b..6297d4ad3846aa3828582f7b19e9115fc660eff8 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -3080,6 +3080,24 @@ public final class CraftServer implements Server { +@@ -3098,6 +3098,24 @@ public final class CraftServer implements Server { }; } diff --git a/patches/server/0102-5-second-TPS-average.patch b/gale-server/paper-patches/features/0016-5-second-TPS-average.patch similarity index 64% rename from patches/server/0102-5-second-TPS-average.patch rename to gale-server/paper-patches/features/0016-5-second-TPS-average.patch index 23adb64..a468ded 100644 --- a/patches/server/0102-5-second-TPS-average.patch +++ b/gale-server/paper-patches/features/0016-5-second-TPS-average.patch @@ -57,31 +57,11 @@ index 12b327eea95e0de9e9c39b7d039badee8ec46508..6178f0212214a2a075cea60c758dca79 setListData(vector); } -diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index cef6268d6f90e3578cc27ec21aea4d24a64e3f0a..640fe4217474828ce07580972460615c027fcddd 100644 ---- a/src/main/java/net/minecraft/server/MinecraftServer.java -+++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -1157,6 +1157,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 0 && args[0].equals("mem") && sender.hasPermission("bukkit.command.tpsmemory")) { diff --git a/patches/server/0104-Last-tick-time-API.patch b/gale-server/paper-patches/features/0017-Last-tick-time-API.patch similarity index 93% rename from patches/server/0104-Last-tick-time-API.patch rename to gale-server/paper-patches/features/0017-Last-tick-time-API.patch index 5519ad0..72b26dd 100644 --- a/patches/server/0104-Last-tick-time-API.patch +++ b/gale-server/paper-patches/features/0017-Last-tick-time-API.patch @@ -23,10 +23,10 @@ The above copyright notice and this permission notice shall be included in all c THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 7308c2177f81455792819d622c3702a140741de2..c11f638e120ae4989d110f55c4569dd67b6f3260 100644 +index cb87306d17c6813ede91633be48d99b397be44d9..ea189ace87b5e8f6a71255b1b87f054c8329000f 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -3321,4 +3321,21 @@ public final class CraftServer implements Server { +@@ -3339,4 +3339,21 @@ public final class CraftServer implements Server { this.console.addPluginAllowingSleep(plugin.getName(), value); } // Paper end - API to check if the server is sleeping diff --git a/gale-server/paper-patches/features/0018-Show-last-tick-time-in-tps-command.patch b/gale-server/paper-patches/features/0018-Show-last-tick-time-in-tps-command.patch new file mode 100644 index 0000000..554d881 --- /dev/null +++ b/gale-server/paper-patches/features/0018-Show-last-tick-time-in-tps-command.patch @@ -0,0 +1,69 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Sat, 26 Nov 2022 21:02:58 +0100 +Subject: [PATCH] Show last tick time in /tps command + +License: MIT (https://opensource.org/licenses/MIT) +Gale - https://galemc.org + +This patch is based on the following patch: +"Add getLastTickMs api" +By: tr7zw +As part of: YAPFA (https://github.com/tr7zw/YAPFA) +Licensed under: MIT (https://opensource.org/licenses/MIT) + +* YAPFA copyright * + +Copyright 2020 tr7zw + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +diff --git a/src/main/java/org/spigotmc/TicksPerSecondCommand.java b/src/main/java/org/spigotmc/TicksPerSecondCommand.java +index d336b27ee314366fe44760db6fdb68370ab3995a..bb5e442fa66de449decf5daf78fd8e5dd8bca99e 100644 +--- a/src/main/java/org/spigotmc/TicksPerSecondCommand.java ++++ b/src/main/java/org/spigotmc/TicksPerSecondCommand.java +@@ -46,6 +46,24 @@ public class TicksPerSecondCommand extends Command { + builder.append(text("TPS from last 5s, 1m, 5m, 15m: ", NamedTextColor.GOLD)); // Gale - Purpur - 5 second TPS average + builder.append(Component.join(JoinConfiguration.commas(true), tpsAvg)); + sender.sendMessage(builder.asComponent()); ++ // Gale start - YAPFA - last tick time - in TPS command ++ if (org.galemc.gale.configuration.GaleGlobalConfiguration.get().misc.lastTickTimeInTpsCommand.enabled) { ++ long lastTickProperTime = net.minecraft.server.MinecraftServer.lastTickProperTime; ++ long lastTickOversleepTime = net.minecraft.server.MinecraftServer.lastTickOversleepTime; ++ var lastTickTimeMessage = text("Last tick: ") ++ .append(formatTickTimeDuration(lastTickProperTime, 44, 50, 51)); ++ if (org.galemc.gale.configuration.GaleGlobalConfiguration.get().misc.lastTickTimeInTpsCommand.addOversleep) { ++ lastTickTimeMessage = lastTickTimeMessage.append(text(" self + ")) ++ .append(formatTickTimeDuration(lastTickOversleepTime, Math.max(1, 51 - lastTickProperTime), Math.max(2, 52 - lastTickProperTime), Math.max(3, 53 - lastTickProperTime))) ++ .append(text(" oversleep = ")) ++ .append(formatTickTimeDuration(lastTickProperTime + lastTickOversleepTime, 51, 52, 53)); ++ } ++ lastTickTimeMessage = lastTickTimeMessage.color(NamedTextColor.GOLD); ++ sender.sendMessage( ++ lastTickTimeMessage ++ ); ++ } ++ // Gale end - YAPFA - last tick time - in TPS command + if (args.length > 0 && args[0].equals("mem") && sender.hasPermission("bukkit.command.tpsmemory")) { + sender.sendMessage(text() + .append(text("Current Memory Usage: ", NamedTextColor.GOLD)) +@@ -68,4 +86,15 @@ public class TicksPerSecondCommand extends Command { + return text(amount, color); + // Paper end + } ++ ++ // Gale start - YAPFA - last tick time - in TPS command ++ private static final TextColor safeColor = NamedTextColor.GREEN; ++ private static final TextColor closeColor = NamedTextColor.YELLOW; ++ private static final TextColor problematicColor = TextColor.color(0xf77c1e); ++ private static final TextColor severeColor = NamedTextColor.RED; ++ public static Component formatTickTimeDuration(long ms, long safeLimit, long closeLimit, long nonSevereLimit) { ++ return text(ms + " ", ms <= safeLimit ? safeColor : ms <= closeLimit ? closeColor : ms <= nonSevereLimit ? problematicColor : severeColor) ++ .append(text("ms", NamedTextColor.GOLD)); ++ } ++ // Gale end - YAPFA - last tick time - in TPS command + } diff --git a/patches/server/0110-Pre-compute-VarLong-sizes.patch b/gale-server/paper-patches/features/0019-Pre-compute-VarLong-sizes.patch similarity index 86% rename from patches/server/0110-Pre-compute-VarLong-sizes.patch rename to gale-server/paper-patches/features/0019-Pre-compute-VarLong-sizes.patch index 58253fc..9ed13cb 100644 --- a/patches/server/0110-Pre-compute-VarLong-sizes.patch +++ b/gale-server/paper-patches/features/0019-Pre-compute-VarLong-sizes.patch @@ -20,29 +20,6 @@ Given that we do a lot of varint writing as well, this should provide a small pe This includes a test to ensure that the behavior is as expected and fixes the initialization loop so that the correct results will be given. Much thanks to @octylFractal for acting as my duck while trying to figure this out. -diff --git a/src/main/java/net/minecraft/network/VarLong.java b/src/main/java/net/minecraft/network/VarLong.java -index c4fd722f4203e3f4de7b41de9d6ef47b5cfaed10..11339185fc70b1a34130c92d28c397d4b05569cb 100644 ---- a/src/main/java/net/minecraft/network/VarLong.java -+++ b/src/main/java/net/minecraft/network/VarLong.java -@@ -9,6 +9,18 @@ public class VarLong { - private static final int DATA_BITS_PER_BYTE = 7; - - public static int getByteSize(long l) { -+ // Gale start - Velocity - pre-compute VarInt and VarLong sizes -+ return VARLONG_EXACT_BYTE_LENGTHS[Long.numberOfLeadingZeros(l)]; -+ } -+ private static final int[] VARLONG_EXACT_BYTE_LENGTHS = new int[65]; -+ static { -+ for (int i = 0; i < 64; ++i) { -+ VARLONG_EXACT_BYTE_LENGTHS[i] = (int) Math.ceil((63d - (i - 1)) / 7d); -+ } -+ VARLONG_EXACT_BYTE_LENGTHS[64] = 1; // Special case for the number 0 -+ } -+ static int getByteSizeOld(long l) { // public -> package-private -+ // Gale end - Velocity - pre-compute VarInt and VarLong sizes - for (int i = 1; i < 10; i++) { - if ((l & -1L << i * 7) == 0L) { - return i; diff --git a/src/test/java/net/minecraft/network/VarIntLongTest.java b/src/test/java/net/minecraft/network/VarIntLongTest.java new file mode 100644 index 0000000000000000000000000000000000000000..bbea09ffc2180c3c62e15d7dff51f8c220425bfe diff --git a/gale-server/paper-patches/features/0020-Optimize-VarInt-write-and-VarLong-write.patch b/gale-server/paper-patches/features/0020-Optimize-VarInt-write-and-VarLong-write.patch new file mode 100644 index 0000000..03e7a4f --- /dev/null +++ b/gale-server/paper-patches/features/0020-Optimize-VarInt-write-and-VarLong-write.patch @@ -0,0 +1,81 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Tue, 22 Aug 2023 21:38:37 +0200 +Subject: [PATCH] Optimize VarInt#write and VarLong#write + +License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) +Gale - https://galemc.org + +This patch is based on the following commit: +"Reapply "Optimize varint writing"" +By: Andrew Steinborn +As part of: Velocity (https://github.com/PaperMC/Velocity) +Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) + +* Velocity description * + +Inspired by the approach described at the bottom of https://richardstartin.github.io/posts/dont-use-protobuf-for-telemetry + +Given that we do a lot of varint writing as well, this should provide a small performance boost for larger/complex packets whilst not regressing hard on smaller packets. + +This includes a test to ensure that the behavior is as expected and fixes the initialization loop so that the correct results will be given. Much thanks to @octylFractal for acting as my duck while trying to figure this out. + +diff --git a/src/test/java/net/minecraft/network/VarIntLongTest.java b/src/test/java/net/minecraft/network/VarIntLongTest.java +index bbea09ffc2180c3c62e15d7dff51f8c220425bfe..0c11670d8d7307307a7cd12be5d0dca40155829d 100644 +--- a/src/test/java/net/minecraft/network/VarIntLongTest.java ++++ b/src/test/java/net/minecraft/network/VarIntLongTest.java +@@ -2,6 +2,7 @@ + + package net.minecraft.network; + ++import io.netty.buffer.Unpooled; + import it.unimi.dsi.fastutil.ints.IntOpenHashSet; + import it.unimi.dsi.fastutil.ints.IntSet; + import it.unimi.dsi.fastutil.longs.LongOpenHashSet; +@@ -156,4 +157,46 @@ public class VarIntLongTest { + } + // Gale end - Velocity - pre-compute VarInt and VarLong sizes + ++ // Gale - Velocity - optimized VarInt#write and VarLong#write ++ @Test ++ public void testWriteVarIntComparedToOld() { ++ integerCases.forEach(value -> { ++ // given ++ int capacity = 5; ++ FriendlyByteBuf buf1 = new FriendlyByteBuf(Unpooled.buffer(capacity)); ++ FriendlyByteBuf buf2 = new FriendlyByteBuf(Unpooled.buffer(capacity)); ++ VarInt.writeOld(buf1, value); ++ ++ // when ++ buf2.writeVarInt(value); ++ ++ // then ++ Assertions.assertEquals(buf1.writerIndex(), buf2.writerIndex(), "Writer index of optimized buffer (" + buf2.writerIndex() + ") is not equal to writer index of original buffer (" + buf1.writerIndex() + ") for test case value " + value + " (binary: " + padStringWithLeadingZeros(Integer.toBinaryString(value), 32) + ")"); ++ for (int i = 0; i < capacity; i++) { ++ Assertions.assertEquals(buf1.getByte(i), buf2.getByte(i), "Buffer byte (at index " + i + ") in optimized buffer (" + buf2.getByte(i) + " (binary: " + padStringWithLeadingZeros(Integer.toBinaryString(Byte.toUnsignedInt(buf2.getByte(i))), 8) + ")) is not equal to the same byte in original buffer (" + buf1.getByte(i) + " (binary: " + padStringWithLeadingZeros(Integer.toBinaryString(Byte.toUnsignedInt(buf1.getByte(i))), 8) + ")) for test case value " + value + " (binary: " + padStringWithLeadingZeros(Integer.toBinaryString(value), 32) + ")"); ++ } ++ }); ++ } ++ ++ @Test ++ public void testWriteVarLongComparedToOld() { ++ longCases.forEach(value -> { ++ // given ++ int capacity = 10; ++ FriendlyByteBuf buf1 = new FriendlyByteBuf(Unpooled.buffer(capacity)); ++ FriendlyByteBuf buf2 = new FriendlyByteBuf(Unpooled.buffer(capacity)); ++ VarLong.writeOld(buf1, value); ++ ++ // when ++ buf2.writeVarLong(value); ++ ++ // then ++ Assertions.assertEquals(buf1.writerIndex(), buf2.writerIndex(), "Writer index of optimized buffer (" + buf2.writerIndex() + ") is not equal to writer index of original buffer (" + buf1.writerIndex() + ") for test case value " + value + " (binary: " + padStringWithLeadingZeros(Long.toBinaryString(value), 64) + ")"); ++ for (int i = 0; i < capacity; i++) { ++ Assertions.assertEquals(buf1.getByte(i), buf2.getByte(i), "Buffer byte (at index " + i + ") in optimized buffer (" + buf2.getByte(i) + " (binary: " + padStringWithLeadingZeros(Integer.toBinaryString(Byte.toUnsignedInt(buf2.getByte(i))), 8) + ")) is not equal to the same byte in original buffer (" + buf1.getByte(i) + " (binary: " + padStringWithLeadingZeros(Integer.toBinaryString(Byte.toUnsignedInt(buf1.getByte(i))), 8) + ")) for test case value " + value + " (binary: " + padStringWithLeadingZeros(Long.toBinaryString(value), 64) + ")"); ++ } ++ }); ++ } ++ // Gale end - Velocity - optimized VarInt#write and VarLong#write ++ + } diff --git a/gale-server/paper-patches/features/0021-Add-xor-shift-random.patch b/gale-server/paper-patches/features/0021-Add-xor-shift-random.patch new file mode 100644 index 0000000..bbe0602 --- /dev/null +++ b/gale-server/paper-patches/features/0021-Add-xor-shift-random.patch @@ -0,0 +1,67 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Tue, 8 Aug 2023 21:12:58 +0200 +Subject: [PATCH] Add xor-shift random +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +License: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html) +Gale - https://galemc.org + +This patch is based on the following patch: +"Apply faster random" +By: AlphaKR93 +As part of: Plazma (https://github.com/PlazmaMC/Plazma) +Class `org.plazmamc.plazma.Random` licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html) +Other changes licensed under: MIT (https://opensource.org/licenses/MIT) + +* Plazma copyright * + +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +diff --git a/src/main/java/com/destroystokyo/paper/loottable/PaperLootableInventoryData.java b/src/main/java/com/destroystokyo/paper/loottable/PaperLootableInventoryData.java +index 861bff267cb397e13e8e1c79bd0776b130c6e5da..30972bf7889973cf63b5f32ad166afdc9800bee1 100644 +--- a/src/main/java/com/destroystokyo/paper/loottable/PaperLootableInventoryData.java ++++ b/src/main/java/com/destroystokyo/paper/loottable/PaperLootableInventoryData.java +@@ -21,7 +21,7 @@ import org.checkerframework.framework.qual.DefaultQualifier; + @DefaultQualifier(NonNull.class) + public class PaperLootableInventoryData { + +- private static final Random RANDOM = new Random(); ++ public static Random RANDOM; // Gale - xor-shift random - set in GaleGlobalConfiguration + + private long lastFill = -1; + private long nextRefill = -1; +diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +index 544305f9d08ece4245810dbcf47a396017adead6..03af99e2fddf3626fec150198bc0b142d3aef0d9 100644 +--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java ++++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +@@ -284,7 +284,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { + } + // Paper end + +- private static final Random rand = new Random(); ++ public static Random rand; // Gale - xor-shift random - set in GaleGlobalConfiguration + + public CraftWorld(ServerLevel world, ChunkGenerator gen, BiomeProvider biomeProvider, Environment env) { + this.world = world; +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java +index 759b6e54db93792c9862b1f1625118ac6fa49d7a..4b5e9bc33c25ac98c32aff1bd13788edf0eeee8c 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java +@@ -14,7 +14,7 @@ import org.bukkit.inventory.meta.FireworkMeta; + + public class CraftFirework extends CraftProjectile implements Firework { + +- private final Random random = new Random(); ++ private final Random random = org.galemc.gale.configuration.GaleGlobalConfiguration.get().smallOptimizations.useXorShiftRandom.elytraFireworkSpeed ? new org.galemc.gale.random.XorShiftRandom() : new Random(); // Gale - xor-shift random - not thread-safe but it is not really a concern here + //private CraftItemStack item; // Paper - Remove usage, not accurate representation of current item. + + public CraftFirework(CraftServer server, FireworkRocketEntity entity) { diff --git a/gale-server/paper-patches/features/0022-Virtual-thread-support.patch b/gale-server/paper-patches/features/0022-Virtual-thread-support.patch new file mode 100644 index 0000000..87c56e9 --- /dev/null +++ b/gale-server/paper-patches/features/0022-Virtual-thread-support.patch @@ -0,0 +1,35 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Wed, 9 Aug 2023 15:04:56 +0200 +Subject: [PATCH] Virtual thread support + +License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) +Gale - https://galemc.org + +diff --git a/src/main/java/com/destroystokyo/paper/Metrics.java b/src/main/java/com/destroystokyo/paper/Metrics.java +index dbe3d8748c1e6fbad7ee4ccf39dfc0422b0ce50b..3d8ed4ff9a5a30d123508aeb485250271b528a6e 100644 +--- a/src/main/java/com/destroystokyo/paper/Metrics.java ++++ b/src/main/java/com/destroystokyo/paper/Metrics.java +@@ -975,6 +975,22 @@ public class Metrics { + })); + // Gale end - SIMD support - include in metrics + ++ // Gale start - virtual thread support - include in metrics ++ Map> virtualThreadSupportMap = new HashMap<>(2); ++ { ++ Map entry = new HashMap<>(2); ++ boolean isSupported = org.galemc.gale.virtualthread.VirtualThreadService.isSupported(); ++ try { ++ int javaMajorVersion = org.galemc.gale.virtualthread.VirtualThreadService.getJavaMajorVersion(); ++ entry.put(isSupported + " (Java " + javaMajorVersion + ")", 1); ++ } catch (Exception ignored) { ++ entry.put(String.valueOf(isSupported), 1); ++ } ++ virtualThreadSupportMap.put(String.valueOf(isSupported), entry); ++ } ++ metrics.addCustomChart(new Metrics.DrilldownPie("virtual_thread_support", () -> virtualThreadSupportMap)); ++ // Gale end - virtual thread support - include in metrics ++ + } + + } diff --git a/gale-server/paper-patches/files/src/main/resources/data/.paperassetsroot.patch b/gale-server/paper-patches/files/src/main/resources/data/.paperassetsroot.patch new file mode 100644 index 0000000..b41d58b --- /dev/null +++ b/gale-server/paper-patches/files/src/main/resources/data/.paperassetsroot.patch @@ -0,0 +1,3 @@ +--- a/src/main/resources/data/.paperassetsroot ++++ b/src/main/resources/data/.paperassetsroot +@@ -1,0 +_,0 @@ diff --git a/gale-server/src/main/java/me/titaniumtown/ArrayConstants.java b/gale-server/src/main/java/me/titaniumtown/ArrayConstants.java new file mode 100644 index 0000000..211c5b0 --- /dev/null +++ b/gale-server/src/main/java/me/titaniumtown/ArrayConstants.java @@ -0,0 +1,19 @@ +// Gale - JettPack - reduce array allocations + +package me.titaniumtown; + +public final class ArrayConstants { + + private ArrayConstants() {} + + public static final Object[] emptyObjectArray = new Object[0]; + public static final short[] emptyShortArray = new short[0]; + public static final int[] emptyIntArray = new int[0]; + public static final int[] zeroSingletonIntArray = new int[]{0}; + public static final byte[] emptyByteArray = new byte[0]; + public static final String[] emptyStringArray = new String[0]; + public static final long[] emptyLongArray = new long[0]; + public static final org.bukkit.entity.Entity[] emptyBukkitEntityArray = new org.bukkit.entity.Entity[0]; + public static final net.minecraft.world.entity.Entity[] emptyEntityArray = new net.minecraft.world.entity.Entity[0]; + //public static final net.minecraft.server.level.ServerLevel[] emptyServerLevelArray = new net.minecraft.server.level.ServerLevel[0]; +} diff --git a/gale-server/src/main/java/net/caffeinemc/mods/lithium/common/world/chunk/LithiumHashPalette.java b/gale-server/src/main/java/net/caffeinemc/mods/lithium/common/world/chunk/LithiumHashPalette.java new file mode 100644 index 0000000..8ca3642 --- /dev/null +++ b/gale-server/src/main/java/net/caffeinemc/mods/lithium/common/world/chunk/LithiumHashPalette.java @@ -0,0 +1,215 @@ +// Gale - Lithium - faster chunk serialization + +package net.caffeinemc.mods.lithium.common.world.chunk; + +import com.google.common.collect.ImmutableList; +import it.unimi.dsi.fastutil.HashCommon; +import it.unimi.dsi.fastutil.objects.Reference2IntMap; +import it.unimi.dsi.fastutil.objects.Reference2IntOpenHashMap; +import net.minecraft.CrashReport; +import net.minecraft.CrashReportCategory; +import net.minecraft.ReportedException; +import net.minecraft.core.IdMap; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.network.VarInt; +import net.minecraft.world.level.chunk.MissingPaletteEntryException; +import net.minecraft.world.level.chunk.Palette; +import net.minecraft.world.level.chunk.PaletteResize; + +import java.util.Arrays; +import java.util.List; +import java.util.function.Predicate; + +import static it.unimi.dsi.fastutil.Hash.FAST_LOAD_FACTOR; + +/** + * Generally provides better performance over the vanilla {@link net.minecraft.world.level.chunk.HashMapPalette} when calling + * {@link LithiumHashPalette#idFor(Object)} through using a faster backing map and reducing pointer chasing. + */ +public class LithiumHashPalette implements Palette { + private static final int ABSENT_VALUE = -1; + + private final IdMap idList; + private final PaletteResize resizeHandler; + private final int indexBits; + + private final Reference2IntMap table; + private T[] entries; + private int size = 0; + + public LithiumHashPalette(IdMap idList, PaletteResize resizeHandler, int indexBits, T[] entries, Reference2IntMap table, int size) { + this.idList = idList; + this.resizeHandler = resizeHandler; + this.indexBits = indexBits; + this.entries = entries; + this.table = table; + this.size = size; + } + + public LithiumHashPalette(IdMap idList, int bits, PaletteResize resizeHandler, List list) { + this(idList, bits, resizeHandler); + + for (T t : list) { + this.addEntry(t); + } + } + + @SuppressWarnings("unchecked") + public LithiumHashPalette(IdMap idList, int bits, PaletteResize resizeHandler) { + this.idList = idList; + this.indexBits = bits; + this.resizeHandler = resizeHandler; + + int capacity = 1 << bits; + + this.entries = (T[]) new Object[capacity]; + this.table = new Reference2IntOpenHashMap<>(capacity, FAST_LOAD_FACTOR); + this.table.defaultReturnValue(ABSENT_VALUE); + } + + @Override + public int idFor(T obj) { + int id = this.table.getInt(obj); + + if (id == ABSENT_VALUE) { + id = this.computeEntry(obj); + } + + return id; + } + + @Override + public boolean maybeHas(Predicate predicate) { + for (int i = 0; i < this.size; ++i) { + if (predicate.test(this.entries[i])) { + return true; + } + } + + return false; + } + + private int computeEntry(T obj) { + int id = this.addEntry(obj); + + if (id >= 1 << this.indexBits) { + if (this.resizeHandler == null) { + throw new IllegalStateException("Cannot grow"); + } else { + id = this.resizeHandler.onResize(this.indexBits + 1, obj); + } + } + + return id; + } + + private int addEntry(T obj) { + int nextId = this.size; + + if (nextId >= this.entries.length) { + this.resize(this.size); + } + + this.table.put(obj, nextId); + this.entries[nextId] = obj; + + this.size++; + + return nextId; + } + + private void resize(int neededCapacity) { + this.entries = Arrays.copyOf(this.entries, HashCommon.nextPowerOfTwo(neededCapacity + 1)); + } + + @Override + public T valueFor(int id) { + T[] entries = this.entries; + + T entry = null; + if (id >= 0 && id < entries.length) { + entry = entries[id]; + } + + if (entry != null) { + return entry; + } else { + throw this.missingPaletteEntryCrash(id); + } + } + + private ReportedException missingPaletteEntryCrash(int id) { + try { + throw new MissingPaletteEntryException(id); + } catch (MissingPaletteEntryException e) { + CrashReport crashReport = CrashReport.forThrowable(e, "[Lithium] Getting Palette Entry"); + CrashReportCategory crashReportCategory = crashReport.addCategory("Chunk section"); + crashReportCategory.setDetail("IndexBits", this.indexBits); + crashReportCategory.setDetail("Entries", this.entries.length + " Elements: " + Arrays.toString(this.entries)); + crashReportCategory.setDetail("Table", this.table.size() + " Elements: " + this.table); + return new ReportedException(crashReport); + } + } + + @Override + public void read(FriendlyByteBuf buf) { + this.clear(); + + int entryCount = buf.readVarInt(); + + for (int i = 0; i < entryCount; ++i) { + this.addEntry(this.idList.byId(buf.readVarInt())); + } + } + + @Override + public void write(FriendlyByteBuf buf) { + int size = this.size; + buf.writeVarInt(size); + + for (int i = 0; i < size; ++i) { + buf.writeVarInt(this.idList.getId(this.valueFor(i))); + } + } + + @Override + public int getSerializedSize() { + int size = VarInt.getByteSize(this.size); + + for (int i = 0; i < this.size; ++i) { + size += VarInt.getByteSize(this.idList.getId(this.valueFor(i))); + } + + return size; + } + + @Override + public int getSize() { + return this.size; + } + + @Override + public Palette copy(PaletteResize resizeHandler) { + return new LithiumHashPalette<>(this.idList, resizeHandler, this.indexBits, this.entries.clone(), new Reference2IntOpenHashMap<>(this.table), this.size); + } + + private void clear() { + Arrays.fill(this.entries, null); + this.table.clear(); + this.size = 0; + } + + public List getElements() { + ImmutableList.Builder builder = new ImmutableList.Builder<>(); + for (T entry : this.entries) { + if (entry != null) { + builder.add(entry); + } + } + return builder.build(); + } + + public static Palette create(int bits, IdMap idList, PaletteResize listener, List list) { + return new LithiumHashPalette<>(idList, bits, listener, list); + } +} diff --git a/gale-server/src/main/java/org/galemc/gale/command/GaleCommand.java b/gale-server/src/main/java/org/galemc/gale/command/GaleCommand.java new file mode 100644 index 0000000..c200020 --- /dev/null +++ b/gale-server/src/main/java/org/galemc/gale/command/GaleCommand.java @@ -0,0 +1,179 @@ +// Gale - Gale commands - /gale command + +package org.galemc.gale.command; + +import io.papermc.paper.command.CommandUtil; +import it.unimi.dsi.fastutil.Pair; +import net.minecraft.Util; +import org.galemc.gale.command.subcommands.InfoCommand; +import org.galemc.gale.command.subcommands.ReloadCommand; +import org.galemc.gale.command.subcommands.VersionCommand; +import org.jetbrains.annotations.Nullable; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.permissions.Permission; +import org.bukkit.permissions.PermissionDefault; +import org.bukkit.plugin.PluginManager; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.stream.Collectors; + +import static net.kyori.adventure.text.Component.newline; +import static net.kyori.adventure.text.Component.text; +import static net.kyori.adventure.text.format.NamedTextColor.GRAY; +import static net.kyori.adventure.text.format.NamedTextColor.RED; + +public final class GaleCommand extends Command { + public static final String COMMAND_LABEL = "gale"; + public static final String BASE_PERM = GaleCommands.COMMAND_BASE_PERM + "." + COMMAND_LABEL; + private static final Permission basePermission = new Permission(BASE_PERM, PermissionDefault.TRUE); + // subcommand label -> subcommand + private static final GaleSubcommand RELOAD_SUBCOMMAND = new ReloadCommand(); + private static final GaleSubcommand VERSION_SUBCOMMAND = new VersionCommand(); + private static final GaleSubcommand INFO_SUBCOMMAND = new InfoCommand(); + private static final Map SUBCOMMANDS = Util.make(() -> { + final Map, GaleSubcommand> commands = new HashMap<>(); + + commands.put(Set.of(ReloadCommand.LITERAL_ARGUMENT), RELOAD_SUBCOMMAND); + commands.put(Set.of(VersionCommand.LITERAL_ARGUMENT), VERSION_SUBCOMMAND); + commands.put(Set.of(InfoCommand.LITERAL_ARGUMENT), INFO_SUBCOMMAND); + + return commands.entrySet().stream() + .flatMap(entry -> entry.getKey().stream().map(s -> Map.entry(s, entry.getValue()))) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + }); + // alias -> subcommand label + private static final Map ALIASES = Util.make(() -> { + final Map> aliases = new HashMap<>(); + + aliases.put(VersionCommand.LITERAL_ARGUMENT, Set.of("ver")); + aliases.put(InfoCommand.LITERAL_ARGUMENT, Set.of("about")); + + return aliases.entrySet().stream() + .flatMap(entry -> entry.getValue().stream().map(s -> Map.entry(s, entry.getKey()))) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + }); + + private String createUsageMessage(Collection arguments) { + return "/" + COMMAND_LABEL + " [" + String.join(" | ", arguments) + "]"; + } + + public GaleCommand() { + super(COMMAND_LABEL); + this.description = "Gale related commands"; + this.usageMessage = this.createUsageMessage(SUBCOMMANDS.keySet()); + final List permissions = SUBCOMMANDS.values().stream().map(GaleSubcommand::getPermission).filter(Objects::nonNull).toList(); + this.setPermission(BASE_PERM); + final PluginManager pluginManager = Bukkit.getServer().getPluginManager(); + pluginManager.addPermission(basePermission); + for (final Permission permission : permissions) { + pluginManager.addPermission(permission); + } + } + + @Override + public List tabComplete( + final CommandSender sender, + final String alias, + final String[] args, + final @Nullable Location location + ) throws IllegalArgumentException { + if (args.length <= 1) { + List subCommandArguments = new ArrayList<>(SUBCOMMANDS.size()); + for (Map.Entry subCommandEntry : SUBCOMMANDS.entrySet()) { + if (subCommandEntry.getValue().testPermission(sender)) { + subCommandArguments.add(subCommandEntry.getKey()); + } + } + return CommandUtil.getListMatchingLast(sender, args, subCommandArguments); + } + + final @Nullable Pair subCommand = resolveCommand(args[0]); + if (subCommand != null && subCommand.second().testPermission(sender)) { + return subCommand.second().tabComplete(sender, subCommand.first(), Arrays.copyOfRange(args, 1, args.length)); + } + + return Collections.emptyList(); + } + + private boolean testHasOnePermission(CommandSender sender) { + for (Map.Entry subCommandEntry : SUBCOMMANDS.entrySet()) { + if (subCommandEntry.getValue().testPermission(sender)) { + return true; + } + } + return false; + } + + @Override + public boolean execute( + final CommandSender sender, + final String commandLabel, + final String[] args + ) { + + // Check if the sender has the base permission and at least one specific permission + if (!sender.hasPermission(basePermission) || !this.testHasOnePermission(sender)) { + sender.sendMessage(Bukkit.permissionMessage()); + return true; + } + + // Determine the usage message with the subcommands they can perform + List subCommandArguments = new ArrayList<>(SUBCOMMANDS.size()); + for (Map.Entry subCommandEntry : SUBCOMMANDS.entrySet()) { + if (subCommandEntry.getValue().testPermission(sender)) { + subCommandArguments.add(subCommandEntry.getKey()); + } + } + String specificUsageMessage = this.createUsageMessage(subCommandArguments); + + // If they did not give a subcommand + if (args.length == 0) { + INFO_SUBCOMMAND.execute(sender, InfoCommand.LITERAL_ARGUMENT, me.titaniumtown.ArrayConstants.emptyStringArray); // Gale - JettPack - reduce array allocations + sender.sendMessage(newline().append(text("Command usage: " + specificUsageMessage, GRAY))); + return false; + } + + // If they do not have permission for the subcommand they gave, or the argument is not a valid subcommand + final @Nullable Pair subCommand = resolveCommand(args[0]); + if (subCommand == null || !subCommand.second().testPermission(sender)) { + sender.sendMessage(text("Usage: " + specificUsageMessage, RED)); + return false; + } + + // Execute the subcommand + final String[] choppedArgs = Arrays.copyOfRange(args, 1, args.length); + return subCommand.second().execute(sender, subCommand.first(), choppedArgs); + + } + + private static @Nullable Pair resolveCommand(String label) { + label = label.toLowerCase(Locale.ENGLISH); + @Nullable GaleSubcommand subCommand = SUBCOMMANDS.get(label); + if (subCommand == null) { + final @Nullable String command = ALIASES.get(label); + if (command != null) { + label = command; + subCommand = SUBCOMMANDS.get(command); + } + } + + if (subCommand != null) { + return Pair.of(label, subCommand); + } + + return null; + } + +} diff --git a/gale-server/src/main/java/org/galemc/gale/command/GaleCommands.java b/gale-server/src/main/java/org/galemc/gale/command/GaleCommands.java new file mode 100644 index 0000000..555d2aa --- /dev/null +++ b/gale-server/src/main/java/org/galemc/gale/command/GaleCommands.java @@ -0,0 +1,31 @@ +// Gale - Gale commands + +package org.galemc.gale.command; + +import net.minecraft.server.MinecraftServer; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.framework.qual.DefaultQualifier; +import org.bukkit.command.Command; +import org.bukkit.craftbukkit.util.permissions.CraftDefaultPermissions; + +import java.util.HashMap; +import java.util.Map; + +@DefaultQualifier(NonNull.class) +public final class GaleCommands { + + public static final String COMMAND_BASE_PERM = CraftDefaultPermissions.GALE_ROOT + ".command"; + + private GaleCommands() {} + + private static final Map COMMANDS = new HashMap<>(); + static { + COMMANDS.put(GaleCommand.COMMAND_LABEL, new GaleCommand()); + } + + public static void registerCommands(final MinecraftServer server) { + COMMANDS.forEach((s, command) -> { + server.server.getCommandMap().register(s, "Gale", command); + }); + } +} diff --git a/gale-server/src/main/java/org/galemc/gale/command/GaleSubcommand.java b/gale-server/src/main/java/org/galemc/gale/command/GaleSubcommand.java new file mode 100644 index 0000000..d2b32a4 --- /dev/null +++ b/gale-server/src/main/java/org/galemc/gale/command/GaleSubcommand.java @@ -0,0 +1,27 @@ +// Gale - Gale commands + +package org.galemc.gale.command; + +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.framework.qual.DefaultQualifier; +import org.jetbrains.annotations.Nullable; +import org.bukkit.command.CommandSender; +import org.bukkit.permissions.Permission; + +import java.util.Collections; +import java.util.List; + +@DefaultQualifier(NonNull.class) +public interface GaleSubcommand { + + boolean execute(CommandSender sender, String subCommand, String[] args); + + default List tabComplete(final CommandSender sender, final String subCommand, final String[] args) { + return Collections.emptyList(); + } + + boolean testPermission(CommandSender sender); + + @Nullable Permission getPermission(); + +} diff --git a/gale-server/src/main/java/org/galemc/gale/command/PermissionedGaleSubcommand.java b/gale-server/src/main/java/org/galemc/gale/command/PermissionedGaleSubcommand.java new file mode 100644 index 0000000..40d84d0 --- /dev/null +++ b/gale-server/src/main/java/org/galemc/gale/command/PermissionedGaleSubcommand.java @@ -0,0 +1,32 @@ +// Gale - Gale commands + +package org.galemc.gale.command; + +import org.jetbrains.annotations.Nullable; +import org.bukkit.command.CommandSender; +import org.bukkit.permissions.Permission; +import org.bukkit.permissions.PermissionDefault; + +public abstract class PermissionedGaleSubcommand implements GaleSubcommand { + + public final Permission permission; + + protected PermissionedGaleSubcommand(Permission permission) { + this.permission = permission; + } + + protected PermissionedGaleSubcommand(String permission, PermissionDefault permissionDefault) { + this(new Permission(permission, permissionDefault)); + } + + @Override + public boolean testPermission(CommandSender sender) { + return sender.hasPermission(this.permission); + } + + @Override + public @Nullable Permission getPermission() { + return this.permission; + } + +} diff --git a/gale-server/src/main/java/org/galemc/gale/command/subcommands/InfoCommand.java b/gale-server/src/main/java/org/galemc/gale/command/subcommands/InfoCommand.java new file mode 100644 index 0000000..f65e61f --- /dev/null +++ b/gale-server/src/main/java/org/galemc/gale/command/subcommands/InfoCommand.java @@ -0,0 +1,42 @@ +// Gale - Gale commands - /gale info command + +package org.galemc.gale.command.subcommands; + +import net.kyori.adventure.text.event.ClickEvent; +import net.kyori.adventure.text.format.TextDecoration; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.framework.qual.DefaultQualifier; +import org.galemc.gale.command.GaleSubcommand; +import org.jetbrains.annotations.Nullable; +import org.bukkit.command.CommandSender; +import org.bukkit.permissions.Permission; + +import static net.kyori.adventure.text.Component.text; + +@DefaultQualifier(NonNull.class) +public final class InfoCommand implements GaleSubcommand { + + public final static String LITERAL_ARGUMENT = "info"; + + @Override + public boolean execute(final CommandSender sender, final String subCommand, final String[] args) { + sender.sendMessage( + text("Gale is a performant Minecraft server system. Find us on: ") + .append(text("https://github.com/GaleMC/Gale") + .decorate(TextDecoration.UNDERLINED) + .clickEvent(ClickEvent.openUrl("https://github.com/GaleMC/Gale"))) + ); + return true; + } + + @Override + public boolean testPermission(CommandSender sender) { + return true; + } + + @Override + public @Nullable Permission getPermission() { + return null; + } + +} diff --git a/gale-server/src/main/java/org/galemc/gale/command/subcommands/ReloadCommand.java b/gale-server/src/main/java/org/galemc/gale/command/subcommands/ReloadCommand.java new file mode 100644 index 0000000..94f39d5 --- /dev/null +++ b/gale-server/src/main/java/org/galemc/gale/command/subcommands/ReloadCommand.java @@ -0,0 +1,46 @@ +// Gale - Gale commands - /gale reload command + +package org.galemc.gale.command.subcommands; + +import net.minecraft.server.MinecraftServer; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.framework.qual.DefaultQualifier; +import org.galemc.gale.command.GaleCommand; +import org.galemc.gale.command.PermissionedGaleSubcommand; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.permissions.PermissionDefault; + +import static net.kyori.adventure.text.Component.text; +import static net.kyori.adventure.text.format.NamedTextColor.GREEN; +import static net.kyori.adventure.text.format.NamedTextColor.RED; + +@DefaultQualifier(NonNull.class) +public final class ReloadCommand extends PermissionedGaleSubcommand { + + public final static String LITERAL_ARGUMENT = "reload"; + public static final String PERM = GaleCommand.BASE_PERM + "." + LITERAL_ARGUMENT; + + public ReloadCommand() { + super(PERM, PermissionDefault.OP); + } + + @Override + public boolean execute(final CommandSender sender, final String subCommand, final String[] args) { + this.doReload(sender); + return true; + } + + private void doReload(final CommandSender sender) { + Command.broadcastCommandMessage(sender, text("Please note that this command is not supported and may cause issues.", RED)); + Command.broadcastCommandMessage(sender, text("If you encounter any issues please use the /stop command to restart your server.", RED)); + + MinecraftServer server = ((CraftServer) sender.getServer()).getServer(); + server.galeConfigurations.reloadConfigs(server); + server.server.reloadCount++; + + Command.broadcastCommandMessage(sender, text("Gale config reload complete.", GREEN)); + } + +} diff --git a/gale-server/src/main/java/org/galemc/gale/command/subcommands/VersionCommand.java b/gale-server/src/main/java/org/galemc/gale/command/subcommands/VersionCommand.java new file mode 100644 index 0000000..a68f993 --- /dev/null +++ b/gale-server/src/main/java/org/galemc/gale/command/subcommands/VersionCommand.java @@ -0,0 +1,39 @@ +// Gale - Gale commands - /gale version command + +package org.galemc.gale.command.subcommands; + +import net.minecraft.server.MinecraftServer; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.framework.qual.DefaultQualifier; +import org.galemc.gale.command.GaleCommand; +import org.galemc.gale.command.PermissionedGaleSubcommand; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.permissions.PermissionDefault; + +@DefaultQualifier(NonNull.class) +public final class VersionCommand extends PermissionedGaleSubcommand { + + public final static String LITERAL_ARGUMENT = "version"; + public static final String PERM = GaleCommand.BASE_PERM + "." + LITERAL_ARGUMENT; + + public VersionCommand() { + super(PERM, PermissionDefault.TRUE); + } + + @Override + public boolean execute(final CommandSender sender, final String subCommand, final String[] args) { + final @Nullable Command ver = MinecraftServer.getServer().server.getCommandMap().getCommand("version"); + if (ver != null) { + ver.execute(sender, GaleCommand.COMMAND_LABEL, me.titaniumtown.ArrayConstants.emptyStringArray); // Gale - JettPack - reduce array allocations + } + return true; + } + + @Override + public boolean testPermission(CommandSender sender) { + return super.testPermission(sender) && sender.hasPermission("bukkit.command.version"); + } + +} diff --git a/gale-server/src/main/java/org/galemc/gale/configuration/GaleConfigurations.java b/gale-server/src/main/java/org/galemc/gale/configuration/GaleConfigurations.java new file mode 100644 index 0000000..f14c0bf --- /dev/null +++ b/gale-server/src/main/java/org/galemc/gale/configuration/GaleConfigurations.java @@ -0,0 +1,302 @@ +// Gale - Gale configuration + +package org.galemc.gale.configuration; + +import com.google.common.collect.Table; +import com.mojang.logging.LogUtils; +import io.leangen.geantyref.TypeToken; +import io.papermc.paper.configuration.Configuration; +import io.papermc.paper.configuration.ConfigurationPart; +import io.papermc.paper.configuration.Configurations; +import io.papermc.paper.configuration.NestedSetting; +import io.papermc.paper.configuration.PaperConfigurations; +import io.papermc.paper.configuration.legacy.RequiresSpigotInitialization; +import io.papermc.paper.configuration.mapping.InnerClassFieldDiscoverer; +import io.papermc.paper.configuration.serializer.ComponentSerializer; +import io.papermc.paper.configuration.serializer.EnumValueSerializer; +import io.papermc.paper.configuration.serializer.PacketClassSerializer; +import io.papermc.paper.configuration.serializer.StringRepresentableSerializer; +import io.papermc.paper.configuration.serializer.collections.FastutilMapSerializer; +import io.papermc.paper.configuration.serializer.collections.MapSerializer; +import io.papermc.paper.configuration.serializer.collections.TableSerializer; +import io.papermc.paper.configuration.serializer.registry.RegistryHolderSerializer; +import io.papermc.paper.configuration.serializer.registry.RegistryValueSerializer; +import io.papermc.paper.configuration.transformation.Transformations; +import io.papermc.paper.configuration.type.BooleanOrDefault; +import io.papermc.paper.configuration.type.Duration; +import io.papermc.paper.configuration.type.EngineMode; +import io.papermc.paper.configuration.type.fallback.FallbackValueSerializer; +import io.papermc.paper.configuration.type.number.DoubleOr; +import io.papermc.paper.configuration.type.number.IntOr; +import it.unimi.dsi.fastutil.objects.Reference2IntMap; +import it.unimi.dsi.fastutil.objects.Reference2IntOpenHashMap; +import it.unimi.dsi.fastutil.objects.Reference2LongMap; +import it.unimi.dsi.fastutil.objects.Reference2LongOpenHashMap; +import net.minecraft.core.RegistryAccess; +import net.minecraft.core.registries.Registries; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.item.Item; +import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; +import org.jetbrains.annotations.Nullable; +import org.slf4j.Logger; +import org.spongepowered.configurate.ConfigurateException; +import org.spongepowered.configurate.ConfigurationNode; +import org.spongepowered.configurate.ConfigurationOptions; +import org.spongepowered.configurate.NodePath; +import org.spongepowered.configurate.objectmapping.ObjectMapper; +import org.spongepowered.configurate.transformation.ConfigurationTransformation; +import org.spongepowered.configurate.transformation.TransformAction; +import org.spongepowered.configurate.yaml.YamlConfigurationLoader; + +import java.io.IOException; +import java.lang.reflect.Type; +import java.nio.file.Path; +import java.util.Collections; +import java.util.List; +import java.util.function.Function; + +import static io.leangen.geantyref.GenericTypeReflector.erase; + +@SuppressWarnings("Convert2Diamond") +public class GaleConfigurations extends Configurations { + + private static final Logger LOGGER = LogUtils.getLogger(); + static final String GLOBAL_CONFIG_FILE_NAME = "gale-global.yml"; + static final String WORLD_DEFAULTS_CONFIG_FILE_NAME = "gale-world-defaults.yml"; + static final String WORLD_CONFIG_FILE_NAME = "gale-world.yml"; + public static final String CONFIG_DIR = "config"; + + private static final String GLOBAL_HEADER = String.format(""" + This is the global configuration file for Gale. + As you can see, there's a lot to configure. Some options may impact gameplay, so use + with caution, and make sure you know what each option does before configuring. + + If you need help with the configuration or have any questions related to Gale, + join us in our Discord, or check the GitHub Wiki pages. + + The world configuration options are inside + their respective world folder. The files are named %s + + Wiki: https://github.com/GaleMC/Gale/wiki + Discord: https://discord.gg/gwezNT8c24""", WORLD_CONFIG_FILE_NAME); + + private static final String WORLD_DEFAULTS_HEADER = """ + This is the world defaults configuration file for Gale. + As you can see, there's a lot to configure. Some options may impact gameplay, so use + with caution, and make sure you know what each option does before configuring. + + If you need help with the configuration or have any questions related to Gale, + join us in our Discord, or check the GitHub Wiki pages. + + Configuration options here apply to all worlds, unless you specify overrides inside + the world-specific config file inside each world folder. + + Wiki: https://github.com/GaleMC/Gale/wiki + Discord: https://discord.gg/gwezNT8c24"""; + + private static final Function WORLD_HEADER = map -> String.format(""" + This is a world configuration file for Gale. + This file may start empty but can be filled with settings to override ones in the %s/%s + + World: %s (%s)""", + CONFIG_DIR, + WORLD_DEFAULTS_CONFIG_FILE_NAME, + map.require(WORLD_NAME), + map.require(WORLD_KEY) + ); + + private static final String MOVED_NOTICE = """ + The global and world default configuration files have moved to %s + and the world-specific configuration file has been moved inside + the respective world folder. + + See https://github.com/GaleMC/Gale/wiki for more information. + """; + + public GaleConfigurations(final Path globalFolder) { + super(globalFolder, GaleGlobalConfiguration.class, GaleWorldConfiguration.class, GLOBAL_CONFIG_FILE_NAME, WORLD_DEFAULTS_CONFIG_FILE_NAME, WORLD_CONFIG_FILE_NAME); + } + + @Override + protected YamlConfigurationLoader.Builder createLoaderBuilder() { + return super.createLoaderBuilder() + .defaultOptions(GaleConfigurations::defaultOptions); + } + + private static ConfigurationOptions defaultOptions(ConfigurationOptions options) { + return options.serializers(builder -> builder + .register(MapSerializer.TYPE, new MapSerializer(false)) + .register(new EnumValueSerializer()) + .register(new ComponentSerializer()) + ); + } + + @Override + protected ObjectMapper.Factory.Builder createGlobalObjectMapperFactoryBuilder() { + return defaultGlobalFactoryBuilder(super.createGlobalObjectMapperFactoryBuilder()); + } + + private static ObjectMapper.Factory.Builder defaultGlobalFactoryBuilder(ObjectMapper.Factory.Builder builder) { + return builder.addDiscoverer(InnerClassFieldDiscoverer.globalConfig()); + } + + @Override + protected YamlConfigurationLoader.Builder createGlobalLoaderBuilder() { + return super.createGlobalLoaderBuilder() + .defaultOptions(GaleConfigurations::defaultGlobalOptions); + } + + private static ConfigurationOptions defaultGlobalOptions(ConfigurationOptions options) { + return options + .header(GLOBAL_HEADER) + .serializers(builder -> builder.register(new PacketClassSerializer())); + } + + @Override + public GaleGlobalConfiguration initializeGlobalConfiguration(final RegistryAccess registryAccess) throws ConfigurateException { + GaleGlobalConfiguration configuration = super.initializeGlobalConfiguration(registryAccess); + GaleGlobalConfiguration.set(configuration); + return configuration; + } + + @Override + protected ContextMap.Builder createDefaultContextMap(final RegistryAccess registryAccess) { + return super.createDefaultContextMap(registryAccess) + .put(PaperConfigurations.SPIGOT_WORLD_CONFIG_CONTEXT_KEY, PaperConfigurations.SPIGOT_WORLD_DEFAULTS); + } + + @Override + protected ObjectMapper.Factory.Builder createWorldObjectMapperFactoryBuilder(final ContextMap contextMap) { + return super.createWorldObjectMapperFactoryBuilder(contextMap) + .addNodeResolver(new RequiresSpigotInitialization.Factory(contextMap.require(PaperConfigurations.SPIGOT_WORLD_CONFIG_CONTEXT_KEY).get())) + .addNodeResolver(new NestedSetting.Factory()) + .addDiscoverer(InnerClassFieldDiscoverer.galeWorldConfig(contextMap)); + } + + @Override + protected YamlConfigurationLoader.Builder createWorldConfigLoaderBuilder(final ContextMap contextMap) { + final RegistryAccess access = contextMap.require(REGISTRY_ACCESS); + return super.createWorldConfigLoaderBuilder(contextMap) + .defaultOptions(options -> options + .header(contextMap.require(WORLD_NAME).equals(WORLD_DEFAULTS) ? WORLD_DEFAULTS_HEADER : WORLD_HEADER.apply(contextMap)) + .serializers(serializers -> serializers + .register(new TypeToken>() {}, new FastutilMapSerializer.SomethingToPrimitive>(Reference2IntOpenHashMap::new, Integer.TYPE)) + .register(new TypeToken>() {}, new FastutilMapSerializer.SomethingToPrimitive>(Reference2LongOpenHashMap::new, Long.TYPE)) + .register(new TypeToken>() {}, new TableSerializer()) + .register(new StringRepresentableSerializer()) + .register(IntOr.Default.SERIALIZER) + .register(IntOr.Disabled.SERIALIZER) + .register(DoubleOr.Default.SERIALIZER) + .register(BooleanOrDefault.SERIALIZER) + .register(Duration.SERIALIZER) + .register(EngineMode.SERIALIZER) + .register(FallbackValueSerializer.create(contextMap.require(PaperConfigurations.SPIGOT_WORLD_CONFIG_CONTEXT_KEY).get(), MinecraftServer::getServer)) + .register(new RegistryValueSerializer<>(new TypeToken>() {}, access, Registries.ENTITY_TYPE, true)) + .register(new RegistryValueSerializer<>(Item.class, access, Registries.ITEM, true)) + .register(new RegistryHolderSerializer<>(new TypeToken>() {}, access, Registries.CONFIGURED_FEATURE, false)) + .register(new RegistryHolderSerializer<>(Item.class, access, Registries.ITEM, true)) + ) + ); + } + + @Override + protected void applyWorldConfigTransformations(final ContextMap contextMap, final ConfigurationNode node, final @Nullable ConfigurationNode defaultsNode) throws ConfigurateException { + final ConfigurationNode version = node.node(Configuration.VERSION_FIELD); + final String world = contextMap.require(WORLD_NAME); + if (version.virtual()) { + LOGGER.warn("The Gale world config file for " + world + " didn't have a version set, assuming latest"); + version.raw(GaleWorldConfiguration.CURRENT_VERSION); + } + if (GaleRemovedConfigurations.REMOVED_WORLD_PATHS.length > 0) { + ConfigurationTransformation.Builder builder = ConfigurationTransformation.builder(); + for (NodePath path : GaleRemovedConfigurations.REMOVED_WORLD_PATHS) { + builder.addAction(path, TransformAction.remove()); + } + builder.build().apply(node); + } + // ADD FUTURE TRANSFORMS HERE + } + + @Override + protected void applyGlobalConfigTransformations(ConfigurationNode node) throws ConfigurateException { + if (GaleRemovedConfigurations.REMOVED_GLOBAL_PATHS.length > 0) { + ConfigurationTransformation.Builder builder = ConfigurationTransformation.builder(); + for (NodePath path : GaleRemovedConfigurations.REMOVED_GLOBAL_PATHS) { + builder.addAction(path, TransformAction.remove()); + } + builder.build().apply(node); + } + // ADD FUTURE TRANSFORMS HERE + } + + private static final List DEFAULT_AWARE_TRANSFORMATIONS = Collections.emptyList(); + + @Override + protected void applyDefaultsAwareWorldConfigTransformations(final ContextMap contextMap, final ConfigurationNode worldNode, final ConfigurationNode defaultsNode) throws ConfigurateException { + final ConfigurationTransformation.Builder builder = ConfigurationTransformation.builder(); + // ADD FUTURE TRANSFORMS HERE (these transforms run after the defaults have been merged into the node) + DEFAULT_AWARE_TRANSFORMATIONS.forEach(transform -> transform.apply(builder, contextMap, defaultsNode)); + + ConfigurationTransformation transformation; + try { + transformation = builder.build(); // build throws IAE if no actions were provided (bad zml) + } catch (IllegalArgumentException ignored) { + return; + } + transformation.apply(worldNode); + } + + @Override + public GaleWorldConfiguration createWorldConfig(final ContextMap contextMap) { + final String levelName = contextMap.require(WORLD_NAME); + try { + return super.createWorldConfig(contextMap); + } catch (IOException exception) { + throw new RuntimeException("Could not create Gale world config for " + levelName, exception); + } + } + + @Override + protected boolean isConfigType(final Type type) { + return ConfigurationPart.class.isAssignableFrom(erase(type)); + } + + public void reloadConfigs(MinecraftServer server) { + try { + this.initializeGlobalConfiguration(reloader(this.globalConfigClass, GaleGlobalConfiguration.get())); + this.initializeWorldDefaultsConfiguration(server.registryAccess()); + for (ServerLevel level : server.getAllLevels()) { + this.createWorldConfig(PaperConfigurations.createWorldContextMap(level), reloader(this.worldConfigClass, level.galeConfig())); + } + } catch (Exception ex) { + throw new RuntimeException("Could not reload Gale configuration files", ex); + } + } + + public static GaleConfigurations setup(final Path configDir) throws Exception { + try { + PaperConfigurations.createDirectoriesSymlinkAware(configDir); + return new GaleConfigurations(configDir); + } catch (final IOException ex) { + throw new RuntimeException("Could not setup GaleConfigurations", ex); + } + } + + @Override + protected int globalConfigVersion() { + return GaleGlobalConfiguration.CURRENT_VERSION; + } + + @Override + protected int worldConfigVersion() { + return getWorldConfigurationCurrentVersion(); + } + + @Override + public int getWorldConfigurationCurrentVersion() { + return GaleWorldConfiguration.CURRENT_VERSION; + } + +} diff --git a/gale-server/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java b/gale-server/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java new file mode 100644 index 0000000..792fc95 --- /dev/null +++ b/gale-server/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java @@ -0,0 +1,151 @@ +// Gale - Gale configuration + +package org.galemc.gale.configuration; + +import io.papermc.paper.configuration.Configuration; +import io.papermc.paper.configuration.ConfigurationPart; +import net.minecraft.world.level.levelgen.structure.PoolElementStructurePiece; +import org.spongepowered.configurate.objectmapping.meta.PostProcess; +import org.spongepowered.configurate.objectmapping.meta.Setting; +import org.bukkit.plugin.java.JavaPluginLoader; + +import java.util.Locale; +import java.util.Random; +import java.util.function.Consumer; + +@SuppressWarnings({"CanBeFinal", "FieldCanBeLocal", "FieldMayBeFinal", "NotNullFieldNotInitialized", "InnerClassMayBeStatic"}) +public class GaleGlobalConfiguration extends ConfigurationPart { + static final int CURRENT_VERSION = 1; + private static GaleGlobalConfiguration instance; + public static GaleGlobalConfiguration get() { + return instance; + } + static void set(GaleGlobalConfiguration instance) { + GaleGlobalConfiguration.instance = instance; + } + + @Setting(Configuration.VERSION_FIELD) + public int version = CURRENT_VERSION; + + public SmallOptimizations smallOptimizations; + public class SmallOptimizations extends ConfigurationPart { + + public ReducedIntervals reducedIntervals; + public class ReducedIntervals extends ConfigurationPart { + + public int increaseTimeStatistics = 20; // Gale - Hydrinity - increase time statistics in intervals + public int updateEntityLineOfSight = 4; // Gale - Petal - reduce line of sight updates + + @PostProcess + public void postProcess() { + net.minecraft.world.entity.player.Player.increaseTimeStatisticsInterval = Math.max(1, increaseTimeStatistics); // Gale - Hydrinity - increase time statistics in intervals - store as static field for fast access + } + + } + + // Gale start - xor-shift random + public UseXorShiftRandom useXorShiftRandom; + public class UseXorShiftRandom extends ConfigurationPart { + + public boolean autoReplenishLootableRefill = true; + public boolean elytraFireworkSpeed = true; + public boolean entityWakeUpDuration = true; + public boolean lightningRandomTick = true; + + @Setting("generate-tree-with-bukkit-api") + public boolean generateTreeWithBukkitAPI = true; + + @PostProcess + public void postProcess() { + com.destroystokyo.paper.loottable.PaperLootableInventoryData.RANDOM = autoReplenishLootableRefill ? new org.galemc.gale.random.XorShiftRandom() : new Random(); + io.papermc.paper.entity.activation.ActivationRange.wakeUpDurationRandom = entityWakeUpDuration ? new org.galemc.gale.random.XorShiftRandom() : new Random(); + org.bukkit.craftbukkit.CraftWorld.rand = generateTreeWithBukkitAPI ? new org.galemc.gale.random.XorShiftRandom() : new Random(); + } + + } + // Gale end - xor-shift random + + } + + public GameplayMechanics gameplayMechanics; + public class GameplayMechanics extends ConfigurationPart { + + public boolean enableBookWriting = true; // Gale - Pufferfish - make book writing configurable + + } + + public Misc misc; + public class Misc extends ConfigurationPart { + + public boolean verifyChatOrder = true; // Gale - Pufferfish - make chat order verification configurable + public int premiumAccountSlowLoginTimeout = -1; // Gale - make slow login timeout configurable + public boolean ignoreNullLegacyStructureData = false; // Gale - MultiPaper - ignore null legacy structure data + + public Keepalive keepalive; + public class Keepalive extends ConfigurationPart { + public boolean sendMultiple = true; // Gale - Purpur - send multiple keep-alive packets + } + + // Gale start - YAPFA - last tick time - in TPS command + public LastTickTimeInTpsCommand lastTickTimeInTpsCommand; + public class LastTickTimeInTpsCommand extends ConfigurationPart { + public boolean enabled = false; + public boolean addOversleep = false; + } + // Gale end - YAPFA - last tick time - in TPS command + + } + + public LogToConsole logToConsole; + public class LogToConsole extends ConfigurationPart { // Gale - EMC - softly log invalid pool element errors + + public boolean invalidStatistics = true; // Gale - EMC - do not log invalid statistics + public boolean ignoredAdvancements = true; // Gale - Purpur - do not log ignored advancements + public boolean setBlockInFarChunk = true; // Gale - Purpur - do not log setBlock in far chunks + public boolean unrecognizedRecipes = false; // Gale - Purpur - do not log unrecognized recipes + public boolean legacyMaterialInitialization = false; // Gale - Purpur - do not log legacy Material initialization + public boolean nullIdDisconnections = true; // Gale - Pufferfish - do not log disconnections with null id + public boolean playerLoginLocations = true; // Gale - JettPack - make logging login location configurable + + public Chat chat; + public class Chat extends ConfigurationPart { + public boolean emptyMessageWarning = false; // Gale - do not log empty message warnings + public boolean expiredMessageWarning = false; // Gale - do not log expired message warnings + public boolean notSecureMarker = true; // Gale - do not log Not Secure marker + } + + // Gale start - Purpur - do not log plugin library loads + public PluginLibraryLoader pluginLibraryLoader; + public class PluginLibraryLoader extends ConfigurationPart { + + public boolean downloads = true; + public boolean startLoadLibrariesForPlugin = true; + public boolean libraryLoaded = true; + + @PostProcess + public void postProcess() { + JavaPluginLoader.logDownloads = this.downloads; + JavaPluginLoader.logStartLoadLibrariesForPlugin = this.startLoadLibrariesForPlugin; + JavaPluginLoader.logLibraryLoaded = this.libraryLoaded; + } + + } + // Gale end - Purpur - do not log plugin library loads + + // Gale start - EMC - softly log invalid pool element errors + public String invalidPoolElementErrorLogLevel = "info"; + public transient Consumer invalidPoolElementErrorStringConsumer; + + @PostProcess + public void postProcess() { + this.invalidPoolElementErrorStringConsumer = switch (this.invalidPoolElementErrorLogLevel.toLowerCase(Locale.ROOT)) { + case "none" -> $ -> {}; + case "info", "log" -> PoolElementStructurePiece.LOGGER::info; + case "warn", "warning" -> PoolElementStructurePiece.LOGGER::warn; + default -> PoolElementStructurePiece.LOGGER::error; + }; + } + // Gale end - EMC - softly log invalid pool element errors + + } +} diff --git a/gale-server/src/main/java/org/galemc/gale/configuration/GaleRemovedConfigurations.java b/gale-server/src/main/java/org/galemc/gale/configuration/GaleRemovedConfigurations.java new file mode 100644 index 0000000..9db3221 --- /dev/null +++ b/gale-server/src/main/java/org/galemc/gale/configuration/GaleRemovedConfigurations.java @@ -0,0 +1,13 @@ +// Gale - Gale configuration + +package org.galemc.gale.configuration; + +import org.spongepowered.configurate.NodePath; + +interface GaleRemovedConfigurations { + + NodePath[] REMOVED_WORLD_PATHS = {}; + + NodePath[] REMOVED_GLOBAL_PATHS = {}; + +} diff --git a/gale-server/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java b/gale-server/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java new file mode 100644 index 0000000..a12b0fa --- /dev/null +++ b/gale-server/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java @@ -0,0 +1,131 @@ +// Gale - Gale configuration + +package org.galemc.gale.configuration; + +import com.mojang.logging.LogUtils; +import io.papermc.paper.configuration.Configuration; +import io.papermc.paper.configuration.ConfigurationPart; +import io.papermc.paper.configuration.PaperConfigurations; +import net.minecraft.resources.ResourceLocation; +import org.slf4j.Logger; +import org.spigotmc.SpigotWorldConfig; +import org.spongepowered.configurate.objectmapping.meta.Setting; + +@SuppressWarnings({"FieldCanBeLocal", "FieldMayBeFinal", "NotNullFieldNotInitialized", "InnerClassMayBeStatic"}) +public class GaleWorldConfiguration extends ConfigurationPart { + private static final Logger LOGGER = LogUtils.getLogger(); + public static final int CURRENT_VERSION = 1; + + private transient final SpigotWorldConfig spigotConfig; + private transient final ResourceLocation worldKey; + public GaleWorldConfiguration(SpigotWorldConfig spigotConfig, ResourceLocation worldKey) { + this.spigotConfig = spigotConfig; + this.worldKey = worldKey; + } + + public boolean isDefault() { + return this.worldKey.equals(PaperConfigurations.WORLD_DEFAULTS_KEY); + } + + @Setting(Configuration.VERSION_FIELD) + public int version = CURRENT_VERSION; + + public SmallOptimizations smallOptimizations; + public class SmallOptimizations extends ConfigurationPart { + + public boolean saveFireworks = true; // Gale - EMC - make saving fireworks configurable + public boolean useOptimizedSheepOffspringColor = true; // Gale - carpet-fixes - optimize sheep offspring color + + // Gale start - Airplane - reduce projectile chunk loading + public MaxProjectileChunkLoads maxProjectileChunkLoads; + public class MaxProjectileChunkLoads extends ConfigurationPart { + + public int perTick = 10; + + public PerProjectile perProjectile; + public class PerProjectile extends ConfigurationPart { + public int max = 10; + public boolean resetMovementAfterReachLimit = false; + public boolean removeFromWorldAfterReachLimit = false; + } + + } + // Gale end - Airplane - reduce projectile chunk loading + + public ReducedIntervals reducedIntervals; + public class ReducedIntervals extends ConfigurationPart { + + public int acquirePoiForStuckEntity = 60; // Gale - Airplane - reduce acquire POI for stuck entities + public int checkStuckInWall = 10; // Gale - Pufferfish - reduce in wall checks + public int villagerItemRepickup = 100; // Gale - EMC - reduce villager item re-pickup + + public CheckNearbyItem checkNearbyItem; + public class CheckNearbyItem extends ConfigurationPart { + + // Gale start - EMC - reduce hopper item checks + public Hopper hopper; + public class Hopper extends ConfigurationPart { + + public int interval = 1; + + public Minecart minecart; + public class Minecart extends ConfigurationPart { + + public int interval = 1; + + public TemporaryImmunity temporaryImmunity; + public class TemporaryImmunity extends ConfigurationPart { + public int duration = 100; + public int nearbyItemMaxAge = 1200; + public int checkForMinecartNearItemInterval = 20; + public boolean checkForMinecartNearItemWhileInactive = true; + public double maxItemHorizontalDistance = 24.0; + public double maxItemVerticalDistance = 4.0; + } + + } + + } + // Gale end - EMC - reduce hopper item checks + + } + + } + + public LoadChunks loadChunks; + public class LoadChunks extends ConfigurationPart { + public boolean toSpawnPhantoms = false; // Gale - MultiPaper - don't load chunks to spawn phantoms + public boolean toActivateClimbingEntities = false; // Gale - don't load chunks to activate climbing entities + } + + } + + public GameplayMechanics gameplayMechanics; + public class GameplayMechanics extends ConfigurationPart { + + public Fixes fixes; + public class Fixes extends ConfigurationPart { + + public boolean broadcastCritAnimationsAsTheEntityBeingCritted = false; // Gale - MultiPaper - broadcast crit animations as the entity being critted + + // Gale start - Purpur - fix MC-238526 + @Setting("mc-238526") + public boolean mc238526 = false; + // Gale end - Purpur - fix MC-238526 + + // Gale start - Purpur - fix MC-121706 + @Setting("mc-121706") + public boolean mc121706 = false; + // Gale end - Purpur - fix MC-121706 + + } + + public boolean arrowMovementResetsDespawnCounter = true; // Gale - Purpur - make arrow movement resetting despawn counter configurable + public boolean entitiesCanRandomStrollIntoNonTickingChunks = true; // Gale - MultiPaper - prevent entities random strolling into non-ticking chunks + public double entityWakeUpDurationRatioStandardDeviation = 0.2; // Gale - variable entity wake-up duration + public boolean hideFlamesOnEntitiesWithFireResistance = false; // Gale - Slice - hide flames on entities with fire resistance + public boolean tryRespawnEnderDragonAfterEndCrystalPlace = true; // Gale - Pufferfish - make ender dragon respawn attempt after placing end crystals configurable + + } + +} diff --git a/gale-server/src/main/java/org/galemc/gale/random/XorShiftRandom.java b/gale-server/src/main/java/org/galemc/gale/random/XorShiftRandom.java new file mode 100644 index 0000000..60dc2c1 --- /dev/null +++ b/gale-server/src/main/java/org/galemc/gale/random/XorShiftRandom.java @@ -0,0 +1,404 @@ +// Gale - xor-shift random + +package org.galemc.gale.random; + +import java.util.Random; + +/** + * A random number generator based on the simple and fast xor-shift pseudo + * random number generator (RNG) specified in: + *
+ *     Marsaglia, George. (2003). + *
Xorshift RNGs. + *
+ * Code from: + *
+ *     Random.java + * by Xyene. + *
+ * Translated from: + *
+ *      + * A fast equivalent for System.Random by colgreen. + *
+ * Licensed under GNU Lesser General Public License version 3. + */ +public final class XorShiftRandom extends Random { + final double REAL_UNIT_INT = 1.0 / (0x7FFFFFFFL); + final double REAL_UNIT_UINT = 1.0 / (0xFFFFFFFFL); + final long Y = 842502087L, Z = 3579807591L, W = 273326509L; + long x, y, z, w; + + public XorShiftRandom() { + seed((int) System.currentTimeMillis()); + } + + @Override + public void setSeed(long seed) { + seed((int) seed); + } + + public void seed(int seed) { + // The only stipulation stated for the xorshift RNG is that at least one of + // the seeds x,y,z,w is non-zero. We fulfill that requirement by only allowing + // resetting of the x seed + x = seed; + y = Y; + z = Z; + w = W; + } + + long boolBuffer; + int boolBufferBits = 0; + + @Override + public boolean nextBoolean() { + if (boolBufferBits == 0) { + boolBuffer = nextUInt(); + boolBufferBits = 32; + } + boolBuffer >>= 1; + boolean bit = (boolBuffer & 1) == 0; + --boolBufferBits; + return bit; + } + + @Override + public void nextBytes(byte[] buffer) { + // Fill up the bulk of the buffer in chunks of 4 bytes at a time. + long x = this.x, y = this.y, z = this.z, w = this.w; + int i = 0; + long t; + for (int bound = buffer.length - 3; i < bound; ) { + // Generate 4 bytes. + // Increased performance is achieved by generating 4 random bytes per loop. + // Also note that no mask needs to be applied to zero out the higher order bytes before + // casting because the cast ignores thos bytes. Thanks to Stefan Trosch黷z for pointing this out. + t = (x ^ (x << 11)); + x = y; + y = z; + z = w; + w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); + + buffer[i++] = (byte) w; + buffer[i++] = (byte) (w >> 8); + buffer[i++] = (byte) (w >> 16); + buffer[i++] = (byte) (w >> 24); + } + + // Fill up any remaining bytes in the buffer. + if (i < buffer.length) { + // Generate 4 bytes. + t = (x ^ (x << 11)); + x = y; + y = z; + z = w; + w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); + + buffer[i++] = (byte) w; + if (i < buffer.length) { + buffer[i++] = (byte) (w >> 8); + if (i < buffer.length) { + buffer[i++] = (byte) (w >> 16); + if (i < buffer.length) { + buffer[i] = (byte) (w >> 24); + } + } + } + } + this.x = x; + this.y = y; + this.z = z; + this.w = w; + } + + @Override + public double nextDouble() { + long t = (x ^ (x << 11)); + x = y; + y = z; + z = w; + + // Here we can gain a 2x speed improvement by generating a value that can be cast to + // an int instead of the more easily available uint. If we then explicitly cast to an + // int the compiler will then cast the int to a double to perform the multiplication, + // this final cast is a lot faster than casting from a uint to a double. The extra cast + // to an int is very fast (the allocated bits remain the same) and so the overall effect + // of the extra cast is a significant performance improvement. + // + // Also note that the loss of one bit of precision is equivalent to what occurs within + // System.Random. + return (REAL_UNIT_INT * (int) (0x7FFFFFFF & (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8))))); + } + + public double random() { + return nextDouble(); + } + + @Override + public float nextFloat() { + return (float) nextDouble(); + } + + @Override + public int nextInt() { + long t = (x ^ (x << 11)); + x = y; + y = z; + z = w; + return (int) (0x7FFFFFFF & (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)))); + } + + @Override + public int nextInt(int upperBound) { + if (upperBound < 0) + throw new IllegalArgumentException("upperBound must be >=0"); + + long t = (x ^ (x << 11)); + x = y; + y = z; + z = w; + + return (int) ((REAL_UNIT_INT * (int) (0x7FFFFFFF & (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8))))) * upperBound); + } + + public int nextInt(int lowerBound, int upperBound) { + if (lowerBound > upperBound) + throw new IllegalArgumentException("upperBound must be >=lowerBound"); + + long t = (x ^ (x << 11)); + x = y; + y = z; + z = w; + + // The explicit int cast before the first multiplication gives better performance. + // See comments in NextDouble. + int range = upperBound - lowerBound; + if (range < 0) { + // If range is <0 then an overflow has occured and must resort to using long integer arithmetic instead (slower). + // We also must use all 32 bits of precision, instead of the normal 31, which again is slower. + return lowerBound + (int) ((REAL_UNIT_UINT * (double) (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)))) * (double) ((long) upperBound - (long) lowerBound)); + } + // 31 bits of precision will suffice if range<=int.MaxValue. This allows us to cast to an int and gain + // a little more performance. + return lowerBound + (int) ((REAL_UNIT_INT * (double) (int) (0x7FFFFFFF & (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8))))) * (double) range); + } + + public long nextUInt() { + long t = (x ^ (x << 11)); + x = y; + y = z; + z = w; + return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8))) & (0xFFFFFFFFL); + } + + @Override + public long nextLong() { + return nextUInt() << 32 + nextUInt(); + } + + double gaussNext; + boolean hasGaussNext; + final double TWOPI = Math.PI * 2; + + /** + * Get a random number in the range [min, max) or [min, max] depending on rounding. + * + * @param min Low bound + * @param max High bound + * @return A uniformly distributed double + */ + public double uniform(double min, double max) { + return min + (max - min) * nextDouble(); + } + + /** + * Triangular distribution. + *

+ * Continuous distribution bounded by given lower and upper limits, + * and having a given mode value in-between. + * http://en.wikipedia.org/wiki/Triangular_distribution + * + * @param low Low bound + * @param high High bound + * @param mode Mode + * @return A number from the triangular distribution specified + */ + public double triangular(int low, int high, int mode) { + double u = nextDouble(); + double c = (mode - low) / (high - low); + if (u > c) { + u = 1.0 - u; + c = 1.0 - c; + int k = low; + low = high; + high = k; + } + return low + (high - low) * Math.sqrt(u * c); + } + + /** + * Gaussian distribution, mean is 0 and standard deviation is 1. + *

+ * mu is the mean, and sigma is the standard deviation. + * + * @return A double in Gaussian distribution + */ + public double gauss() { + return nextGaussian(); + } + + /** + * Gaussian distribution, with user-specified mean and standard deviation. + *

+ * mu is the mean, and sigma is the standard deviation. + * + * @return A double in Gaussian distribution + */ + public double gauss(double mu, double sigma) { + return mu + sigma * nextGaussian(); + } + + public double gaussUnsigned(double mu, double sigma) { + double out = gauss(mu, sigma); + return out > 1 ? out : 1; + } + + /** + * Log normal distribution. + *

+ * If you take the natural logarithm of this distribution, you'll get a + * normal distribution with mean mu and standard deviation sigma. + * mu can have any value, and sigma must be greater than zero. + * + * @param mu Mean + * @param sigma Standard deviation + * @return A number from the log normal distribution specified + */ + public double logNormal(double mu, double sigma) { + return Math.exp(gauss(mu, sigma)); + } + + /** + * Exponential distribution. + *

+ * lambda is 1.0 divided by the desired mean. It should be + * nonzero. Returned values range from 0 to positive infinity + * if lambda is positive, and from negative infinity to 0 + * if lambda is negative. + * + * @param lambda A non-zero value + */ + public double exponential(double lambda) { + return -Math.log(1.0 - random()) / lambda; + } + + /** + * Circular data distribution. + *

+ * If kappa is equal to zero, this distribution reduces + * to a uniform random angle over the range 0 to 2*pi. + * + * @param mu the mean angle, expressed in radians between 0 and 2*pi. + * @param kappa the concentration parameter, which must be greater than or + * equal to zero. + * @return A number from the circular data distribution specified + */ + public double circularData(double mu, double kappa) { + if (kappa <= 1e-6) + return TWOPI * nextDouble(); + + double a = 1.0 + Math.sqrt(1.0 + 4.0 * kappa * kappa); + double b = (a - Math.sqrt(2.0 * a)) / (2.0 * kappa); + double r = (1.0 + b * b) / (2.0 * b); + double u1, u2, u3, f, c, z, theta = 0; + + while (true) { + u1 = nextDouble(); + + z = Math.cos(Math.PI * u1); + f = (1.0 + r * z) / (r + z); + c = kappa * (r - f); + + u2 = nextDouble(); + + if (u2 < c * (2.0 - c) || u2 <= c * Math.exp(1.0 - c)) + break; + + u3 = nextDouble(); + if (u3 > 0.5) + theta = (mu % TWOPI) + Math.acos(f); + else + theta = (mu % TWOPI) - Math.acos(f); + } + return theta; + } + + + final double LOG4 = Math.log(4); + final double SG_MAGICCONST = 1.0 + Math.log(4.5); + + /** + * Gamma distribution. Not the gamma function! + * Conditions on the parameters are alpha > 0 and beta > 0. + *

+ * The probability distribution function is: + * pdf(x) = (x ** (alpha - 1) * math.exp(-x / beta)) / (math.gamma(alpha) * beta ** alpha) + * + * @param alpha Alpha + * @param beta Beta + * @return A number from the gamma distribution specified + */ + public double gamma(double alpha, double beta) { + if (alpha <= 0.0 || beta <= 0.0) + throw new IllegalArgumentException("alpha and beta must be > 0.0"); + + if (alpha > 1.0) { + double ainv = Math.sqrt(2.0 * alpha - 1.0); + double bbb = alpha - LOG4; + double ccc = alpha + ainv; + double u1, u2, v, x, z, r; + + while (true) { + u1 = random(); + if (!(1e-7 < u1 && u1 < .9999999)) + continue; + u2 = 1.0 - random(); + v = Math.log(u1 / (1.0 - u1)) / ainv; + x = alpha * Math.exp(v); + z = u1 * u1 * u2; + r = bbb + ccc * v - x; + if (r + SG_MAGICCONST - 4.5 * z >= 0.0 || r >= Math.log(z)) + return x * beta; + } + } else if (alpha == 1.0) { + // exponential(1) + double u; + u = random(); + while (u <= 1e-7) + u = random(); + return -Math.log(u) * beta; + } else { + // alpha is between 0 and 1 (exclusive) + // Uses ALGORITHM GS of Statistical Computing -Kennedy & Gentle + + double u, b, p, x, u1; + while (true) { + u = random(); + b = (Math.E + alpha) / Math.E; + p = b * u; + if (p <= 1.0) + x = Math.pow(p, (1.0 / alpha)); + else + x = -Math.log((b - p) / alpha); + u1 = random(); + if (p > 1.0) { + if (u1 <= Math.pow(x, (alpha - 1.0))) + break; + } else if (u1 <= Math.exp(-x)) + break; + } + return x * beta; + } + } +} diff --git a/gale-server/src/main/java/org/galemc/gale/version/AbstractPaperVersionFetcher.java b/gale-server/src/main/java/org/galemc/gale/version/AbstractPaperVersionFetcher.java new file mode 100644 index 0000000..fab5d5a --- /dev/null +++ b/gale-server/src/main/java/org/galemc/gale/version/AbstractPaperVersionFetcher.java @@ -0,0 +1,154 @@ +// Gale - branding changes - version fetcher + +package org.galemc.gale.version; + +import com.destroystokyo.paper.PaperVersionFetcher; +import com.destroystokyo.paper.VersionHistoryManager; +import com.destroystokyo.paper.util.VersionFetcher; +import com.google.common.base.Charsets; +import com.google.gson.Gson; +import com.google.gson.JsonObject; +import com.google.gson.JsonSyntaxException; +import com.mojang.logging.LogUtils; +import io.papermc.paper.ServerBuildInfo; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.event.ClickEvent; +import net.kyori.adventure.text.format.NamedTextColor; +import net.kyori.adventure.text.format.TextDecoration; +import org.jetbrains.annotations.NotNull; +import org.slf4j.Logger; + +import javax.annotation.Nullable; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.URI; +import java.util.Optional; + +import static net.kyori.adventure.text.Component.text; +import static net.kyori.adventure.text.format.TextColor.color; + +/** + * An abstract version fetcher, derived from {@link PaperVersionFetcher}. + * This class was then made to be a superclass of both {@link PaperVersionFetcher} + * and {@link GaleVersionFetcher}. + *
+ * Changes to {@link PaperVersionFetcher} are indicated by Gale marker comments. + */ +public abstract class AbstractPaperVersionFetcher implements VersionFetcher { + protected static final Logger LOGGER = LogUtils.getClassLogger(); + protected static final int DISTANCE_ERROR = -1; + protected static final int DISTANCE_UNKNOWN = -2; + protected static final ServerBuildInfo BUILD_INFO = ServerBuildInfo.buildInfo(); + + // Gale start - branding changes - version fetcher + protected final String gitHubBranchName; + protected final String downloadPage; + protected final String organizationDisplayName; + protected final String projectDisplayName; + protected final String gitHubOrganizationName; + protected final String gitHubRepoName; + + protected AbstractPaperVersionFetcher(String githubBranchName, String downloadPage, String organizationDisplayName, String projectDisplayName, String gitHubOrganizationName, String gitHubRepoName) { + this.gitHubBranchName = githubBranchName; + this.downloadPage = downloadPage; + this.organizationDisplayName = organizationDisplayName; + this.projectDisplayName = projectDisplayName; + this.gitHubOrganizationName = gitHubOrganizationName; + this.gitHubRepoName = gitHubRepoName; + } + // Gale end - branding changes - version fetcher + + @Override + public long getCacheTime() { + return 720000; + } + + @Override + public @NotNull Component getVersionMessage(final @NotNull String serverVersion) { + final Component updateMessage; + final ServerBuildInfo build = ServerBuildInfo.buildInfo(); + if (build.buildNumber().isEmpty() && build.gitCommit().isEmpty()) { + updateMessage = text("You are running a development version without access to version information", color(0xFF5300)); + } else { + updateMessage = getUpdateStatusMessage(this.gitHubOrganizationName + "/" + this.gitHubRepoName, build); // Gale - branding changes - version fetcher + } + final @Nullable Component history = this.getHistory(); + + return history != null ? Component.textOfChildren(updateMessage, Component.newline(), history) : updateMessage; + } + + // Gale start - branding changes - version fetcher + protected boolean canFetchDistanceFromSiteApi() { + return false; + } + + protected int fetchDistanceFromSiteApi(int jenkinsBuild) { + return -1; + } + // Gale end - branding changes - version fetcher + + private Component getUpdateStatusMessage(final String repo, final ServerBuildInfo build) { + int distance = DISTANCE_ERROR; + + // Gale start - branding changes - version fetcher + final Optional gitBranch = build.gitBranch(); + final Optional gitCommit = build.gitCommit(); + if (gitBranch.isPresent() && gitCommit.isPresent()) { + distance = fetchDistanceFromGitHub(repo, gitBranch.get(), gitCommit.get()); + } + // Gale end - branding changes - version fetcher + + return switch (distance) { + case DISTANCE_ERROR -> text("Error obtaining version information", NamedTextColor.YELLOW); + case 0 -> text("You are running the latest version", NamedTextColor.GREEN); + case DISTANCE_UNKNOWN -> text("Unknown version", NamedTextColor.YELLOW); + default -> text("You are " + distance + " version(s) behind", NamedTextColor.YELLOW) + .append(Component.newline()) + .append(text("Download the new version at: ") + .append(text(this.downloadPage, NamedTextColor.GOLD) // Gale - branding changes - version fetcher + .hoverEvent(text("Click to open", NamedTextColor.WHITE)) + .clickEvent(ClickEvent.openUrl(this.downloadPage)))); // Gale - branding changes - version fetcher + }; + } + + // Contributed by Techcable in GH-65 + private static int fetchDistanceFromGitHub(final String repo, final String branch, final String hash) { + try { + final HttpURLConnection connection = (HttpURLConnection) URI.create("https://api.github.com/repos/%s/compare/%s...%s".formatted(repo, branch, hash)).toURL().openConnection(); + connection.connect(); + if (connection.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) + return DISTANCE_UNKNOWN; // Unknown commit + try (final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), Charsets.UTF_8))) { + final JsonObject obj = new Gson().fromJson(reader, JsonObject.class); + final String status = obj.get("status").getAsString(); + return switch (status) { + case "identical" -> 0; + case "behind" -> obj.get("behind_by").getAsInt(); + default -> DISTANCE_ERROR; + }; + } catch (final JsonSyntaxException | NumberFormatException e) { + LOGGER.error("Error parsing json from GitHub's API", e); + return DISTANCE_ERROR; + } + } catch (final IOException e) { + LOGGER.error("Error while parsing version", e); + return DISTANCE_ERROR; + } + } + + private @Nullable Component getHistory() { + final VersionHistoryManager.VersionData data = VersionHistoryManager.INSTANCE.getVersionData(); + if (data == null) { + return null; + } + + final @Nullable String oldVersion = data.getOldVersion(); + if (oldVersion == null) { + return null; + } + + return text("Previous version: " + oldVersion, NamedTextColor.GRAY, TextDecoration.ITALIC); + } +} diff --git a/gale-server/src/main/java/org/galemc/gale/version/GaleSemanticVersion.java b/gale-server/src/main/java/org/galemc/gale/version/GaleSemanticVersion.java new file mode 100644 index 0000000..f873cac --- /dev/null +++ b/gale-server/src/main/java/org/galemc/gale/version/GaleSemanticVersion.java @@ -0,0 +1,37 @@ +// Gale - semantic version + +package org.galemc.gale.version; + +import org.jetbrains.annotations.NotNull; + +/** + * A holder for the Gale semantic version. + */ +public final class GaleSemanticVersion { + + private GaleSemanticVersion() { + throw new RuntimeException(); + } + + /** + * A semantic version in the format "major.minor.patch", for example "1.5.1". + * The major version is incremented when a large and overarching set of features, with a large + * and overarching common goal or effect, has been added compared to the first release with that major version. + * The minor version is incremented for each build that has a different intended feature set + * (for example, some features or part of them were added or removed). + * The patch version is incremented for small changes that do not affect the goal of any feature, + * such as bug fixes, performance improvements or changes in wording. + */ + public static final @NotNull String version = "0.6.15"; + + /** + * The "major.minor" portion of the {@link #version}. + */ + public static final @NotNull String majorMinorVersion; + static { + int firstDotIndex = version.indexOf('.'); + int secondDotIndex = version.indexOf('.', firstDotIndex + 1); + majorMinorVersion = version.substring(0, secondDotIndex); + } + +} diff --git a/gale-server/src/main/java/org/galemc/gale/version/GaleVersionFetcher.java b/gale-server/src/main/java/org/galemc/gale/version/GaleVersionFetcher.java new file mode 100644 index 0000000..9a03014 --- /dev/null +++ b/gale-server/src/main/java/org/galemc/gale/version/GaleVersionFetcher.java @@ -0,0 +1,17 @@ +// Gale - branding changes - version fetcher + +package org.galemc.gale.version; + +public class GaleVersionFetcher extends AbstractPaperVersionFetcher { + + public GaleVersionFetcher() { + super( + "ver/1.21.3", + "https://github.com/Dreeam-qwq/Gale", + "GaleMC", + "Gale", + "GaleMC", + "Gale"); + } + +} diff --git a/gale-server/src/main/java/org/galemc/gale/virtualthread/DirectVirtualThreadService.java b/gale-server/src/main/java/org/galemc/gale/virtualthread/DirectVirtualThreadService.java new file mode 100644 index 0000000..38d3b77 --- /dev/null +++ b/gale-server/src/main/java/org/galemc/gale/virtualthread/DirectVirtualThreadService.java @@ -0,0 +1,50 @@ +// Gale - virtual thread support + +package org.galemc.gale.virtualthread; + +import org.jetbrains.annotations.NotNull; + +import java.util.Objects; +import java.util.concurrent.ThreadFactory; + +/** + * An implementation of {@link VirtualThreadService} that can create virtual threads directly. + * + * @author Martijn Muijsers + */ +final class DirectVirtualThreadService extends VirtualThreadService { + + private DirectVirtualThreadService() { + super(); + } + + @Override + public @NotNull ThreadFactory createFactory() { + // Disabled until Minecraft requires servers to have a Java version that can read class files compiled with functionality from Java 19+ on preview / Java 21+ on stable + //throw new UnsupportedOperationException(); + return Thread.ofVirtual().factory(); + } + + @Override + public @NotNull Thread start(@NotNull Runnable task) { + // Disabled until Minecraft requires servers to have a Java version that can read class files compiled with functionality from Java 19+ on preview / Java 21+ on stable + //throw new UnsupportedOperationException(); + Objects.requireNonNull(task, "The task to start a virtual thread cannot be null"); + return Thread.ofVirtual().start(task); + } + + /** + * @return A functional {@link DirectVirtualThreadService}. + * @throws Throwable If creating virtual threads directly is not supported by the current runtime. + * This could be any {@link Throwable}, including an {@link Exception} or an {@link Error}. + */ + static @NotNull DirectVirtualThreadService create() throws Throwable { + // Disabled until Minecraft requires servers to have a Java version that can read class files compiled with functionality from Java 19+ on preview / Java 21+ on stable + //throw new UnsupportedOperationException(); + var service = new DirectVirtualThreadService(); + // Run some tests to verify + service.runTest(); + // If we end up here, it works + return service; + } +} diff --git a/gale-server/src/main/java/org/galemc/gale/virtualthread/ReflectionVirtualThreadService.java b/gale-server/src/main/java/org/galemc/gale/virtualthread/ReflectionVirtualThreadService.java new file mode 100644 index 0000000..19b83cf --- /dev/null +++ b/gale-server/src/main/java/org/galemc/gale/virtualthread/ReflectionVirtualThreadService.java @@ -0,0 +1,75 @@ +// Gale - virtual thread support + +package org.galemc.gale.virtualthread; + +import org.jetbrains.annotations.NotNull; + +import java.lang.reflect.Method; +import java.util.Objects; +import java.util.concurrent.ThreadFactory; + +/** + * An implementation of {@link VirtualThreadService} that can create virtual threads using Java reflection. + * + * @author Martijn Muijsers + */ +final class ReflectionVirtualThreadService extends VirtualThreadService { + + /** + * The {@link Thread}#ofVirtual() method. + */ + private final @NotNull Method Thread_ofVirtual_method; + + /** + * The {@link Thread}.Builder#factory() method. + */ + private final @NotNull Method Thread_Builder_factory_method; + + /** + * The {@link Thread}.Builder#start(Runnable) method. + */ + private final @NotNull Method Thread_Builder_start_method; + + private ReflectionVirtualThreadService() throws Throwable { + this.Thread_ofVirtual_method = Objects.requireNonNull(Thread.class.getMethod("ofVirtual")); + // The Thread.Builder class + var Thread_Builder_class = Objects.requireNonNull(Class.forName("java.lang.Thread$Builder")); + this.Thread_Builder_factory_method = Objects.requireNonNull(Thread_Builder_class.getMethod("factory")); + this.Thread_Builder_start_method = Objects.requireNonNull(Thread_Builder_class.getMethod("start", Runnable.class)); + } + + @Override + public @NotNull ThreadFactory createFactory() { + try { + return (ThreadFactory) this.Thread_Builder_factory_method.invoke(this.Thread_ofVirtual_method.invoke(null)); + } catch (Exception e) { + // This should not be possible because it was tested in create() + throw new RuntimeException(e); + } + } + + @Override + public @NotNull Thread start(@NotNull Runnable task) { + Objects.requireNonNull(task, "The task to start a virtual thread cannot be null"); + try { + return (Thread) this.Thread_Builder_start_method.invoke(this.Thread_ofVirtual_method.invoke(null), task); + } catch (Exception e) { + // This should not be possible because it was tested in create() + throw new RuntimeException(e); + } + } + + /** + * @return A functional {@link ReflectionVirtualThreadService}. + * @throws Throwable If creating virtual threads via reflection is not supported by the current runtime. + * This could be any {@link Throwable}, including an {@link Exception} or an {@link Error}. + */ + static @NotNull ReflectionVirtualThreadService create() throws Throwable { + // This will already throw something if the reflection fails + var service = new ReflectionVirtualThreadService(); + // Run some tests to verify + service.runTest(); + // If we end up here, it works + return service; + } +} diff --git a/gale-server/src/main/java/org/galemc/gale/virtualthread/VirtualThreadService.java b/gale-server/src/main/java/org/galemc/gale/virtualthread/VirtualThreadService.java new file mode 100644 index 0000000..e9757e8 --- /dev/null +++ b/gale-server/src/main/java/org/galemc/gale/virtualthread/VirtualThreadService.java @@ -0,0 +1,104 @@ +// Gale - virtual thread support + +package org.galemc.gale.virtualthread; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.concurrent.ThreadFactory; + +/** + * An abstract service to create virtual threads. + * + * @author Martijn Muijsers + */ +public sealed abstract class VirtualThreadService permits ReflectionVirtualThreadService, DirectVirtualThreadService { + + /** + * @return A {@link ThreadFactory} that produces virtual threads. + */ + public abstract @NotNull ThreadFactory createFactory(); + + /** + * @param task The runnable for the thread to execute. + * @return A virtual thread that has been started with the given task. + */ + public abstract @NotNull Thread start(Runnable task); + + /** + * Runs a test on the {@link #createFactory} and {@link #start} methods, + * which certainly throws some {@link Throwable} if something goes wrong. + */ + protected void runTest() throws Throwable { + // This will definitely throw something if it doesn't work + try { + this.start(() -> {}).join(); + } catch (InterruptedException ignored) {} // Except InterruptedException, we don't care about that one + try { + var thread = this.createFactory().newThread(() -> {}); + thread.start(); + thread.join(); + } catch (InterruptedException ignored) {} // Except InterruptedException, we don't care about that one + // If we end up here, it works + } + + private static boolean initialized = false; + + /** + * The {@link VirtualThreadService} for the current runtime, + * or null if virtual threads are not supported, or if not {@link #initialized} yet. + */ + private static @Nullable VirtualThreadService implementation; + + /** + * @return Whether virtual threads are supported on the current runtime. + */ + public static boolean isSupported() { + return get() != null; + } + + /** + * @return The {@link VirtualThreadService} for the current runtime, + * or null if virtual threads are not {@linkplain #isSupported() supported}. + * + * This method is thread-safe only after the first time it has been fully run. + */ + public static @Nullable VirtualThreadService get() { + if (!initialized) { + initialized = true; + try { + implementation = DirectVirtualThreadService.create(); + } catch (Throwable ignored) { + try { + implementation = ReflectionVirtualThreadService.create(); + } catch (Throwable ignored2) {} + } + } + return implementation; + } + + /** + * The minimum major version of Java that is known to support using virtual threads + * (although possibly behind a feature preview flag). + */ + public static final int minimumJavaMajorVersionWithFeaturePreview = 19; + + /** + * The minimum major version of Java that is known to support using virtual threads + * even without any feature preview flags. + */ + public static final int minimumJavaMajorVersionWithoutFeaturePreview = 21; + + public static int getJavaMajorVersion() { + var version = System.getProperty("java.version"); + if (version.startsWith("1.")) { + return version.charAt(2) - '0'; + } + if (version.contains("-")) { + version = version.substring(0, version.indexOf("-")); + } + + int dotIndex = version.indexOf("."); + return Integer.parseInt(dotIndex == -1 ? version : version.substring(0, dotIndex)); + } +} diff --git a/gradle.properties b/gradle.properties index a3d5b77..fb63566 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,10 +1,11 @@ group=org.galemc.gale -version=1.21.3-R0.1-SNAPSHOT +version=1.21.4-R0.1-SNAPSHOT -mcVersion=1.21.3 -paperRef=da7138233f6392e791d790d1c3407414c855f9c2 +mcVersion=1.21.4 +paperRef=49d15f6345b59b2085ded0a634336d3406d62fdc -org.gradle.caching=false +org.gradle.configuration-cache=true +org.gradle.caching=true org.gradle.parallel=true org.gradle.vfs.watch=false org.gradle.jvmargs = -Xmx4G \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index df97d72..cea7a79 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index f5feea6..f3b75f3 100755 --- a/gradlew +++ b/gradlew @@ -86,8 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s -' "$PWD" ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum diff --git a/patches/api/0001-Hide-irrelevant-compilation-warnings.patch b/patches/api/0001-Hide-irrelevant-compilation-warnings.patch deleted file mode 100644 index f714f44..0000000 --- a/patches/api/0001-Hide-irrelevant-compilation-warnings.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Martijn Muijsers -Date: Tue, 29 Nov 2022 01:15:55 +0100 -Subject: [PATCH] Hide irrelevant compilation warnings - -License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) -Gale - https://galemc.org - -diff --git a/build.gradle.kts b/build.gradle.kts -index e29e5024fa693baae469d47fe77b57118f14627c..0225bbd7773527a34e267a0404ba7db7809d8e5a 100644 ---- a/build.gradle.kts -+++ b/build.gradle.kts -@@ -148,6 +148,15 @@ val generateApiVersioningFile by tasks.registering { - } - } - -+// Gale start - hide irrelevant compilation warnings -+tasks.withType { -+ val compilerArgs = options.compilerArgs -+ compilerArgs.add("-Xlint:-module") -+ compilerArgs.add("-Xlint:-removal") -+ compilerArgs.add("-Xlint:-dep-ann") -+} -+// Gale end - hide irrelevant compilation warnings -+ - tasks.jar { - from(generateApiVersioningFile.map { it.outputs.files.singleFile }) { - into("META-INF/maven/${project.group}/${project.name}") -@@ -207,6 +216,8 @@ tasks.withType { - into("build/docs/javadoc") - } - } -+ -+ options.addStringOption("Xdoclint:none", "-quiet") // Gale - hide irrelevant compilation warnings - } - - tasks.test { diff --git a/patches/server/0001-Gale-project-setup.patch b/patches/server/0001-Gale-project-setup.patch deleted file mode 100644 index 088f40a..0000000 --- a/patches/server/0001-Gale-project-setup.patch +++ /dev/null @@ -1,21 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Martijn Muijsers -Date: Thu, 24 Nov 2022 21:26:57 +0100 -Subject: [PATCH] Gale project setup - -License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) -Gale - https://galemc.org - -diff --git a/build.gradle.kts b/build.gradle.kts -index faf3e3fd72e8c915e7a4803dacbe1bb576c6663e..7b7054ebe7eb73f56b30fcdf7fe61d50e7b535cb 100644 ---- a/build.gradle.kts -+++ b/build.gradle.kts -@@ -25,7 +25,7 @@ abstract class MockitoAgentProvider : CommandLineArgumentProvider { - // Paper end - configure mockito agent that is needed in newer java versions - - dependencies { -- implementation(project(":paper-api")) -+ implementation(project(":gale-api")) // Gale start - project setup - Depend on own API - // Paper start - implementation("org.jline:jline-terminal-ffm:3.27.1") // use ffm on java 22+ - implementation("org.jline:jline-terminal-jni:3.27.1") // fall back to jni on java 21 diff --git a/patches/server/0003-Hide-irrelevant-compilation-warnings.patch b/patches/server/0003-Hide-irrelevant-compilation-warnings.patch deleted file mode 100644 index 6086915..0000000 --- a/patches/server/0003-Hide-irrelevant-compilation-warnings.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Martijn Muijsers -Date: Sun, 24 Sep 2023 14:58:55 +0200 -Subject: [PATCH] Hide irrelevant compilation warnings - -License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) -Gale - https://galemc.org - -diff --git a/build.gradle.kts b/build.gradle.kts -index 7b7054ebe7eb73f56b30fcdf7fe61d50e7b535cb..5e37caba6b6ac2dc4b11a15e17bc67ab5ec5b1c4 100644 ---- a/build.gradle.kts -+++ b/build.gradle.kts -@@ -86,6 +86,15 @@ paperweight { - craftBukkitPackageVersion.set("v1_21_R2") // also needs to be updated in MappingEnvironment - } - -+// Gale start - hide irrelevant compilation warnings -+tasks.withType { -+ val compilerArgs = options.compilerArgs -+ compilerArgs.add("-Xlint:-module") -+ compilerArgs.add("-Xlint:-removal") -+ compilerArgs.add("-Xlint:-dep-ann") -+} -+// Gale end - hide irrelevant compilation warnings -+ - tasks.jar { - archiveClassifier.set("dev") - diff --git a/patches/server/0004-Enable-preview-features-for-development-runs.patch b/patches/server/0004-Enable-preview-features-for-development-runs.patch deleted file mode 100644 index 70e6037..0000000 --- a/patches/server/0004-Enable-preview-features-for-development-runs.patch +++ /dev/null @@ -1,20 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Martijn Muijsers -Date: Mon, 13 Feb 2023 21:18:44 +0100 -Subject: [PATCH] Enable preview features for development runs - -License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) -Gale - https://galemc.org - -diff --git a/build.gradle.kts b/build.gradle.kts -index 5e37caba6b6ac2dc4b11a15e17bc67ab5ec5b1c4..1bbd7458f6031cedde5c7efa652481bf4c66b5d6 100644 ---- a/build.gradle.kts -+++ b/build.gradle.kts -@@ -209,6 +209,7 @@ fun TaskContainer.registerRunTask( - val memoryGb = providers.gradleProperty("paper.runMemoryGb").getOrElse("2") - minHeapSize = "${memoryGb}G" - maxHeapSize = "${memoryGb}G" -+ jvmArgs("--enable-preview") // Gale - enable preview features for development runs - - doFirst { - workingDir.mkdirs() diff --git a/patches/server/0007-Gale-semantic-version.patch b/patches/server/0007-Gale-semantic-version.patch deleted file mode 100644 index af18615..0000000 --- a/patches/server/0007-Gale-semantic-version.patch +++ /dev/null @@ -1,72 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Martijn Muijsers -Date: Wed, 9 Aug 2023 19:04:22 +0200 -Subject: [PATCH] Gale semantic version - -License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) -Gale - https://galemc.org - -diff --git a/src/main/java/com/destroystokyo/paper/Metrics.java b/src/main/java/com/destroystokyo/paper/Metrics.java -index e848529892c07cad638090a39ef738b4a068db3e..cb9e42fea57856f9ab649e33df26071db1b7790f 100644 ---- a/src/main/java/com/destroystokyo/paper/Metrics.java -+++ b/src/main/java/com/destroystokyo/paper/Metrics.java -@@ -926,6 +926,16 @@ public class Metrics { - })); - // Gale end - metrics - runtime max memory - -+ // Gale start - semantic version - include in metrics -+ Map> semanticVersionMap = new HashMap<>(2); -+ { -+ Map entry = new HashMap<>(2); -+ entry.put(org.galemc.gale.version.GaleSemanticVersion.version, 1); -+ semanticVersionMap.put(org.galemc.gale.version.GaleSemanticVersion.majorMinorVersion, entry); -+ } -+ metrics.addCustomChart(new Metrics.DrilldownPie("gale_semantic_version", () -> semanticVersionMap)); -+ // Gale end - semantic version - include in metrics -+ - } - - } -diff --git a/src/main/java/org/galemc/gale/version/GaleSemanticVersion.java b/src/main/java/org/galemc/gale/version/GaleSemanticVersion.java -new file mode 100644 -index 0000000000000000000000000000000000000000..f873cac7566e1951fc2977d6f7c4ba3cefa1a9f1 ---- /dev/null -+++ b/src/main/java/org/galemc/gale/version/GaleSemanticVersion.java -@@ -0,0 +1,37 @@ -+// Gale - semantic version -+ -+package org.galemc.gale.version; -+ -+import org.jetbrains.annotations.NotNull; -+ -+/** -+ * A holder for the Gale semantic version. -+ */ -+public final class GaleSemanticVersion { -+ -+ private GaleSemanticVersion() { -+ throw new RuntimeException(); -+ } -+ -+ /** -+ * A semantic version in the format "major.minor.patch", for example "1.5.1". -+ * The major version is incremented when a large and overarching set of features, with a large -+ * and overarching common goal or effect, has been added compared to the first release with that major version. -+ * The minor version is incremented for each build that has a different intended feature set -+ * (for example, some features or part of them were added or removed). -+ * The patch version is incremented for small changes that do not affect the goal of any feature, -+ * such as bug fixes, performance improvements or changes in wording. -+ */ -+ public static final @NotNull String version = "0.6.15"; -+ -+ /** -+ * The "major.minor" portion of the {@link #version}. -+ */ -+ public static final @NotNull String majorMinorVersion; -+ static { -+ int firstDotIndex = version.indexOf('.'); -+ int secondDotIndex = version.indexOf('.', firstDotIndex + 1); -+ majorMinorVersion = version.substring(0, secondDotIndex); -+ } -+ -+} diff --git a/patches/server/0008-Gale-configuration.patch b/patches/server/0008-Gale-configuration.patch deleted file mode 100644 index 407b3fe..0000000 --- a/patches/server/0008-Gale-configuration.patch +++ /dev/null @@ -1,707 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Martijn Muijsers -Date: Wed, 23 Nov 2022 21:05:47 +0100 -Subject: [PATCH] Gale configuration - -License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) -Gale - https://galemc.org - -This patch is based on the following patch: -"Paper config files" -By: Jake Potrebic -As part of: Paper (https://github.com/PaperMC/Paper) -Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) - -diff --git a/src/main/java/io/papermc/paper/configuration/Configurations.java b/src/main/java/io/papermc/paper/configuration/Configurations.java -index 8cf720f08514e8e4f62f4ad196f1277bd761c6b2..63afa5284028f3c423d19c2d5cb35b83c89050fd 100644 ---- a/src/main/java/io/papermc/paper/configuration/Configurations.java -+++ b/src/main/java/io/papermc/paper/configuration/Configurations.java -@@ -94,7 +94,7 @@ public abstract class Configurations { - }; - } - -- static CheckedFunction reloader(Class type, T instance) { -+ public static CheckedFunction reloader(Class type, T instance) { // Gale - Gale configuration - return node -> { - ObjectMapper.Factory factory = (ObjectMapper.Factory) Objects.requireNonNull(node.options().serializers().get(type)); - ObjectMapper.Mutable mutable = (ObjectMapper.Mutable) factory.get(type); -@@ -168,7 +168,7 @@ public abstract class Configurations { - final YamlConfigurationLoader loader = result.loader(); - final ConfigurationNode node = loader.load(); - if (result.isNewFile()) { // add version to new files -- node.node(Configuration.VERSION_FIELD).raw(this.worldConfigVersion()); -+ node.node(Configuration.VERSION_FIELD).raw(getWorldConfigurationCurrentVersion()); // Gale - Gale configuration - } else { - this.verifyWorldConfigVersion(contextMap, node); - } -@@ -230,7 +230,7 @@ public abstract class Configurations { - .build(); - final ConfigurationNode worldNode = worldLoader.load(); - if (newFile) { // set the version field if new file -- worldNode.node(Configuration.VERSION_FIELD).set(this.worldConfigVersion()); -+ worldNode.node(Configuration.VERSION_FIELD).set(getWorldConfigurationCurrentVersion()); // Gale - Gale configuration - } else { - this.verifyWorldConfigVersion(contextMap, worldNode); - } -@@ -356,4 +356,25 @@ public abstract class Configurations { - return "ContextKey{" + this.name + "}"; - } - } -+ -+ // Gale start - Gale configuration -+ -+ public static final String legacyWorldsSectionKey = "__________WORLDS__________"; -+ public static final String legacyWorldDefaultsSectionKey = "__defaults__"; -+ -+ @Deprecated -+ public org.bukkit.configuration.file.YamlConfiguration createLegacyObject(final net.minecraft.server.MinecraftServer server) { -+ org.bukkit.configuration.file.YamlConfiguration global = org.bukkit.configuration.file.YamlConfiguration.loadConfiguration(this.globalFolder.resolve(this.globalConfigFileName).toFile()); -+ org.bukkit.configuration.ConfigurationSection worlds = global.createSection(legacyWorldsSectionKey); -+ worlds.set(legacyWorldDefaultsSectionKey, org.bukkit.configuration.file.YamlConfiguration.loadConfiguration(this.globalFolder.resolve(this.defaultWorldConfigFileName).toFile())); -+ for (ServerLevel level : server.getAllLevels()) { -+ worlds.set(level.getWorld().getName(), org.bukkit.configuration.file.YamlConfiguration.loadConfiguration(getWorldConfigFile(level).toFile())); -+ } -+ return global; -+ } -+ -+ public abstract int getWorldConfigurationCurrentVersion(); -+ -+ // Gale end - Gale configuration -+ - } -diff --git a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java -index c5644d8d64f12073e39bc6ed79c8714f4560ff89..b993d3e2e9d987115129067e3a51060880453ee2 100644 ---- a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java -+++ b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java -@@ -326,7 +326,7 @@ public class PaperConfigurations extends Configurations globalConfig() { -+ // Gale start - Gale configuration -+ public static FieldDiscoverer galeWorldConfig(io.papermc.paper.configuration.Configurations.ContextMap contextMap) { -+ final Map, Object> overrides = Map.of( -+ org.galemc.gale.configuration.GaleWorldConfiguration.class, new org.galemc.gale.configuration.GaleWorldConfiguration( -+ contextMap.require(io.papermc.paper.configuration.PaperConfigurations.SPIGOT_WORLD_CONFIG_CONTEXT_KEY).get(), -+ contextMap.require(io.papermc.paper.configuration.Configurations.WORLD_KEY) -+ ) -+ ); -+ return new InnerClassFieldDiscoverer(overrides); -+ } -+ // Gale end - Gale configuration -+ -+ public static FieldDiscoverer globalConfig() { // Gale - Gale configuration - return new InnerClassFieldDiscoverer(Collections.emptyMap()); - } - } -diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index c26e3a239441376f2694782d4f07943538677c71..39e166379617630ca9cbad0f5dc4647d183a7570 100644 ---- a/src/main/java/net/minecraft/server/MinecraftServer.java -+++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -327,6 +327,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop public - - public static Services create(YggdrasilAuthenticationService authenticationService, File rootDirectory, File userCacheFile, joptsimple.OptionSet optionSet) throws Exception { // Paper - add optionset to load paper config files; add userCacheFile parameter -@@ -34,7 +39,10 @@ public record Services( - final java.nio.file.Path legacyConfigPath = ((File) optionSet.valueOf("paper-settings")).toPath(); - final java.nio.file.Path configDirPath = ((File) optionSet.valueOf("paper-settings-directory")).toPath(); - io.papermc.paper.configuration.PaperConfigurations paperConfigurations = io.papermc.paper.configuration.PaperConfigurations.setup(legacyConfigPath, configDirPath, rootDirectory.toPath(), (File) optionSet.valueOf("spigot-settings")); -- return new Services(minecraftSessionService, authenticationService.getServicesKeySet(), gameProfileRepository, gameProfileCache, paperConfigurations); -+ // Gale start - Gale configuration -+ org.galemc.gale.configuration.GaleConfigurations galeConfigurations = org.galemc.gale.configuration.GaleConfigurations.setup(configDirPath); -+ return new Services(minecraftSessionService, authenticationService.getServicesKeySet(), gameProfileRepository, gameProfileCache, paperConfigurations, galeConfigurations); -+ // Gale end - Gale configuration - // Paper end - load paper config files from cli options - } - -diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -index 17a158ff6ce6520b69a5a0032ba4c05449dd0cf8..9ce281e220089ea2a9218c25879f42aafa0a4011 100644 ---- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -@@ -223,6 +223,10 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface - this.paperConfigurations.initializeGlobalConfiguration(this.registryAccess()); - this.paperConfigurations.initializeWorldDefaultsConfiguration(this.registryAccess()); - // Paper end - initialize global and world-defaults configuration -+ // Gale start - Gale configuration -+ galeConfigurations.initializeGlobalConfiguration(this.registryAccess()); -+ galeConfigurations.initializeWorldDefaultsConfiguration(this.registryAccess()); -+ // Gale end - Gale configuration - this.server.spark.enableEarlyIfRequested(); // Paper - spark - // Paper start - fix converting txt to json file; convert old users earlier after PlayerList creation but before file load/save - if (this.convertOldUsers()) { -diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index b4027f5cf90935a1fe3ab2c28b0bcbb55a7b541b..73bed8c899d146893e7e2f845b7bbf991d5d8a1f 100644 ---- a/src/main/java/net/minecraft/server/level/ServerLevel.java -+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java -@@ -597,7 +597,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe - - // Add env and gen to constructor, IWorldDataServer -> WorldDataServer - public ServerLevel(MinecraftServer minecraftserver, Executor executor, LevelStorageSource.LevelStorageAccess convertable_conversionsession, PrimaryLevelData iworlddataserver, ResourceKey resourcekey, LevelStem worlddimension, ChunkProgressListener worldloadlistener, boolean flag, long i, List list, boolean flag1, @Nullable RandomSequences randomsequences, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) { -- super(iworlddataserver, resourcekey, minecraftserver.registryAccess(), worlddimension.type(), false, flag, i, minecraftserver.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> minecraftserver.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(convertable_conversionsession.levelDirectory.path(), iworlddataserver.getLevelName(), resourcekey.location(), spigotConfig, minecraftserver.registryAccess(), iworlddataserver.getGameRules())), executor); // Paper - create paper world configs; Async-Anti-Xray: Pass executor -+ super(iworlddataserver, resourcekey, minecraftserver.registryAccess(), worlddimension.type(), false, flag, i, minecraftserver.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> minecraftserver.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(convertable_conversionsession.levelDirectory.path(), iworlddataserver.getLevelName(), resourcekey.location(), spigotConfig, minecraftserver.registryAccess(), iworlddataserver.getGameRules())), spigotConfig -> minecraftserver.galeConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(convertable_conversionsession.levelDirectory.path(), iworlddataserver.getLevelName(), resourcekey.location(), spigotConfig, minecraftserver.registryAccess(), iworlddataserver.getGameRules())), executor); // Paper - create paper world configs; Async-Anti-Xray: Pass executor // Gale - Gale configuration - this.pvpMode = minecraftserver.isPvpAllowed(); - this.convertable = convertable_conversionsession; - this.uuid = WorldUUID.getUUID(convertable_conversionsession.levelDirectory.path().toFile()); -diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index 0de2b79481352b52438dde284262019b29949ad8..5ac5b21b5193cadeaa16250747be3b6685ca21ff 100644 ---- a/src/main/java/net/minecraft/world/level/Level.java -+++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -172,6 +172,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl - return this.paperConfig; - } - // Paper end - add paper world config -+ // Gale start - Gale configuration -+ private final org.galemc.gale.configuration.GaleWorldConfiguration galeConfig; -+ public org.galemc.gale.configuration.GaleWorldConfiguration galeConfig() { -+ return this.galeConfig; -+ } -+ // Gale end - Gale configuration - - public final com.destroystokyo.paper.antixray.ChunkPacketBlockController chunkPacketBlockController; // Paper - Anti-Xray - public static BlockPos lastPhysicsProblem; // Spigot -@@ -830,7 +836,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl - } - // Paper end - optimise random ticking - -- protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, RegistryAccess iregistrycustom, Holder holder, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function paperWorldConfigCreator, java.util.concurrent.Executor executor) { // Paper - create paper world config & Anti-Xray -+ protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, RegistryAccess iregistrycustom, Holder holder, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function paperWorldConfigCreator, java.util.function.Function galeWorldConfigCreator, java.util.concurrent.Executor executor) { // Paper - create paper world config & Anti-Xray // Gale - Gale configuration - // Paper start - getblock optimisations - cache world height/sections - final DimensionType dimType = holder.value(); - this.minY = dimType.minY(); -@@ -842,6 +848,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl - // Paper end - getblock optimisations - cache world height/sections - this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot - this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper - create paper world config -+ this.galeConfig = galeWorldConfigCreator.apply(this.spigotConfig); // Gale - Gale configuration - this.generator = gen; - this.world = new CraftWorld((ServerLevel) this, gen, biomeProvider, env); - -diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index ac8af406180bc680d46e8edc3da0fc2e5211345a..269e3937b4ad1bdf04faa214245a2accbdc3a225 100644 ---- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java -+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -1086,6 +1086,7 @@ public final class CraftServer implements Server { - - org.spigotmc.SpigotConfig.init((File) this.console.options.valueOf("spigot-settings")); // Spigot - this.console.paperConfigurations.reloadConfigs(this.console); -+ this.console.galeConfigurations.reloadConfigs(this.console); // Gale - Gale configuration - for (ServerLevel world : this.console.getAllLevels()) { - // world.serverLevelData.setDifficulty(config.difficulty); // Paper - per level difficulty - world.setSpawnSettings(world.serverLevelData.getDifficulty() != Difficulty.PEACEFUL && config.spawnMonsters); // Paper - per level difficulty (from MinecraftServer#setDifficulty(ServerLevel, Difficulty, boolean)) -@@ -3031,6 +3032,14 @@ public final class CraftServer implements Server { - return CraftServer.this.console.paperConfigurations.createLegacyObject(CraftServer.this.console); - } - -+ // Gale start - Gale configuration - API -+ @Override -+ public YamlConfiguration getGaleConfig() -+ { -+ return CraftServer.this.console.galeConfigurations.createLegacyObject(CraftServer.this.console); -+ } -+ // Gale end - Gale configuration - API -+ - @Override - public void restart() { - org.spigotmc.RestartCommand.restart(); -diff --git a/src/main/java/org/galemc/gale/configuration/GaleConfigurations.java b/src/main/java/org/galemc/gale/configuration/GaleConfigurations.java -new file mode 100644 -index 0000000000000000000000000000000000000000..de25d0b4001363e63873af8f0f2165e5449786df ---- /dev/null -+++ b/src/main/java/org/galemc/gale/configuration/GaleConfigurations.java -@@ -0,0 +1,304 @@ -+// Gale - Gale configuration -+ -+package org.galemc.gale.configuration; -+ -+import com.google.common.collect.Table; -+import com.mojang.logging.LogUtils; -+import io.leangen.geantyref.TypeToken; -+import io.papermc.paper.configuration.Configuration; -+import io.papermc.paper.configuration.ConfigurationPart; -+import io.papermc.paper.configuration.Configurations; -+import io.papermc.paper.configuration.GlobalConfiguration; -+import io.papermc.paper.configuration.WorldConfiguration; -+import io.papermc.paper.configuration.mapping.InnerClassFieldDiscoverer; -+import io.papermc.paper.configuration.NestedSetting; -+import io.papermc.paper.configuration.PaperConfigurations; -+import io.papermc.paper.configuration.legacy.RequiresSpigotInitialization; -+import io.papermc.paper.configuration.serializer.ComponentSerializer; -+import io.papermc.paper.configuration.serializer.EnumValueSerializer; -+import io.papermc.paper.configuration.serializer.collections.FastutilMapSerializer; -+import io.papermc.paper.configuration.serializer.PacketClassSerializer; -+import io.papermc.paper.configuration.serializer.StringRepresentableSerializer; -+import io.papermc.paper.configuration.serializer.collections.TableSerializer; -+import io.papermc.paper.configuration.serializer.collections.MapSerializer; -+import io.papermc.paper.configuration.serializer.registry.RegistryHolderSerializer; -+import io.papermc.paper.configuration.serializer.registry.RegistryValueSerializer; -+import io.papermc.paper.configuration.transformation.Transformations; -+import io.papermc.paper.configuration.type.BooleanOrDefault; -+import io.papermc.paper.configuration.type.number.DoubleOr; -+import io.papermc.paper.configuration.type.Duration; -+import io.papermc.paper.configuration.type.EngineMode; -+import io.papermc.paper.configuration.type.number.IntOr; -+import io.papermc.paper.configuration.type.fallback.FallbackValueSerializer; -+import it.unimi.dsi.fastutil.objects.Reference2IntMap; -+import it.unimi.dsi.fastutil.objects.Reference2IntOpenHashMap; -+import it.unimi.dsi.fastutil.objects.Reference2LongMap; -+import it.unimi.dsi.fastutil.objects.Reference2LongOpenHashMap; -+import net.minecraft.core.RegistryAccess; -+import net.minecraft.core.registries.Registries; -+import net.minecraft.server.MinecraftServer; -+import net.minecraft.server.level.ServerLevel; -+import net.minecraft.world.entity.EntityType; -+import net.minecraft.world.item.Item; -+import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; -+import org.jetbrains.annotations.Nullable; -+import org.slf4j.Logger; -+import org.spongepowered.configurate.ConfigurateException; -+import org.spongepowered.configurate.ConfigurationNode; -+import org.spongepowered.configurate.ConfigurationOptions; -+import org.spongepowered.configurate.NodePath; -+import org.spongepowered.configurate.objectmapping.ObjectMapper; -+import org.spongepowered.configurate.transformation.ConfigurationTransformation; -+import org.spongepowered.configurate.transformation.TransformAction; -+import org.spongepowered.configurate.yaml.YamlConfigurationLoader; -+ -+import java.io.IOException; -+import java.lang.reflect.Type; -+import java.nio.file.Path; -+import java.util.Collections; -+import java.util.List; -+import java.util.function.Function; -+ -+import static io.leangen.geantyref.GenericTypeReflector.erase; -+ -+@SuppressWarnings("Convert2Diamond") -+public class GaleConfigurations extends Configurations { -+ -+ private static final Logger LOGGER = LogUtils.getLogger(); -+ static final String GLOBAL_CONFIG_FILE_NAME = "gale-global.yml"; -+ static final String WORLD_DEFAULTS_CONFIG_FILE_NAME = "gale-world-defaults.yml"; -+ static final String WORLD_CONFIG_FILE_NAME = "gale-world.yml"; -+ public static final String CONFIG_DIR = "config"; -+ -+ private static final String GLOBAL_HEADER = String.format(""" -+ This is the global configuration file for Gale. -+ As you can see, there's a lot to configure. Some options may impact gameplay, so use -+ with caution, and make sure you know what each option does before configuring. -+ -+ If you need help with the configuration or have any questions related to Gale, -+ join us in our Discord, or check the GitHub Wiki pages. -+ -+ The world configuration options are inside -+ their respective world folder. The files are named %s -+ -+ Wiki: https://github.com/GaleMC/Gale/wiki -+ Discord: https://discord.gg/gwezNT8c24""", WORLD_CONFIG_FILE_NAME); -+ -+ private static final String WORLD_DEFAULTS_HEADER = """ -+ This is the world defaults configuration file for Gale. -+ As you can see, there's a lot to configure. Some options may impact gameplay, so use -+ with caution, and make sure you know what each option does before configuring. -+ -+ If you need help with the configuration or have any questions related to Gale, -+ join us in our Discord, or check the GitHub Wiki pages. -+ -+ Configuration options here apply to all worlds, unless you specify overrides inside -+ the world-specific config file inside each world folder. -+ -+ Wiki: https://github.com/GaleMC/Gale/wiki -+ Discord: https://discord.gg/gwezNT8c24"""; -+ -+ private static final Function WORLD_HEADER = map -> String.format(""" -+ This is a world configuration file for Gale. -+ This file may start empty but can be filled with settings to override ones in the %s/%s -+ -+ World: %s (%s)""", -+ CONFIG_DIR, -+ WORLD_DEFAULTS_CONFIG_FILE_NAME, -+ map.require(WORLD_NAME), -+ map.require(WORLD_KEY) -+ ); -+ -+ private static final String MOVED_NOTICE = """ -+ The global and world default configuration files have moved to %s -+ and the world-specific configuration file has been moved inside -+ the respective world folder. -+ -+ See https://github.com/GaleMC/Gale/wiki for more information. -+ """; -+ -+ public GaleConfigurations(final Path globalFolder) { -+ super(globalFolder, GaleGlobalConfiguration.class, GaleWorldConfiguration.class, GLOBAL_CONFIG_FILE_NAME, WORLD_DEFAULTS_CONFIG_FILE_NAME, WORLD_CONFIG_FILE_NAME); -+ } -+ -+ @Override -+ protected YamlConfigurationLoader.Builder createLoaderBuilder() { -+ return super.createLoaderBuilder() -+ .defaultOptions(GaleConfigurations::defaultOptions); -+ } -+ -+ private static ConfigurationOptions defaultOptions(ConfigurationOptions options) { -+ return options.serializers(builder -> builder -+ .register(MapSerializer.TYPE, new MapSerializer(false)) -+ .register(new EnumValueSerializer()) -+ .register(new ComponentSerializer()) -+ ); -+ } -+ -+ @Override -+ protected ObjectMapper.Factory.Builder createGlobalObjectMapperFactoryBuilder() { -+ return defaultGlobalFactoryBuilder(super.createGlobalObjectMapperFactoryBuilder()); -+ } -+ -+ private static ObjectMapper.Factory.Builder defaultGlobalFactoryBuilder(ObjectMapper.Factory.Builder builder) { -+ return builder.addDiscoverer(InnerClassFieldDiscoverer.globalConfig()); -+ } -+ -+ @Override -+ protected YamlConfigurationLoader.Builder createGlobalLoaderBuilder() { -+ return super.createGlobalLoaderBuilder() -+ .defaultOptions(GaleConfigurations::defaultGlobalOptions); -+ } -+ -+ private static ConfigurationOptions defaultGlobalOptions(ConfigurationOptions options) { -+ return options -+ .header(GLOBAL_HEADER) -+ .serializers(builder -> builder.register(new PacketClassSerializer())); -+ } -+ -+ @Override -+ public GaleGlobalConfiguration initializeGlobalConfiguration(final RegistryAccess registryAccess) throws ConfigurateException { -+ GaleGlobalConfiguration configuration = super.initializeGlobalConfiguration(registryAccess); -+ GaleGlobalConfiguration.set(configuration); -+ return configuration; -+ } -+ -+ @Override -+ protected ContextMap.Builder createDefaultContextMap(final RegistryAccess registryAccess) { -+ return super.createDefaultContextMap(registryAccess) -+ .put(PaperConfigurations.SPIGOT_WORLD_CONFIG_CONTEXT_KEY, PaperConfigurations.SPIGOT_WORLD_DEFAULTS); -+ } -+ -+ @Override -+ protected ObjectMapper.Factory.Builder createWorldObjectMapperFactoryBuilder(final ContextMap contextMap) { -+ return super.createWorldObjectMapperFactoryBuilder(contextMap) -+ .addNodeResolver(new RequiresSpigotInitialization.Factory(contextMap.require(PaperConfigurations.SPIGOT_WORLD_CONFIG_CONTEXT_KEY).get())) -+ .addNodeResolver(new NestedSetting.Factory()) -+ .addDiscoverer(InnerClassFieldDiscoverer.galeWorldConfig(contextMap)); -+ } -+ -+ @Override -+ protected YamlConfigurationLoader.Builder createWorldConfigLoaderBuilder(final ContextMap contextMap) { -+ final RegistryAccess access = contextMap.require(REGISTRY_ACCESS); -+ return super.createWorldConfigLoaderBuilder(contextMap) -+ .defaultOptions(options -> options -+ .header(contextMap.require(WORLD_NAME).equals(WORLD_DEFAULTS) ? WORLD_DEFAULTS_HEADER : WORLD_HEADER.apply(contextMap)) -+ .serializers(serializers -> serializers -+ .register(new TypeToken>() {}, new FastutilMapSerializer.SomethingToPrimitive>(Reference2IntOpenHashMap::new, Integer.TYPE)) -+ .register(new TypeToken>() {}, new FastutilMapSerializer.SomethingToPrimitive>(Reference2LongOpenHashMap::new, Long.TYPE)) -+ .register(new TypeToken>() {}, new TableSerializer()) -+ .register(new StringRepresentableSerializer()) -+ .register(IntOr.Default.SERIALIZER) -+ .register(IntOr.Disabled.SERIALIZER) -+ .register(DoubleOr.Default.SERIALIZER) -+ .register(BooleanOrDefault.SERIALIZER) -+ .register(Duration.SERIALIZER) -+ .register(EngineMode.SERIALIZER) -+ .register(FallbackValueSerializer.create(contextMap.require(PaperConfigurations.SPIGOT_WORLD_CONFIG_CONTEXT_KEY).get(), MinecraftServer::getServer)) -+ .register(new RegistryValueSerializer<>(new TypeToken>() {}, access, Registries.ENTITY_TYPE, true)) -+ .register(new RegistryValueSerializer<>(Item.class, access, Registries.ITEM, true)) -+ .register(new RegistryHolderSerializer<>(new TypeToken>() {}, access, Registries.CONFIGURED_FEATURE, false)) -+ .register(new RegistryHolderSerializer<>(Item.class, access, Registries.ITEM, true)) -+ ) -+ ); -+ } -+ -+ @Override -+ protected void applyWorldConfigTransformations(final ContextMap contextMap, final ConfigurationNode node, final @Nullable ConfigurationNode defaultsNode) throws ConfigurateException { -+ final ConfigurationNode version = node.node(Configuration.VERSION_FIELD); -+ final String world = contextMap.require(WORLD_NAME); -+ if (version.virtual()) { -+ LOGGER.warn("The Gale world config file for " + world + " didn't have a version set, assuming latest"); -+ version.raw(GaleWorldConfiguration.CURRENT_VERSION); -+ } -+ if (GaleRemovedConfigurations.REMOVED_WORLD_PATHS.length > 0) { -+ ConfigurationTransformation.Builder builder = ConfigurationTransformation.builder(); -+ for (NodePath path : GaleRemovedConfigurations.REMOVED_WORLD_PATHS) { -+ builder.addAction(path, TransformAction.remove()); -+ } -+ builder.build().apply(node); -+ } -+ // ADD FUTURE TRANSFORMS HERE -+ } -+ -+ @Override -+ protected void applyGlobalConfigTransformations(ConfigurationNode node) throws ConfigurateException { -+ if (GaleRemovedConfigurations.REMOVED_GLOBAL_PATHS.length > 0) { -+ ConfigurationTransformation.Builder builder = ConfigurationTransformation.builder(); -+ for (NodePath path : GaleRemovedConfigurations.REMOVED_GLOBAL_PATHS) { -+ builder.addAction(path, TransformAction.remove()); -+ } -+ builder.build().apply(node); -+ } -+ // ADD FUTURE TRANSFORMS HERE -+ } -+ -+ private static final List DEFAULT_AWARE_TRANSFORMATIONS = Collections.emptyList(); -+ -+ @Override -+ protected void applyDefaultsAwareWorldConfigTransformations(final ContextMap contextMap, final ConfigurationNode worldNode, final ConfigurationNode defaultsNode) throws ConfigurateException { -+ final ConfigurationTransformation.Builder builder = ConfigurationTransformation.builder(); -+ // ADD FUTURE TRANSFORMS HERE (these transforms run after the defaults have been merged into the node) -+ DEFAULT_AWARE_TRANSFORMATIONS.forEach(transform -> transform.apply(builder, contextMap, defaultsNode)); -+ -+ ConfigurationTransformation transformation; -+ try { -+ transformation = builder.build(); // build throws IAE if no actions were provided (bad zml) -+ } catch (IllegalArgumentException ignored) { -+ return; -+ } -+ transformation.apply(worldNode); -+ } -+ -+ @Override -+ public GaleWorldConfiguration createWorldConfig(final ContextMap contextMap) { -+ final String levelName = contextMap.require(WORLD_NAME); -+ try { -+ return super.createWorldConfig(contextMap); -+ } catch (IOException exception) { -+ throw new RuntimeException("Could not create Gale world config for " + levelName, exception); -+ } -+ } -+ -+ @Override -+ protected boolean isConfigType(final Type type) { -+ return ConfigurationPart.class.isAssignableFrom(erase(type)); -+ } -+ -+ public void reloadConfigs(MinecraftServer server) { -+ try { -+ this.initializeGlobalConfiguration(reloader(this.globalConfigClass, GaleGlobalConfiguration.get())); -+ this.initializeWorldDefaultsConfiguration(server.registryAccess()); -+ for (ServerLevel level : server.getAllLevels()) { -+ this.createWorldConfig(PaperConfigurations.createWorldContextMap(level), reloader(this.worldConfigClass, level.galeConfig())); -+ } -+ } catch (Exception ex) { -+ throw new RuntimeException("Could not reload Gale configuration files", ex); -+ } -+ } -+ -+ public static GaleConfigurations setup(final Path configDir) throws Exception { -+ try { -+ PaperConfigurations.createDirectoriesSymlinkAware(configDir); -+ return new GaleConfigurations(configDir); -+ } catch (final IOException ex) { -+ throw new RuntimeException("Could not setup GaleConfigurations", ex); -+ } -+ } -+ -+ @Override -+ protected int globalConfigVersion() { -+ return GaleGlobalConfiguration.CURRENT_VERSION; -+ } -+ -+ @Override -+ protected int worldConfigVersion() { -+ return getWorldConfigurationCurrentVersion(); -+ } -+ -+ @Override -+ public int getWorldConfigurationCurrentVersion() { -+ return GaleWorldConfiguration.CURRENT_VERSION; -+ } -+ -+} -diff --git a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -new file mode 100644 -index 0000000000000000000000000000000000000000..8f8fd98f96cd390ba43033521982a13044df91cf ---- /dev/null -+++ b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -@@ -0,0 +1,30 @@ -+// Gale - Gale configuration -+ -+package org.galemc.gale.configuration; -+ -+import io.papermc.paper.configuration.Configuration; -+import io.papermc.paper.configuration.ConfigurationPart; -+import org.spongepowered.configurate.objectmapping.meta.Setting; -+ -+@SuppressWarnings({"CanBeFinal", "FieldCanBeLocal", "FieldMayBeFinal", "NotNullFieldNotInitialized", "InnerClassMayBeStatic"}) -+public class GaleGlobalConfiguration extends ConfigurationPart { -+ static final int CURRENT_VERSION = 1; -+ private static GaleGlobalConfiguration instance; -+ public static GaleGlobalConfiguration get() { -+ return instance; -+ } -+ static void set(GaleGlobalConfiguration instance) { -+ GaleGlobalConfiguration.instance = instance; -+ } -+ -+ @Setting(Configuration.VERSION_FIELD) -+ public int version = CURRENT_VERSION; -+ -+ public SmallOptimizations smallOptimizations; -+ public class SmallOptimizations extends ConfigurationPart { -+ -+ public int dummyValue = 0; -+ -+ } -+ -+} -diff --git a/src/main/java/org/galemc/gale/configuration/GaleRemovedConfigurations.java b/src/main/java/org/galemc/gale/configuration/GaleRemovedConfigurations.java -new file mode 100644 -index 0000000000000000000000000000000000000000..9db322100dacbf2343fbb86e3e83d99febfa9d9d ---- /dev/null -+++ b/src/main/java/org/galemc/gale/configuration/GaleRemovedConfigurations.java -@@ -0,0 +1,13 @@ -+// Gale - Gale configuration -+ -+package org.galemc.gale.configuration; -+ -+import org.spongepowered.configurate.NodePath; -+ -+interface GaleRemovedConfigurations { -+ -+ NodePath[] REMOVED_WORLD_PATHS = {}; -+ -+ NodePath[] REMOVED_GLOBAL_PATHS = {}; -+ -+} -diff --git a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -new file mode 100644 -index 0000000000000000000000000000000000000000..b82bb95b524c95cdefb81abef906eded0717e9a1 ---- /dev/null -+++ b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -@@ -0,0 +1,40 @@ -+// Gale - Gale configuration -+ -+package org.galemc.gale.configuration; -+ -+import com.mojang.logging.LogUtils; -+import io.papermc.paper.configuration.Configuration; -+import io.papermc.paper.configuration.ConfigurationPart; -+import io.papermc.paper.configuration.PaperConfigurations; -+import net.minecraft.resources.ResourceLocation; -+import org.slf4j.Logger; -+import org.spigotmc.SpigotWorldConfig; -+import org.spongepowered.configurate.objectmapping.meta.Setting; -+ -+@SuppressWarnings({"FieldCanBeLocal", "FieldMayBeFinal", "NotNullFieldNotInitialized", "InnerClassMayBeStatic"}) -+public class GaleWorldConfiguration extends ConfigurationPart { -+ private static final Logger LOGGER = LogUtils.getLogger(); -+ public static final int CURRENT_VERSION = 1; -+ -+ private transient final SpigotWorldConfig spigotConfig; -+ private transient final ResourceLocation worldKey; -+ public GaleWorldConfiguration(SpigotWorldConfig spigotConfig, ResourceLocation worldKey) { -+ this.spigotConfig = spigotConfig; -+ this.worldKey = worldKey; -+ } -+ -+ public boolean isDefault() { -+ return this.worldKey.equals(PaperConfigurations.WORLD_DEFAULTS_KEY); -+ } -+ -+ @Setting(Configuration.VERSION_FIELD) -+ public int version = CURRENT_VERSION; -+ -+ public SmallOptimizations smallOptimizations; -+ public class SmallOptimizations extends ConfigurationPart { -+ -+ public int dummyValue = 0; -+ -+ } -+ -+} diff --git a/patches/server/0010-Gale-commands.patch b/patches/server/0010-Gale-commands.patch deleted file mode 100644 index 1a507bf..0000000 --- a/patches/server/0010-Gale-commands.patch +++ /dev/null @@ -1,464 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Martijn Muijsers -Date: Sat, 26 Nov 2022 10:47:56 +0100 -Subject: [PATCH] Gale commands - -License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) -Gale - https://galemc.org - -This patch is based on the following patch: -"Paper command" -By: Zach Brown -As part of: Paper (https://github.com/PaperMC/Paper) -Licensed under: MIT (https://opensource.org/licenses/MIT) - -diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -index 9ce281e220089ea2a9218c25879f42aafa0a4011..9ce34bd0dbdd87d1e75d54ed037bca2d01e0210d 100644 ---- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -@@ -237,6 +237,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface - org.spigotmc.WatchdogThread.doStart(org.spigotmc.SpigotConfig.timeoutTime, org.spigotmc.SpigotConfig.restartOnCrash); // Paper - start watchdog thread - thread.start(); // Paper - Enhance console tab completions for brigadier commands; start console thread after MinecraftServer.console & PaperConfig are initialized - io.papermc.paper.command.PaperCommands.registerCommands(this); // Paper - setup /paper command -+ org.galemc.gale.command.GaleCommands.registerCommands(this); // Gale - Gale commands - register commands - this.server.spark.registerCommandBeforePlugins(this.server); // Paper - spark - com.destroystokyo.paper.Metrics.PaperMetrics.startMetrics(); // Paper - start metrics - com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // Paper - load version history now -diff --git a/src/main/java/org/galemc/gale/command/GaleCommand.java b/src/main/java/org/galemc/gale/command/GaleCommand.java -new file mode 100644 -index 0000000000000000000000000000000000000000..87d3aed35341dfa9358af064dd54d7de95078269 ---- /dev/null -+++ b/src/main/java/org/galemc/gale/command/GaleCommand.java -@@ -0,0 +1,179 @@ -+// Gale - Gale commands - /gale command -+ -+package org.galemc.gale.command; -+ -+import io.papermc.paper.command.CommandUtil; -+import it.unimi.dsi.fastutil.Pair; -+import net.minecraft.Util; -+import org.bukkit.Bukkit; -+import org.bukkit.Location; -+import org.bukkit.command.Command; -+import org.bukkit.command.CommandSender; -+import org.bukkit.permissions.Permission; -+import org.bukkit.permissions.PermissionDefault; -+import org.bukkit.plugin.PluginManager; -+import org.galemc.gale.command.subcommands.InfoCommand; -+import org.galemc.gale.command.subcommands.ReloadCommand; -+import org.galemc.gale.command.subcommands.VersionCommand; -+import org.jetbrains.annotations.Nullable; -+ -+import java.util.ArrayList; -+import java.util.Arrays; -+import java.util.Collection; -+import java.util.Collections; -+import java.util.HashMap; -+import java.util.List; -+import java.util.Locale; -+import java.util.Map; -+import java.util.Objects; -+import java.util.Set; -+import java.util.stream.Collectors; -+ -+import static net.kyori.adventure.text.Component.newline; -+import static net.kyori.adventure.text.Component.text; -+import static net.kyori.adventure.text.format.NamedTextColor.RED; -+import static net.kyori.adventure.text.format.NamedTextColor.GRAY; -+ -+public final class GaleCommand extends Command { -+ public static final String COMMAND_LABEL = "gale"; -+ public static final String BASE_PERM = GaleCommands.COMMAND_BASE_PERM + "." + COMMAND_LABEL; -+ private static final Permission basePermission = new Permission(BASE_PERM, PermissionDefault.TRUE); -+ // subcommand label -> subcommand -+ private static final GaleSubcommand RELOAD_SUBCOMMAND = new ReloadCommand(); -+ private static final GaleSubcommand VERSION_SUBCOMMAND = new VersionCommand(); -+ private static final GaleSubcommand INFO_SUBCOMMAND = new InfoCommand(); -+ private static final Map SUBCOMMANDS = Util.make(() -> { -+ final Map, GaleSubcommand> commands = new HashMap<>(); -+ -+ commands.put(Set.of(ReloadCommand.LITERAL_ARGUMENT), RELOAD_SUBCOMMAND); -+ commands.put(Set.of(VersionCommand.LITERAL_ARGUMENT), VERSION_SUBCOMMAND); -+ commands.put(Set.of(InfoCommand.LITERAL_ARGUMENT), INFO_SUBCOMMAND); -+ -+ return commands.entrySet().stream() -+ .flatMap(entry -> entry.getKey().stream().map(s -> Map.entry(s, entry.getValue()))) -+ .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); -+ }); -+ // alias -> subcommand label -+ private static final Map ALIASES = Util.make(() -> { -+ final Map> aliases = new HashMap<>(); -+ -+ aliases.put(VersionCommand.LITERAL_ARGUMENT, Set.of("ver")); -+ aliases.put(InfoCommand.LITERAL_ARGUMENT, Set.of("about")); -+ -+ return aliases.entrySet().stream() -+ .flatMap(entry -> entry.getValue().stream().map(s -> Map.entry(s, entry.getKey()))) -+ .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); -+ }); -+ -+ private String createUsageMessage(Collection arguments) { -+ return "/" + COMMAND_LABEL + " [" + String.join(" | ", arguments) + "]"; -+ } -+ -+ public GaleCommand() { -+ super(COMMAND_LABEL); -+ this.description = "Gale related commands"; -+ this.usageMessage = this.createUsageMessage(SUBCOMMANDS.keySet()); -+ final List permissions = SUBCOMMANDS.values().stream().map(GaleSubcommand::getPermission).filter(Objects::nonNull).toList(); -+ this.setPermission(BASE_PERM); -+ final PluginManager pluginManager = Bukkit.getServer().getPluginManager(); -+ pluginManager.addPermission(basePermission); -+ for (final Permission permission : permissions) { -+ pluginManager.addPermission(permission); -+ } -+ } -+ -+ @Override -+ public List tabComplete( -+ final CommandSender sender, -+ final String alias, -+ final String[] args, -+ final @Nullable Location location -+ ) throws IllegalArgumentException { -+ if (args.length <= 1) { -+ List subCommandArguments = new ArrayList<>(SUBCOMMANDS.size()); -+ for (Map.Entry subCommandEntry : SUBCOMMANDS.entrySet()) { -+ if (subCommandEntry.getValue().testPermission(sender)) { -+ subCommandArguments.add(subCommandEntry.getKey()); -+ } -+ } -+ return CommandUtil.getListMatchingLast(sender, args, subCommandArguments); -+ } -+ -+ final @Nullable Pair subCommand = resolveCommand(args[0]); -+ if (subCommand != null && subCommand.second().testPermission(sender)) { -+ return subCommand.second().tabComplete(sender, subCommand.first(), Arrays.copyOfRange(args, 1, args.length)); -+ } -+ -+ return Collections.emptyList(); -+ } -+ -+ private boolean testHasOnePermission(CommandSender sender) { -+ for (Map.Entry subCommandEntry : SUBCOMMANDS.entrySet()) { -+ if (subCommandEntry.getValue().testPermission(sender)) { -+ return true; -+ } -+ } -+ return false; -+ } -+ -+ @Override -+ public boolean execute( -+ final CommandSender sender, -+ final String commandLabel, -+ final String[] args -+ ) { -+ -+ // Check if the sender has the base permission and at least one specific permission -+ if (!sender.hasPermission(basePermission) || !this.testHasOnePermission(sender)) { -+ sender.sendMessage(Bukkit.permissionMessage()); -+ return true; -+ } -+ -+ // Determine the usage message with the subcommands they can perform -+ List subCommandArguments = new ArrayList<>(SUBCOMMANDS.size()); -+ for (Map.Entry subCommandEntry : SUBCOMMANDS.entrySet()) { -+ if (subCommandEntry.getValue().testPermission(sender)) { -+ subCommandArguments.add(subCommandEntry.getKey()); -+ } -+ } -+ String specificUsageMessage = this.createUsageMessage(subCommandArguments); -+ -+ // If they did not give a subcommand -+ if (args.length == 0) { -+ INFO_SUBCOMMAND.execute(sender, InfoCommand.LITERAL_ARGUMENT, new String[0]); -+ sender.sendMessage(newline().append(text("Command usage: " + specificUsageMessage, GRAY))); -+ return false; -+ } -+ -+ // If they do not have permission for the subcommand they gave, or the argument is not a valid subcommand -+ final @Nullable Pair subCommand = resolveCommand(args[0]); -+ if (subCommand == null || !subCommand.second().testPermission(sender)) { -+ sender.sendMessage(text("Usage: " + specificUsageMessage, RED)); -+ return false; -+ } -+ -+ // Execute the subcommand -+ final String[] choppedArgs = Arrays.copyOfRange(args, 1, args.length); -+ return subCommand.second().execute(sender, subCommand.first(), choppedArgs); -+ -+ } -+ -+ private static @Nullable Pair resolveCommand(String label) { -+ label = label.toLowerCase(Locale.ENGLISH); -+ @Nullable GaleSubcommand subCommand = SUBCOMMANDS.get(label); -+ if (subCommand == null) { -+ final @Nullable String command = ALIASES.get(label); -+ if (command != null) { -+ label = command; -+ subCommand = SUBCOMMANDS.get(command); -+ } -+ } -+ -+ if (subCommand != null) { -+ return Pair.of(label, subCommand); -+ } -+ -+ return null; -+ } -+ -+} -diff --git a/src/main/java/org/galemc/gale/command/GaleCommands.java b/src/main/java/org/galemc/gale/command/GaleCommands.java -new file mode 100644 -index 0000000000000000000000000000000000000000..b729f2c778e6158f1cb3aecc7f0ed0a746ff6339 ---- /dev/null -+++ b/src/main/java/org/galemc/gale/command/GaleCommands.java -@@ -0,0 +1,31 @@ -+// Gale - Gale commands -+ -+package org.galemc.gale.command; -+ -+import net.minecraft.server.MinecraftServer; -+import org.bukkit.command.Command; -+import org.bukkit.craftbukkit.util.permissions.CraftDefaultPermissions; -+import org.checkerframework.checker.nullness.qual.NonNull; -+import org.checkerframework.framework.qual.DefaultQualifier; -+ -+import java.util.HashMap; -+import java.util.Map; -+ -+@DefaultQualifier(NonNull.class) -+public final class GaleCommands { -+ -+ public static final String COMMAND_BASE_PERM = CraftDefaultPermissions.GALE_ROOT + ".command"; -+ -+ private GaleCommands() {} -+ -+ private static final Map COMMANDS = new HashMap<>(); -+ static { -+ COMMANDS.put(GaleCommand.COMMAND_LABEL, new GaleCommand()); -+ } -+ -+ public static void registerCommands(final MinecraftServer server) { -+ COMMANDS.forEach((s, command) -> { -+ server.server.getCommandMap().register(s, "Gale", command); -+ }); -+ } -+} -diff --git a/src/main/java/org/galemc/gale/command/GaleSubcommand.java b/src/main/java/org/galemc/gale/command/GaleSubcommand.java -new file mode 100644 -index 0000000000000000000000000000000000000000..7bcf875f91f5018daa06ef3280c4cdd7e8df4fd5 ---- /dev/null -+++ b/src/main/java/org/galemc/gale/command/GaleSubcommand.java -@@ -0,0 +1,27 @@ -+// Gale - Gale commands -+ -+package org.galemc.gale.command; -+ -+import org.bukkit.command.CommandSender; -+import org.bukkit.permissions.Permission; -+import org.checkerframework.checker.nullness.qual.NonNull; -+import org.checkerframework.framework.qual.DefaultQualifier; -+import org.jetbrains.annotations.Nullable; -+ -+import java.util.Collections; -+import java.util.List; -+ -+@DefaultQualifier(NonNull.class) -+public interface GaleSubcommand { -+ -+ boolean execute(CommandSender sender, String subCommand, String[] args); -+ -+ default List tabComplete(final CommandSender sender, final String subCommand, final String[] args) { -+ return Collections.emptyList(); -+ } -+ -+ boolean testPermission(CommandSender sender); -+ -+ @Nullable Permission getPermission(); -+ -+} -diff --git a/src/main/java/org/galemc/gale/command/PermissionedGaleSubcommand.java b/src/main/java/org/galemc/gale/command/PermissionedGaleSubcommand.java -new file mode 100644 -index 0000000000000000000000000000000000000000..35ffa5f1bb682ac962ab9466e682a461efa65e7b ---- /dev/null -+++ b/src/main/java/org/galemc/gale/command/PermissionedGaleSubcommand.java -@@ -0,0 +1,32 @@ -+// Gale - Gale commands -+ -+package org.galemc.gale.command; -+ -+import org.bukkit.command.CommandSender; -+import org.bukkit.permissions.Permission; -+import org.bukkit.permissions.PermissionDefault; -+import org.jetbrains.annotations.Nullable; -+ -+public abstract class PermissionedGaleSubcommand implements GaleSubcommand { -+ -+ public final Permission permission; -+ -+ protected PermissionedGaleSubcommand(Permission permission) { -+ this.permission = permission; -+ } -+ -+ protected PermissionedGaleSubcommand(String permission, PermissionDefault permissionDefault) { -+ this(new Permission(permission, permissionDefault)); -+ } -+ -+ @Override -+ public boolean testPermission(CommandSender sender) { -+ return sender.hasPermission(this.permission); -+ } -+ -+ @Override -+ public @Nullable Permission getPermission() { -+ return this.permission; -+ } -+ -+} -diff --git a/src/main/java/org/galemc/gale/command/subcommands/InfoCommand.java b/src/main/java/org/galemc/gale/command/subcommands/InfoCommand.java -new file mode 100644 -index 0000000000000000000000000000000000000000..a781afaf6821a4b7bd770b33eaf65527bfbed04e ---- /dev/null -+++ b/src/main/java/org/galemc/gale/command/subcommands/InfoCommand.java -@@ -0,0 +1,42 @@ -+// Gale - Gale commands - /gale info command -+ -+package org.galemc.gale.command.subcommands; -+ -+import net.kyori.adventure.text.event.ClickEvent; -+import net.kyori.adventure.text.format.TextDecoration; -+import org.bukkit.command.CommandSender; -+import org.bukkit.permissions.Permission; -+import org.checkerframework.checker.nullness.qual.NonNull; -+import org.checkerframework.framework.qual.DefaultQualifier; -+import org.galemc.gale.command.GaleSubcommand; -+import org.jetbrains.annotations.Nullable; -+ -+import static net.kyori.adventure.text.Component.text; -+ -+@DefaultQualifier(NonNull.class) -+public final class InfoCommand implements GaleSubcommand { -+ -+ public final static String LITERAL_ARGUMENT = "info"; -+ -+ @Override -+ public boolean execute(final CommandSender sender, final String subCommand, final String[] args) { -+ sender.sendMessage( -+ text("Gale is a performant Minecraft server system. Find us on: ") -+ .append(text("https://github.com/GaleMC/Gale") -+ .decorate(TextDecoration.UNDERLINED) -+ .clickEvent(ClickEvent.openUrl("https://github.com/GaleMC/Gale"))) -+ ); -+ return true; -+ } -+ -+ @Override -+ public boolean testPermission(CommandSender sender) { -+ return true; -+ } -+ -+ @Override -+ public @Nullable Permission getPermission() { -+ return null; -+ } -+ -+} -diff --git a/src/main/java/org/galemc/gale/command/subcommands/ReloadCommand.java b/src/main/java/org/galemc/gale/command/subcommands/ReloadCommand.java -new file mode 100644 -index 0000000000000000000000000000000000000000..c6ca5d3cf7e709f59f68ccd28db378e9e6303fdd ---- /dev/null -+++ b/src/main/java/org/galemc/gale/command/subcommands/ReloadCommand.java -@@ -0,0 +1,46 @@ -+// Gale - Gale commands - /gale reload command -+ -+package org.galemc.gale.command.subcommands; -+ -+import net.minecraft.server.MinecraftServer; -+import org.bukkit.command.Command; -+import org.bukkit.command.CommandSender; -+import org.bukkit.craftbukkit.CraftServer; -+import org.bukkit.permissions.PermissionDefault; -+import org.checkerframework.checker.nullness.qual.NonNull; -+import org.checkerframework.framework.qual.DefaultQualifier; -+import org.galemc.gale.command.GaleCommand; -+import org.galemc.gale.command.PermissionedGaleSubcommand; -+ -+import static net.kyori.adventure.text.Component.text; -+import static net.kyori.adventure.text.format.NamedTextColor.GREEN; -+import static net.kyori.adventure.text.format.NamedTextColor.RED; -+ -+@DefaultQualifier(NonNull.class) -+public final class ReloadCommand extends PermissionedGaleSubcommand { -+ -+ public final static String LITERAL_ARGUMENT = "reload"; -+ public static final String PERM = GaleCommand.BASE_PERM + "." + LITERAL_ARGUMENT; -+ -+ public ReloadCommand() { -+ super(PERM, PermissionDefault.OP); -+ } -+ -+ @Override -+ public boolean execute(final CommandSender sender, final String subCommand, final String[] args) { -+ this.doReload(sender); -+ return true; -+ } -+ -+ private void doReload(final CommandSender sender) { -+ Command.broadcastCommandMessage(sender, text("Please note that this command is not supported and may cause issues.", RED)); -+ Command.broadcastCommandMessage(sender, text("If you encounter any issues please use the /stop command to restart your server.", RED)); -+ -+ MinecraftServer server = ((CraftServer) sender.getServer()).getServer(); -+ server.galeConfigurations.reloadConfigs(server); -+ server.server.reloadCount++; -+ -+ Command.broadcastCommandMessage(sender, text("Gale config reload complete.", GREEN)); -+ } -+ -+} -diff --git a/src/main/java/org/galemc/gale/command/subcommands/VersionCommand.java b/src/main/java/org/galemc/gale/command/subcommands/VersionCommand.java -new file mode 100644 -index 0000000000000000000000000000000000000000..675cd4295dabfade1b9cc5473010b5b20dc32039 ---- /dev/null -+++ b/src/main/java/org/galemc/gale/command/subcommands/VersionCommand.java -@@ -0,0 +1,39 @@ -+// Gale - Gale commands - /gale version command -+ -+package org.galemc.gale.command.subcommands; -+ -+import net.minecraft.server.MinecraftServer; -+import org.bukkit.command.Command; -+import org.bukkit.command.CommandSender; -+import org.bukkit.permissions.PermissionDefault; -+import org.checkerframework.checker.nullness.qual.NonNull; -+import org.checkerframework.checker.nullness.qual.Nullable; -+import org.checkerframework.framework.qual.DefaultQualifier; -+import org.galemc.gale.command.GaleCommand; -+import org.galemc.gale.command.PermissionedGaleSubcommand; -+ -+@DefaultQualifier(NonNull.class) -+public final class VersionCommand extends PermissionedGaleSubcommand { -+ -+ public final static String LITERAL_ARGUMENT = "version"; -+ public static final String PERM = GaleCommand.BASE_PERM + "." + LITERAL_ARGUMENT; -+ -+ public VersionCommand() { -+ super(PERM, PermissionDefault.TRUE); -+ } -+ -+ @Override -+ public boolean execute(final CommandSender sender, final String subCommand, final String[] args) { -+ final @Nullable Command ver = MinecraftServer.getServer().server.getCommandMap().getCommand("version"); -+ if (ver != null) { -+ ver.execute(sender, GaleCommand.COMMAND_LABEL, new String[0]); -+ } -+ return true; -+ } -+ -+ @Override -+ public boolean testPermission(CommandSender sender) { -+ return super.testPermission(sender) && sender.hasPermission("bukkit.command.version"); -+ } -+ -+} diff --git a/patches/server/0011-Remove-vanilla-profiler.patch b/patches/server/0011-Remove-vanilla-profiler.patch deleted file mode 100644 index 8625a34..0000000 --- a/patches/server/0011-Remove-vanilla-profiler.patch +++ /dev/null @@ -1,2351 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Martijn Muijsers -Date: Thu, 22 Dec 2022 22:32:18 +0100 -Subject: [PATCH] Remove vanilla profiler - -License: MIT (https://opensource.org/licenses/MIT) -Gale - https://galemc.org - -This patch is based on the following patch: -"Remove Mojang Profiler" -By: BillyGalbreath -As part of: Purpur (https://github.com/PurpurMC/Purpur) -Licensed under: MIT (https://opensource.org/licenses/MIT) - -* Purpur copyright * - -MIT License - -Copyright (c) 2019-2022 PurpurMC - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - -diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java -index 64bf4444ffba25cb40743a32267aa790ad1738f9..f584215a19cff134866ea6eb3015eacf4208a285 100644 ---- a/src/main/java/net/minecraft/commands/Commands.java -+++ b/src/main/java/net/minecraft/commands/Commands.java -@@ -55,7 +55,6 @@ import net.minecraft.server.commands.CloneCommands; - import net.minecraft.server.commands.DamageCommand; - import net.minecraft.server.commands.DataPackCommand; - import net.minecraft.server.commands.DeOpCommands; --import net.minecraft.server.commands.DebugCommand; - import net.minecraft.server.commands.DebugConfigCommand; - import net.minecraft.server.commands.DebugMobSpawningCommand; - import net.minecraft.server.commands.DebugPathCommand; -@@ -132,7 +131,6 @@ import net.minecraft.server.commands.WorldBorderCommand; - import net.minecraft.server.commands.data.DataCommands; - import net.minecraft.server.level.ServerPlayer; - import net.minecraft.tags.TagKey; --import net.minecraft.util.profiling.Profiler; - import net.minecraft.util.profiling.jfr.JvmProfiler; - import net.minecraft.world.flag.FeatureFlagSet; - import net.minecraft.world.flag.FeatureFlags; -@@ -169,7 +167,6 @@ public class Commands { - DamageCommand.register(this.dispatcher, commandRegistryAccess); - DataCommands.register(this.dispatcher); - DataPackCommand.register(this.dispatcher); -- DebugCommand.register(this.dispatcher); - DefaultGameModeCommands.register(this.dispatcher); - DifficultyCommand.register(this.dispatcher); - EffectCommands.register(this.dispatcher, commandRegistryAccess); -@@ -345,9 +342,6 @@ public class Commands { - // Paper end - CommandSourceStack commandlistenerwrapper = (CommandSourceStack) parseresults.getContext().getSource(); - -- Profiler.get().push(() -> { -- return "/" + s; -- }); - ContextChain contextchain = this.finishParsing(parseresults, s, commandlistenerwrapper, label); // CraftBukkit // Paper - Add UnknownCommandEvent - - try { -@@ -376,8 +370,6 @@ public class Commands { - commandlistenerwrapper.sendFailure(Component.literal(Util.describeError(exception))); - Commands.LOGGER.error("'/{}' threw an exception", s, exception); - } -- } finally { -- Profiler.get().pop(); - } - - } -@@ -440,7 +432,7 @@ public class Commands { - int j = minecraftserver.getGameRules().getInt(GameRules.RULE_MAX_COMMAND_FORK_COUNT); - - try { -- ExecutionContext executioncontext1 = new ExecutionContext<>(i, j, Profiler.get()); -+ ExecutionContext executioncontext1 = new ExecutionContext<>(i, j); // Gale - Purpur - remove vanilla profiler - - try { - Commands.CURRENT_EXECUTION_CONTEXT.set(executioncontext1); -diff --git a/src/main/java/net/minecraft/commands/execution/ExecutionContext.java b/src/main/java/net/minecraft/commands/execution/ExecutionContext.java -index f626a2f28f2aebb3237cebb6afef3c4fa1a6cb37..2200d34ce40c61c0eee81b8f8903458c548e65ec 100644 ---- a/src/main/java/net/minecraft/commands/execution/ExecutionContext.java -+++ b/src/main/java/net/minecraft/commands/execution/ExecutionContext.java -@@ -20,7 +20,6 @@ public class ExecutionContext implements AutoCloseable { - private static final Logger LOGGER = LogUtils.getLogger(); - private final int commandLimit; - private final int forkLimit; -- private final ProfilerFiller profiler; - @Nullable - private TraceCallbacks tracer; - private int commandQuota; -@@ -29,10 +28,9 @@ public class ExecutionContext implements AutoCloseable { - private final List> newTopCommands = new ObjectArrayList<>(); - private int currentFrameDepth; - -- public ExecutionContext(int maxCommandChainLength, int maxCommandForkCount, ProfilerFiller profiler) { -+ public ExecutionContext(int maxCommandChainLength, int maxCommandForkCount) { // Gale - Purpur - remove vanilla profiler - this.commandLimit = maxCommandChainLength; - this.forkLimit = maxCommandForkCount; -- this.profiler = profiler; - this.commandQuota = maxCommandChainLength; - } - -@@ -130,7 +128,7 @@ public class ExecutionContext implements AutoCloseable { - } - - public ProfilerFiller profiler() { -- return this.profiler; -+ return net.minecraft.util.profiling.InactiveProfiler.INSTANCE; // Gale - Purpur - remove vanilla profiler - } - - public int forkLimit() { -diff --git a/src/main/java/net/minecraft/commands/execution/tasks/BuildContexts.java b/src/main/java/net/minecraft/commands/execution/tasks/BuildContexts.java -index e8b8c453a7ff7af0a60ae915cfd85aba313139c9..0bb5f1e421b56703d9c4d99a98db29d31ffc26f9 100644 ---- a/src/main/java/net/minecraft/commands/execution/tasks/BuildContexts.java -+++ b/src/main/java/net/minecraft/commands/execution/tasks/BuildContexts.java -@@ -42,9 +42,6 @@ public class BuildContexts> { - ChainModifiers chainModifiers = flags; - List list = sources; - if (contextChain.getStage() != Stage.EXECUTE) { -- context.profiler().push(() -> "prepare " + this.commandInput); -- -- try { - for (int i = context.forkLimit(); contextChain.getStage() != Stage.EXECUTE; contextChain = contextChain.nextStage()) { - CommandContext commandContext = contextChain.getTopContext(); - if (commandContext.isForked()) { -@@ -85,9 +82,6 @@ public class BuildContexts> { - list = list2; - } - } -- } finally { -- context.profiler().pop(); -- } - } - - if (list.isEmpty()) { -diff --git a/src/main/java/net/minecraft/commands/execution/tasks/ExecuteCommand.java b/src/main/java/net/minecraft/commands/execution/tasks/ExecuteCommand.java -index e9775b4506909bee65a74964f0d5391a0513de1d..1c4dd8acdcd571aceffe4b78599ca2c7362aea5d 100644 ---- a/src/main/java/net/minecraft/commands/execution/tasks/ExecuteCommand.java -+++ b/src/main/java/net/minecraft/commands/execution/tasks/ExecuteCommand.java -@@ -23,8 +23,6 @@ public class ExecuteCommand> implements Unbo - - @Override - public void execute(T executionCommandSource, ExecutionContext executionContext, Frame frame) { -- executionContext.profiler().push(() -> "execute " + this.commandInput); -- - try { - executionContext.incrementCost(); - int i = ContextChain.runExecutable( -@@ -36,8 +34,6 @@ public class ExecuteCommand> implements Unbo - } - } catch (CommandSyntaxException var9) { - executionCommandSource.handleError(var9, this.modifiers.isForked(), executionContext.tracer()); -- } finally { -- executionContext.profiler().pop(); - } - } - } -diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 0888715de790e99bb2b6c3ebbcfa4ecccd137037..cef6268d6f90e3578cc27ec21aea4d24a64e3f0a 100644 ---- a/src/main/java/net/minecraft/server/MinecraftServer.java -+++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -111,19 +111,8 @@ import net.minecraft.util.datafix.DataFixers; - import net.minecraft.util.debugchart.RemoteDebugSampleType; - import net.minecraft.util.debugchart.SampleLogger; - import net.minecraft.util.debugchart.TpsDebugDimensions; --import net.minecraft.util.profiling.EmptyProfileResults; --import net.minecraft.util.profiling.ProfileResults; --import net.minecraft.util.profiling.Profiler; --import net.minecraft.util.profiling.ProfilerFiller; --import net.minecraft.util.profiling.ResultField; --import net.minecraft.util.profiling.SingleTickProfiler; - import net.minecraft.util.profiling.jfr.JvmProfiler; - import net.minecraft.util.profiling.jfr.callback.ProfiledDuration; --import net.minecraft.util.profiling.metrics.profiling.ActiveMetricsRecorder; --import net.minecraft.util.profiling.metrics.profiling.InactiveMetricsRecorder; --import net.minecraft.util.profiling.metrics.profiling.MetricsRecorder; --import net.minecraft.util.profiling.metrics.profiling.ServerMetricsSamplersProvider; --import net.minecraft.util.profiling.metrics.storage.MetricsPersister; - import net.minecraft.util.thread.ReentrantBlockableEventLoop; - import net.minecraft.world.Difficulty; - import net.minecraft.world.RandomSequences; -@@ -229,13 +218,6 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop tickables = Lists.newArrayList(); -- private MetricsRecorder metricsRecorder; -- private Consumer onMetricsRecordingStopped; -- private Consumer onMetricsRecordingFinished; -- private boolean willStartRecordingMetrics; -- @Nullable -- private MinecraftServer.TimeProfiler debugCommandProfiler; -- private boolean debugCommandProfilerDelayStart; - private ServerConnectionListener connection; - public final ChunkProgressListenerFactory progressListenerFactory; - @Nullable -@@ -430,12 +412,6 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { -- this.stopRecordingMetrics(); -- }; -- this.onMetricsRecordingFinished = (path) -> { -- }; - this.random = RandomSource.create(); - this.port = -1; - this.levels = Maps.newLinkedHashMap(); -@@ -1050,9 +1026,6 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { - return false; -@@ -1340,7 +1301,6 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 0 && this.tickCount % autosavePeriod == 0; - try { - this.isSaving = true; -@@ -1692,11 +1630,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { - entityplayer.connection.suspendFlushing(); - }); -@@ -1819,9 +1747,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { -- String s = String.valueOf(worldserver); -- -- return s + " " + String.valueOf(worldserver.dimension().location()); -- }); - /* Drop global time updates - if (this.tickCount % 20 == 0) { -- gameprofilerfiller.push("timeSync"); - this.synchronizeTime(worldserver); -- gameprofilerfiller.pop(); - } - // CraftBukkit end */ - -- gameprofilerfiller.push("tick"); -- - try { - worldserver.tick(shouldKeepTicking); - } catch (Throwable throwable) { -@@ -1883,27 +1800,20 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { -- this.executeBlocking(() -> { -- this.saveDebugReport(path.resolve("server")); -- }); -- this.onMetricsRecordingFinished.accept(path); -- }); -- this.willStartRecordingMetrics = false; -- } -- -- this.metricsRecorder.startTick(); -- return SingleTickProfiler.decorateFiller(this.metricsRecorder.getProfiler(), SingleTickProfiler.createTickProfiler("Server")); -- } -- -- public void endMetricsRecordingTick() { -- this.metricsRecorder.endTick(); -- } -- -- public boolean isRecordingMetrics() { -- return this.metricsRecorder.isRecording(); -- } -- -- public void startRecordingMetrics(Consumer resultConsumer, Consumer dumpConsumer) { -- this.onMetricsRecordingStopped = (methodprofilerresults) -> { -- this.stopRecordingMetrics(); -- resultConsumer.accept(methodprofilerresults); -- }; -- this.onMetricsRecordingFinished = dumpConsumer; -- this.willStartRecordingMetrics = true; -- } -- -- public void stopRecordingMetrics() { -- this.metricsRecorder = InactiveMetricsRecorder.INSTANCE; -- } -- -- public void finishRecordingMetrics() { -- this.metricsRecorder.end(); -- } -- -- public void cancelRecordingMetrics() { -- this.metricsRecorder.cancel(); -- } -- - public Path getWorldPath(LevelResource worldSavePath) { - return this.storageSource.getLevelPath(worldSavePath); - } -@@ -2981,25 +2840,6 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop getTimes(String parentPath) { -- return Collections.emptyList(); -- } -- -- @Override -- public boolean saveResults(Path path) { -- return false; -- } -- -- @Override -- public long getStartTimeNano() { -- return TimeProfiler.this.startNanos; -- } -- -- @Override -- public int getStartTimeTicks() { -- return TimeProfiler.this.startTick; -- } -- -- @Override -- public long getEndTimeNano() { -- return endTime; -- } -- -- @Override -- public int getEndTimeTicks() { -- return endTick; -- } -- -- @Override -- public String getProfilerResults() { -- return ""; -- } -- }; -- } -- } -- - public static record ServerResourcePackInfo(UUID id, String url, String hash, boolean isRequired, @Nullable Component prompt) { - - } -diff --git a/src/main/java/net/minecraft/server/ReloadableServerResources.java b/src/main/java/net/minecraft/server/ReloadableServerResources.java -index 47d5d5fcc8623969c6ab7c148c043bc367f1d6cf..eaccec0df4ae9ea8f22074ab551209c6604ea054 100644 ---- a/src/main/java/net/minecraft/server/ReloadableServerResources.java -+++ b/src/main/java/net/minecraft/server/ReloadableServerResources.java -@@ -98,7 +98,7 @@ public class ReloadableServerResources { - prepareExecutor, - applyExecutor, - DATA_RELOAD_INITIAL_TASK, -- LOGGER.isDebugEnabled() -+ false // Gale - Purpur - remove vanilla profiler - ) - .done() - .thenApply(void_ -> reloadableServerResources); -diff --git a/src/main/java/net/minecraft/server/ServerFunctionManager.java b/src/main/java/net/minecraft/server/ServerFunctionManager.java -index 0b348f701b61c7b7ed0190eff8b2d73f3a3d5c74..13b637afe8652327a69c926eded50b0afbf27103 100644 ---- a/src/main/java/net/minecraft/server/ServerFunctionManager.java -+++ b/src/main/java/net/minecraft/server/ServerFunctionManager.java -@@ -16,8 +16,6 @@ import net.minecraft.commands.functions.CommandFunction; - import net.minecraft.commands.functions.InstantiatedFunction; - import net.minecraft.nbt.CompoundTag; - import net.minecraft.resources.ResourceLocation; --import net.minecraft.util.profiling.Profiler; --import net.minecraft.util.profiling.ProfilerFiller; - import org.slf4j.Logger; - - public class ServerFunctionManager { -@@ -54,10 +52,7 @@ public class ServerFunctionManager { - } - - private void executeTagFunctions(Collection> functions, ResourceLocation label) { -- ProfilerFiller gameprofilerfiller = Profiler.get(); -- - Objects.requireNonNull(label); -- gameprofilerfiller.push(label::toString); - Iterator iterator = functions.iterator(); - - while (iterator.hasNext()) { -@@ -65,17 +60,9 @@ public class ServerFunctionManager { - - this.execute(commandfunction, this.getGameLoopSender()); - } -- -- Profiler.get().pop(); - } - - public void execute(CommandFunction function, CommandSourceStack source) { -- ProfilerFiller gameprofilerfiller = Profiler.get(); -- -- gameprofilerfiller.push(() -> { -- return "function " + String.valueOf(function.id()); -- }); -- - try { - InstantiatedFunction instantiatedfunction = function.instantiate((CompoundTag) null, this.getDispatcher()); - -@@ -86,8 +73,6 @@ public class ServerFunctionManager { - ; - } catch (Exception exception) { - ServerFunctionManager.LOGGER.warn("Failed to execute function {}", function.id(), exception); -- } finally { -- gameprofilerfiller.pop(); - } - - } -diff --git a/src/main/java/net/minecraft/server/commands/PerfCommand.java b/src/main/java/net/minecraft/server/commands/PerfCommand.java -index 8c587f829c5e8c6b6df3150024c4ae704988c47b..9f00cd7d23710787d0cb94377f21a541b7e19a95 100644 ---- a/src/main/java/net/minecraft/server/commands/PerfCommand.java -+++ b/src/main/java/net/minecraft/server/commands/PerfCommand.java -@@ -42,6 +42,9 @@ public class PerfCommand { - } - - private static int startProfilingDedicatedServer(CommandSourceStack source) throws CommandSyntaxException { -+ // Gale start - Purpur - remove vanilla profiler -+ return removedMessage(source); -+ /* - MinecraftServer minecraftServer = source.getServer(); - if (minecraftServer.isRecordingMetrics()) { - throw ERROR_ALREADY_RUNNING.create(); -@@ -52,9 +55,14 @@ public class PerfCommand { - source.sendSuccess(() -> Component.translatable("commands.perf.started"), false); - return 0; - } -+ */ -+ // Gale end - Purpur - remove vanilla profiler - } - - private static int stopProfilingDedicatedServer(CommandSourceStack source) throws CommandSyntaxException { -+ // Gale start - Purpur - remove vanilla profiler -+ return removedMessage(source); -+ /* - MinecraftServer minecraftServer = source.getServer(); - if (!minecraftServer.isRecordingMetrics()) { - throw ERROR_NOT_RUNNING.create(); -@@ -62,8 +70,22 @@ public class PerfCommand { - minecraftServer.finishRecordingMetrics(); - return 0; - } -+ */ -+ // Gale end - Purpur - remove vanilla profiler - } - -+ // Gale start - Purpur - remove vanilla profiler -+ private static int removedMessage(CommandSourceStack source) { -+ net.kyori.adventure.text.minimessage.MiniMessage mm = net.kyori.adventure.text.minimessage.MiniMessage.miniMessage(); -+ -+ source.getSender().sendMessage(mm.deserialize("Gale has removed Mojang's Profiler to save your performance. Please use /spark instead")); -+ source.getSender().sendMessage(mm.deserialize("For more information, view its documentation at")); -+ source.getSender().sendMessage(mm.deserialize("https://spark.lucko.me/docs/Command-Usage")); -+ -+ return 0; -+ } -+ // Gale end - Purpur - remove vanilla profiler -+ - private static void saveResults(CommandSourceStack source, Path tempProfilingDirectory, MinecraftServer server) { - String string = String.format( - Locale.ROOT, "%s-%s-%s", Util.getFilenameFormattedDateTime(), server.getWorldData().getLevelName(), SharedConstants.getCurrentVersion().getId() -diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -index 9ce34bd0dbdd87d1e75d54ed037bca2d01e0210d..bd3a4bb0192d2af4868bcd96b1b6205c4b05fe20 100644 ---- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -@@ -836,12 +836,6 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface - return this.settings.getProperties().serverResourcePackInfo; - } - -- @Override -- public void endMetricsRecordingTick() { -- super.endMetricsRecordingTick(); -- this.debugSampleSubscriptionTracker.tick(this.getTickCount()); -- } -- - @Override - public SampleLogger getTickTimeLogger() { - return this.tickTimeLogger; -diff --git a/src/main/java/net/minecraft/server/level/ChunkGenerationTask.java b/src/main/java/net/minecraft/server/level/ChunkGenerationTask.java -index 7ea8c13c9993576c1408e710d3ceb9947b09090d..6a0a44ecc7ee6e838574b82f2faf5dcbd19abfa6 100644 ---- a/src/main/java/net/minecraft/server/level/ChunkGenerationTask.java -+++ b/src/main/java/net/minecraft/server/level/ChunkGenerationTask.java -@@ -5,8 +5,6 @@ import java.util.List; - import java.util.concurrent.CompletableFuture; - import javax.annotation.Nullable; - import net.minecraft.util.StaticCache2D; --import net.minecraft.util.profiling.Profiler; --import net.minecraft.util.profiling.Zone; - import net.minecraft.world.level.ChunkPos; - import net.minecraft.world.level.chunk.ChunkAccess; - import net.minecraft.world.level.chunk.status.ChunkDependencies; -@@ -113,8 +111,6 @@ public class ChunkGenerationTask { - } - - private void scheduleLayer(ChunkStatus targetStatus, boolean allowGeneration) { -- try (Zone zone = Profiler.get().zone("scheduleLayer")) { -- zone.addText(targetStatus::getName); - int i = this.getRadiusForLayer(targetStatus, allowGeneration); - - for (int j = this.pos.x - i; j <= this.pos.x + i; j++) { -@@ -125,7 +121,6 @@ public class ChunkGenerationTask { - } - } - } -- } - } - - private int getRadiusForLayer(ChunkStatus status, boolean generate) { -diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java -index cfeeddf2cb4ff50dbc29c6913e78ca1dee076790..8b5a51558214c3a900b2e7c942e3c663280fdfb8 100644 ---- a/src/main/java/net/minecraft/server/level/ChunkMap.java -+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java -@@ -65,8 +65,6 @@ import net.minecraft.server.network.ServerPlayerConnection; - import net.minecraft.util.CsvOutput; - import net.minecraft.util.Mth; - import net.minecraft.util.StaticCache2D; --import net.minecraft.util.profiling.Profiler; --import net.minecraft.util.profiling.ProfilerFiller; - import net.minecraft.util.thread.BlockableEventLoop; - import net.minecraft.util.thread.ConsecutiveExecutor; - import net.minecraft.world.entity.Entity; -@@ -406,16 +404,10 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider - } - - protected void tick(BooleanSupplier shouldKeepTicking) { -- ProfilerFiller gameprofilerfiller = Profiler.get(); -- -- gameprofilerfiller.push("poi"); - this.poiManager.tick(shouldKeepTicking); -- gameprofilerfiller.popPush("chunk_unload"); - if (!this.level.noSave()) { - this.processUnloads(shouldKeepTicking); - } -- -- gameprofilerfiller.pop(); - } - - public boolean hasWork() { -diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index d021cd5b6136f0125076513977f430c6d4dd4f9f..a34906265ff34937736718e164bd55f4cccd1a20 100644 ---- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java -+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -@@ -26,8 +26,6 @@ import net.minecraft.network.protocol.Packet; - import net.minecraft.server.MinecraftServer; - import net.minecraft.server.level.progress.ChunkProgressListener; - import net.minecraft.util.VisibleForDebug; --import net.minecraft.util.profiling.Profiler; --import net.minecraft.util.profiling.ProfilerFiller; - import net.minecraft.util.thread.BlockableEventLoop; - import net.minecraft.world.entity.Entity; - import net.minecraft.world.entity.ai.village.poi.PoiManager; -@@ -439,38 +437,28 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon - // CraftBukkit start - modelled on below - public void purgeUnload() { - if (true) return; // Paper - rewrite chunk system -- ProfilerFiller gameprofilerfiller = Profiler.get(); - -- gameprofilerfiller.push("purge"); - this.distanceManager.purgeStaleTickets(); - this.runDistanceManagerUpdates(); -- gameprofilerfiller.popPush("unload"); - this.chunkMap.tick(() -> true); -- gameprofilerfiller.pop(); - this.clearCache(); - } - // CraftBukkit end - - @Override - public void tick(BooleanSupplier shouldKeepTicking, boolean tickChunks) { -- ProfilerFiller gameprofilerfiller = Profiler.get(); -- -- gameprofilerfiller.push("purge"); - if (this.level.tickRateManager().runsNormally() || !tickChunks || this.level.spigotConfig.unloadFrozenChunks) { // Spigot - this.distanceManager.purgeStaleTickets(); - } - - this.runDistanceManagerUpdates(); -- gameprofilerfiller.popPush("chunks"); - if (tickChunks) { - ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)this.level).moonrise$getPlayerChunkLoader().tick(); // Paper - rewrite chunk system - this.tickChunks(); - this.chunkMap.tick(); - } - -- gameprofilerfiller.popPush("unload"); - this.chunkMap.tick(shouldKeepTicking); -- gameprofilerfiller.pop(); - this.clearCache(); - } - -@@ -480,34 +468,26 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon - - this.lastInhabitedUpdate = i; - if (!this.level.isDebug()) { -- ProfilerFiller gameprofilerfiller = Profiler.get(); -- -- gameprofilerfiller.push("pollingChunks"); - if (this.level.tickRateManager().runsNormally()) { - List list = this.tickingChunks; - - try { -- gameprofilerfiller.push("filteringTickingChunks"); - this.collectTickingChunks(list); -- gameprofilerfiller.popPush("shuffleChunks"); - // Paper start - chunk tick iteration optimisation - this.shuffleRandom.setSeed(this.level.random.nextLong()); - if (!this.level.paperConfig().entities.spawning.perPlayerMobSpawns) Util.shuffle(list, this.shuffleRandom); // Paper - Optional per player mob spawns; do not need this when per-player is enabled - // Paper end - chunk tick iteration optimisation -- this.tickChunks(gameprofilerfiller, j, list); -- gameprofilerfiller.pop(); -+ this.tickChunks(j, list); // Gale - Purpur - remove vanilla profiler - } finally { - list.clear(); - } - } - -- this.broadcastChangedChunks(gameprofilerfiller); -- gameprofilerfiller.pop(); -+ this.broadcastChangedChunks(); // Gale - Purpur - remove vanilla profiler - } - } - -- private void broadcastChangedChunks(ProfilerFiller profiler) { -- profiler.push("broadcast"); -+ private void broadcastChangedChunks() { // Gale - Purpur - remove vanilla profiler - Iterator iterator = this.chunkHoldersToBroadcast.iterator(); - - while (iterator.hasNext()) { -@@ -520,7 +500,6 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon - } - - this.chunkHoldersToBroadcast.clear(); -- profiler.pop(); - } - - private void collectTickingChunks(List chunks) { -@@ -546,8 +525,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon - // Paper end - chunk tick iteration optimisation - } - -- private void tickChunks(ProfilerFiller profiler, long timeDelta, List chunks) { -- profiler.popPush("naturalSpawnCount"); -+ private void tickChunks(long timeDelta, List chunks) { // Gale - Purpur - remove vanilla profiler - int j = this.distanceManager.getNaturalSpawnChunkCount(); - // Paper start - Optional per player mob spawns - final int naturalSpawnChunkCount = j; -@@ -574,7 +552,6 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon - // Paper end - Optional per player mob spawns - - this.lastSpawnState = spawnercreature_d; -- profiler.popPush("spawnAndTick"); - boolean flag = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !this.level.players().isEmpty(); // CraftBukkit - int k = this.level.getGameRules().getInt(GameRules.RULE_RANDOMTICKING); - List list1; -@@ -611,7 +588,6 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon - } - } - -- profiler.popPush("customSpawners"); - if (flag) { - this.level.tickCustomSpawners(this.spawnEnemies, this.spawnFriendlies); - } -@@ -809,7 +785,6 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon - - @Override - protected void doRunTask(Runnable task) { -- Profiler.get().incrementCounter("runTask"); - super.doRunTask(task); - } - -diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index b85078fad36deded2e6c76acee0cd7f4bcbab099..2e365ddde76b57d48836018bcb8243728160ed7f 100644 ---- a/src/main/java/net/minecraft/server/level/ServerLevel.java -+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java -@@ -79,8 +79,6 @@ import net.minecraft.util.ProgressListener; - import net.minecraft.util.RandomSource; - import net.minecraft.util.Unit; - import net.minecraft.util.datafix.DataFixTypes; --import net.minecraft.util.profiling.Profiler; --import net.minecraft.util.profiling.ProfilerFiller; - import net.minecraft.util.valueproviders.IntProvider; - import net.minecraft.util.valueproviders.UniformInt; - import net.minecraft.world.DifficultyInstance; -@@ -710,18 +708,13 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe - } - - public void tick(BooleanSupplier shouldKeepTicking) { -- ProfilerFiller gameprofilerfiller = Profiler.get(); -- - this.handlingTick = true; - TickRateManager tickratemanager = this.tickRateManager(); - boolean flag = tickratemanager.runsNormally(); - - if (flag) { -- gameprofilerfiller.push("world border"); - this.getWorldBorder().tick(); -- gameprofilerfiller.popPush("weather"); - this.advanceWeatherCycle(); -- gameprofilerfiller.pop(); - } - - int i = this.getGameRules().getInt(GameRules.RULE_PLAYERS_SLEEPING_PERCENTAGE); -@@ -752,30 +745,22 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe - this.tickTime(); - } - -- gameprofilerfiller.push("tickPending"); - if (!this.isDebug() && flag) { - j = this.getGameTime(); -- gameprofilerfiller.push("blockTicks"); - this.blockTicks.tick(j, paperConfig().environment.maxBlockTicks, this::tickBlock); // Paper - configurable max block ticks -- gameprofilerfiller.popPush("fluidTicks"); - this.fluidTicks.tick(j, paperConfig().environment.maxFluidTicks, this::tickFluid); // Paper - configurable max fluid ticks -- gameprofilerfiller.pop(); - } - -- gameprofilerfiller.popPush("raid"); - if (flag) { - this.raids.tick(); - } - -- gameprofilerfiller.popPush("chunkSource"); - this.getChunkSource().tick(shouldKeepTicking, true); -- gameprofilerfiller.popPush("blockEvents"); - if (flag) { - this.runBlockEvents(); - } - - this.handlingTick = false; -- gameprofilerfiller.pop(); - boolean flag1 = !paperConfig().unsupportedSettings.disableWorldTickingWhenEmpty || !this.players.isEmpty() || !this.getForcedChunks().isEmpty(); // CraftBukkit - this prevents entity cleanup, other issues on servers with no players // Paper - restore this - - if (flag1) { -@@ -783,20 +768,15 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe - } - - if (flag1 || this.emptyTime++ < 300) { -- gameprofilerfiller.push("entities"); - if (this.dragonFight != null && flag) { -- gameprofilerfiller.push("dragonFight"); - this.dragonFight.tick(); -- gameprofilerfiller.pop(); - } - - org.spigotmc.ActivationRange.activateEntities(this); // Spigot - this.entityTickList.forEach((entity) -> { - if (!entity.isRemoved()) { - if (!tickratemanager.isEntityFrozen(entity)) { -- gameprofilerfiller.push("checkDespawn"); - entity.checkDespawn(); -- gameprofilerfiller.pop(); - if (true) { // Paper - rewrite chunk system - Entity entity1 = entity.getVehicle(); - -@@ -808,20 +788,15 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe - entity.stopRiding(); - } - -- gameprofilerfiller.push("tick"); - this.guardEntityTick(this::tickNonPassenger, entity); -- gameprofilerfiller.pop(); - } - } - } - }); -- gameprofilerfiller.pop(); - this.tickBlockEntities(); - } - -- gameprofilerfiller.push("entityManagement"); - // Paper - rewrite chunk system -- gameprofilerfiller.pop(); - } - - @Override -@@ -837,9 +812,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe - long i = this.levelData.getGameTime() + 1L; - - this.serverLevelData.setGameTime(i); -- Profiler.get().push("scheduledFunctions"); - this.serverLevelData.getScheduledEvents().tick(this.server, i); -- Profiler.get().pop(); - if (this.serverLevelData.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)) { - this.setDayTime(this.levelData.getDayTime() + 1L); - } -@@ -927,9 +900,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe - boolean flag = this.isRaining(); - int j = chunkcoordintpair.getMinBlockX(); - int k = chunkcoordintpair.getMinBlockZ(); -- ProfilerFiller gameprofilerfiller = Profiler.get(); - -- gameprofilerfiller.push("thunder"); - if (!this.paperConfig().environment.disableThunder && flag && this.isThundering() && this.spigotConfig.thunderChance > 0 && simpleRandom.nextInt(this.spigotConfig.thunderChance) == 0) { // Spigot // Paper - Option to disable thunder // Paper - optimise random ticking - BlockPos blockposition = this.findLightningTargetAround(this.getBlockRandomPos(j, 0, k, 15)); - -@@ -958,8 +929,6 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe - } - } - -- gameprofilerfiller.popPush("iceandsnow"); -- - if (!this.paperConfig().environment.disableIceAndSnow) { // Paper - Option to disable ice and snow - for (int l = 0; l < randomTickSpeed; ++l) { - if (simpleRandom.nextInt(48) == 0) { // Paper - optimise random ticking -@@ -968,12 +937,9 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe - } - } // Paper - Option to disable ice and snow - -- gameprofilerfiller.popPush("tickBlocks"); - if (randomTickSpeed > 0) { - this.optimiseRandomTick(chunk, randomTickSpeed); // Paper - optimise random ticking - } -- -- gameprofilerfiller.pop(); - } - - @VisibleForTesting -@@ -1293,19 +1259,14 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe - }*/ // Paper - comment out EAR 2 - // Spigot end - entity.setOldPosAndRot(); -- ProfilerFiller gameprofilerfiller = Profiler.get(); - - ++entity.tickCount; -- gameprofilerfiller.push(() -> { -- return BuiltInRegistries.ENTITY_TYPE.getKey(entity.getType()).toString(); -- }); -- gameprofilerfiller.incrementCounter("tickNonPassenger"); -+ - final boolean isActive = org.spigotmc.ActivationRange.checkIfActive(entity); // Paper - EAR 2 - if (isActive) { // Paper - EAR 2 - entity.tick(); - entity.postTick(); // CraftBukkit - } else { entity.inactiveTick(); } // Paper - EAR 2 -- gameprofilerfiller.pop(); - Iterator iterator = entity.getPassengers().iterator(); - - while (iterator.hasNext()) { -@@ -1328,12 +1289,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe - if (passenger instanceof Player || this.entityTickList.contains(passenger)) { - passenger.setOldPosAndRot(); - ++passenger.tickCount; -- ProfilerFiller gameprofilerfiller = Profiler.get(); - -- gameprofilerfiller.push(() -> { -- return BuiltInRegistries.ENTITY_TYPE.getKey(passenger.getType()).toString(); -- }); -- gameprofilerfiller.incrementCounter("tickPassenger"); - // Paper start - EAR 2 - if (isActive) { - passenger.rideTick(); -@@ -1345,7 +1301,6 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe - vehicle.positionRider(passenger); - } - // Paper end - EAR 2 -- gameprofilerfiller.pop(); - Iterator iterator = passenger.getPassengers().iterator(); - - while (iterator.hasNext()) { -diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java -index 5a8f396d47577f087abb415c972fd4f51e50faba..bfda30ebaaa02986dd0d4134ede5c822a19b03bc 100644 ---- a/src/main/java/net/minecraft/server/level/ServerPlayer.java -+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java -@@ -102,8 +102,6 @@ import net.minecraft.tags.FluidTags; - import net.minecraft.util.Mth; - import net.minecraft.util.RandomSource; - import net.minecraft.util.Unit; --import net.minecraft.util.profiling.Profiler; --import net.minecraft.util.profiling.ProfilerFiller; - import net.minecraft.world.damagesource.DamageSource; - import net.minecraft.world.damagesource.DamageTypes; - import net.minecraft.world.effect.MobEffectInstance; -@@ -1643,15 +1641,10 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple - this.unsetRemoved(); - */ - // CraftBukkit end -- ProfilerFiller gameprofilerfiller = Profiler.get(); -- -- gameprofilerfiller.push("moving"); - if (worldserver != null && resourcekey == LevelStem.OVERWORLD && worldserver.getTypeKey() == LevelStem.NETHER) { // CraftBukkit - empty to fall through to null to event - this.enteredNetherPosition = this.position(); - } - -- gameprofilerfiller.pop(); -- gameprofilerfiller.push("placing"); - // CraftBukkit start - this.isChangingDimension = true; // CraftBukkit - Set teleport invulnerability only if player changing worlds - LevelData worlddata = worldserver.getLevelData(); -@@ -1668,7 +1661,6 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple - this.connection.internalTeleport(PositionMoveRotation.of(teleportTarget), teleportTarget.relatives()); // CraftBukkit - use internal teleport without event - this.connection.resetPosition(); - worldserver.addDuringTeleport(this); -- gameprofilerfiller.pop(); - this.triggerDimensionChangeTriggers(worldserver1); - this.stopUsingItem(); - this.connection.send(new ClientboundPlayerAbilitiesPacket(this.getAbilities())); -diff --git a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java -index b0bc66dc7248aae691dcab68b925b52a1695e63f..d777e5914148103dbdbfef7c8e4f8e012fa58b6d 100644 ---- a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java -+++ b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java -@@ -30,7 +30,6 @@ import net.minecraft.server.MinecraftServer; - import net.minecraft.server.level.ClientInformation; - import net.minecraft.server.level.ServerPlayer; - import net.minecraft.util.VisibleForDebug; --import net.minecraft.util.profiling.Profiler; - import net.minecraft.util.thread.BlockableEventLoop; - import org.slf4j.Logger; - -@@ -255,7 +254,6 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack - } - - protected void keepConnectionAlive() { -- Profiler.get().push("keepAlive"); - // Paper start - give clients a longer time to respond to pings as per pre 1.12.2 timings - // This should effectively place the keepalive handling back to "as it was" before 1.12.2 - long currentTime = Util.getMillis(); -@@ -272,8 +270,6 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack - } - } - // Paper end - give clients a longer time to respond to pings as per pre 1.12.2 timings -- -- Profiler.get().pop(); - } - - private boolean checkIfClosed(long time) { -diff --git a/src/main/java/net/minecraft/server/packs/resources/ProfiledReloadInstance.java b/src/main/java/net/minecraft/server/packs/resources/ProfiledReloadInstance.java -index 5a2b07340c63577f6d32c0658ce5f9b616c82f91..cac2ac26242e6901080fc0a92684d2f4a11b0c47 100644 ---- a/src/main/java/net/minecraft/server/packs/resources/ProfiledReloadInstance.java -+++ b/src/main/java/net/minecraft/server/packs/resources/ProfiledReloadInstance.java -@@ -9,8 +9,6 @@ import java.util.concurrent.TimeUnit; - import java.util.concurrent.atomic.AtomicLong; - import net.minecraft.Util; - import net.minecraft.util.Unit; --import net.minecraft.util.profiling.Profiler; --import net.minecraft.util.profiling.ProfilerFiller; - import org.slf4j.Logger; - - public class ProfiledReloadInstance extends SimpleReloadInstance { -@@ -51,12 +49,9 @@ public class ProfiledReloadInstance extends SimpleReloadInstance executor.execute(() -> { -- ProfilerFiller profilerFiller = Profiler.get(); -- profilerFiller.push(string); - long l = Util.getNanos(); - runnable.run(); - atomicLong.addAndGet(Util.getNanos() - l); -- profilerFiller.pop(); - }); - } - -diff --git a/src/main/java/net/minecraft/server/packs/resources/ReloadableResourceManager.java b/src/main/java/net/minecraft/server/packs/resources/ReloadableResourceManager.java -index f0257e295d9e856391b8e881370610c06fab9fba..7b327b59374474f68b189cefbf97d4a4b4478472 100644 ---- a/src/main/java/net/minecraft/server/packs/resources/ReloadableResourceManager.java -+++ b/src/main/java/net/minecraft/server/packs/resources/ReloadableResourceManager.java -@@ -41,7 +41,7 @@ public class ReloadableResourceManager implements ResourceManager, AutoCloseable - LOGGER.info("Reloading ResourceManager: {}", LogUtils.defer(() -> packs.stream().map(PackResources::packId).collect(Collectors.joining(", ")))); - this.resources.close(); - this.resources = new MultiPackResourceManager(this.type, packs); -- return SimpleReloadInstance.create(this.resources, this.listeners, prepareExecutor, applyExecutor, initialStage, LOGGER.isDebugEnabled()); -+ return SimpleReloadInstance.create(this.resources, this.listeners, prepareExecutor, applyExecutor, initialStage, false); // Gale - Purpur - remove vanilla profiler - } - - @Override -diff --git a/src/main/java/net/minecraft/server/packs/resources/ResourceManagerReloadListener.java b/src/main/java/net/minecraft/server/packs/resources/ResourceManagerReloadListener.java -index d2d82e4f22bfeac8881b6815e4bef56c254fded9..fd5d678dd2d514ab7b60c4378e05182be38f52c4 100644 ---- a/src/main/java/net/minecraft/server/packs/resources/ResourceManagerReloadListener.java -+++ b/src/main/java/net/minecraft/server/packs/resources/ResourceManagerReloadListener.java -@@ -3,20 +3,13 @@ package net.minecraft.server.packs.resources; - import java.util.concurrent.CompletableFuture; - import java.util.concurrent.Executor; - import net.minecraft.util.Unit; --import net.minecraft.util.profiling.Profiler; --import net.minecraft.util.profiling.ProfilerFiller; - - public interface ResourceManagerReloadListener extends PreparableReloadListener { - @Override - default CompletableFuture reload( - PreparableReloadListener.PreparationBarrier synchronizer, ResourceManager manager, Executor prepareExecutor, Executor applyExecutor - ) { -- return synchronizer.wait(Unit.INSTANCE).thenRunAsync(() -> { -- ProfilerFiller profilerFiller = Profiler.get(); -- profilerFiller.push("listener"); -- this.onResourceManagerReload(manager); -- profilerFiller.pop(); -- }, applyExecutor); -+ return synchronizer.wait(Unit.INSTANCE).thenRunAsync(() -> this.onResourceManagerReload(manager), applyExecutor); // Gale - Purpur - remove vanilla profiler - } - - void onResourceManagerReload(ResourceManager manager); -diff --git a/src/main/java/net/minecraft/server/packs/resources/SimplePreparableReloadListener.java b/src/main/java/net/minecraft/server/packs/resources/SimplePreparableReloadListener.java -index 0aaab6a2a10bf012c9d275f7cee2095c8fbb8809..0d8f20035e051af8143dea154593f8a6fc3235f2 100644 ---- a/src/main/java/net/minecraft/server/packs/resources/SimplePreparableReloadListener.java -+++ b/src/main/java/net/minecraft/server/packs/resources/SimplePreparableReloadListener.java -@@ -2,7 +2,8 @@ package net.minecraft.server.packs.resources; - - import java.util.concurrent.CompletableFuture; - import java.util.concurrent.Executor; --import net.minecraft.util.profiling.Profiler; -+ -+import net.minecraft.util.profiling.InactiveProfiler; - import net.minecraft.util.profiling.ProfilerFiller; - - public abstract class SimplePreparableReloadListener implements PreparableReloadListener { -@@ -10,9 +11,9 @@ public abstract class SimplePreparableReloadListener implements PreparableRel - public final CompletableFuture reload( - PreparableReloadListener.PreparationBarrier synchronizer, ResourceManager manager, Executor prepareExecutor, Executor applyExecutor - ) { -- return CompletableFuture.supplyAsync(() -> this.prepare(manager, Profiler.get()), prepareExecutor) -+ return CompletableFuture.supplyAsync(() -> this.prepare(manager, InactiveProfiler.INSTANCE), prepareExecutor) // Gale - Purpur - remove vanilla profiler - .thenCompose(synchronizer::wait) -- .thenAcceptAsync(prepared -> this.apply((T)prepared, manager, Profiler.get()), applyExecutor); -+ .thenAcceptAsync(prepared -> this.apply((T)prepared, manager, InactiveProfiler.INSTANCE), applyExecutor); // Gale - Purpur - remove vanilla profiler - } - - protected abstract T prepare(ResourceManager manager, ProfilerFiller profiler); -diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index a15546e433ebba6c0de01bdaaef201a3d99a87b5..cd4461c175e88b9dd6f05a8bcd9363de60725370 100644 ---- a/src/main/java/net/minecraft/world/entity/Entity.java -+++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -84,8 +84,6 @@ import net.minecraft.tags.FluidTags; - import net.minecraft.tags.TagKey; - import net.minecraft.util.Mth; - import net.minecraft.util.RandomSource; --import net.minecraft.util.profiling.Profiler; --import net.minecraft.util.profiling.ProfilerFiller; - import net.minecraft.world.InteractionHand; - import net.minecraft.world.InteractionResult; - import net.minecraft.world.Nameable; -@@ -889,9 +887,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess - // CraftBukkit end - - public void baseTick() { -- ProfilerFiller gameprofilerfiller = Profiler.get(); -- -- gameprofilerfiller.push("entityBaseTick"); - if (firstTick && this instanceof net.minecraft.world.entity.NeutralMob neutralMob) neutralMob.tickInitialPersistentAnger(level); // Paper - Prevent entity loading causing async lookups - this.inBlockState = null; - if (this.isPassenger() && this.getVehicle().isRemoved()) { -@@ -959,8 +954,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess - Leashable.tickLeash(worldserver, (Entity & Leashable) this); // CraftBukkit - decompile error - } - } -- -- gameprofilerfiller.pop(); - } - - public void setSharedFlagOnFire(boolean onFire) { -@@ -1186,9 +1179,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess - } - } - -- ProfilerFiller gameprofilerfiller = Profiler.get(); -- -- gameprofilerfiller.push("move"); - if (this.stuckSpeedMultiplier.lengthSqr() > 1.0E-7D) { - movement = movement.multiply(this.stuckSpeedMultiplier); - this.stuckSpeedMultiplier = Vec3.ZERO; -@@ -1197,7 +1187,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess - // Paper start - ignore movement changes while inactive. - if (isTemporarilyActive && !(this instanceof ItemEntity) && movement == getDeltaMovement() && type == MoverType.SELF) { - setDeltaMovement(Vec3.ZERO); -- gameprofilerfiller.pop(); - return; - } - // Paper end -@@ -1218,8 +1207,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess - this.setPos(this.getX() + vec3d1.x, this.getY() + vec3d1.y, this.getZ() + vec3d1.z); - } - -- gameprofilerfiller.pop(); -- gameprofilerfiller.push("rest"); - boolean flag = !Mth.equal(movement.x, vec3d1.x); - boolean flag1 = !Mth.equal(movement.z, vec3d1.z); - -@@ -1241,7 +1228,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess - } - - if (this.isRemoved()) { -- gameprofilerfiller.pop(); - } else { - if (this.horizontalCollision) { - Vec3 vec3d2 = this.getDeltaMovement(); -@@ -1290,7 +1276,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess - float f = this.getBlockSpeedFactor(); - - this.setDeltaMovement(this.getDeltaMovement().multiply((double) f, 1.0D, (double) f)); -- gameprofilerfiller.pop(); - } - } - // Paper start - detailed watchdog information -@@ -3436,9 +3421,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess - this.processPortalCooldown(); - if (this.portalProcess != null) { - if (this.portalProcess.processPortalTeleportation(worldserver, this, this.canUsePortal(false))) { -- ProfilerFiller gameprofilerfiller = Profiler.get(); -- -- gameprofilerfiller.push("portal"); - this.setPortalCooldown(); - TeleportTransition teleporttransition = this.portalProcess.getPortalDestination(worldserver, this); - -@@ -3449,8 +3431,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess - this.teleport(teleporttransition); - } - } -- -- gameprofilerfiller.pop(); - } else if (this.portalProcess.hasExpired()) { - this.portalProcess = null; - } -@@ -3972,16 +3952,12 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess - entity.teleport(this.calculatePassengerTransition(teleportTarget, entity)); - } - -- ProfilerFiller gameprofilerfiller = Profiler.get(); -- -- gameprofilerfiller.push("teleportSameDimension"); - this.teleportSetPosition(PositionMoveRotation.of(teleportTarget), teleportTarget.relatives()); - if (!teleportTarget.asPassenger()) { - this.sendTeleportTransitionToRidingPlayers(teleportTarget); - } - - teleportTarget.postTeleportTransition().onTransition(this); -- gameprofilerfiller.pop(); - return this; - } - -@@ -4003,12 +3979,8 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess - } - } - -- ProfilerFiller gameprofilerfiller = Profiler.get(); -- -- gameprofilerfiller.push("teleportCrossDimension"); - entity = this.getType().create(world, EntitySpawnReason.DIMENSION_TRAVEL); - if (entity == null) { -- gameprofilerfiller.pop(); - return null; - } else { - // Paper start - Fix item duplication and teleport issues -@@ -4034,7 +4006,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess - - world.resetEmptyTime(); - teleportTarget.postTeleportTransition().onTransition(entity); -- gameprofilerfiller.pop(); - return entity; - } - } -diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index f36a075dbee2b96d01899e02460b1d8443e91749..b1af5a5eafcd7e090beb36b1a1734e3f1a063f03 100644 ---- a/src/main/java/net/minecraft/world/entity/LivingEntity.java -+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -73,8 +73,6 @@ import net.minecraft.tags.FluidTags; - import net.minecraft.tags.ItemTags; - import net.minecraft.tags.TagKey; - import net.minecraft.util.Mth; --import net.minecraft.util.profiling.Profiler; --import net.minecraft.util.profiling.ProfilerFiller; - import net.minecraft.world.Difficulty; - import net.minecraft.world.InteractionHand; - import net.minecraft.world.damagesource.CombatRules; -@@ -452,9 +450,7 @@ public abstract class LivingEntity extends Entity implements Attackable { - } - - super.baseTick(); -- ProfilerFiller gameprofilerfiller = Profiler.get(); - -- gameprofilerfiller.push("livingEntityBaseTick"); - if (this.fireImmune() || this.level().isClientSide) { - this.clearFire(); - } -@@ -561,7 +557,6 @@ public abstract class LivingEntity extends Entity implements Attackable { - this.yHeadRotO = this.yHeadRot; - this.yRotO = this.getYRot(); - this.xRotO = this.getXRot(); -- gameprofilerfiller.pop(); - } - - @Override -@@ -3338,12 +3333,8 @@ public abstract class LivingEntity extends Entity implements Attackable { - } - - this.run += (f3 - this.run) * 0.3F; -- ProfilerFiller gameprofilerfiller = Profiler.get(); - -- gameprofilerfiller.push("headTurn"); - f2 = this.tickHeadTurn(f1, f2); -- gameprofilerfiller.pop(); -- gameprofilerfiller.push("rangeChecks"); - - // Paper start - stop large pitch and yaw changes from crashing the server - this.yRotO += Math.round((this.getYRot() - this.yRotO) / 360.0F) * 360.0F; -@@ -3355,7 +3346,6 @@ public abstract class LivingEntity extends Entity implements Attackable { - this.yHeadRotO += Math.round((this.yHeadRot - this.yHeadRotO) / 360.0F) * 360.0F; - // Paper end - -- gameprofilerfiller.pop(); - this.animStep += f2; - if (this.isFallFlying()) { - ++this.fallFlyTicks; -@@ -3585,21 +3575,15 @@ public abstract class LivingEntity extends Entity implements Attackable { - } - - this.setDeltaMovement(d0, d1, d2); -- ProfilerFiller gameprofilerfiller = Profiler.get(); - -- gameprofilerfiller.push("ai"); - if (this.isImmobile()) { - this.jumping = false; - this.xxa = 0.0F; - this.zza = 0.0F; - } else if (this.isEffectiveAi()) { -- gameprofilerfiller.push("newAi"); - this.serverAiStep(); -- gameprofilerfiller.pop(); - } - -- gameprofilerfiller.pop(); -- gameprofilerfiller.push("jump"); - if (this.jumping && this.isAffectedByFluids()) { - double d3; - -@@ -3626,8 +3610,6 @@ public abstract class LivingEntity extends Entity implements Attackable { - this.noJumpDelay = 0; - } - -- gameprofilerfiller.pop(); -- gameprofilerfiller.push("travel"); - this.xxa *= 0.98F; - this.zza *= 0.98F; - if (this.isFallFlying()) { -@@ -3660,8 +3642,6 @@ public abstract class LivingEntity extends Entity implements Attackable { - } - - this.calculateEntityAnimation(this instanceof FlyingAnimal); -- gameprofilerfiller.pop(); -- gameprofilerfiller.push("freezing"); - if (!this.level().isClientSide && !this.isDeadOrDying() && !this.freezeLocked) { // Paper - Freeze Tick Lock API - int i = this.getTicksFrozen(); - -@@ -3682,15 +3662,13 @@ public abstract class LivingEntity extends Entity implements Attackable { - } - } - -- gameprofilerfiller.pop(); -- gameprofilerfiller.push("push"); - if (this.autoSpinAttackTicks > 0) { - --this.autoSpinAttackTicks; - this.checkAutoSpinAttack(axisalignedbb, this.getBoundingBox()); - } - - this.pushEntities(); -- gameprofilerfiller.pop(); -+ - // Paper start - Add EntityMoveEvent - if (((ServerLevel) this.level()).hasEntityMoveEvent && !(this instanceof net.minecraft.world.entity.player.Player)) { - if (this.xo != this.getX() || this.yo != this.getY() || this.zo != this.getZ() || this.yRotO != this.getYRot() || this.xRotO != this.getXRot()) { -diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java -index dbd321f3dc3cc80737830db63aed47a6935e8e89..3ccc39e142f946e3fc34753fdc91a2cb62f9bd2d 100644 ---- a/src/main/java/net/minecraft/world/entity/Mob.java -+++ b/src/main/java/net/minecraft/world/entity/Mob.java -@@ -34,8 +34,6 @@ import net.minecraft.sounds.SoundEvent; - import net.minecraft.tags.TagKey; - import net.minecraft.util.Mth; - import net.minecraft.util.RandomSource; --import net.minecraft.util.profiling.Profiler; --import net.minecraft.util.profiling.ProfilerFiller; - import net.minecraft.world.Difficulty; - import net.minecraft.world.DifficultyInstance; - import net.minecraft.world.InteractionHand; -@@ -369,15 +367,11 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab - @Override - public void baseTick() { - super.baseTick(); -- ProfilerFiller gameprofilerfiller = Profiler.get(); - -- gameprofilerfiller.push("mobBaseTick"); - if (this.isAlive() && this.random.nextInt(1000) < this.ambientSoundTime++) { - this.resetAmbientSoundTime(); - this.playAmbientSound(); - } -- -- gameprofilerfiller.pop(); - } - - @Override -@@ -670,9 +664,7 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab - @Override - public void aiStep() { - super.aiStep(); -- ProfilerFiller gameprofilerfiller = Profiler.get(); - -- gameprofilerfiller.push("looting"); - Level world = this.level(); - - if (world instanceof ServerLevel worldserver) { -@@ -695,8 +687,6 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab - } - } - } -- -- gameprofilerfiller.pop(); - } - - protected Vec3i getPickupReach() { -@@ -918,44 +908,24 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab - return; - } - // Paper end - Allow nerfed mobs to jump and float -- ProfilerFiller gameprofilerfiller = Profiler.get(); - -- gameprofilerfiller.push("sensing"); - this.sensing.tick(); -- gameprofilerfiller.pop(); -+ - int i = this.tickCount + this.getId(); - - if (i % 2 != 0 && this.tickCount > 1) { -- gameprofilerfiller.push("targetSelector"); - this.targetSelector.tickRunningGoals(false); -- gameprofilerfiller.pop(); -- gameprofilerfiller.push("goalSelector"); - this.goalSelector.tickRunningGoals(false); -- gameprofilerfiller.pop(); - } else { -- gameprofilerfiller.push("targetSelector"); - this.targetSelector.tick(); -- gameprofilerfiller.pop(); -- gameprofilerfiller.push("goalSelector"); - this.goalSelector.tick(); -- gameprofilerfiller.pop(); - } - -- gameprofilerfiller.push("navigation"); - this.navigation.tick(); -- gameprofilerfiller.pop(); -- gameprofilerfiller.push("mob tick"); - this.customServerAiStep((ServerLevel) this.level()); -- gameprofilerfiller.pop(); -- gameprofilerfiller.push("controls"); -- gameprofilerfiller.push("move"); - this.moveControl.tick(); -- gameprofilerfiller.popPush("look"); - this.lookControl.tick(); -- gameprofilerfiller.popPush("jump"); - this.jumpControl.tick(); -- gameprofilerfiller.pop(); -- gameprofilerfiller.pop(); - this.sendDebugPackets(); - } - -diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java b/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java -index 29ae74339a4831ccef3d01e8054931715ba192ad..7ac88cb8704f84f1d932dff0fee927dfab8cad6a 100644 ---- a/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java -+++ b/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java -@@ -7,8 +7,6 @@ import java.util.EnumSet; - import java.util.Map; - import java.util.Set; - import java.util.function.Predicate; --import net.minecraft.util.profiling.Profiler; --import net.minecraft.util.profiling.ProfilerFiller; - - public class GoalSelector { - private static final WrappedGoal NO_GOAL = new WrappedGoal(Integer.MAX_VALUE, new Goal() { -@@ -82,9 +80,6 @@ public class GoalSelector { - } - - public void tick() { -- ProfilerFiller profilerFiller = Profiler.get(); -- profilerFiller.push("goalCleanup"); -- - for (WrappedGoal wrappedGoal : this.availableGoals) { - if (wrappedGoal.isRunning() && (goalContainsAnyFlags(wrappedGoal, this.goalTypes) || !wrappedGoal.canContinueToUse())) { // Paper - Perf: optimize goal types by removing streams - wrappedGoal.stop(); -@@ -92,8 +87,6 @@ public class GoalSelector { - } - - this.lockedFlags.entrySet().removeIf(entry -> !entry.getValue().isRunning()); -- profilerFiller.pop(); -- profilerFiller.push("goalUpdate"); - - for (WrappedGoal wrappedGoal2 : this.availableGoals) { - // Paper start -@@ -113,21 +106,15 @@ public class GoalSelector { - } - } - -- profilerFiller.pop(); - this.tickRunningGoals(true); - } - - public void tickRunningGoals(boolean tickAll) { -- ProfilerFiller profilerFiller = Profiler.get(); -- profilerFiller.push("goalTick"); -- - for (WrappedGoal wrappedGoal : this.availableGoals) { - if (wrappedGoal.isRunning() && (tickAll || wrappedGoal.requiresUpdateEveryTick())) { - wrappedGoal.tick(); - } - } -- -- profilerFiller.pop(); - } - - public Set getAvailableGoals() { -diff --git a/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java b/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java -index 48c0de870a5bbf647309e69361dfb10ab56c65ab..79342566ae54b5a8ccd8cab01b8282fada5b7bab 100644 ---- a/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java -+++ b/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java -@@ -10,8 +10,6 @@ import net.minecraft.core.Vec3i; - import net.minecraft.network.protocol.game.DebugPackets; - import net.minecraft.tags.BlockTags; - import net.minecraft.util.Mth; --import net.minecraft.util.profiling.Profiler; --import net.minecraft.util.profiling.ProfilerFiller; - import net.minecraft.world.entity.Entity; - import net.minecraft.world.entity.Mob; - import net.minecraft.world.entity.ai.attributes.Attributes; -@@ -188,13 +186,10 @@ public abstract class PathNavigation { - } - } - // Paper end - EntityPathfindEvent -- ProfilerFiller profilerFiller = Profiler.get(); -- profilerFiller.push("pathfind"); - BlockPos blockPos = useHeadPos ? this.mob.blockPosition().above() : this.mob.blockPosition(); - int i = (int)(followRange + (float)range); - PathNavigationRegion pathNavigationRegion = new PathNavigationRegion(this.level, blockPos.offset(-i, -i, -i), blockPos.offset(i, i, i)); - Path path = this.pathFinder.findPath(pathNavigationRegion, this.mob, positions, followRange, distance, this.maxVisitedNodesMultiplier); -- profilerFiller.pop(); - if (path != null && path.getTarget() != null) { - this.targetPos = path.getTarget(); - this.reachRange = distance; -diff --git a/src/main/java/net/minecraft/world/entity/ai/sensing/Sensing.java b/src/main/java/net/minecraft/world/entity/ai/sensing/Sensing.java -index 116b1e251ffe68bae5c404d0823c2bc7c1afddf6..ed440b9a84ac0e4619c075491515fa072d6aebec 100644 ---- a/src/main/java/net/minecraft/world/entity/ai/sensing/Sensing.java -+++ b/src/main/java/net/minecraft/world/entity/ai/sensing/Sensing.java -@@ -2,8 +2,6 @@ package net.minecraft.world.entity.ai.sensing; - - import it.unimi.dsi.fastutil.ints.IntOpenHashSet; - import it.unimi.dsi.fastutil.ints.IntSet; --import net.minecraft.util.profiling.Profiler; --import net.minecraft.util.profiling.ProfilerFiller; - import net.minecraft.world.entity.Entity; - import net.minecraft.world.entity.Mob; - -@@ -28,10 +26,7 @@ public class Sensing { - } else if (this.unseen.contains(i)) { - return false; - } else { -- ProfilerFiller profilerFiller = Profiler.get(); -- profilerFiller.push("hasLineOfSight"); - boolean bl = this.mob.hasLineOfSight(entity); -- profilerFiller.pop(); - if (bl) { - this.seen.add(i); - } else { -diff --git a/src/main/java/net/minecraft/world/entity/animal/allay/Allay.java b/src/main/java/net/minecraft/world/entity/animal/allay/Allay.java -index 05c3d43fafc781e2c2d762dd5f509753df8da3b3..3a89c8bb4fbbe5a3a219e2fbc823c3abe529d1f2 100644 ---- a/src/main/java/net/minecraft/world/entity/animal/allay/Allay.java -+++ b/src/main/java/net/minecraft/world/entity/animal/allay/Allay.java -@@ -31,8 +31,6 @@ import net.minecraft.tags.GameEventTags; - import net.minecraft.tags.ItemTags; - import net.minecraft.tags.TagKey; - import net.minecraft.util.Mth; --import net.minecraft.util.profiling.Profiler; --import net.minecraft.util.profiling.ProfilerFiller; - import net.minecraft.world.InteractionHand; - import net.minecraft.world.InteractionResult; - import net.minecraft.world.SimpleContainer; -@@ -221,14 +219,8 @@ public class Allay extends PathfinderMob implements InventoryCarrier, VibrationS - - @Override - protected void customServerAiStep(ServerLevel world) { -- ProfilerFiller gameprofilerfiller = Profiler.get(); -- -- gameprofilerfiller.push("allayBrain"); - this.getBrain().tick(world, this); -- gameprofilerfiller.pop(); -- gameprofilerfiller.push("allayActivityUpdate"); - AllayAi.updateActivity(this); -- gameprofilerfiller.pop(); - super.customServerAiStep(world); - } - -diff --git a/src/main/java/net/minecraft/world/entity/animal/armadillo/Armadillo.java b/src/main/java/net/minecraft/world/entity/animal/armadillo/Armadillo.java -index c1ef714096159608752d744b98f615cd45fe459a..844a5a61428234adcc12e7e8af8f2781a4ad4be8 100644 ---- a/src/main/java/net/minecraft/world/entity/animal/armadillo/Armadillo.java -+++ b/src/main/java/net/minecraft/world/entity/animal/armadillo/Armadillo.java -@@ -23,8 +23,6 @@ import net.minecraft.util.ByIdMap; - import net.minecraft.util.RandomSource; - import net.minecraft.util.StringRepresentable; - import net.minecraft.util.TimeUtil; --import net.minecraft.util.profiling.Profiler; --import net.minecraft.util.profiling.ProfilerFiller; - import net.minecraft.world.InteractionHand; - import net.minecraft.world.InteractionResult; - import net.minecraft.world.damagesource.DamageSource; -@@ -135,14 +133,8 @@ public class Armadillo extends Animal { - - @Override - protected void customServerAiStep(ServerLevel world) { -- ProfilerFiller gameprofilerfiller = Profiler.get(); -- -- gameprofilerfiller.push("armadilloBrain"); - ((Brain) this.brain).tick(world, this); // CraftBukkit - decompile error -- gameprofilerfiller.pop(); -- gameprofilerfiller.push("armadilloActivityUpdate"); - ArmadilloAi.updateActivity(this); -- gameprofilerfiller.pop(); - if (this.isAlive() && !this.isBaby() && --this.scuteTime <= 0) { - this.forceDrops = true; // CraftBukkit - if (this.dropFromGiftLootTable(world, BuiltInLootTables.ARMADILLO_SHED, this::spawnAtLocation)) { -diff --git a/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java b/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java -index 31b10cd404b672d7ce21c2107d8f83e32de26ef4..22dbc237498d765bc9a13f6c5924769122406c8a 100644 ---- a/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java -+++ b/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java -@@ -26,8 +26,6 @@ import net.minecraft.util.ByIdMap; - import net.minecraft.util.Mth; - import net.minecraft.util.RandomSource; - import net.minecraft.util.StringRepresentable; --import net.minecraft.util.profiling.Profiler; --import net.minecraft.util.profiling.ProfilerFiller; - import net.minecraft.world.DifficultyInstance; - import net.minecraft.world.InteractionHand; - import net.minecraft.world.InteractionResult; -@@ -294,14 +292,8 @@ public class Axolotl extends Animal implements VariantHolder, B - - @Override - protected void customServerAiStep(ServerLevel world) { -- ProfilerFiller gameprofilerfiller = Profiler.get(); -- -- gameprofilerfiller.push("axolotlBrain"); - this.getBrain().tick(world, this); -- gameprofilerfiller.pop(); -- gameprofilerfiller.push("axolotlActivityUpdate"); - AxolotlAi.updateActivity(this); -- gameprofilerfiller.pop(); - if (!this.isNoAi()) { - Optional optional = this.getBrain().getMemory(MemoryModuleType.PLAY_DEAD_TICKS); - -diff --git a/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java b/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java -index f3c884ab9c09f04dd01cabf2ee9de3b5b620563d..002e8b5a7037e48a7d9bd84c321b152f40fe1fce 100644 ---- a/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java -+++ b/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java -@@ -17,8 +17,6 @@ import net.minecraft.sounds.SoundSource; - import net.minecraft.tags.BlockTags; - import net.minecraft.tags.ItemTags; - import net.minecraft.util.Mth; --import net.minecraft.util.profiling.Profiler; --import net.minecraft.util.profiling.ProfilerFiller; - import net.minecraft.world.DifficultyInstance; - import net.minecraft.world.InteractionHand; - import net.minecraft.world.InteractionResult; -@@ -143,16 +141,10 @@ public class Camel extends AbstractHorse { - - @Override - protected void customServerAiStep(ServerLevel world) { -- ProfilerFiller gameprofilerfiller = Profiler.get(); -- -- gameprofilerfiller.push("camelBrain"); - Brain behaviorcontroller = (Brain) this.getBrain(); // CraftBukkit - decompile error - - behaviorcontroller.tick(world, this); -- gameprofilerfiller.pop(); -- gameprofilerfiller.push("camelActivityUpdate"); - CamelAi.updateActivity(this); -- gameprofilerfiller.pop(); - super.customServerAiStep(world); - } - -diff --git a/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java b/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java -index 36846ba6b6c7494c745ebd8b221479a9d02ff318..1a71f1d094271b5ce798210562000f6d0160eaa6 100644 ---- a/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java -+++ b/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java -@@ -28,8 +28,6 @@ import net.minecraft.tags.ItemTags; - import net.minecraft.util.Mth; - import net.minecraft.util.RandomSource; - import net.minecraft.util.Unit; --import net.minecraft.util.profiling.Profiler; --import net.minecraft.util.profiling.ProfilerFiller; - import net.minecraft.world.DifficultyInstance; - import net.minecraft.world.damagesource.DamageSource; - import net.minecraft.world.entity.AgeableMob; -@@ -186,13 +184,8 @@ public class Frog extends Animal implements VariantHolder> { - - @Override - protected void customServerAiStep(ServerLevel world) { -- ProfilerFiller profilerFiller = Profiler.get(); -- profilerFiller.push("frogBrain"); - this.getBrain().tick(world, this); -- profilerFiller.pop(); -- profilerFiller.push("frogActivityUpdate"); - FrogAi.updateActivity(this); -- profilerFiller.pop(); - super.customServerAiStep(world); - } - -diff --git a/src/main/java/net/minecraft/world/entity/animal/frog/Tadpole.java b/src/main/java/net/minecraft/world/entity/animal/frog/Tadpole.java -index 48ac8c3f6e00c3c2dc67b6c994be7c0ac6dfcf81..76ecf98d91a368cd223f09bb0c56a50320999735 100644 ---- a/src/main/java/net/minecraft/world/entity/animal/frog/Tadpole.java -+++ b/src/main/java/net/minecraft/world/entity/animal/frog/Tadpole.java -@@ -12,8 +12,6 @@ import net.minecraft.server.level.ServerLevel; - import net.minecraft.sounds.SoundEvent; - import net.minecraft.sounds.SoundEvents; - import net.minecraft.tags.ItemTags; --import net.minecraft.util.profiling.Profiler; --import net.minecraft.util.profiling.ProfilerFiller; - import net.minecraft.world.InteractionHand; - import net.minecraft.world.InteractionResult; - import net.minecraft.world.damagesource.DamageSource; -@@ -85,14 +83,8 @@ public class Tadpole extends AbstractFish { - - @Override - protected void customServerAiStep(ServerLevel world) { -- ProfilerFiller gameprofilerfiller = Profiler.get(); -- -- gameprofilerfiller.push("tadpoleBrain"); - this.getBrain().tick(world, this); -- gameprofilerfiller.pop(); -- gameprofilerfiller.push("tadpoleActivityUpdate"); - TadpoleAi.updateActivity(this); -- gameprofilerfiller.pop(); - super.customServerAiStep(world); - } - -diff --git a/src/main/java/net/minecraft/world/entity/animal/goat/Goat.java b/src/main/java/net/minecraft/world/entity/animal/goat/Goat.java -index 76aca47d8638d5c37c57d3a59fa7f8ceaa5a53b4..f480ee1d0cde254d9621b85b4064771bdab2d3a3 100644 ---- a/src/main/java/net/minecraft/world/entity/animal/goat/Goat.java -+++ b/src/main/java/net/minecraft/world/entity/animal/goat/Goat.java -@@ -20,8 +20,6 @@ import net.minecraft.tags.ItemTags; - import net.minecraft.tags.TagKey; - import net.minecraft.util.Mth; - import net.minecraft.util.RandomSource; --import net.minecraft.util.profiling.Profiler; --import net.minecraft.util.profiling.ProfilerFiller; - import net.minecraft.world.DifficultyInstance; - import net.minecraft.world.InteractionHand; - import net.minecraft.world.InteractionResult; -@@ -194,14 +192,8 @@ public class Goat extends Animal { - - @Override - protected void customServerAiStep(ServerLevel world) { -- ProfilerFiller gameprofilerfiller = Profiler.get(); -- -- gameprofilerfiller.push("goatBrain"); - this.getBrain().tick(world, this); -- gameprofilerfiller.pop(); -- gameprofilerfiller.push("goatActivityUpdate"); - GoatAi.updateActivity(this); -- gameprofilerfiller.pop(); - super.customServerAiStep(world); - } - -diff --git a/src/main/java/net/minecraft/world/entity/animal/sniffer/Sniffer.java b/src/main/java/net/minecraft/world/entity/animal/sniffer/Sniffer.java -index af2f6e690fc51d319b77d081466c2dc7a1d8fe19..b61b41f542bd52965a9fbd79644038c68e7dea98 100644 ---- a/src/main/java/net/minecraft/world/entity/animal/sniffer/Sniffer.java -+++ b/src/main/java/net/minecraft/world/entity/animal/sniffer/Sniffer.java -@@ -30,8 +30,6 @@ import net.minecraft.tags.BlockTags; - import net.minecraft.tags.ItemTags; - import net.minecraft.util.ByIdMap; - import net.minecraft.util.Mth; --import net.minecraft.util.profiling.Profiler; --import net.minecraft.util.profiling.ProfilerFiller; - import net.minecraft.world.InteractionHand; - import net.minecraft.world.InteractionResult; - import net.minecraft.world.damagesource.DamageSource; -@@ -467,13 +465,8 @@ public class Sniffer extends Animal { - - @Override - protected void customServerAiStep(ServerLevel world) { -- ProfilerFiller gameprofilerfiller = Profiler.get(); -- -- gameprofilerfiller.push("snifferBrain"); - this.getBrain().tick(world, this); -- gameprofilerfiller.popPush("snifferActivityUpdate"); - SnifferAi.updateActivity(this); -- gameprofilerfiller.pop(); - super.customServerAiStep(world); - } - -diff --git a/src/main/java/net/minecraft/world/entity/monster/Zoglin.java b/src/main/java/net/minecraft/world/entity/monster/Zoglin.java -index 35b0c5c322864e2f5ae5a412296072f268adcd05..50b559a92b54c0be7624b1aebc70537573c58666 100644 ---- a/src/main/java/net/minecraft/world/entity/monster/Zoglin.java -+++ b/src/main/java/net/minecraft/world/entity/monster/Zoglin.java -@@ -15,8 +15,6 @@ import net.minecraft.network.syncher.SynchedEntityData; - import net.minecraft.server.level.ServerLevel; - import net.minecraft.sounds.SoundEvent; - import net.minecraft.sounds.SoundEvents; --import net.minecraft.util.profiling.Profiler; --import net.minecraft.util.profiling.ProfilerFiller; - import net.minecraft.util.valueproviders.UniformInt; - import net.minecraft.world.DifficultyInstance; - import net.minecraft.world.damagesource.DamageSource; -@@ -248,10 +246,7 @@ public class Zoglin extends Monster implements HoglinBase { - - @Override - protected void customServerAiStep(ServerLevel world) { -- ProfilerFiller profilerFiller = Profiler.get(); -- profilerFiller.push("zoglinBrain"); - this.getBrain().tick(world, this); -- profilerFiller.pop(); - this.updateActivity(); - } - -diff --git a/src/main/java/net/minecraft/world/entity/monster/breeze/Breeze.java b/src/main/java/net/minecraft/world/entity/monster/breeze/Breeze.java -index 489644b66266257828fd216e4298bd6d33f7777b..2e6b6ef451cd3caa1fde466e5c670b7f17814753 100644 ---- a/src/main/java/net/minecraft/world/entity/monster/breeze/Breeze.java -+++ b/src/main/java/net/minecraft/world/entity/monster/breeze/Breeze.java -@@ -12,8 +12,6 @@ import net.minecraft.sounds.SoundEvent; - import net.minecraft.sounds.SoundEvents; - import net.minecraft.sounds.SoundSource; - import net.minecraft.tags.EntityTypeTags; --import net.minecraft.util.profiling.Profiler; --import net.minecraft.util.profiling.ProfilerFiller; - import net.minecraft.world.damagesource.DamageSource; - import net.minecraft.world.entity.AnimationState; - import net.minecraft.world.entity.Entity; -@@ -236,13 +234,8 @@ public class Breeze extends Monster { - - @Override - protected void customServerAiStep(ServerLevel world) { -- ProfilerFiller gameprofilerfiller = Profiler.get(); -- -- gameprofilerfiller.push("breezeBrain"); - this.getBrain().tick(world, this); -- gameprofilerfiller.popPush("breezeActivityUpdate"); - BreezeAi.updateActivity(this); -- gameprofilerfiller.pop(); - super.customServerAiStep(world); - } - -diff --git a/src/main/java/net/minecraft/world/entity/monster/creaking/Creaking.java b/src/main/java/net/minecraft/world/entity/monster/creaking/Creaking.java -index 7b5f9284972b3a6bd8125891b23f73438e875c08..444e67eb9fa1fabff2304896bdd71772747dc437 100644 ---- a/src/main/java/net/minecraft/world/entity/monster/creaking/Creaking.java -+++ b/src/main/java/net/minecraft/world/entity/monster/creaking/Creaking.java -@@ -13,8 +13,6 @@ import net.minecraft.network.syncher.SynchedEntityData; - import net.minecraft.server.level.ServerLevel; - import net.minecraft.sounds.SoundEvent; - import net.minecraft.sounds.SoundEvents; --import net.minecraft.util.profiling.Profiler; --import net.minecraft.util.profiling.ProfilerFiller; - import net.minecraft.world.damagesource.DamageSource; - import net.minecraft.world.entity.AnimationState; - import net.minecraft.world.entity.Entity; -@@ -121,10 +119,7 @@ public class Creaking extends Monster { - - @Override - protected void customServerAiStep(ServerLevel world) { -- ProfilerFiller profilerFiller = Profiler.get(); -- profilerFiller.push("creakingBrain"); - this.getBrain().tick((ServerLevel)this.level(), this); -- profilerFiller.pop(); - CreakingAi.updateActivity(this); - } - -diff --git a/src/main/java/net/minecraft/world/entity/monster/hoglin/Hoglin.java b/src/main/java/net/minecraft/world/entity/monster/hoglin/Hoglin.java -index 92270912ef26924f611a1df7cb3d5b485b0a262d..05a2d7a104161bde1dd913e14afb045264a54e87 100644 ---- a/src/main/java/net/minecraft/world/entity/monster/hoglin/Hoglin.java -+++ b/src/main/java/net/minecraft/world/entity/monster/hoglin/Hoglin.java -@@ -16,8 +16,6 @@ import net.minecraft.sounds.SoundEvents; - import net.minecraft.sounds.SoundSource; - import net.minecraft.tags.ItemTags; - import net.minecraft.util.RandomSource; --import net.minecraft.util.profiling.Profiler; --import net.minecraft.util.profiling.ProfilerFiller; - import net.minecraft.world.DifficultyInstance; - import net.minecraft.world.InteractionHand; - import net.minecraft.world.InteractionResult; -@@ -140,11 +138,7 @@ public class Hoglin extends Animal implements Enemy, HoglinBase { - - @Override - protected void customServerAiStep(ServerLevel world) { -- ProfilerFiller gameprofilerfiller = Profiler.get(); -- -- gameprofilerfiller.push("hoglinBrain"); - this.getBrain().tick(world, this); -- gameprofilerfiller.pop(); - HoglinAi.updateActivity(this); - if (this.isConverting()) { - ++this.timeInOverworld; -diff --git a/src/main/java/net/minecraft/world/entity/monster/piglin/Piglin.java b/src/main/java/net/minecraft/world/entity/monster/piglin/Piglin.java -index e04d2c5e75dc774fe893a552474fdb8045c32693..ad987660373cf1fd0edb778fa4203e3948b12fd4 100644 ---- a/src/main/java/net/minecraft/world/entity/monster/piglin/Piglin.java -+++ b/src/main/java/net/minecraft/world/entity/monster/piglin/Piglin.java -@@ -6,8 +6,6 @@ import java.util.List; - import javax.annotation.Nullable; - import net.minecraft.util.RandomSource; - import net.minecraft.util.VisibleForDebug; --import net.minecraft.util.profiling.Profiler; --import net.minecraft.util.profiling.ProfilerFiller; - import net.minecraft.world.DifficultyInstance; - import net.minecraft.world.InteractionHand; - import net.minecraft.world.InteractionResult; -@@ -306,11 +304,7 @@ public class Piglin extends AbstractPiglin implements CrossbowAttackMob, Invento - - @Override - protected void customServerAiStep(ServerLevel world) { -- ProfilerFiller gameprofilerfiller = Profiler.get(); -- -- gameprofilerfiller.push("piglinBrain"); - this.getBrain().tick(world, this); -- gameprofilerfiller.pop(); - PiglinAi.updateActivity(this); - super.customServerAiStep(world); - } -diff --git a/src/main/java/net/minecraft/world/entity/monster/piglin/PiglinBrute.java b/src/main/java/net/minecraft/world/entity/monster/piglin/PiglinBrute.java -index 24eaeb93284fe1a573026b85818a93a34fd9e1ec..0cab5d5aa80f9ca8c34f982f0b81044328ba2d8f 100644 ---- a/src/main/java/net/minecraft/world/entity/monster/piglin/PiglinBrute.java -+++ b/src/main/java/net/minecraft/world/entity/monster/piglin/PiglinBrute.java -@@ -8,8 +8,6 @@ import net.minecraft.server.level.ServerLevel; - import net.minecraft.sounds.SoundEvent; - import net.minecraft.sounds.SoundEvents; - import net.minecraft.util.RandomSource; --import net.minecraft.util.profiling.Profiler; --import net.minecraft.util.profiling.ProfilerFiller; - import net.minecraft.world.DifficultyInstance; - import net.minecraft.world.damagesource.DamageSource; - import net.minecraft.world.entity.EntitySpawnReason; -@@ -115,10 +113,7 @@ public class PiglinBrute extends AbstractPiglin { - - @Override - protected void customServerAiStep(ServerLevel world) { -- ProfilerFiller profilerFiller = Profiler.get(); -- profilerFiller.push("piglinBruteBrain"); - this.getBrain().tick(world, this); -- profilerFiller.pop(); - PiglinBruteAi.updateActivity(this); - PiglinBruteAi.maybePlayActivitySound(this); - super.customServerAiStep(world); -diff --git a/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java b/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java -index 6180019da58b19d2595da508aed3196af922d587..9d9d58ab055b5bccedd6ebc9f6853ca8206cde65 100644 ---- a/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java -+++ b/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java -@@ -32,8 +32,6 @@ import net.minecraft.tags.TagKey; - import net.minecraft.util.Mth; - import net.minecraft.util.RandomSource; - import net.minecraft.util.Unit; --import net.minecraft.util.profiling.Profiler; --import net.minecraft.util.profiling.ProfilerFiller; - import net.minecraft.world.DifficultyInstance; - import net.minecraft.world.damagesource.DamageSource; - import net.minecraft.world.effect.MobEffectInstance; -@@ -277,11 +275,7 @@ public class Warden extends Monster implements VibrationSystem { - - @Override - protected void customServerAiStep(ServerLevel world) { -- ProfilerFiller gameprofilerfiller = Profiler.get(); -- -- gameprofilerfiller.push("wardenBrain"); - this.getBrain().tick(world, this); -- gameprofilerfiller.pop(); - super.customServerAiStep(world); - if ((this.tickCount + this.getId()) % 120 == 0) { - Warden.applyDarknessAround(world, this.position(), this, 20); -diff --git a/src/main/java/net/minecraft/world/entity/npc/Villager.java b/src/main/java/net/minecraft/world/entity/npc/Villager.java -index b7a34f1c4d7b5ef3f7a843d152e33c839dcdedd5..08c780e9e1e167b84f70dce691bb564c8420b286 100644 ---- a/src/main/java/net/minecraft/world/entity/npc/Villager.java -+++ b/src/main/java/net/minecraft/world/entity/npc/Villager.java -@@ -38,8 +38,6 @@ import net.minecraft.stats.Stats; - import net.minecraft.tags.ItemTags; - import net.minecraft.util.Mth; - import net.minecraft.util.SpawnUtil; --import net.minecraft.util.profiling.Profiler; --import net.minecraft.util.profiling.ProfilerFiller; - import net.minecraft.world.Difficulty; - import net.minecraft.world.DifficultyInstance; - import net.minecraft.world.InteractionHand; -@@ -252,11 +250,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler - } - protected void customServerAiStep(ServerLevel world, final boolean inactive) { - // Paper end - EAR 2 -- ProfilerFiller gameprofilerfiller = Profiler.get(); -- -- gameprofilerfiller.push("villagerBrain"); - if (!inactive) this.getBrain().tick(world, this); -- gameprofilerfiller.pop(); - if (this.assignProfessionWhenSpawned) { - this.assignProfessionWhenSpawned = false; - } -diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index 5ac5b21b5193cadeaa16250747be3b6685ca21ff..37ed8ec7cac117e674d39a3dbc3ce8b99e4459e9 100644 ---- a/src/main/java/net/minecraft/world/level/Level.java -+++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -35,8 +35,6 @@ import net.minecraft.util.AbortableIterationConsumer; - import net.minecraft.util.Mth; - import net.minecraft.util.RandomSource; - import net.minecraft.util.StringRepresentable; --import net.minecraft.util.profiling.Profiler; --import net.minecraft.util.profiling.ProfilerFiller; - import net.minecraft.world.DifficultyInstance; - import net.minecraft.world.TickRateManager; - import net.minecraft.world.damagesource.DamageSource; -@@ -232,7 +230,6 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl - - @Override - public final List getEntitiesOfClass(final Class entityClass, final AABB boundingBox, final Predicate predicate) { -- Profiler.get().incrementCounter("getEntities"); - final List ret = new java.util.ArrayList<>(); - - ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemLevel)this).moonrise$getEntityLookup().getEntities(entityClass, null, boundingBox, ret, predicate); -@@ -242,7 +239,6 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl - - @Override - public final List moonrise$getHardCollidingEntities(final Entity entity, final AABB box, final Predicate predicate) { -- Profiler.get().incrementCounter("getEntities"); - final List ret = new java.util.ArrayList<>(); - - ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemLevel)this).moonrise$getEntityLookup().getHardCollidingEntities(entity, box, ret, predicate); -@@ -1447,9 +1443,6 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl - } - - protected void tickBlockEntities() { -- ProfilerFiller gameprofilerfiller = Profiler.get(); -- -- gameprofilerfiller.push("blockEntities"); - this.tickingBlockEntities = true; - if (!this.pendingBlockEntityTickers.isEmpty()) { - this.blockEntityTickers.addAll(this.pendingBlockEntityTickers); -@@ -1487,7 +1480,6 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl - this.blockEntityTickers.removeAll(toRemove); // Paper - Fix MC-117075 - - this.tickingBlockEntities = false; -- gameprofilerfiller.pop(); - this.spigotConfig.currentPrimedTnt = 0; // Spigot - } - -@@ -1657,7 +1649,6 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl - - @Override - public List getEntities(@Nullable Entity except, AABB box, Predicate predicate) { -- Profiler.get().incrementCounter("getEntities"); - List list = Lists.newArrayList(); - - // Paper start - rewrite chunk system -@@ -1687,8 +1678,6 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl - public void getEntities(final EntityTypeTest entityTypeTest, - final AABB boundingBox, final Predicate predicate, - final List into, final int maxCount) { -- Profiler.get().incrementCounter("getEntities"); -- - if (entityTypeTest instanceof net.minecraft.world.entity.EntityType byType) { - if (maxCount != Integer.MAX_VALUE) { - ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemLevel)this).moonrise$getEntityLookup().getEntities(byType, boundingBox, into, predicate, maxCount); -diff --git a/src/main/java/net/minecraft/world/level/NaturalSpawner.java b/src/main/java/net/minecraft/world/level/NaturalSpawner.java -index c1b76a1ebc1eea7ab70cf61d8175a31794dd122a..2febef53fc1c2bbacab94feb5de4e6934e47038e 100644 ---- a/src/main/java/net/minecraft/world/level/NaturalSpawner.java -+++ b/src/main/java/net/minecraft/world/level/NaturalSpawner.java -@@ -24,8 +24,6 @@ import net.minecraft.tags.BlockTags; - import net.minecraft.util.Mth; - import net.minecraft.util.RandomSource; - import net.minecraft.util.VisibleForDebug; --import net.minecraft.util.profiling.Profiler; --import net.minecraft.util.profiling.ProfilerFiller; - import net.minecraft.util.random.WeightedRandomList; - import net.minecraft.world.entity.Entity; - import net.minecraft.world.entity.EntitySpawnReason; -@@ -163,9 +161,6 @@ public final class NaturalSpawner { - } - - public static void spawnForChunk(ServerLevel world, LevelChunk chunk, NaturalSpawner.SpawnState info, List spawnableGroups) { -- ProfilerFiller gameprofilerfiller = Profiler.get(); -- -- gameprofilerfiller.push("spawner"); - Iterator iterator = spawnableGroups.iterator(); - - while (iterator.hasNext()) { -@@ -210,8 +205,6 @@ public final class NaturalSpawner { - // Paper end - Optional per player mob spawns - } - } -- -- gameprofilerfiller.pop(); - } - - // Paper start - Add mobcaps commands -diff --git a/src/main/java/net/minecraft/world/level/ServerExplosion.java b/src/main/java/net/minecraft/world/level/ServerExplosion.java -index bbbd451ff184be8fa13bd93d53c89a9502f9951a..4de71492339c3d31a34f1fa2aa75e8b216485ef0 100644 ---- a/src/main/java/net/minecraft/world/level/ServerExplosion.java -+++ b/src/main/java/net/minecraft/world/level/ServerExplosion.java -@@ -15,8 +15,6 @@ import net.minecraft.core.BlockPos; - import net.minecraft.core.Holder; - import net.minecraft.server.level.ServerLevel; - import net.minecraft.util.Mth; --import net.minecraft.util.profiling.Profiler; --import net.minecraft.util.profiling.ProfilerFiller; - import net.minecraft.world.damagesource.DamageSource; - import net.minecraft.world.entity.Entity; - import net.minecraft.world.entity.EntityType; -@@ -683,11 +681,7 @@ public class ServerExplosion implements Explosion { - - this.hurtEntities(); - if (this.interactsWithBlocks()) { -- ProfilerFiller gameprofilerfiller = Profiler.get(); -- -- gameprofilerfiller.push("explosion_blocks"); - this.interactWithBlocks(list); -- gameprofilerfiller.pop(); - } - - if (this.fire) { -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 4640baec5bed6c2d53cc0f8ca1d273cc115abe9b..09a6d7410bc029889ce4b89ab149a52f31468b9b 100644 ---- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java -+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java -@@ -25,8 +25,6 @@ import net.minecraft.network.FriendlyByteBuf; - import net.minecraft.network.protocol.game.ClientboundLevelChunkPacketData; - import net.minecraft.server.level.FullChunkStatus; - import net.minecraft.server.level.ServerLevel; --import net.minecraft.util.profiling.Profiler; --import net.minecraft.util.profiling.ProfilerFiller; - import net.minecraft.world.entity.Entity; - import net.minecraft.world.level.ChunkPos; - import net.minecraft.world.level.Level; -@@ -405,13 +403,8 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p - } - - if (LightEngine.hasDifferentLightProperties(iblockdata1, iblockdata)) { -- ProfilerFiller gameprofilerfiller = Profiler.get(); -- -- gameprofilerfiller.push("updateSkyLightSources"); - // Paper - rewrite chunk system -- gameprofilerfiller.popPush("queueCheckLight"); - this.level.getChunkSource().getLightEngine().checkBlock(blockposition); -- gameprofilerfiller.pop(); - } - - boolean flag3 = iblockdata1.hasBlockEntity(); -@@ -1058,9 +1051,6 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p - - if (LevelChunk.this.isTicking(blockposition)) { - try { -- ProfilerFiller gameprofilerfiller = Profiler.get(); -- -- gameprofilerfiller.push(this::getType); - BlockState iblockdata = LevelChunk.this.getBlockState(blockposition); - - if (this.blockEntity.getType().isValid(iblockdata)) { -@@ -1075,8 +1065,6 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p - } - // Paper end - Remove the Block Entity if it's invalid - } -- -- gameprofilerfiller.pop(); - } catch (Throwable throwable) { - if (throwable instanceof ThreadDeath) throw throwable; // Paper - // Paper start - Prevent block entity and entity crashes -diff --git a/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java b/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java -index cc7d94144e39f7dace7b569b4567def98396e8f9..d7ac3a6a1d7d5561aae153ecb1455b8972d9a61d 100644 ---- a/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java -+++ b/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java -@@ -12,9 +12,6 @@ import java.util.function.Function; - import java.util.stream.Collectors; - import javax.annotation.Nullable; - import net.minecraft.core.BlockPos; --import net.minecraft.util.profiling.Profiler; --import net.minecraft.util.profiling.ProfilerFiller; --import net.minecraft.util.profiling.metrics.MetricCategory; - import net.minecraft.world.entity.Mob; - import net.minecraft.world.level.PathNavigationRegion; - -@@ -58,9 +55,6 @@ public class PathFinder { - @Nullable - // Paper start - Perf: remove streams and optimize collection - private Path findPath(Node startNode, List> positions, float followRange, int distance, float rangeMultiplier) { -- ProfilerFiller profilerFiller = Profiler.get(); -- profilerFiller.push("find_path"); -- profilerFiller.markForCharting(MetricCategory.PATH_FINDING); - // Set set = positions.keySet(); - startNode.g = 0.0F; - startNode.h = this.getBestH(startNode, positions); // Paper - optimize collection -@@ -128,7 +122,6 @@ public class PathFinder { - if (best == null || comparator.compare(path, best) < 0) - best = path; - } -- profilerFiller.pop(); - return best; - // Paper end - Perf: remove streams and optimize collection - } -diff --git a/src/main/java/net/minecraft/world/ticks/LevelTicks.java b/src/main/java/net/minecraft/world/ticks/LevelTicks.java -index 778e6476c86d823dc8efe603a95e589e8b2ea9d9..97f304e287603dbe44080182665ef4454df2c66f 100644 ---- a/src/main/java/net/minecraft/world/ticks/LevelTicks.java -+++ b/src/main/java/net/minecraft/world/ticks/LevelTicks.java -@@ -23,8 +23,6 @@ import net.minecraft.Util; - import net.minecraft.core.BlockPos; - import net.minecraft.core.SectionPos; - import net.minecraft.core.Vec3i; --import net.minecraft.util.profiling.Profiler; --import net.minecraft.util.profiling.ProfilerFiller; - import net.minecraft.world.level.ChunkPos; - import net.minecraft.world.level.levelgen.structure.BoundingBox; - -@@ -79,20 +77,13 @@ public class LevelTicks implements LevelTickAccess { - } - - public void tick(long time, int maxTicks, BiConsumer ticker) { -- ProfilerFiller profilerFiller = Profiler.get(); -- profilerFiller.push("collect"); -- this.collectTicks(time, maxTicks, profilerFiller); -- profilerFiller.popPush("run"); -- profilerFiller.incrementCounter("ticksToRun", this.toRunThisTick.size()); -+ this.collectTicks(time, maxTicks); // Gale - Purpur - remove vanilla profiler - this.runCollectedTicks(ticker); -- profilerFiller.popPush("cleanup"); - this.cleanupAfterTick(); -- profilerFiller.pop(); - } - -- private void collectTicks(long time, int maxTicks, ProfilerFiller profiler) { -+ private void collectTicks(long time, int maxTicks) { // Gale - Purpur - remove vanilla profiler - this.sortContainersToTick(time); -- profiler.incrementCounter("containersToTick", this.containersToTick.size()); - this.drainContainers(time, maxTicks); - this.rescheduleLeftoverContainers(); - } diff --git a/patches/server/0013-Faster-floating-point-positive-modulo.patch b/patches/server/0013-Faster-floating-point-positive-modulo.patch deleted file mode 100644 index ffe7f06..0000000 --- a/patches/server/0013-Faster-floating-point-positive-modulo.patch +++ /dev/null @@ -1,54 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Martijn Muijsers -Date: Tue, 29 Aug 2023 22:29:08 +0200 -Subject: [PATCH] Faster floating-point positive modulo - -License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) -Gale - https://galemc.org - -diff --git a/src/main/java/net/minecraft/util/Mth.java b/src/main/java/net/minecraft/util/Mth.java -index 6b21782ad18cd5dbd1b9a59e5dc12c670c2a42fb..34bfbbabe3dfbf033f4a4e22a049323213fb23f3 100644 ---- a/src/main/java/net/minecraft/util/Mth.java -+++ b/src/main/java/net/minecraft/util/Mth.java -@@ -149,14 +149,26 @@ public class Mth { - return Math.floorMod(dividend, divisor); - } - -- public static float positiveModulo(float dividend, float divisor) { -+ public static float positiveModuloForAnyDivisor(float dividend, float divisor) { // Gale - faster floating-point positive modulo - return (dividend % divisor + divisor) % divisor; - } - -- public static double positiveModulo(double dividend, double divisor) { -+ public static double positiveModuloForAnyDivisor(double dividend, double divisor) { // Gale - faster floating-point positive modulo - return (dividend % divisor + divisor) % divisor; - } - -+ // Gale start - faster floating-point positive modulo -+ public static float positiveModuloForPositiveIntegerDivisor(float dividend, float divisor) { -+ var modulo = dividend % divisor; -+ return modulo < 0 ? modulo + divisor : modulo; -+ } -+ -+ public static double positiveModuloForPositiveIntegerDivisor(double dividend, double divisor) { -+ var modulo = dividend % divisor; -+ return modulo < 0 ? modulo + divisor : modulo; -+ } -+ // Gale end - faster floating-point positive modulo -+ - public static boolean isMultipleOf(int a, int b) { - return a % b == 0; - } -diff --git a/src/main/java/net/minecraft/world/level/levelgen/blending/Blender.java b/src/main/java/net/minecraft/world/level/levelgen/blending/Blender.java -index d058e71d6047bbd9256f6c71bb21966cfc056a7d..079edef073e751f38063b42515df893cecd2fcc4 100644 ---- a/src/main/java/net/minecraft/world/level/levelgen/blending/Blender.java -+++ b/src/main/java/net/minecraft/world/level/levelgen/blending/Blender.java -@@ -146,7 +146,7 @@ public class Blender { - private static double heightToOffset(double height) { - double d = 1.0; - double e = height + 0.5; -- double f = Mth.positiveModulo(e, 8.0); -+ double f = Mth.positiveModuloForPositiveIntegerDivisor(e, 8.0); // Gale - faster floating-point positive modulo - return 1.0 * (32.0 * (e - 128.0) - 3.0 * (e - 120.0) * f + 3.0 * f * f) / (128.0 * (32.0 - 3.0 * f)); - } - diff --git a/patches/server/0020-Reduce-acquire-POI-for-stuck-entities.patch b/patches/server/0020-Reduce-acquire-POI-for-stuck-entities.patch deleted file mode 100644 index 5259c60..0000000 --- a/patches/server/0020-Reduce-acquire-POI-for-stuck-entities.patch +++ /dev/null @@ -1,83 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Martijn Muijsers -Date: Wed, 23 Nov 2022 20:12:48 +0100 -Subject: [PATCH] Reduce acquire POI for stuck entities - -License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) -Gale - https://galemc.org - -This patch is based on the following patch: -"Skip POI finding if stuck in vehicle" -By: Paul Sauve -As part of: Airplane (https://github.com/TECHNOVE/Airplane) -Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) - -* Airplane copyright * - -Airplane -Copyright (C) 2020 Technove LLC - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . - -diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java b/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java -index e1b6fe9ecda25f86431baf414f1bfd3a26a8b2bd..59732e3b17c20143ecbdc6afa480fdbdc1afc55f 100644 ---- a/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java -+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java -@@ -26,6 +26,13 @@ import org.apache.commons.lang3.mutable.MutableLong; - public class AcquirePoi { - public static final int SCAN_RANGE = 48; - -+ // Gale start - Airplane - reduce acquire POI for stuck entities -+ public static void addAdditionalTimeToMutableLongIfEntityIsStuck(MutableLong mutableLong, net.minecraft.server.level.ServerLevel world, PathfinderMob entity) { -+ long stuckEntityAdditionalWaitTime = world.galeConfig().smallOptimizations.reducedIntervals.acquirePoiForStuckEntity; -+ mutableLong.add(stuckEntityAdditionalWaitTime <= 0L ? 0L : entity.getNavigation().isStuck() ? stuckEntityAdditionalWaitTime : 0L); -+ } -+ // Gale end - Airplane - reduce acquire POI for stuck entities -+ - public static BehaviorControl create( - Predicate> poiPredicate, MemoryModuleType poiPosModule, boolean onlyRunIfChild, Optional entityStatus - ) { -@@ -52,12 +59,13 @@ public class AcquirePoi { - return false; - } else if (mutableLong.getValue() == 0L) { - mutableLong.setValue(world.getGameTime() + (long)world.random.nextInt(20)); -+ addAdditionalTimeToMutableLongIfEntityIsStuck(mutableLong, world, entity); // Gale - Airplane - reduce acquire POI for stuck entities - return false; - } else if (world.getGameTime() < mutableLong.getValue()) { - return false; - } else { - mutableLong.setValue(time + 20L + (long)world.getRandom().nextInt(20)); -- if (entity.getNavigation().isStuck()) mutableLong.add(200); // Paper - Perf: Wait an additional 10s to check again if they're stuck -+ addAdditionalTimeToMutableLongIfEntityIsStuck(mutableLong, world, entity); // Paper - Perf: Wait an additional 10s to check again if they're stuck // Gale - Airplane - reduce acquire POI for stuck entities - PoiManager poiManager = world.getPoiManager(); - long2ObjectMap.long2ObjectEntrySet().removeIf(entry -> !entry.getValue().isStillValid(time)); - Predicate predicate2 = pos -> { -diff --git a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -index eabe9e6a7f99a7ad1f2a9f210f8a7489a89dc4cc..8a0416775d00148bf3478b51d92b00d9d485c667 100644 ---- a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -+++ b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -@@ -49,6 +49,13 @@ public class GaleWorldConfiguration extends ConfigurationPart { - } - // Gale end - Airplane - reduce projectile chunk loading - -+ public ReducedIntervals reducedIntervals; -+ public class ReducedIntervals extends ConfigurationPart { -+ -+ public int acquirePoiForStuckEntity = 60; // Gale - Airplane - reduce acquire POI for stuck entities -+ -+ } -+ - } - - } diff --git a/patches/server/0026-Better-checking-for-useless-move-packets.patch b/patches/server/0026-Better-checking-for-useless-move-packets.patch deleted file mode 100644 index c1df304..0000000 --- a/patches/server/0026-Better-checking-for-useless-move-packets.patch +++ /dev/null @@ -1,52 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Martijn Muijsers -Date: Wed, 23 Nov 2022 22:26:37 +0100 -Subject: [PATCH] Better checking for useless move packets - -License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) -Gale - https://galemc.org - -This patch is based on the following patch: -"Better checking for useless move packets" -By: Paul Sauve -As part of: Airplane (https://github.com/TECHNOVE/Airplane) -Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) - -* Airplane copyright * - -Airplane -Copyright (C) 2020 Technove LLC - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . - -diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java -index 90eb4927fa51ce3df86aa7b6c71f49150a03e337..bf813380d5767ce05cdeca7084e6f19aa106803a 100644 ---- a/src/main/java/net/minecraft/server/level/ServerEntity.java -+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java -@@ -207,6 +207,7 @@ public class ServerEntity { - boolean flag5 = i < -32768L || i > 32767L || j < -32768L || j > 32767L || k < -32768L || k > 32767L; - - if (!this.forceStateResync && !flag5 && this.teleportDelay <= 400 && !this.wasRiding && this.wasOnGround == this.entity.onGround()) { // Paper - fix desync when a player is added to the tracker -+ if (flag2 || flag || this.entity instanceof AbstractArrow) { // Gale - Airplane - better checking for useless move packets - if ((!flag2 || !flag) && !(this.entity instanceof AbstractArrow)) { - if (flag2) { - packet1 = new ClientboundMoveEntityPacket.Pos(this.entity.getId(), (short) ((int) i), (short) ((int) j), (short) ((int) k), this.entity.onGround()); -@@ -220,6 +221,7 @@ public class ServerEntity { - flag3 = true; - flag4 = true; - } -+ } // Gale - Airplane - better checking for useless move packets - } else { - this.wasOnGround = this.entity.onGround(); - this.teleportDelay = 0; diff --git a/patches/server/0029-Remove-lambda-from-ticking-guard.patch b/patches/server/0029-Remove-lambda-from-ticking-guard.patch deleted file mode 100644 index 69163bd..0000000 --- a/patches/server/0029-Remove-lambda-from-ticking-guard.patch +++ /dev/null @@ -1,81 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Martijn Muijsers -Date: Wed, 23 Nov 2022 23:13:56 +0100 -Subject: [PATCH] Remove lambda from ticking guard - -License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) -Gale - https://galemc.org - -This patch is based on the following patch: -"Remove lambda from ticking guard" -By: Paul Sauve -As part of: Airplane (https://github.com/TECHNOVE/Airplane) -Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) - -* Airplane copyright * - -Airplane -Copyright (C) 2020 Technove LLC - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . - -diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index b424fe78d3c9410e6d6378a7f104cfd5069f0d1e..cd73c5bc1cd56a4e7bbac5171015cd6904acf68d 100644 ---- a/src/main/java/net/minecraft/server/level/ServerLevel.java -+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java -@@ -788,7 +788,20 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe - entity.stopRiding(); - } - -- this.guardEntityTick(this::tickNonPassenger, entity); -+ // Gale start - Airplane - remove lambda from ticking guard - copied from guardEntityTick -+ try { -+ this.tickNonPassenger(entity); // Gale - Airplane - remove lambda from ticking guard - changed -+ } catch (Throwable throwable) { -+ if (throwable instanceof ThreadDeath) throw throwable; // Paper -+ // Paper start - Prevent block entity and entity crashes -+ final String msg = String.format("Entity threw exception at %s:%s,%s,%s", entity.level().getWorld().getName(), entity.getX(), entity.getY(), entity.getZ()); -+ MinecraftServer.LOGGER.error(msg, throwable); -+ getCraftServer().getPluginManager().callEvent(new com.destroystokyo.paper.event.server.ServerExceptionEvent(new com.destroystokyo.paper.exception.ServerInternalException(msg, throwable))); // Paper - ServerExceptionEvent -+ entity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD); -+ // Paper end - Prevent block entity and entity crashes -+ } -+ this.moonrise$midTickTasks(); // Paper - rewrite chunk system -+ // Gale end - Airplane - remove lambda from ticking guard - copied from guardEntityTick - } - } - } -diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index 5419efc40cd27c532acff423edaa259edacd862a..f019e1eb20a8ec3a57e5d90386cb10244ddfcb66 100644 ---- a/src/main/java/net/minecraft/world/level/Level.java -+++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -1489,15 +1489,15 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl - try { - tickConsumer.accept(entity); - } catch (Throwable throwable) { -- if (throwable instanceof ThreadDeath) throw throwable; // Paper -+ if (throwable instanceof ThreadDeath) throw throwable; // Paper // Gale - Airplane - remove lambda from ticking guard - diff on change ServerLevel#tick - // Paper start - Prevent block entity and entity crashes - final String msg = String.format("Entity threw exception at %s:%s,%s,%s", entity.level().getWorld().getName(), entity.getX(), entity.getY(), entity.getZ()); - MinecraftServer.LOGGER.error(msg, throwable); - getCraftServer().getPluginManager().callEvent(new com.destroystokyo.paper.event.server.ServerExceptionEvent(new com.destroystokyo.paper.exception.ServerInternalException(msg, throwable))); // Paper - ServerExceptionEvent -- entity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD); -+ entity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD); // Gale - Airplane - remove lambda from ticking guard - diff on change ServerLevel#tick - // Paper end - Prevent block entity and entity crashes - } -- this.moonrise$midTickTasks(); // Paper - rewrite chunk system -+ this.moonrise$midTickTasks(); // Paper - rewrite chunk system // Gale - Airplane - remove lambda from ticking guard - diff on change ServerLevel#tick - } - // Paper start - Option to prevent armor stands from doing entity lookups - @Override diff --git a/patches/server/0035-Make-ender-dragon-respawn-attempt-after-placing-end-.patch b/patches/server/0035-Make-ender-dragon-respawn-attempt-after-placing-end-.patch deleted file mode 100644 index 9006a31..0000000 --- a/patches/server/0035-Make-ender-dragon-respawn-attempt-after-placing-end-.patch +++ /dev/null @@ -1,61 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Martijn Muijsers -Date: Mon, 7 Aug 2023 21:35:57 +0200 -Subject: [PATCH] Make ender dragon respawn attempt after placing end crystals - configurable - -The original Pufferfish description has been included below for reference, -but please note that on Gale, there is no need to disable end crystal -spawning for performance: Gale already contains other performance -enhancements that make the end crystal checks very fast. - -License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) -Gale - https://galemc.org - -This patch is based on the following patch: -"Option to disable end crystal dragon respawning" -By: Kevin Raneri -As part of: Pufferfish (https://github.com/pufferfish-gg/Pufferfish) -Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) - -* Pufferfish description * - -On servers that expect end crystal fights in the end dimension, -disabling this will prevent the server from performing an expensive -search to attempt respawning the ender dragon whenever a player places -an end crystal. - -diff --git a/src/main/java/net/minecraft/world/item/EndCrystalItem.java b/src/main/java/net/minecraft/world/item/EndCrystalItem.java -index b62db8c7c8c57e43869ee239ebf4b02f112355d9..9f92b9addaedb4bae06b32226a74c8e5ddc6c2a2 100644 ---- a/src/main/java/net/minecraft/world/item/EndCrystalItem.java -+++ b/src/main/java/net/minecraft/world/item/EndCrystalItem.java -@@ -55,11 +55,13 @@ public class EndCrystalItem extends Item { - // CraftBukkit end - world.addFreshEntity(entityendercrystal); - world.gameEvent((Entity) context.getPlayer(), (Holder) GameEvent.ENTITY_PLACE, blockposition1); -+ if (world.galeConfig().gameplayMechanics.tryRespawnEnderDragonAfterEndCrystalPlace) { // Gale - Pufferfish - make ender dragon respawn attempt after placing end crystals configurable - EndDragonFight enderdragonbattle = ((ServerLevel) world).getDragonFight(); - - if (enderdragonbattle != null) { - enderdragonbattle.tryRespawn(aboveBlockPosition); // Paper - Perf: Do crystal-portal proximity check before entity lookup - } -+ } // Gale - Pufferfish - make ender dragon respawn attempt after placing end crystals configurable - } - - context.getItemInHand().shrink(1); -diff --git a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -index 08a02055b535c024cc806db17bb45fd333a56929..7e7e01f6514f6bbb9c89dc3c878fb6da25eb6b1f 100644 ---- a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -+++ b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -@@ -59,4 +59,11 @@ public class GaleWorldConfiguration extends ConfigurationPart { - - } - -+ public GameplayMechanics gameplayMechanics; -+ public class GameplayMechanics extends ConfigurationPart { -+ -+ public boolean tryRespawnEnderDragonAfterEndCrystalPlace = true; // Gale - Pufferfish - make ender dragon respawn attempt after placing end crystals configurable -+ -+ } -+ - } diff --git a/patches/server/0036-Make-saving-fireworks-configurable.patch b/patches/server/0036-Make-saving-fireworks-configurable.patch deleted file mode 100644 index 7609b5d..0000000 --- a/patches/server/0036-Make-saving-fireworks-configurable.patch +++ /dev/null @@ -1,50 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Martijn Muijsers -Date: Mon, 26 Dec 2022 07:30:30 +0100 -Subject: [PATCH] Make saving fireworks configurable - -License: MIT (https://opensource.org/licenses/MIT) -Gale - https://galemc.org - -This patch is based on the following patch: -"Don't save Fireworks" -By: Aikar -As part of: EmpireCraft (https://github.com/starlis/empirecraft) -Licensed under: MIT (https://opensource.org/licenses/MIT) - -* EmpireCraft description * - -Fireworks can bug out and not detonate, and an automated -launcher can very easily fill a chunk. - -Prevent saving Fireworks so that chunk unloads will wipe a chunks fireworks in this case. - -diff --git a/src/main/java/net/minecraft/world/entity/projectile/FireworkRocketEntity.java b/src/main/java/net/minecraft/world/entity/projectile/FireworkRocketEntity.java -index 8a4e7e1c0c4919d2ee34121c14f9665b9ad95273..7bd7045128f1f55a687047eafd895971ec12e565 100644 ---- a/src/main/java/net/minecraft/world/entity/projectile/FireworkRocketEntity.java -+++ b/src/main/java/net/minecraft/world/entity/projectile/FireworkRocketEntity.java -@@ -381,4 +381,11 @@ public class FireworkRocketEntity extends Projectile implements ItemSupplier { - - return DoubleDoubleImmutablePair.of(d0, d1); - } -+ -+ // Gale start - EMC - make saving fireworks configurable -+ @Override -+ public boolean shouldBeSaved() { -+ return this.level().galeConfig().smallOptimizations.saveFireworks; -+ } -+ // Gale end - EMC - make saving fireworks configurable - } -diff --git a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -index 7e7e01f6514f6bbb9c89dc3c878fb6da25eb6b1f..00a327bd0e4e0f2def0bb29d5ecff4f0ec4ba1eb 100644 ---- a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -+++ b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -@@ -33,6 +33,8 @@ public class GaleWorldConfiguration extends ConfigurationPart { - public SmallOptimizations smallOptimizations; - public class SmallOptimizations extends ConfigurationPart { - -+ public boolean saveFireworks = true; // Gale - EMC - make saving fireworks configurable -+ - // Gale start - Airplane - reduce projectile chunk loading - public MaxProjectileChunkLoads maxProjectileChunkLoads; - public class MaxProjectileChunkLoads extends ConfigurationPart { diff --git a/patches/server/0037-Reduce-hopper-item-checks.patch b/patches/server/0037-Reduce-hopper-item-checks.patch deleted file mode 100644 index c027033..0000000 --- a/patches/server/0037-Reduce-hopper-item-checks.patch +++ /dev/null @@ -1,193 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Martijn Muijsers -Date: Thu, 24 Nov 2022 23:03:52 +0100 -Subject: [PATCH] Reduce hopper item checks - -License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) -Gale - https://galemc.org - -This patch is based on the following patch: -"Improve Hopper Performance" -By: Aikar -As part of: EmpireCraft (https://github.com/starlis/empirecraft) -Licensed under: MIT (https://opensource.org/licenses/MIT) - -* EmpireCraft description * - -Only do an item "suck in" action once per second - -diff --git a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java -index 0f086af57a5ff08c264dcbf89a8c3931ec73a609..ca36be3c3189adc99ef04e4ce4307948adda1deb 100644 ---- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java -+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java -@@ -234,11 +234,31 @@ public class ItemEntity extends Entity implements TraceableEntity { - } - // CraftBukkit end - this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause -+ return; // Gale - EMC - reduce hopper item checks - } -+ this.markNearbyHopperCartsAsImmune(); // Gale - EMC - reduce hopper item checks - - } - } - -+ // Gale start - EMC - reduce hopper item checks -+ private void markNearbyHopperCartsAsImmune() { -+ var config = level().galeConfig().smallOptimizations.reducedIntervals.checkNearbyItem.hopper.minecart; -+ // No need to mark hopper minecarts as immune if they can pull every tick anyway -+ if (config.interval <= 1) { -+ return; -+ } -+ if (config.temporaryImmunity.duration > 0 && this.isAlive() && this.onGround && !this.isRemoved() && (config.temporaryImmunity.nearbyItemMaxAge == -1 || this.age <= config.temporaryImmunity.nearbyItemMaxAge) && this.age % Math.max(1, config.temporaryImmunity.checkForMinecartNearItemInterval) == 0 && config.temporaryImmunity.maxItemHorizontalDistance >= 0 && config.temporaryImmunity.maxItemVerticalDistance >= 0) { -+ net.minecraft.world.phys.AABB aabb = this.getBoundingBox().inflate(config.temporaryImmunity.maxItemHorizontalDistance, config.temporaryImmunity.maxItemVerticalDistance, config.temporaryImmunity.maxItemHorizontalDistance); -+ for (Entity entity : this.level().getEntities(this, aabb)) { -+ if (entity instanceof net.minecraft.world.entity.vehicle.MinecartHopper hopper) { -+ hopper.pickupImmunity = MinecraftServer.currentTick + config.temporaryImmunity.duration; -+ } -+ } -+ } -+ } -+ // Gale end - EMC - reduce hopper item checks -+ - // Spigot start - copied from above - @Override - public void inactiveTick() { -@@ -259,7 +279,13 @@ public class ItemEntity extends Entity implements TraceableEntity { - } - // CraftBukkit end - this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause -+ return; // Gale - EMC - reduce hopper item checks -+ } -+ // Gale start - EMC - reduce hopper item checks -+ if (level().galeConfig().smallOptimizations.reducedIntervals.checkNearbyItem.hopper.minecart.temporaryImmunity.checkForMinecartNearItemWhileInactive) { -+ this.markNearbyHopperCartsAsImmune(); - } -+ // Gale end - EMC - reduce hopper item checks - } - // Spigot end - -diff --git a/src/main/java/net/minecraft/world/entity/vehicle/MinecartHopper.java b/src/main/java/net/minecraft/world/entity/vehicle/MinecartHopper.java -index d81a6874e8b25f098df619f84c359e146c7f64de..f799c993754802583f9b9c0cf8c7220bebd92f8d 100644 ---- a/src/main/java/net/minecraft/world/entity/vehicle/MinecartHopper.java -+++ b/src/main/java/net/minecraft/world/entity/vehicle/MinecartHopper.java -@@ -21,6 +21,7 @@ import net.minecraft.world.level.block.state.properties.RailShape; - public class MinecartHopper extends AbstractMinecartContainer implements Hopper { - private boolean enabled = true; - private boolean consumedItemThisFrame = false; -+ public int pickupImmunity = 0; // Gale - EMC - reduce hopper item checks - - public MinecartHopper(EntityType type, Level world) { - super(type, world); -@@ -149,4 +150,12 @@ public class MinecartHopper extends AbstractMinecartContainer implements Hopper - } - // Paper end - -+ // Gale start - EMC - reduce hopper item checks -+ private long tickAttempts = 0; -+ @Override -+ public long getAndIncrementAttemptCounter() { -+ return tickAttempts++; -+ } -+ // Gale end EMC - - reduce hopper item checks -+ - } -diff --git a/src/main/java/net/minecraft/world/level/block/entity/Hopper.java b/src/main/java/net/minecraft/world/level/block/entity/Hopper.java -index 5f042e294db605827000123252b0df646968f897..e1cc15f28fe8da23b74ff4504c5b2da2236fda3f 100644 ---- a/src/main/java/net/minecraft/world/level/block/entity/Hopper.java -+++ b/src/main/java/net/minecraft/world/level/block/entity/Hopper.java -@@ -11,6 +11,8 @@ public interface Hopper extends Container { - return SUCK_AABB; - } - -+ long getAndIncrementAttemptCounter(); // Gale - EMC - reduce hopper item checks -+ - double getLevelX(); - - double getLevelY(); -diff --git a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java -index 5ebbdb94d9b91c442ff60eb6872f740ebd790fa0..aa55698303f7ffc6542f34311234be6c6b400a9d 100644 ---- a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java -+++ b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java -@@ -568,7 +568,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen - } else { - boolean flag = hopper.isGridAligned() && iblockdata.isCollisionShapeFullBlock(world, blockposition) && !iblockdata.is(BlockTags.DOES_NOT_BLOCK_HOPPERS); - -- if (!flag) { -+ if (!flag && shouldSuckIn(world, hopper)) { // Gale - EMC - reduce hopper item checks - Iterator iterator = HopperBlockEntity.getItemsAtAndAbove(world, hopper).iterator(); - - while (iterator.hasNext()) { -@@ -882,6 +882,31 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen - return first.getCount() < first.getMaxStackSize() && ItemStack.isSameItemSameComponents(first, second); // Paper - Perf: Optimize Hoppers; used to return true for full itemstacks?! - } - -+ // Gale start - EMC - reduce hopper item checks -+ private long tickAttempts = 0; -+ @Override -+ public long getAndIncrementAttemptCounter() { -+ return tickAttempts++; -+ } -+ private static boolean shouldSuckIn(Level world, Hopper hopper) { -+ int suckInterval; -+ if (hopper instanceof net.minecraft.world.entity.vehicle.MinecartHopper minecartHopper) { -+ if (minecartHopper.pickupImmunity > net.minecraft.server.MinecraftServer.currentTick) { -+ return true; -+ } -+ suckInterval = world.galeConfig().smallOptimizations.reducedIntervals.checkNearbyItem.hopper.minecart.interval; -+ } else { -+ suckInterval = world.galeConfig().smallOptimizations.reducedIntervals.checkNearbyItem.hopper.interval; -+ } -+ if (suckInterval <= 1) { -+ return true; -+ } -+ -+ final int hopperId = (int) hopper.getLevelX() + (int) hopper.getLevelY() + (int) hopper.getLevelZ(); -+ return (hopper.getAndIncrementAttemptCounter() + hopperId) % suckInterval == 0; -+ } -+ // Gale end - EMC - reduce hopper item checks -+ - @Override - public double getLevelX() { - return (double) this.worldPosition.getX() + 0.5D; -diff --git a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -index 00a327bd0e4e0f2def0bb29d5ecff4f0ec4ba1eb..a52de3800a3e4b8ff6a521c8c5edcca9d49f7473 100644 ---- a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -+++ b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -@@ -57,6 +57,37 @@ public class GaleWorldConfiguration extends ConfigurationPart { - public int acquirePoiForStuckEntity = 60; // Gale - Airplane - reduce acquire POI for stuck entities - public int checkStuckInWall = 10; // Gale - Pufferfish - reduce in wall checks - -+ public CheckNearbyItem checkNearbyItem; -+ public class CheckNearbyItem extends ConfigurationPart { -+ -+ // Gale start - EMC - reduce hopper item checks -+ public Hopper hopper; -+ public class Hopper extends ConfigurationPart { -+ -+ public int interval = 1; -+ -+ public Minecart minecart; -+ public class Minecart extends ConfigurationPart { -+ -+ public int interval = 1; -+ -+ public TemporaryImmunity temporaryImmunity; -+ public class TemporaryImmunity extends ConfigurationPart { -+ public int duration = 100; -+ public int nearbyItemMaxAge = 1200; -+ public int checkForMinecartNearItemInterval = 20; -+ public boolean checkForMinecartNearItemWhileInactive = true; -+ public double maxItemHorizontalDistance = 24.0; -+ public double maxItemVerticalDistance = 4.0; -+ } -+ -+ } -+ -+ } -+ // Gale end - EMC - reduce hopper item checks -+ -+ } -+ - } - - } diff --git a/patches/server/0038-Reduce-villager-item-re-pickup.patch b/patches/server/0038-Reduce-villager-item-re-pickup.patch deleted file mode 100644 index 73ca7e5..0000000 --- a/patches/server/0038-Reduce-villager-item-re-pickup.patch +++ /dev/null @@ -1,53 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Martijn Muijsers -Date: Thu, 24 Nov 2022 23:15:49 +0100 -Subject: [PATCH] Reduce villager item re-pickup - -License: MIT (https://opensource.org/licenses/MIT) -Gale - https://galemc.org - -This patch is based on the following patch: -"Slow down villager pickup of thrown items" -By: Aikar -As part of: EmpireCraft (https://github.com/starlis/empirecraft) -Licensed under: MIT (https://opensource.org/licenses/MIT) - -* EmpireCraft description * - -Helps 1.8 Farms let hoppers pick it up before Villager -due to our hopper changes - -diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java b/src/main/java/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java -index d98b28e9488a5a7736719cf656736bb026ec8c7e..25dacd924f182d197bcbdcd7c1d8caa482fd8d37 100644 ---- a/src/main/java/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java -+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java -@@ -99,7 +99,16 @@ public class BehaviorUtils { - - vec3d2 = vec3d2.normalize().multiply(velocityFactor.x, velocityFactor.y, velocityFactor.z); - entityitem.setDeltaMovement(vec3d2); -- entityitem.setDefaultPickUpDelay(); -+ // Gale start - EMC - reduce villager item re-pickup -+ if (entity instanceof net.minecraft.world.entity.npc.Villager) { -+ int repickupDelay = entity.level().galeConfig().smallOptimizations.reducedIntervals.villagerItemRepickup; -+ if (repickupDelay <= -1) { -+ entityitem.setDefaultPickUpDelay(); -+ } else { -+ entityitem.pickupDelay = repickupDelay; -+ } -+ } -+ // Gale end - EMC - reduce villager item re-pickup - // CraftBukkit start - org.bukkit.event.entity.EntityDropItemEvent event = new org.bukkit.event.entity.EntityDropItemEvent(entity.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity()); - entityitem.level().getCraftServer().getPluginManager().callEvent(event); -diff --git a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -index a52de3800a3e4b8ff6a521c8c5edcca9d49f7473..9ac3c235a7adc42af1ba22aaa4efbce5b006f98d 100644 ---- a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -+++ b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -@@ -56,6 +56,7 @@ public class GaleWorldConfiguration extends ConfigurationPart { - - public int acquirePoiForStuckEntity = 60; // Gale - Airplane - reduce acquire POI for stuck entities - public int checkStuckInWall = 10; // Gale - Pufferfish - reduce in wall checks -+ public int villagerItemRepickup = 100; // Gale - EMC - reduce villager item re-pickup - - public CheckNearbyItem checkNearbyItem; - public class CheckNearbyItem extends ConfigurationPart { diff --git a/patches/server/0041-Do-not-log-invalid-statistics.patch b/patches/server/0041-Do-not-log-invalid-statistics.patch deleted file mode 100644 index 3c6b5cf..0000000 --- a/patches/server/0041-Do-not-log-invalid-statistics.patch +++ /dev/null @@ -1,53 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Martijn Muijsers -Date: Thu, 24 Nov 2022 23:39:32 +0100 -Subject: [PATCH] Do not log invalid statistics - -License: MIT (https://opensource.org/licenses/MIT) -Gale - https://galemc.org - -This patch is based on the following patch: -"Ignore statistics warnings" -By: Aikar -As part of: EmpireCraft (https://github.com/starlis/empirecraft) -Licensed under: MIT (https://opensource.org/licenses/MIT) - -diff --git a/src/main/java/net/minecraft/stats/ServerStatsCounter.java b/src/main/java/net/minecraft/stats/ServerStatsCounter.java -index da7e1a69ecb4e6b3be2d8544ac406aa519bd196e..b51fb5f1f20ef709f1f741044746eef034230c5d 100644 ---- a/src/main/java/net/minecraft/stats/ServerStatsCounter.java -+++ b/src/main/java/net/minecraft/stats/ServerStatsCounter.java -@@ -137,15 +137,15 @@ public class ServerStatsCounter extends StatsCounter { - Util.ifElse(this.getStat(statisticwrapper, s2), (statistic) -> { - this.stats.put(statistic, nbttagcompound2.getInt(s2)); - }, () -> { -- ServerStatsCounter.LOGGER.warn("Invalid statistic in {}: Don't know what {} is", this.file, s2); -+ if (org.galemc.gale.configuration.GaleGlobalConfiguration.get().logToConsole.invalidStatistics) ServerStatsCounter.LOGGER.warn("Invalid statistic in {}: Don't know what {} is", this.file, s2); // Gale - EMC - do not log invalid statistics - }); - } else { -- ServerStatsCounter.LOGGER.warn("Invalid statistic value in {}: Don't know what {} is for key {}", new Object[]{this.file, nbttagcompound2.get(s2), s2}); -+ if (org.galemc.gale.configuration.GaleGlobalConfiguration.get().logToConsole.invalidStatistics) ServerStatsCounter.LOGGER.warn("Invalid statistic value in {}: Don't know what {} is for key {}", new Object[]{this.file, nbttagcompound2.get(s2), s2}); // Gale - EMC - do not log invalid statistics - } - } - - }, () -> { -- ServerStatsCounter.LOGGER.warn("Invalid statistic type in {}: Don't know what {} is", this.file, s1); -+ if (org.galemc.gale.configuration.GaleGlobalConfiguration.get().logToConsole.invalidStatistics) ServerStatsCounter.LOGGER.warn("Invalid statistic type in {}: Don't know what {} is", this.file, s1); // Gale - EMC - do not log invalid statistics - }); - } - } -diff --git a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -index 8075e5c17f469f1bf5b7758a1334943d6ed8383f..56aa01dfbfc0817b71315322ed3f676bd62ad825 100644 ---- a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -+++ b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -@@ -47,4 +47,11 @@ public class GaleGlobalConfiguration extends ConfigurationPart { - - public boolean verifyChatOrder = true; // Gale - Pufferfish - make chat order verification configurable - } -+ -+ public LogToConsole logToConsole; -+ public class LogToConsole extends ConfigurationPart { -+ -+ public boolean invalidStatistics = true; // Gale - EMC - do not log invalid statistics -+ -+ } - } diff --git a/patches/server/0042-Do-not-log-empty-message-warnings.patch b/patches/server/0042-Do-not-log-empty-message-warnings.patch deleted file mode 100644 index 65ad030..0000000 --- a/patches/server/0042-Do-not-log-empty-message-warnings.patch +++ /dev/null @@ -1,36 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Martijn Muijsers -Date: Thu, 24 Nov 2022 23:45:57 +0100 -Subject: [PATCH] Do not log empty message warnings - -License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) -Gale - https://galemc.org - -diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index ad53a045efaa6ed44a5b345586366b7c50e5688a..25e91c5e5f5cf1a9dbb2931b964c754408926788 100644 ---- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -2543,7 +2543,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl - // CraftBukkit start - String s = message.signedContent(); - if (s.isEmpty()) { -- ServerGamePacketListenerImpl.LOGGER.warn(this.player.getScoreboardName() + " tried to send an empty message"); -+ if (org.galemc.gale.configuration.GaleGlobalConfiguration.get().logToConsole.chat.emptyMessageWarning) ServerGamePacketListenerImpl.LOGGER.warn(this.player.getScoreboardName() + " tried to send an empty message"); // Gale - do not log empty message warnings - } else if (this.getCraftPlayer().isConversing()) { - final String conversationInput = s; - this.server.processQueue.add(new Runnable() { -diff --git a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -index 56aa01dfbfc0817b71315322ed3f676bd62ad825..8ef64ac15626633ecdba555b39a20da11d917b65 100644 ---- a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -+++ b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -@@ -53,5 +53,10 @@ public class GaleGlobalConfiguration extends ConfigurationPart { - - public boolean invalidStatistics = true; // Gale - EMC - do not log invalid statistics - -+ public Chat chat; -+ public class Chat extends ConfigurationPart { -+ public boolean emptyMessageWarning = false; // Gale - do not log empty message warnings -+ } -+ - } - } diff --git a/patches/server/0043-Do-not-log-ignored-advancements.patch b/patches/server/0043-Do-not-log-ignored-advancements.patch deleted file mode 100644 index a246c18..0000000 --- a/patches/server/0043-Do-not-log-ignored-advancements.patch +++ /dev/null @@ -1,63 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Martijn Muijsers -Date: Fri, 25 Nov 2022 13:18:54 +0100 -Subject: [PATCH] Do not log ignored advancements - -License: MIT (https://opensource.org/licenses/MIT) -Gale - https://galemc.org - -This patch is based on the following patch: -"Logger settings (suppressing pointless logs)" -By: William Blake Galbreath -As part of: Purpur (https://github.com/PurpurMC/Purpur) -Licensed under: MIT (https://opensource.org/licenses/MIT) - -* Purpur copyright * - -MIT License - -Copyright (c) 2019-2022 PurpurMC - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - -diff --git a/src/main/java/net/minecraft/server/PlayerAdvancements.java b/src/main/java/net/minecraft/server/PlayerAdvancements.java -index 8e2eb7b61421ceb063654826941f1a81f6f50bdf..66e7fa8a01d5364f7a82ed36f41edc6735b0b5ef 100644 ---- a/src/main/java/net/minecraft/server/PlayerAdvancements.java -+++ b/src/main/java/net/minecraft/server/PlayerAdvancements.java -@@ -199,7 +199,7 @@ public class PlayerAdvancements { - - if (advancementholder == null) { - if (!minecraftkey.getNamespace().equals("minecraft")) return; // CraftBukkit -- PlayerAdvancements.LOGGER.warn("Ignored advancement '{}' in progress file {} - it doesn't exist anymore?", minecraftkey, this.playerSavePath); -+ if (org.galemc.gale.configuration.GaleGlobalConfiguration.get().logToConsole.ignoredAdvancements) PlayerAdvancements.LOGGER.warn("Ignored advancement '{}' in progress file {} - it doesn't exist anymore?", minecraftkey, this.playerSavePath); // Gale - Purpur - do not log ignored advancements - } else { - this.startProgress(advancementholder, advancementprogress); - this.progressChanged.add(advancementholder); -diff --git a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -index 8ef64ac15626633ecdba555b39a20da11d917b65..0ffbe284abfc8ef8f9ed21c8539c497cad685380 100644 ---- a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -+++ b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -@@ -52,6 +52,7 @@ public class GaleGlobalConfiguration extends ConfigurationPart { - public class LogToConsole extends ConfigurationPart { - - public boolean invalidStatistics = true; // Gale - EMC - do not log invalid statistics -+ public boolean ignoredAdvancements = true; // Gale - Purpur - do not log ignored advancements - - public Chat chat; - public class Chat extends ConfigurationPart { diff --git a/patches/server/0045-Do-not-log-unrecognized-recipes.patch b/patches/server/0045-Do-not-log-unrecognized-recipes.patch deleted file mode 100644 index 4e587f9..0000000 --- a/patches/server/0045-Do-not-log-unrecognized-recipes.patch +++ /dev/null @@ -1,63 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Martijn Muijsers -Date: Fri, 25 Nov 2022 15:01:30 +0100 -Subject: [PATCH] Do not log unrecognized recipes - -License: MIT (https://opensource.org/licenses/MIT) -Gale - https://galemc.org - -This patch is based on the following patch: -"Logger settings (suppressing pointless logs)" -By: William Blake Galbreath -As part of: Purpur (https://github.com/PurpurMC/Purpur) -Licensed under: MIT (https://opensource.org/licenses/MIT) - -* Purpur copyright * - -MIT License - -Copyright (c) 2019-2022 PurpurMC - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - -diff --git a/src/main/java/net/minecraft/stats/ServerRecipeBook.java b/src/main/java/net/minecraft/stats/ServerRecipeBook.java -index 5c7484ce2850a2eb698a2183b81134b89b0bbcc7..deab78ef1a751d4d01e1ab45864e5ead3a320ad7 100644 ---- a/src/main/java/net/minecraft/stats/ServerRecipeBook.java -+++ b/src/main/java/net/minecraft/stats/ServerRecipeBook.java -@@ -159,7 +159,7 @@ public class ServerRecipeBook extends RecipeBook { - ResourceKey> resourcekey = ResourceKey.create(Registries.RECIPE, ResourceLocation.parse(s)); - - if (!validPredicate.test(resourcekey)) { -- ServerRecipeBook.LOGGER.error("Tried to load unrecognized recipe: {} removed now.", resourcekey); -+ if (org.galemc.gale.configuration.GaleGlobalConfiguration.get().logToConsole.unrecognizedRecipes) ServerRecipeBook.LOGGER.error("Tried to load unrecognized recipe: {} removed now.", resourcekey); // Gale - Purpur - do not log unrecognized recipes - } else { - handler.accept(resourcekey); - } -diff --git a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -index 0844babd79d3743abe240e68a50e082f58e2f01c..360c48ce9f64e7bbfadd56ce4fa2b78c4787734d 100644 ---- a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -+++ b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -@@ -54,6 +54,7 @@ public class GaleGlobalConfiguration extends ConfigurationPart { - public boolean invalidStatistics = true; // Gale - EMC - do not log invalid statistics - public boolean ignoredAdvancements = true; // Gale - Purpur - do not log ignored advancements - public boolean setBlockInFarChunk = true; // Gale - Purpur - do not log setBlock in far chunks -+ public boolean unrecognizedRecipes = false; // Gale - Purpur - do not log unrecognized recipes - - public Chat chat; - public class Chat extends ConfigurationPart { diff --git a/patches/server/0047-Do-not-log-plugin-library-loads.patch b/patches/server/0047-Do-not-log-plugin-library-loads.patch deleted file mode 100644 index 4b99c6e..0000000 --- a/patches/server/0047-Do-not-log-plugin-library-loads.patch +++ /dev/null @@ -1,75 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Martijn Muijsers -Date: Tue, 8 Aug 2023 18:24:01 +0200 -Subject: [PATCH] Do not log plugin library loads - -License: MIT (https://opensource.org/licenses/MIT) -Gale - https://galemc.org - -This patch is based on the following patch: -"Add log suppression for LibraryLoader" -By: Krakenied -As part of: Purpur (https://github.com/PurpurMC/Purpur) -Licensed under: MIT (https://opensource.org/licenses/MIT) - -* Purpur copyright * - -MIT License - -Copyright (c) 2019-2022 PurpurMC - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - -diff --git a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -index 3ad96a516ef51858b91e2c95fd4e923522a93246..dfe4ea3fbdcd36e10a10041d006454a7e6f9e68a 100644 ---- a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -+++ b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -@@ -4,6 +4,8 @@ package org.galemc.gale.configuration; - - import io.papermc.paper.configuration.Configuration; - import io.papermc.paper.configuration.ConfigurationPart; -+import org.bukkit.plugin.java.JavaPluginLoader; -+import org.spongepowered.configurate.objectmapping.meta.PostProcess; - import org.spongepowered.configurate.objectmapping.meta.Setting; - - @SuppressWarnings({"CanBeFinal", "FieldCanBeLocal", "FieldMayBeFinal", "NotNullFieldNotInitialized", "InnerClassMayBeStatic"}) -@@ -62,5 +64,23 @@ public class GaleGlobalConfiguration extends ConfigurationPart { - public boolean emptyMessageWarning = false; // Gale - do not log empty message warnings - } - -+ // Gale start - Purpur - do not log plugin library loads -+ public PluginLibraryLoader pluginLibraryLoader; -+ public class PluginLibraryLoader extends ConfigurationPart { -+ -+ public boolean downloads = true; -+ public boolean startLoadLibrariesForPlugin = true; -+ public boolean libraryLoaded = true; -+ -+ @PostProcess -+ public void postProcess() { -+ JavaPluginLoader.logDownloads = this.downloads; -+ JavaPluginLoader.logStartLoadLibrariesForPlugin = this.startLoadLibrariesForPlugin; -+ JavaPluginLoader.logLibraryLoaded = this.libraryLoaded; -+ } -+ -+ } -+ // Gale end - Purpur - do not log plugin library loads -+ - } - } diff --git a/patches/server/0048-Do-not-log-expired-message-warnings.patch b/patches/server/0048-Do-not-log-expired-message-warnings.patch deleted file mode 100644 index 2eb5d80..0000000 --- a/patches/server/0048-Do-not-log-expired-message-warnings.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Martijn Muijsers -Date: Fri, 25 Nov 2022 15:07:55 +0100 -Subject: [PATCH] Do not log expired message warnings - -License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) -Gale - https://galemc.org - -diff --git a/src/main/java/net/minecraft/network/chat/SignedMessageChain.java b/src/main/java/net/minecraft/network/chat/SignedMessageChain.java -index 987e595ba3d19b081f22891f01dc25fbabb5bb9f..68efb80b1580dde0097eae72365f0260190c53cb 100644 ---- a/src/main/java/net/minecraft/network/chat/SignedMessageChain.java -+++ b/src/main/java/net/minecraft/network/chat/SignedMessageChain.java -@@ -56,7 +56,7 @@ public class SignedMessageChain { - throw new SignedMessageChain.DecodeException(SignedMessageChain.DecodeException.INVALID_SIGNATURE); - } else { - if (playerChatMessage.hasExpiredServer(Instant.now())) { -- SignedMessageChain.LOGGER.warn("Received expired chat: '{}'. Is the client/server system time unsynchronized?", body.content()); -+ if (org.galemc.gale.configuration.GaleGlobalConfiguration.get().logToConsole.chat.expiredMessageWarning) SignedMessageChain.LOGGER.warn("Received expired chat: '{}'. Is the client/server system time unsynchronized?", body.content()); // Gale - do not log expired message warnings - } - - SignedMessageChain.this.nextLink = signedMessageLink.advance(); -diff --git a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -index dfe4ea3fbdcd36e10a10041d006454a7e6f9e68a..3fd497761dfb5e10ae7a3fd83bee8013c3869117 100644 ---- a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -+++ b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -@@ -62,6 +62,7 @@ public class GaleGlobalConfiguration extends ConfigurationPart { - public Chat chat; - public class Chat extends ConfigurationPart { - public boolean emptyMessageWarning = false; // Gale - do not log empty message warnings -+ public boolean expiredMessageWarning = false; // Gale - do not log expired message warnings - } - - // Gale start - Purpur - do not log plugin library loads diff --git a/patches/server/0049-Do-not-log-Not-Secure-marker.patch b/patches/server/0049-Do-not-log-Not-Secure-marker.patch deleted file mode 100644 index 76bc3cf..0000000 --- a/patches/server/0049-Do-not-log-Not-Secure-marker.patch +++ /dev/null @@ -1,46 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Martijn Muijsers -Date: Fri, 25 Nov 2022 15:13:38 +0100 -Subject: [PATCH] Do not log Not Secure marker - -License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) -Gale - https://galemc.org - -diff --git a/src/main/java/io/papermc/paper/adventure/ChatProcessor.java b/src/main/java/io/papermc/paper/adventure/ChatProcessor.java -index 14e412ebf75b0e06ab53a1c8f9dd1be6ad1e2680..506c746980cfca170efd249d035a572361b667c4 100644 ---- a/src/main/java/io/papermc/paper/adventure/ChatProcessor.java -+++ b/src/main/java/io/papermc/paper/adventure/ChatProcessor.java -@@ -317,7 +317,7 @@ public final class ChatProcessor { - - private void sendToServer(final ChatType.Bound chatType, final @Nullable Function msgFunction) { - final PlayerChatMessage toConsoleMessage = msgFunction == null ? ChatProcessor.this.message : ChatProcessor.this.message.withUnsignedContent(msgFunction.apply(ChatProcessor.this.server.console)); -- ChatProcessor.this.server.logChatMessage(toConsoleMessage.decoratedContent(), chatType, ChatProcessor.this.server.getPlayerList().verifyChatTrusted(toConsoleMessage) ? null : "Not Secure"); -+ ChatProcessor.this.server.logChatMessage(toConsoleMessage.decoratedContent(), chatType, !org.galemc.gale.configuration.GaleGlobalConfiguration.get().logToConsole.chat.notSecureMarker || ChatProcessor.this.server.getPlayerList().verifyChatTrusted(toConsoleMessage) ? null : "Not Secure"); // Gale - do not log Not Secure marker - } - } - -diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index 0e2b903dbd783bea891b88902136e1ac9f7fd66c..c78ba7dca18d0890816a6374883f31784de15733 100644 ---- a/src/main/java/net/minecraft/server/players/PlayerList.java -+++ b/src/main/java/net/minecraft/server/players/PlayerList.java -@@ -1361,7 +1361,7 @@ public abstract class PlayerList { - // Paper end - boolean flag = this.verifyChatTrusted(message); - -- this.server.logChatMessage((unsignedFunction == null ? message.decoratedContent() : unsignedFunction.apply(this.server.console)), params, flag ? null : "Not Secure"); // Paper -+ this.server.logChatMessage((unsignedFunction == null ? message.decoratedContent() : unsignedFunction.apply(this.server.console)), params, flag || !org.galemc.gale.configuration.GaleGlobalConfiguration.get().logToConsole.chat.notSecureMarker ? null : "Not Secure"); // Paper // Gale - do not log Not Secure marker - OutgoingChatMessage outgoingchatmessage = OutgoingChatMessage.create(message); - boolean flag1 = false; - -diff --git a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -index 3fd497761dfb5e10ae7a3fd83bee8013c3869117..413c41e8c2fead4de859535007641094a64e97dd 100644 ---- a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -+++ b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -@@ -63,6 +63,7 @@ public class GaleGlobalConfiguration extends ConfigurationPart { - public class Chat extends ConfigurationPart { - public boolean emptyMessageWarning = false; // Gale - do not log empty message warnings - public boolean expiredMessageWarning = false; // Gale - do not log expired message warnings -+ public boolean notSecureMarker = true; // Gale - do not log Not Secure marker - } - - // Gale start - Purpur - do not log plugin library loads diff --git a/patches/server/0053-Softly-log-invalid-pool-element-errors.patch b/patches/server/0053-Softly-log-invalid-pool-element-errors.patch deleted file mode 100644 index 2a7c0ad..0000000 --- a/patches/server/0053-Softly-log-invalid-pool-element-errors.patch +++ /dev/null @@ -1,85 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Martijn Muijsers -Date: Fri, 25 Nov 2022 16:26:04 +0100 -Subject: [PATCH] Softly log invalid pool element errors - -License: MIT (https://opensource.org/licenses/MIT) -Gale - https://galemc.org - -This patch is based on the following patch: -"Change vanilla structure error to info log level" -By: chickeneer -As part of: EmpireCraft (https://github.com/starlis/empirecraft) -Licensed under: MIT (https://opensource.org/licenses/MIT) - -diff --git a/src/main/java/net/minecraft/world/level/levelgen/structure/PoolElementStructurePiece.java b/src/main/java/net/minecraft/world/level/levelgen/structure/PoolElementStructurePiece.java -index 0977cd0d65dd1c2dde04d318759458abe452847e..ee5b317e87c4d403b6d7f5ab1d493e446f9278f6 100644 ---- a/src/main/java/net/minecraft/world/level/levelgen/structure/PoolElementStructurePiece.java -+++ b/src/main/java/net/minecraft/world/level/levelgen/structure/PoolElementStructurePiece.java -@@ -27,7 +27,7 @@ import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemp - import org.slf4j.Logger; - - public class PoolElementStructurePiece extends StructurePiece { -- private static final Logger LOGGER = LogUtils.getLogger(); -+ public static final Logger LOGGER = LogUtils.getLogger(); // Gale - EMC - softly log invalid pool element errors - private -> public - protected final StructurePoolElement element; - protected BlockPos position; - private final int groundLevelDelta; -@@ -80,7 +80,7 @@ public class PoolElementStructurePiece extends StructurePiece { - DynamicOps dynamicOps = context.registryAccess().createSerializationContext(NbtOps.INSTANCE); - StructurePoolElement.CODEC - .encodeStart(dynamicOps, this.element) -- .resultOrPartial(LOGGER::error) -+ .resultOrPartial(org.galemc.gale.configuration.GaleGlobalConfiguration.get().logToConsole.invalidPoolElementErrorStringConsumer) // Gale - EMC - softly log invalid pool element errors - .ifPresent(poolElement -> nbt.put("pool_element", poolElement)); - nbt.putString("rotation", this.rotation.name()); - ListTag listTag = new ListTag(); -diff --git a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -index a1b98b0f92618764304de484c373ce5e106f34f0..3f8c66b35f1910df7d745056fd8f55d9b035b215 100644 ---- a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -+++ b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -@@ -4,10 +4,14 @@ package org.galemc.gale.configuration; - - import io.papermc.paper.configuration.Configuration; - import io.papermc.paper.configuration.ConfigurationPart; -+import net.minecraft.world.level.levelgen.structure.PoolElementStructurePiece; - import org.bukkit.plugin.java.JavaPluginLoader; - import org.spongepowered.configurate.objectmapping.meta.PostProcess; - import org.spongepowered.configurate.objectmapping.meta.Setting; - -+import java.util.Locale; -+import java.util.function.Consumer; -+ - @SuppressWarnings({"CanBeFinal", "FieldCanBeLocal", "FieldMayBeFinal", "NotNullFieldNotInitialized", "InnerClassMayBeStatic"}) - public class GaleGlobalConfiguration extends ConfigurationPart { - static final int CURRENT_VERSION = 1; -@@ -51,7 +55,7 @@ public class GaleGlobalConfiguration extends ConfigurationPart { - } - - public LogToConsole logToConsole; -- public class LogToConsole extends ConfigurationPart { -+ public class LogToConsole extends ConfigurationPart { // Gale - EMC - softly log invalid pool element errors - - public boolean invalidStatistics = true; // Gale - EMC - do not log invalid statistics - public boolean ignoredAdvancements = true; // Gale - Purpur - do not log ignored advancements -@@ -85,5 +89,20 @@ public class GaleGlobalConfiguration extends ConfigurationPart { - } - // Gale end - Purpur - do not log plugin library loads - -+ // Gale start - EMC - softly log invalid pool element errors -+ public String invalidPoolElementErrorLogLevel = "info"; -+ public transient Consumer invalidPoolElementErrorStringConsumer; -+ -+ @PostProcess -+ public void postProcess() { -+ this.invalidPoolElementErrorStringConsumer = switch (this.invalidPoolElementErrorLogLevel.toLowerCase(Locale.ROOT)) { -+ case "none" -> $ -> {}; -+ case "info", "log" -> PoolElementStructurePiece.LOGGER::info; -+ case "warn", "warning" -> PoolElementStructurePiece.LOGGER::warn; -+ default -> PoolElementStructurePiece.LOGGER::error; -+ }; -+ } -+ // Gale end - EMC - softly log invalid pool element errors -+ - } - } diff --git a/patches/server/0055-Fix-MC-238526.patch b/patches/server/0055-Fix-MC-238526.patch deleted file mode 100644 index 2c8d4cf..0000000 --- a/patches/server/0055-Fix-MC-238526.patch +++ /dev/null @@ -1,71 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Martijn Muijsers -Date: Tue, 29 Nov 2022 16:16:35 +0100 -Subject: [PATCH] Fix MC-238526 - -License: MIT (https://opensource.org/licenses/MIT) -Gale - https://galemc.org - -This patch is based on the following patch: -"MC-238526 - Fix spawner not spawning water animals correctly" -By: BillyGalbreath -As part of: Purpur (https://github.com/PurpurMC/Purpur) -Licensed under: MIT (https://opensource.org/licenses/MIT) - -* Purpur copyright * - -MIT License - -Copyright (c) 2019-2022 PurpurMC - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - -diff --git a/src/main/java/net/minecraft/world/entity/animal/WaterAnimal.java b/src/main/java/net/minecraft/world/entity/animal/WaterAnimal.java -index 8c4532a250f8679d729a35c17e9b5bd339264450..d2e65b6b06929c016aefb36de70391d25232e460 100644 ---- a/src/main/java/net/minecraft/world/entity/animal/WaterAnimal.java -+++ b/src/main/java/net/minecraft/world/entity/animal/WaterAnimal.java -@@ -74,6 +74,6 @@ public abstract class WaterAnimal extends PathfinderMob { - i = world.getMinecraftWorld().paperConfig().entities.spawning.wateranimalSpawnHeight.maximum.or(i); - j = world.getMinecraftWorld().paperConfig().entities.spawning.wateranimalSpawnHeight.minimum.or(j); - // Paper end - Make water animal spawn height configurable -- return pos.getY() >= j && pos.getY() <= i && world.getFluidState(pos.below()).is(FluidTags.WATER) && world.getBlockState(pos.above()).is(Blocks.WATER); -+ return ((reason == EntitySpawnReason.SPAWNER && world.getMinecraftWorld().galeConfig().gameplayMechanics.fixes.mc238526) || (pos.getY() >= j && pos.getY() <= i)) && world.getFluidState(pos.below()).is(FluidTags.WATER) && world.getBlockState(pos.above()).is(Blocks.WATER); // Gale - Purpur - fix MC-238526 - } - } -diff --git a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -index 42306d45d3b8f7807b344422fca7382eec52cde2..fff9f552a9b3cc4913837077857c78826bf1bdb0 100644 ---- a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -+++ b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -@@ -96,6 +96,16 @@ public class GaleWorldConfiguration extends ConfigurationPart { - public GameplayMechanics gameplayMechanics; - public class GameplayMechanics extends ConfigurationPart { - -+ public Fixes fixes; -+ public class Fixes extends ConfigurationPart { -+ -+ // Gale start - Purpur - fix MC-238526 -+ @Setting("mc-238526") -+ public boolean mc238526 = false; -+ // Gale end - Purpur - fix MC-238526 -+ -+ } -+ - public double entityWakeUpDurationRatioStandardDeviation = 0.2; // Gale - variable entity wake-up duration - public boolean tryRespawnEnderDragonAfterEndCrystalPlace = true; // Gale - Pufferfish - make ender dragon respawn attempt after placing end crystals configurable - diff --git a/patches/server/0060-Make-logging-login-locations-configurable.patch b/patches/server/0060-Make-logging-login-locations-configurable.patch deleted file mode 100644 index 2b7aa3f..0000000 --- a/patches/server/0060-Make-logging-login-locations-configurable.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Martijn Muijsers -Date: Mon, 26 Dec 2022 00:17:40 +0100 -Subject: [PATCH] Make logging login locations configurable - -License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) -Gale - https://galemc.org - -This patch is based on the following patch: -"configurable logging of player login location" -By: Simon Gardling -As part of: JettPack (https://gitlab.com/Titaniumtown/JettPack) -Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) - -diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index 91d0b4ed03cbe6f8c472e8fb2a1481ed6be67b3b..2b6621b858961b8ec4ad73fb2db797306adf7251 100644 ---- a/src/main/java/net/minecraft/server/players/PlayerList.java -+++ b/src/main/java/net/minecraft/server/players/PlayerList.java -@@ -421,7 +421,13 @@ public abstract class PlayerList { - scoreboard.addPlayerToTeam(player.getScoreboardName(), collideRuleTeam); - } - // Paper end - Configurable player collision -+ if (org.galemc.gale.configuration.GaleGlobalConfiguration.get().logToConsole.playerLoginLocations) { // Gale - JettPack - make logging login location configurable - PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ([{}]{}, {}, {})", player.getName().getString(), s1, player.getId(), worldserver1.serverLevelData.getLevelName(), player.getX(), player.getY(), player.getZ()); -+ // Gale start - JettPack - make logging login location configurable -+ } else { -+ PlayerList.LOGGER.info("{}[{}] logged in with entity id {}", player.getName().getString(), s1, player.getId()); -+ } -+ // Gale end - JettPack - make logging login location configurable - // Paper start - Send empty chunk, so players aren't stuck in the world loading screen with our chunk system not sending chunks when dead - if (player.isDeadOrDying()) { - net.minecraft.core.Holder plains = worldserver1.registryAccess().lookupOrThrow(net.minecraft.core.registries.Registries.BIOME) -diff --git a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -index 3f8c66b35f1910df7d745056fd8f55d9b035b215..b0da100cf972d4e39b130c99550ebcc763f055ee 100644 ---- a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -+++ b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -@@ -63,6 +63,7 @@ public class GaleGlobalConfiguration extends ConfigurationPart { - public boolean unrecognizedRecipes = false; // Gale - Purpur - do not log unrecognized recipes - public boolean legacyMaterialInitialization = false; // Gale - Purpur - do not log legacy Material initialization - public boolean nullIdDisconnections = true; // Gale - Pufferfish - do not log disconnections with null id -+ public boolean playerLoginLocations = true; // Gale - JettPack - make logging login location configurable - - public Chat chat; - public class Chat extends ConfigurationPart { diff --git a/patches/server/0061-Reduce-array-allocations.patch b/patches/server/0061-Reduce-array-allocations.patch deleted file mode 100644 index 7d7bf9f..0000000 --- a/patches/server/0061-Reduce-array-allocations.patch +++ /dev/null @@ -1,618 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Martijn Muijsers -Date: Sat, 26 Nov 2022 11:25:45 +0100 -Subject: [PATCH] Reduce array allocations - -License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) -Gale - https://galemc.org - -This patch is based on the following patch: -"reduce allocs" -By: Simon Gardling -As part of: JettPack (https://gitlab.com/Titaniumtown/JettPack) -Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) - -diff --git a/src/main/java/ca/spottedleaf/moonrise/common/list/EntityList.java b/src/main/java/ca/spottedleaf/moonrise/common/list/EntityList.java -index 7fed43a1e7bcf35c4d7fd3224837a47fedd59860..adc47f1ca3580a6968d145239ae830734a0ebe4a 100644 ---- a/src/main/java/ca/spottedleaf/moonrise/common/list/EntityList.java -+++ b/src/main/java/ca/spottedleaf/moonrise/common/list/EntityList.java -@@ -18,9 +18,7 @@ public final class EntityList implements Iterable { - this.entityToIndex.defaultReturnValue(Integer.MIN_VALUE); - } - -- private static final Entity[] EMPTY_LIST = new Entity[0]; -- -- private Entity[] entities = EMPTY_LIST; -+ private Entity[] entities = me.titaniumtown.ArrayConstants.emptyEntityArray; // Gale - JettPack - reduce array allocations - private int count; - - public int size() { -diff --git a/src/main/java/ca/spottedleaf/moonrise/common/list/IntList.java b/src/main/java/ca/spottedleaf/moonrise/common/list/IntList.java -index 9f3b25bb2439f283f878db93973a02fcdcd14eed..4eb7bf187276f07f807fe181b303dda8e1b9196d 100644 ---- a/src/main/java/ca/spottedleaf/moonrise/common/list/IntList.java -+++ b/src/main/java/ca/spottedleaf/moonrise/common/list/IntList.java -@@ -10,9 +10,7 @@ public final class IntList { - this.map.defaultReturnValue(Integer.MIN_VALUE); - } - -- private static final int[] EMPTY_LIST = new int[0]; -- -- private int[] byIndex = EMPTY_LIST; -+ private int[] byIndex = me.titaniumtown.ArrayConstants.emptyIntArray; // Gale - JettPack - reduce array allocations - private int count; - - public int size() { -diff --git a/src/main/java/ca/spottedleaf/moonrise/common/list/ReferenceList.java b/src/main/java/ca/spottedleaf/moonrise/common/list/ReferenceList.java -index 2e876b918672e8ef3b5197b7e6b1597247fdeaa1..8df9406b77eb3c225ebf88bf76a7adb666452f3b 100644 ---- a/src/main/java/ca/spottedleaf/moonrise/common/list/ReferenceList.java -+++ b/src/main/java/ca/spottedleaf/moonrise/common/list/ReferenceList.java -@@ -7,14 +7,12 @@ import java.util.NoSuchElementException; - - public final class ReferenceList implements Iterable { - -- private static final Object[] EMPTY_LIST = new Object[0]; -- - private final Reference2IntOpenHashMap referenceToIndex; - private E[] references; - private int count; - - public ReferenceList() { -- this((E[])EMPTY_LIST); -+ this((E[]) me.titaniumtown.ArrayConstants.emptyObjectArray); // Gale - JettPack - reduce array allocations - } - - public ReferenceList(final E[] referenceArray) { -diff --git a/src/main/java/ca/spottedleaf/moonrise/common/list/ShortList.java b/src/main/java/ca/spottedleaf/moonrise/common/list/ShortList.java -index 2bae9949ef325d0001aa638150fbbdf968367e75..a72d5db6f6a8667c5c839016033bba4d0f16cf13 100644 ---- a/src/main/java/ca/spottedleaf/moonrise/common/list/ShortList.java -+++ b/src/main/java/ca/spottedleaf/moonrise/common/list/ShortList.java -@@ -10,9 +10,7 @@ public final class ShortList { - this.map.defaultReturnValue(Short.MIN_VALUE); - } - -- private static final short[] EMPTY_LIST = new short[0]; -- -- private short[] byIndex = EMPTY_LIST; -+ private short[] byIndex = me.titaniumtown.ArrayConstants.emptyShortArray; // Gale - JettPack - reduce array allocations - private short count; - - public int size() { -diff --git a/src/main/java/ca/spottedleaf/moonrise/common/list/SortedList.java b/src/main/java/ca/spottedleaf/moonrise/common/list/SortedList.java -index db92261a6cb3758391108361096417c61bc82cdc..1a14fddb36ca3c14d243304db629d0c5aac3906c 100644 ---- a/src/main/java/ca/spottedleaf/moonrise/common/list/SortedList.java -+++ b/src/main/java/ca/spottedleaf/moonrise/common/list/SortedList.java -@@ -6,14 +6,12 @@ import java.util.Comparator; - - public final class SortedList { - -- private static final Object[] EMPTY_LIST = new Object[0]; -- - private Comparator comparator; - private E[] elements; - private int count; - - public SortedList(final Comparator comparator) { -- this((E[])EMPTY_LIST, comparator); -+ this((E[]) me.titaniumtown.ArrayConstants.emptyObjectArray, comparator); // Gale - JettPack - reduce array allocations - } - - public SortedList(final E[] elements, final Comparator comparator) { -diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java -index b3c993a790fc3fab6a408c731deb297f74c959ce..e85a33c477e46f5b4633c0e87cfddcca669a0da7 100644 ---- a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java -+++ b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java -@@ -387,7 +387,7 @@ public final class ChunkEntitySlices { - - private static final class BasicEntityList { - -- private static final Entity[] EMPTY = new Entity[0]; -+ private static final Entity[] EMPTY = me.titaniumtown.ArrayConstants.emptyEntityArray; // Gale - JettPack - reduce array allocations - private static final int DEFAULT_CAPACITY = 4; - - private E[] storage; -diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/server/ServerEntityLookup.java b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/server/ServerEntityLookup.java -index 58d9187adc188b693b6becc400f766e069bf1bf5..e3de64c7e7699547b7470080ff85efc5fbc6c2ee 100644 ---- a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/server/ServerEntityLookup.java -+++ b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/server/ServerEntityLookup.java -@@ -15,10 +15,8 @@ import net.minecraft.world.level.entity.LevelCallback; - - public final class ServerEntityLookup extends EntityLookup { - -- private static final Entity[] EMPTY_ENTITY_ARRAY = new Entity[0]; -- - private final ServerLevel serverWorld; -- public final ReferenceList trackerEntities = new ReferenceList<>(EMPTY_ENTITY_ARRAY); // Moonrise - entity tracker -+ public final ReferenceList trackerEntities = new ReferenceList<>(me.titaniumtown.ArrayConstants.emptyEntityArray); // Moonrise - entity tracker // Gale - JettPack - reduce array allocations - - public ServerEntityLookup(final ServerLevel world, final LevelCallback worldCallback) { - super(world, worldCallback); -diff --git a/src/main/java/io/papermc/paper/command/brigadier/PaperCommands.java b/src/main/java/io/papermc/paper/command/brigadier/PaperCommands.java -index 95d3b42cbe2184b0a04d941f27f7a6e643ef59be..e0dad3b61402b309084a464bc3dfdb80043e69eb 100644 ---- a/src/main/java/io/papermc/paper/command/brigadier/PaperCommands.java -+++ b/src/main/java/io/papermc/paper/command/brigadier/PaperCommands.java -@@ -195,7 +195,7 @@ public class PaperCommands implements Commands, PaperRegistrar { -- basicCommand.execute(stack.getSource(), new String[0]); -+ basicCommand.execute(stack.getSource(), me.titaniumtown.ArrayConstants.emptyStringArray); // Gale - JettPack - reduce array allocations - return com.mojang.brigadier.Command.SINGLE_SUCCESS; - }); - -diff --git a/src/main/java/io/papermc/paper/command/subcommands/VersionCommand.java b/src/main/java/io/papermc/paper/command/subcommands/VersionCommand.java -index ae60bd96b5284d54676d8e7e4dd5d170b526ec1e..89562a86cd33ea2b55b284f77dc5d903ee21a49b 100644 ---- a/src/main/java/io/papermc/paper/command/subcommands/VersionCommand.java -+++ b/src/main/java/io/papermc/paper/command/subcommands/VersionCommand.java -@@ -14,7 +14,7 @@ public final class VersionCommand implements PaperSubcommand { - public boolean execute(final CommandSender sender, final String subCommand, final String[] args) { - final @Nullable Command ver = MinecraftServer.getServer().server.getCommandMap().getCommand("version"); - if (ver != null) { -- ver.execute(sender, "paper", new String[0]); -+ ver.execute(sender, "paper", me.titaniumtown.ArrayConstants.emptyStringArray); // Gale - JettPack - reduce array allocations - } - return true; - } -diff --git a/src/main/java/me/titaniumtown/ArrayConstants.java b/src/main/java/me/titaniumtown/ArrayConstants.java -new file mode 100644 -index 0000000000000000000000000000000000000000..211c5b080919e6e6c360c274963bc6396cd82cff ---- /dev/null -+++ b/src/main/java/me/titaniumtown/ArrayConstants.java -@@ -0,0 +1,19 @@ -+// Gale - JettPack - reduce array allocations -+ -+package me.titaniumtown; -+ -+public final class ArrayConstants { -+ -+ private ArrayConstants() {} -+ -+ public static final Object[] emptyObjectArray = new Object[0]; -+ public static final short[] emptyShortArray = new short[0]; -+ public static final int[] emptyIntArray = new int[0]; -+ public static final int[] zeroSingletonIntArray = new int[]{0}; -+ public static final byte[] emptyByteArray = new byte[0]; -+ public static final String[] emptyStringArray = new String[0]; -+ public static final long[] emptyLongArray = new long[0]; -+ public static final org.bukkit.entity.Entity[] emptyBukkitEntityArray = new org.bukkit.entity.Entity[0]; -+ public static final net.minecraft.world.entity.Entity[] emptyEntityArray = new net.minecraft.world.entity.Entity[0]; -+ //public static final net.minecraft.server.level.ServerLevel[] emptyServerLevelArray = new net.minecraft.server.level.ServerLevel[0]; -+} -diff --git a/src/main/java/net/minecraft/nbt/ByteArrayTag.java b/src/main/java/net/minecraft/nbt/ByteArrayTag.java -index 06648f9751fd8a322d0809ffebf6a544596ee1a4..47c09872c8283efaec2eca05b4d74ddea1388942 100644 ---- a/src/main/java/net/minecraft/nbt/ByteArrayTag.java -+++ b/src/main/java/net/minecraft/nbt/ByteArrayTag.java -@@ -175,7 +175,7 @@ public class ByteArrayTag extends CollectionTag { - } - - public void clear() { -- this.data = new byte[0]; -+ this.data = me.titaniumtown.ArrayConstants.emptyByteArray; // Gale - JettPack - reduce array allocations - } - - @Override -diff --git a/src/main/java/net/minecraft/nbt/CompoundTag.java b/src/main/java/net/minecraft/nbt/CompoundTag.java -index d7bb00a946346dff0b0269cbd65276e146a63fb0..ea48637234fdb1e5f54342590def30e11b6a5df0 100644 ---- a/src/main/java/net/minecraft/nbt/CompoundTag.java -+++ b/src/main/java/net/minecraft/nbt/CompoundTag.java -@@ -409,7 +409,7 @@ public class CompoundTag implements Tag { - throw new ReportedException(this.createReport(key, ByteArrayTag.TYPE, var3)); - } - -- return new byte[0]; -+ return me.titaniumtown.ArrayConstants.emptyByteArray; // Gale - JettPack - reduce array allocations - } - - public int[] getIntArray(String key) { -@@ -421,7 +421,7 @@ public class CompoundTag implements Tag { - throw new ReportedException(this.createReport(key, IntArrayTag.TYPE, var3)); - } - -- return new int[0]; -+ return me.titaniumtown.ArrayConstants.emptyIntArray; // Gale - JettPack - reduce array allocations - } - - public long[] getLongArray(String key) { -@@ -433,7 +433,7 @@ public class CompoundTag implements Tag { - throw new ReportedException(this.createReport(key, LongArrayTag.TYPE, var3)); - } - -- return new long[0]; -+ return me.titaniumtown.ArrayConstants.emptyLongArray; // Gale - JettPack - reduce array allocations - } - - public CompoundTag getCompound(String key) { -diff --git a/src/main/java/net/minecraft/nbt/IntArrayTag.java b/src/main/java/net/minecraft/nbt/IntArrayTag.java -index ff13d67151c50ea11a45117e524c7524e2b1a202..d6975bd5fc9cf98426406b2578bc4b418c0548a9 100644 ---- a/src/main/java/net/minecraft/nbt/IntArrayTag.java -+++ b/src/main/java/net/minecraft/nbt/IntArrayTag.java -@@ -186,7 +186,7 @@ public class IntArrayTag extends CollectionTag { - } - - public void clear() { -- this.data = new int[0]; -+ this.data = me.titaniumtown.ArrayConstants.emptyIntArray; // Gale - JettPack - reduce array allocations - } - - @Override -diff --git a/src/main/java/net/minecraft/nbt/ListTag.java b/src/main/java/net/minecraft/nbt/ListTag.java -index 154bffd341e43be0a0fa710cfbed1a2094f249a3..ef2671f8be6787796c3ed5415a9722713be9a65b 100644 ---- a/src/main/java/net/minecraft/nbt/ListTag.java -+++ b/src/main/java/net/minecraft/nbt/ListTag.java -@@ -258,7 +258,7 @@ public class ListTag extends CollectionTag { - } - } - -- return new int[0]; -+ return me.titaniumtown.ArrayConstants.emptyIntArray; // Gale - JettPack - reduce array allocations - } - - public long[] getLongArray(int index) { -@@ -269,7 +269,7 @@ public class ListTag extends CollectionTag { - } - } - -- return new long[0]; -+ return me.titaniumtown.ArrayConstants.emptyLongArray; // Gale - JettPack - reduce array allocations - } - - public double getDouble(int index) { -diff --git a/src/main/java/net/minecraft/nbt/LongArrayTag.java b/src/main/java/net/minecraft/nbt/LongArrayTag.java -index 2e5c34ebb94a1536cf09d71bdf052a49ecb9159d..786d34117c42bef9f65d1009f77749de99cacac8 100644 ---- a/src/main/java/net/minecraft/nbt/LongArrayTag.java -+++ b/src/main/java/net/minecraft/nbt/LongArrayTag.java -@@ -185,7 +185,7 @@ public class LongArrayTag extends CollectionTag { - - @Override - public void clear() { -- this.data = new long[0]; -+ this.data = me.titaniumtown.ArrayConstants.emptyLongArray; // Gale - JettPack - reduce array allocations - } - - @Override -diff --git a/src/main/java/net/minecraft/network/CipherBase.java b/src/main/java/net/minecraft/network/CipherBase.java -index a2920b8a9eff77d9c5d1d7f70ad3abdacba8f0fa..b34ea5d45a69ffcf26275e79006a3d0309d245b4 100644 ---- a/src/main/java/net/minecraft/network/CipherBase.java -+++ b/src/main/java/net/minecraft/network/CipherBase.java -@@ -7,8 +7,8 @@ import javax.crypto.ShortBufferException; - - public class CipherBase { - private final Cipher cipher; -- private byte[] heapIn = new byte[0]; -- private byte[] heapOut = new byte[0]; -+ private byte[] heapIn = me.titaniumtown.ArrayConstants.emptyByteArray; // Gale - JettPack - reduce array allocations -+ private byte[] heapOut = me.titaniumtown.ArrayConstants.emptyByteArray; // Gale - JettPack - reduce array allocations - - protected CipherBase(Cipher cipher) { - this.cipher = cipher; -diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java -index e693a003ea8f022eef8b49e4332025b769333b30..1900da381257a00fc3b96d397e298caf2f8c861f 100644 ---- a/src/main/java/net/minecraft/network/Connection.java -+++ b/src/main/java/net/minecraft/network/Connection.java -@@ -326,7 +326,7 @@ public class Connection extends SimpleChannelInboundHandler> { - } - - private void validateListener(ProtocolInfo state, PacketListener listener) { -- Validate.notNull(listener, "packetListener", new Object[0]); -+ Validate.notNull(listener, "packetListener", me.titaniumtown.ArrayConstants.emptyObjectArray); // Gale - JettPack - reduce array allocations - PacketFlow enumprotocoldirection = listener.flow(); - String s; - -diff --git a/src/main/java/net/minecraft/network/chat/contents/TranslatableContents.java b/src/main/java/net/minecraft/network/chat/contents/TranslatableContents.java -index 4aa6232bf0f72fcde32d257100bd15b1c5192aaa..2d3f002f85721ff25d95f3f2510779268a87e9ca 100644 ---- a/src/main/java/net/minecraft/network/chat/contents/TranslatableContents.java -+++ b/src/main/java/net/minecraft/network/chat/contents/TranslatableContents.java -@@ -29,7 +29,7 @@ import net.minecraft.util.ExtraCodecs; - import net.minecraft.world.entity.Entity; - - public class TranslatableContents implements ComponentContents { -- public static final Object[] NO_ARGS = new Object[0]; -+ public static final Object[] NO_ARGS = me.titaniumtown.ArrayConstants.emptyObjectArray; // Gale - JettPack - reduce array allocations - private static final Codec PRIMITIVE_ARG_CODEC = ExtraCodecs.JAVA.validate(TranslatableContents::filterAllowedArguments); - private static final Codec ARG_CODEC = Codec.either(PRIMITIVE_ARG_CODEC, ComponentSerialization.CODEC) - .xmap( -diff --git a/src/main/java/net/minecraft/server/Main.java b/src/main/java/net/minecraft/server/Main.java -index 90ca25c4aaf92a5639839a7cdaee2ffcdb75efa7..d3219e3d36ef96bb43c2cb7d86f14ef7a702fcac 100644 ---- a/src/main/java/net/minecraft/server/Main.java -+++ b/src/main/java/net/minecraft/server/Main.java -@@ -90,7 +90,7 @@ public class Main { - OptionSpec optionspec6 = optionparser.accepts("recreateRegionFiles"); - OptionSpec optionspec7 = optionparser.accepts("safeMode", "Loads level with vanilla datapack only"); - OptionSpec optionspec8 = optionparser.accepts("help").forHelp(); -- OptionSpec optionspec9 = optionparser.accepts("universe").withRequiredArg().defaultsTo(".", new String[0]); -+ OptionSpec optionspec9 = optionparser.accepts("universe").withRequiredArg().defaultsTo(".", me.titaniumtown.ArrayConstants.emptyStringArray); // Gale - JettPack - reduce array allocations - OptionSpec optionspec10 = optionparser.accepts("world").withRequiredArg(); - OptionSpec optionspec11 = optionparser.accepts("port").withRequiredArg().ofType(Integer.class).defaultsTo(-1, new Integer[0]); - OptionSpec optionspec12 = optionparser.accepts("serverId").withRequiredArg(); -diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index d32524da655a615a13a03c8536c1f229547d0c6b..c36e21be642ad24231cdcd0ff20d22e1e449e18e 100644 ---- a/src/main/java/net/minecraft/server/level/ServerLevel.java -+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java -@@ -1250,7 +1250,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe - - public static List getCurrentlyTickingEntities() { - Entity ticking = currentlyTickingEntity.get(); -- List ret = java.util.Arrays.asList(ticking == null ? new Entity[0] : new Entity[] { ticking }); -+ List ret = java.util.Arrays.asList(ticking == null ? me.titaniumtown.ArrayConstants.emptyEntityArray : new Entity[] { ticking }); // Gale - JettPack - reduce array allocations - - return ret; - } -diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 13482ce226de563cc2e802cdfeaca22eff8f9096..3455b7f21fee42d21182b8b5f8af7a9a238f646c 100644 ---- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -2842,7 +2842,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl - entity.refreshEntityData(ServerGamePacketListenerImpl.this.player); - // SPIGOT-7136 - Allays - if (entity instanceof Allay || entity instanceof net.minecraft.world.entity.animal.horse.AbstractHorse) { // Paper - Fix horse armor desync -- ServerGamePacketListenerImpl.this.send(new ClientboundSetEquipmentPacket(entity.getId(), Arrays.stream(net.minecraft.world.entity.EquipmentSlot.values()).map((slot) -> Pair.of(slot, ((LivingEntity) entity).getItemBySlot(slot).copy())).collect(Collectors.toList()), true)); // Paper - sanitize -+ ServerGamePacketListenerImpl.this.send(new ClientboundSetEquipmentPacket(entity.getId(), Arrays.stream(net.minecraft.world.entity.EquipmentSlot.VALUES_ARRAY).map((slot) -> Pair.of(slot, ((LivingEntity) entity).getItemBySlot(slot).copy())).collect(Collectors.toList()), true)); // Paper - sanitize // Gale - JettPack - reduce array allocations - } - - ServerGamePacketListenerImpl.this.player.containerMenu.sendAllDataToRemote(); // Paper - fix slot desync - always refresh player inventory -diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -index f89eb72f34ff3dcbb04ec0c9e98dfedce203911a..2f494450b5d67f9c6eb6ed6ebb8164257f124274 100644 ---- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -@@ -180,14 +180,16 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, - - @Override - public void handleHello(ServerboundHelloPacket packet) { -- Validate.validState(this.state == ServerLoginPacketListenerImpl.State.HELLO, "Unexpected hello packet", new Object[0]); -+ // Gale start - JettPack - reduce array allocations -+ Validate.validState(this.state == ServerLoginPacketListenerImpl.State.HELLO, "Unexpected hello packet", me.titaniumtown.ArrayConstants.emptyObjectArray); - // Paper start - Validate usernames - if (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode() - && io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.performUsernameValidation - && !this.iKnowThisMayNotBeTheBestIdeaButPleaseDisableUsernameValidation) { -- Validate.validState(StringUtil.isReasonablePlayerName(packet.name()), "Invalid characters in username", new Object[0]); -+ Validate.validState(StringUtil.isReasonablePlayerName(packet.name()), "Invalid characters in username", me.titaniumtown.ArrayConstants.emptyObjectArray); - } - // Paper end - Validate usernames -+ // Gale end - JettPack - reduce array allocations - this.requestedUsername = packet.name(); - GameProfile gameprofile = this.server.getSingleplayerProfile(); - -@@ -283,7 +285,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, - - @Override - public void handleKey(ServerboundKeyPacket packet) { -- Validate.validState(this.state == ServerLoginPacketListenerImpl.State.KEY, "Unexpected key packet", new Object[0]); -+ Validate.validState(this.state == ServerLoginPacketListenerImpl.State.KEY, "Unexpected key packet", me.titaniumtown.ArrayConstants.emptyObjectArray); // Gale - JettPack - reduce array allocations - - final String s; - -@@ -464,7 +466,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, - @Override - public void handleLoginAcknowledgement(ServerboundLoginAcknowledgedPacket packet) { - PacketUtils.ensureRunningOnSameThread(packet, this, this.server); // CraftBukkit -- Validate.validState(this.state == ServerLoginPacketListenerImpl.State.PROTOCOL_SWITCHING, "Unexpected login acknowledgement packet", new Object[0]); -+ Validate.validState(this.state == ServerLoginPacketListenerImpl.State.PROTOCOL_SWITCHING, "Unexpected login acknowledgement packet", me.titaniumtown.ArrayConstants.emptyObjectArray); // Gale - JettPack - reduce array allocations - this.connection.setupOutboundProtocol(ConfigurationProtocols.CLIENTBOUND); - CommonListenerCookie commonlistenercookie = CommonListenerCookie.createInitial((GameProfile) Objects.requireNonNull(this.authenticatedProfile), this.transferred); - ServerConfigurationPacketListenerImpl serverconfigurationpacketlistenerimpl = new ServerConfigurationPacketListenerImpl(this.server, this.connection, commonlistenercookie, this.player); // CraftBukkit -diff --git a/src/main/java/net/minecraft/server/players/StoredUserList.java b/src/main/java/net/minecraft/server/players/StoredUserList.java -index c038da20b76c0b7b1c18471b20be01e849d29f3a..97737da3c2f13e1bd29dc119133c7267f5d10117 100644 ---- a/src/main/java/net/minecraft/server/players/StoredUserList.java -+++ b/src/main/java/net/minecraft/server/players/StoredUserList.java -@@ -76,7 +76,7 @@ public abstract class StoredUserList> { - } - - public String[] getUserList() { -- return (String[]) this.map.keySet().toArray(new String[0]); -+ return (String[]) this.map.keySet().toArray(me.titaniumtown.ArrayConstants.emptyStringArray); // Gale - JettPack - reduce array allocations - } - - public boolean isEmpty() { -diff --git a/src/main/java/net/minecraft/util/ZeroBitStorage.java b/src/main/java/net/minecraft/util/ZeroBitStorage.java -index 1f9c436a632e4f110be61cf76fcfc3b7eb80334e..6c6ac02129dc7499137da33d8b3d3255b7aa03b6 100644 ---- a/src/main/java/net/minecraft/util/ZeroBitStorage.java -+++ b/src/main/java/net/minecraft/util/ZeroBitStorage.java -@@ -5,7 +5,7 @@ import java.util.function.IntConsumer; - import org.apache.commons.lang3.Validate; - - public class ZeroBitStorage implements BitStorage { -- public static final long[] RAW = new long[0]; -+ public static final long[] RAW = me.titaniumtown.ArrayConstants.emptyLongArray; // Gale - JettPack - reduce array allocations - private final int size; - - public ZeroBitStorage(int size) { -diff --git a/src/main/java/net/minecraft/world/entity/EquipmentSlot.java b/src/main/java/net/minecraft/world/entity/EquipmentSlot.java -index 1a3c9a2b572f7caaf21beb3054d0d1b19c3a174b..c9d2f6ea976f873b76c20194b0ec4895b5adced2 100644 ---- a/src/main/java/net/minecraft/world/entity/EquipmentSlot.java -+++ b/src/main/java/net/minecraft/world/entity/EquipmentSlot.java -@@ -19,7 +19,8 @@ public enum EquipmentSlot implements StringRepresentable { - BODY(EquipmentSlot.Type.ANIMAL_ARMOR, 0, 1, 6, "body"); - - public static final int NO_COUNT_LIMIT = 0; -- public static final List VALUES = List.of(values()); -+ public static final EquipmentSlot[] VALUES_ARRAY = values(); // Gale - JettPack - reduce array allocations -+ public static final List VALUES = List.of(VALUES_ARRAY); - public static final IntFunction BY_ID = ByIdMap.continuous(slot -> slot.id, values(), ByIdMap.OutOfBoundsStrategy.ZERO); - public static final StringRepresentable.EnumCodec CODEC = StringRepresentable.fromEnum(EquipmentSlot::values); - public static final StreamCodec STREAM_CODEC = ByteBufCodecs.idMapper(BY_ID, slot -> slot.id); -diff --git a/src/main/java/net/minecraft/world/entity/EquipmentSlotGroup.java b/src/main/java/net/minecraft/world/entity/EquipmentSlotGroup.java -index f5e79db3ccde0730c3b4fb81c76ca6ed045a7374..5546a873fae5252df5fb4bf8781e70db64522dec 100644 ---- a/src/main/java/net/minecraft/world/entity/EquipmentSlotGroup.java -+++ b/src/main/java/net/minecraft/world/entity/EquipmentSlotGroup.java -@@ -27,6 +27,7 @@ public enum EquipmentSlotGroup implements StringRepresentable { - private final int id; - private final String key; - private final Predicate predicate; -+ public static final EquipmentSlotGroup[] VALUES = EquipmentSlotGroup.values(); // Gale - JettPack - reduce array allocations - - private EquipmentSlotGroup(final int id, final String name, final Predicate slotPredicate) { - this.id = id; -diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java -index 33e7d2884195677c4d6340d8b84c1dd85c636ec1..303b3337b23b6528ed431ba8b6c1c1f3187a4503 100644 ---- a/src/main/java/net/minecraft/world/item/ItemStack.java -+++ b/src/main/java/net/minecraft/world/item/ItemStack.java -@@ -1218,7 +1218,7 @@ public final class ItemStack implements DataComponentHolder { - ItemAttributeModifiers itemattributemodifiers = (ItemAttributeModifiers) this.getOrDefault(DataComponents.ATTRIBUTE_MODIFIERS, ItemAttributeModifiers.EMPTY); - - if (itemattributemodifiers.showInTooltip()) { -- EquipmentSlotGroup[] aequipmentslotgroup = EquipmentSlotGroup.values(); -+ EquipmentSlotGroup[] aequipmentslotgroup = EquipmentSlotGroup.VALUES; // Gale - JettPack - reduce array allocations - int i = aequipmentslotgroup.length; - - for (int j = 0; j < i; ++j) { -diff --git a/src/main/java/net/minecraft/world/item/crafting/ShapedRecipePattern.java b/src/main/java/net/minecraft/world/item/crafting/ShapedRecipePattern.java -index 2490a42c9c35c7e080279ef8566288a28362d167..542916b15fd42d8262b24ead91f146cd228063ed 100644 ---- a/src/main/java/net/minecraft/world/item/crafting/ShapedRecipePattern.java -+++ b/src/main/java/net/minecraft/world/item/crafting/ShapedRecipePattern.java -@@ -121,7 +121,7 @@ public final class ShapedRecipePattern { - } - - if (pattern.size() == l) { -- return new String[0]; -+ return me.titaniumtown.ArrayConstants.emptyStringArray; // Gale - JettPack - reduce array allocations - } else { - String[] strings = new String[pattern.size() - l - k]; - -diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index f019e1eb20a8ec3a57e5d90386cb10244ddfcb66..dd4d40a14cef268fe992f2c5ba523748fb619bd9 100644 ---- a/src/main/java/net/minecraft/world/level/Level.java -+++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -1748,7 +1748,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl - public org.bukkit.entity.Entity[] getChunkEntities(int chunkX, int chunkZ) { - ca.spottedleaf.moonrise.patches.chunk_system.level.entity.ChunkEntitySlices slices = ((ServerLevel)this).moonrise$getEntityLookup().getChunk(chunkX, chunkZ); - if (slices == null) { -- return new org.bukkit.entity.Entity[0]; -+ return me.titaniumtown.ArrayConstants.emptyBukkitEntityArray; // Gale - JettPack - reduce array allocations - } - - List ret = new java.util.ArrayList<>(); -@@ -1759,7 +1759,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl - } - } - -- return ret.toArray(new org.bukkit.entity.Entity[0]); -+ return ret.toArray(me.titaniumtown.ArrayConstants.emptyBukkitEntityArray); // Gale - JettPack - reduce array allocations - } - // Paper end - rewrite chunk system - -diff --git a/src/main/java/net/minecraft/world/level/block/ComposterBlock.java b/src/main/java/net/minecraft/world/level/block/ComposterBlock.java -index db837b250fc35af5b528bf973b3b07f63e79bc46..ceab17cdf519278393e41311488e6d7f99133ebe 100644 ---- a/src/main/java/net/minecraft/world/level/block/ComposterBlock.java -+++ b/src/main/java/net/minecraft/world/level/block/ComposterBlock.java -@@ -434,7 +434,7 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder { - - @Override - public int[] getSlotsForFace(Direction side) { -- return side == Direction.DOWN ? new int[]{0} : new int[0]; -+ return side == Direction.DOWN ? me.titaniumtown.ArrayConstants.zeroSingletonIntArray : me.titaniumtown.ArrayConstants.emptyIntArray; // Gale - JettPack - reduce array allocations - } - - @Override -@@ -483,7 +483,7 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder { - - @Override - public int[] getSlotsForFace(Direction side) { -- return side == Direction.UP ? new int[]{0} : new int[0]; -+ return side == Direction.UP ? me.titaniumtown.ArrayConstants.zeroSingletonIntArray : me.titaniumtown.ArrayConstants.emptyIntArray; // Gale - JettPack - reduce array allocations - } - - @Override -@@ -525,7 +525,7 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder { - - @Override - public int[] getSlotsForFace(Direction side) { -- return new int[0]; -+ return me.titaniumtown.ArrayConstants.emptyIntArray; // Gale - JettPack - reduce array allocations - } - - @Override -diff --git a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java -index 15e0861486a2bda3e2f4049b1b5a299c870acd31..43899f544cc22666f9ca496128650ce7751ec913 100644 ---- a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java -+++ b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java -@@ -61,7 +61,7 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit - protected static final int SLOT_FUEL = 1; - protected static final int SLOT_RESULT = 2; - public static final int DATA_LIT_TIME = 0; -- private static final int[] SLOTS_FOR_UP = new int[]{0}; -+ private static final int[] SLOTS_FOR_UP = me.titaniumtown.ArrayConstants.zeroSingletonIntArray; // Gale - JettPack - reduce array allocations - private static final int[] SLOTS_FOR_DOWN = new int[]{2, 1}; - private static final int[] SLOTS_FOR_SIDES = new int[]{1}; - public static final int DATA_LIT_DURATION = 1; -diff --git a/src/main/java/net/minecraft/world/scores/Team.java b/src/main/java/net/minecraft/world/scores/Team.java -index b968d22e149bf9063f14167fe9856868e5933303..98ef0631fd7843182589f55bb00f2cf1512bfa90 100644 ---- a/src/main/java/net/minecraft/world/scores/Team.java -+++ b/src/main/java/net/minecraft/world/scores/Team.java -@@ -70,7 +70,7 @@ public abstract class Team { - public final int id; - - public static String[] getAllNames() { -- return BY_NAME.keySet().toArray(new String[0]); -+ return BY_NAME.keySet().toArray(me.titaniumtown.ArrayConstants.emptyStringArray); // Gale - JettPack - reduce array allocations - } - - @Nullable -diff --git a/src/main/java/org/bukkit/craftbukkit/CraftEquipmentSlot.java b/src/main/java/org/bukkit/craftbukkit/CraftEquipmentSlot.java -index ae86c45c1d49c7646c721991910592091e7333f8..1368191d6f76d1b4246b1bae7d5afdda44050965 100644 ---- a/src/main/java/org/bukkit/craftbukkit/CraftEquipmentSlot.java -+++ b/src/main/java/org/bukkit/craftbukkit/CraftEquipmentSlot.java -@@ -7,8 +7,10 @@ import org.bukkit.inventory.EquipmentSlot; - - public class CraftEquipmentSlot { - -- private static final net.minecraft.world.entity.EquipmentSlot[] slots = new net.minecraft.world.entity.EquipmentSlot[EquipmentSlot.values().length]; -- private static final EquipmentSlot[] enums = new EquipmentSlot[net.minecraft.world.entity.EquipmentSlot.values().length]; -+ // Gale start - JettPack - reduce array allocations -+ private static final net.minecraft.world.entity.EquipmentSlot[] slots = net.minecraft.world.entity.EquipmentSlot.VALUES_ARRAY; -+ private static final EquipmentSlot[] enums = new EquipmentSlot[net.minecraft.world.entity.EquipmentSlot.VALUES.size()]; -+ // Gale end - JettPack - reduce array allocations - - static { - set(EquipmentSlot.HAND, net.minecraft.world.entity.EquipmentSlot.MAINHAND); -diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftEntityEquipment.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftEntityEquipment.java -index fdcc414f4fa246082ad0732133c870d915ae3084..33ed515d6e79c4135f3e7bbc25fd0e3d83d08540 100644 ---- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftEntityEquipment.java -+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftEntityEquipment.java -@@ -165,7 +165,7 @@ public class CraftEntityEquipment implements EntityEquipment { - - @Override - public void clear() { -- for (net.minecraft.world.entity.EquipmentSlot slot : net.minecraft.world.entity.EquipmentSlot.values()) { -+ for (net.minecraft.world.entity.EquipmentSlot slot : net.minecraft.world.entity.EquipmentSlot.VALUES) { // Gale - JettPack - reduce array allocations - this.setEquipment(slot, null, false); - } - } -diff --git a/src/main/java/org/bukkit/craftbukkit/util/WeakCollection.java b/src/main/java/org/bukkit/craftbukkit/util/WeakCollection.java -index b25dc23b81687dd4d4e70b3615ffb91f8c03c68b..59ff2801592c98e7471404c70dbbdf3db1b7716b 100644 ---- a/src/main/java/org/bukkit/craftbukkit/util/WeakCollection.java -+++ b/src/main/java/org/bukkit/craftbukkit/util/WeakCollection.java -@@ -164,7 +164,7 @@ public final class WeakCollection implements Collection { - - @Override - public Object[] toArray() { -- return this.toArray(new Object[0]); -+ return this.toArray(me.titaniumtown.ArrayConstants.emptyObjectArray); // Gale - JettPack - reduce array allocations - } - - @Override -diff --git a/src/main/java/org/galemc/gale/command/GaleCommand.java b/src/main/java/org/galemc/gale/command/GaleCommand.java -index 87d3aed35341dfa9358af064dd54d7de95078269..925ccf36ee6a2ddd46b0bb604f1f7ed848d371fb 100644 ---- a/src/main/java/org/galemc/gale/command/GaleCommand.java -+++ b/src/main/java/org/galemc/gale/command/GaleCommand.java -@@ -140,7 +140,7 @@ public final class GaleCommand extends Command { - - // If they did not give a subcommand - if (args.length == 0) { -- INFO_SUBCOMMAND.execute(sender, InfoCommand.LITERAL_ARGUMENT, new String[0]); -+ INFO_SUBCOMMAND.execute(sender, InfoCommand.LITERAL_ARGUMENT, me.titaniumtown.ArrayConstants.emptyStringArray); // Gale - JettPack - reduce array allocations - sender.sendMessage(newline().append(text("Command usage: " + specificUsageMessage, GRAY))); - return false; - } -diff --git a/src/main/java/org/galemc/gale/command/subcommands/VersionCommand.java b/src/main/java/org/galemc/gale/command/subcommands/VersionCommand.java -index 675cd4295dabfade1b9cc5473010b5b20dc32039..ac6c098d876c6ded3434d56c32cb314f306d7f65 100644 ---- a/src/main/java/org/galemc/gale/command/subcommands/VersionCommand.java -+++ b/src/main/java/org/galemc/gale/command/subcommands/VersionCommand.java -@@ -26,7 +26,7 @@ public final class VersionCommand extends PermissionedGaleSubcommand { - public boolean execute(final CommandSender sender, final String subCommand, final String[] args) { - final @Nullable Command ver = MinecraftServer.getServer().server.getCommandMap().getCommand("version"); - if (ver != null) { -- ver.execute(sender, GaleCommand.COMMAND_LABEL, new String[0]); -+ ver.execute(sender, GaleCommand.COMMAND_LABEL, me.titaniumtown.ArrayConstants.emptyStringArray); // Gale - JettPack - reduce array allocations - } - return true; - } diff --git a/patches/server/0068-Replace-throttle-tracker-map-with-optimized-collecti.patch b/patches/server/0068-Replace-throttle-tracker-map-with-optimized-collecti.patch deleted file mode 100644 index 9f8231b..0000000 --- a/patches/server/0068-Replace-throttle-tracker-map-with-optimized-collecti.patch +++ /dev/null @@ -1,71 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Martijn Muijsers -Date: Fri, 23 Dec 2022 22:22:47 +0100 -Subject: [PATCH] Replace throttle tracker map with optimized collection - -License: MIT (https://opensource.org/licenses/MIT) -Gale - https://galemc.org - -This patch is based on the following patch: -"Use more fastutil data structures" -By: nopjmp -As part of: Dionysus (https://github.com/nopjmp/Dionysus) -Licensed under: MIT (https://opensource.org/licenses/MIT) - -* Dionysus description * - -Use them in more places. - -* Dionysus copyright * - -Copyright 2021 Kayla Thompson - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -documentation files (the "Software"), to deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit -persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR -IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -diff --git a/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java -index ddf42645402afefc0f5caebc684b191eef9d6ec2..a1e39d4476e932da3d4e0c363ce22eb5be2b8e6c 100644 ---- a/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java -+++ b/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java -@@ -26,7 +26,7 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL - static final java.util.regex.Pattern PROP_PATTERN = java.util.regex.Pattern.compile("\\w{0,16}"); - // Spigot end - // CraftBukkit start - add fields -- private static final HashMap throttleTracker = new HashMap(); -+ private static final it.unimi.dsi.fastutil.objects.Object2LongMap throttleTracker = new it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap<>(); // Gale - Dionysus - replace throttle tracker map with optimized collection - private static int throttleCounter = 0; - // CraftBukkit end - private static final Component IGNORE_STATUS_REASON = Component.translatable("disconnect.ignoring_status_request"); -@@ -87,7 +87,7 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL - InetAddress address = ((java.net.InetSocketAddress) this.connection.getRemoteAddress()).getAddress(); - - synchronized (ServerHandshakePacketListenerImpl.throttleTracker) { -- if (ServerHandshakePacketListenerImpl.throttleTracker.containsKey(address) && !"127.0.0.1".equals(address.getHostAddress()) && currentTime - ServerHandshakePacketListenerImpl.throttleTracker.get(address) < connectionThrottle) { -+ if (ServerHandshakePacketListenerImpl.throttleTracker.containsKey(address) && !"127.0.0.1".equals(address.getHostAddress()) && currentTime - ServerHandshakePacketListenerImpl.throttleTracker.getLong(address) < connectionThrottle) { // Gale - Dionysus - replace throttle tracker map with optimized collection - ServerHandshakePacketListenerImpl.throttleTracker.put(address, currentTime); - Component chatmessage = io.papermc.paper.adventure.PaperAdventure.asVanilla(io.papermc.paper.configuration.GlobalConfiguration.get().messages.kick.connectionThrottle); // Paper - Configurable connection throttle kick message - this.connection.send(new ClientboundLoginDisconnectPacket(chatmessage)); -@@ -101,13 +101,7 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL - ServerHandshakePacketListenerImpl.throttleCounter = 0; - - // Cleanup stale entries -- java.util.Iterator iter = ServerHandshakePacketListenerImpl.throttleTracker.entrySet().iterator(); -- while (iter.hasNext()) { -- java.util.Map.Entry entry = (java.util.Map.Entry) iter.next(); -- if (entry.getValue() > connectionThrottle) { -- iter.remove(); -- } -- } -+ throttleTracker.object2LongEntrySet().removeIf(entry -> entry.getLongValue() > connectionThrottle); // Gale - Dionysus - replace throttle tracker map with optimized collection - } - } - } // Paper - Unix domain socket support diff --git a/patches/server/0072-Replace-division-by-multiplication-in-CubePointRange.patch b/patches/server/0072-Replace-division-by-multiplication-in-CubePointRange.patch deleted file mode 100644 index a632e69..0000000 --- a/patches/server/0072-Replace-division-by-multiplication-in-CubePointRange.patch +++ /dev/null @@ -1,39 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Martijn Muijsers -Date: Wed, 30 Nov 2022 17:24:24 +0100 -Subject: [PATCH] Replace division by multiplication in CubePointRange - -License: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html) -Gale - https://galemc.org - -This patch is based on the following mixin: -"net/caffeinemc/mods/lithium/mixin/shapes/precompute_shape_arrays/FractionalDoubleListMixin.java" -By: 2No2Name <2No2Name@web.de> -As part of: Lithium (https://github.com/CaffeineMC/lithium-fabric) -Licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html) - -diff --git a/src/main/java/net/minecraft/world/phys/shapes/CubePointRange.java b/src/main/java/net/minecraft/world/phys/shapes/CubePointRange.java -index ad02cdb00360165f6405eb3044bd8320f01a7ef1..0b6f3fca7e7b8f2f7cfa0c8f01068f234888f66d 100644 ---- a/src/main/java/net/minecraft/world/phys/shapes/CubePointRange.java -+++ b/src/main/java/net/minecraft/world/phys/shapes/CubePointRange.java -@@ -4,6 +4,7 @@ import it.unimi.dsi.fastutil.doubles.AbstractDoubleList; - - public class CubePointRange extends AbstractDoubleList { - private final int parts; -+ private final double scale; // Gale - Lithium - replace division by multiplication in CubePointRange - - public CubePointRange(int sectionCount) { - if (sectionCount <= 0) { -@@ -11,10 +12,11 @@ public class CubePointRange extends AbstractDoubleList { - } else { - this.parts = sectionCount; - } -+ this.scale = 1.0D / sectionCount; // Gale - Lithium - replace division by multiplication in CubePointRange - } - - public double getDouble(int i) { -- return (double)i / (double)this.parts; -+ return i * this.scale; // Gale - Lithium - replace division by multiplication in CubePointRange - } - - public int size() { diff --git a/patches/server/0074-Check-frozen-ticks-before-landing-block.patch b/patches/server/0074-Check-frozen-ticks-before-landing-block.patch deleted file mode 100644 index e42ffab..0000000 --- a/patches/server/0074-Check-frozen-ticks-before-landing-block.patch +++ /dev/null @@ -1,39 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Martijn Muijsers -Date: Wed, 30 Nov 2022 20:17:41 +0100 -Subject: [PATCH] Check frozen ticks before landing block - -License: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html) -Gale - https://galemc.org - -This patch is based on the following mixin: -"net/caffeinemc/mods/lithium/mixin/entity/fast_powder_snow_check/LivingEntityMixin.java" -By: 2No2Name <2No2Name@web.de> -As part of: Lithium (https://github.com/CaffeineMC/lithium-fabric) -Licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html) - -diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index 948e8a66ebe77093983bb0a552f10fa2b4d70882..887adb618a6eb158b53a96e57d785583a3ac322f 100644 ---- a/src/main/java/net/minecraft/world/entity/LivingEntity.java -+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -579,11 +579,10 @@ public abstract class LivingEntity extends Entity implements Attackable { - } - - protected void tryAddFrost() { -- if (!this.getBlockStateOnLegacy().isAir()) { - int i = this.getTicksFrozen(); - - if (i > 0) { -- AttributeInstance attributemodifiable = this.getAttribute(Attributes.MOVEMENT_SPEED); -+ AttributeInstance attributemodifiable = this.getBlockStateOnLegacy().isAir() ? null : this.getAttribute(Attributes.MOVEMENT_SPEED); // Gale - Lithium - check frozen ticks before landing block - - if (attributemodifiable == null) { - return; -@@ -593,7 +592,6 @@ public abstract class LivingEntity extends Entity implements Attackable { - - attributemodifiable.addTransientModifier(new AttributeModifier(LivingEntity.SPEED_MODIFIER_POWDER_SNOW_ID, (double) f, AttributeModifier.Operation.ADD_VALUE)); - } -- } - - } - diff --git a/patches/server/0075-Faster-chunk-serialization.patch b/patches/server/0075-Faster-chunk-serialization.patch deleted file mode 100644 index 4ac67c8..0000000 --- a/patches/server/0075-Faster-chunk-serialization.patch +++ /dev/null @@ -1,444 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Martijn Muijsers -Date: Wed, 30 Nov 2022 21:51:16 +0100 -Subject: [PATCH] Faster chunk serialization - -License: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html) -Gale - https://galemc.org - -This patch is based on the following mixins and classes: -* "net/caffeinemc/mods/lithium/common/world/chunk/CompactingPackedIntegerArray.java" -* "net/caffeinemc/mods/lithium/common/world/chunk/LithiumHashPalette.java" -* "net/caffeinemc/mods/lithium/mixin/chunk/serialization/PackedIntegerArrayMixin.java" -* "net/caffeinemc/mods/lithium/mixin/chunk/serialization/PalettedContainerMixin.java" -By: Angeline -As part of: Lithium (https://github.com/CaffeineMC/lithium-fabric) -Licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html) - -diff --git a/src/main/java/net/caffeinemc/mods/lithium/common/world/chunk/LithiumHashPalette.java b/src/main/java/net/caffeinemc/mods/lithium/common/world/chunk/LithiumHashPalette.java -new file mode 100644 -index 0000000000000000000000000000000000000000..19eaa1aef1630885d6d5698838664697bd27cd62 ---- /dev/null -+++ b/src/main/java/net/caffeinemc/mods/lithium/common/world/chunk/LithiumHashPalette.java -@@ -0,0 +1,199 @@ -+// Gale - Lithium - faster chunk serialization -+ -+package net.caffeinemc.mods.lithium.common.world.chunk; -+ -+import com.google.common.collect.ImmutableList; -+import it.unimi.dsi.fastutil.HashCommon; -+import it.unimi.dsi.fastutil.objects.Reference2IntMap; -+import it.unimi.dsi.fastutil.objects.Reference2IntOpenHashMap; -+import java.util.Arrays; -+import java.util.List; -+import java.util.function.Predicate; -+import net.minecraft.core.IdMap; -+import net.minecraft.network.FriendlyByteBuf; -+import net.minecraft.network.VarInt; -+import net.minecraft.world.level.chunk.MissingPaletteEntryException; -+import net.minecraft.world.level.chunk.Palette; -+import net.minecraft.world.level.chunk.PaletteResize; -+ -+import static it.unimi.dsi.fastutil.Hash.FAST_LOAD_FACTOR; -+ -+/** -+ * Generally provides better performance over the vanilla {@link net.minecraft.world.level.chunk.HashMapPalette} when calling -+ * {@link LithiumHashPalette#idFor(Object)} through using a faster backing map and reducing pointer chasing. -+ */ -+public class LithiumHashPalette implements Palette { -+ private static final int ABSENT_VALUE = -1; -+ -+ private final IdMap idList; -+ private final PaletteResize resizeHandler; -+ private final int indexBits; -+ -+ private final Reference2IntMap table; -+ private T[] entries; -+ private int size = 0; -+ -+ public LithiumHashPalette(IdMap idList, PaletteResize resizeHandler, int indexBits, T[] entries, Reference2IntMap table, int size) { -+ this.idList = idList; -+ this.resizeHandler = resizeHandler; -+ this.indexBits = indexBits; -+ this.entries = entries; -+ this.table = table; -+ this.size = size; -+ } -+ -+ public LithiumHashPalette(IdMap idList, int bits, PaletteResize resizeHandler, List list) { -+ this(idList, bits, resizeHandler); -+ -+ for (T t : list) { -+ this.addEntry(t); -+ } -+ } -+ -+ @SuppressWarnings("unchecked") -+ public LithiumHashPalette(IdMap idList, int bits, PaletteResize resizeHandler) { -+ this.idList = idList; -+ this.indexBits = bits; -+ this.resizeHandler = resizeHandler; -+ -+ int capacity = 1 << bits; -+ -+ this.entries = (T[]) new Object[capacity]; -+ this.table = new Reference2IntOpenHashMap<>(capacity, FAST_LOAD_FACTOR); -+ this.table.defaultReturnValue(ABSENT_VALUE); -+ } -+ -+ @Override -+ public int idFor(T obj) { -+ int id = this.table.getInt(obj); -+ -+ if (id == ABSENT_VALUE) { -+ id = this.computeEntry(obj); -+ } -+ -+ return id; -+ } -+ -+ @Override -+ public boolean maybeHas(Predicate predicate) { -+ for (int i = 0; i < this.size; ++i) { -+ if (predicate.test(this.entries[i])) { -+ return true; -+ } -+ } -+ -+ return false; -+ } -+ -+ private int computeEntry(T obj) { -+ int id = this.addEntry(obj); -+ -+ if (id >= 1 << this.indexBits) { -+ if (this.resizeHandler == null) { -+ throw new IllegalStateException("Cannot grow"); -+ } else { -+ id = this.resizeHandler.onResize(this.indexBits + 1, obj); -+ } -+ } -+ -+ return id; -+ } -+ -+ private int addEntry(T obj) { -+ int nextId = this.size; -+ -+ if (nextId >= this.entries.length) { -+ this.resize(this.size); -+ } -+ -+ this.table.put(obj, nextId); -+ this.entries[nextId] = obj; -+ -+ this.size++; -+ -+ return nextId; -+ } -+ -+ private void resize(int neededCapacity) { -+ this.entries = Arrays.copyOf(this.entries, HashCommon.nextPowerOfTwo(neededCapacity + 1)); -+ } -+ -+ @Override -+ public T valueFor(int id) { -+ T[] entries = this.entries; -+ -+ T entry = null; -+ if (id >= 0 && id < entries.length) { -+ entry = entries[id]; -+ } -+ -+ // Null check and throw, to be same as vanilla -+ if (entry != null) { -+ return entry; -+ } else { -+ throw new MissingPaletteEntryException(id); -+ } -+ } -+ -+ @Override -+ public void read(FriendlyByteBuf buf) { -+ this.clear(); -+ -+ int entryCount = buf.readVarInt(); -+ -+ for (int i = 0; i < entryCount; ++i) { -+ this.addEntry(this.idList.byId(buf.readVarInt())); -+ } -+ } -+ -+ @Override -+ public void write(FriendlyByteBuf buf) { -+ int size = this.size; -+ buf.writeVarInt(size); -+ -+ for (int i = 0; i < size; ++i) { -+ buf.writeVarInt(this.idList.getId(this.valueFor(i))); -+ } -+ } -+ -+ @Override -+ public int getSerializedSize() { -+ int size = VarInt.getByteSize(this.size); -+ -+ for (int i = 0; i < this.size; ++i) { -+ size += VarInt.getByteSize(this.idList.getId(this.valueFor(i))); -+ } -+ -+ return size; -+ } -+ -+ @Override -+ public int getSize() { -+ return this.size; -+ } -+ -+ @Override -+ public Palette copy(PaletteResize resizeHandler) { -+ return new LithiumHashPalette<>(this.idList, resizeHandler, this.indexBits, this.entries.clone(), new Reference2IntOpenHashMap<>(this.table), this.size); -+ } -+ -+ private void clear() { -+ Arrays.fill(this.entries, null); -+ this.table.clear(); -+ this.size = 0; -+ } -+ -+ public List getElements() { -+ ImmutableList.Builder builder = new ImmutableList.Builder<>(); -+ for (T entry : this.entries) { -+ if (entry != null) { -+ builder.add(entry); -+ } -+ } -+ return builder.build(); -+ } -+ -+ public static Palette create(int bits, IdMap idList, PaletteResize listener, List list) { -+ return new LithiumHashPalette<>(idList, bits, listener, list); -+ } -+} -diff --git a/src/main/java/net/minecraft/util/BitStorage.java b/src/main/java/net/minecraft/util/BitStorage.java -index e4e153cb8899e70273aa150b8ea26907cf68b15c..ddb0d2f47e2a598431802bf21259715fd845f453 100644 ---- a/src/main/java/net/minecraft/util/BitStorage.java -+++ b/src/main/java/net/minecraft/util/BitStorage.java -@@ -38,4 +38,6 @@ public interface BitStorage extends ca.spottedleaf.moonrise.patches.block_counti - return ret; - } - // Paper end - block counting -+ -+ void compact(net.minecraft.world.level.chunk.Palette srcPalette, net.minecraft.world.level.chunk.Palette dstPalette, short[] out); // Gale - Lithium - faster chunk serialization - } -diff --git a/src/main/java/net/minecraft/util/SimpleBitStorage.java b/src/main/java/net/minecraft/util/SimpleBitStorage.java -index d99ec470b4653beab630999a5b2c1a6428b20c38..f8640b8cce9018d877ec69bbba241d5d9e89b8d8 100644 ---- a/src/main/java/net/minecraft/util/SimpleBitStorage.java -+++ b/src/main/java/net/minecraft/util/SimpleBitStorage.java -@@ -472,4 +472,45 @@ public class SimpleBitStorage implements BitStorage { - super(message); - } - } -+ -+ // Gale start - Lithium - faster chunk serialization -+ @Override -+ public void compact(net.minecraft.world.level.chunk.Palette srcPalette, net.minecraft.world.level.chunk.Palette dstPalette, short[] out) { -+ if (this.size >= Short.MAX_VALUE) { -+ throw new IllegalStateException("Array too large"); -+ } -+ -+ if (this.size != out.length) { -+ throw new IllegalStateException("Array size mismatch"); -+ } -+ -+ short[] mappings = new short[(int) (this.mask + 1)]; -+ -+ int idx = 0; -+ -+ for (long word : this.data) { -+ long bits = word; -+ -+ for (int elementIdx = 0; elementIdx < this.valuesPerLong; ++elementIdx) { -+ int value = (int) (bits & this.mask); -+ int remappedId = mappings[value]; -+ -+ if (remappedId == 0) { -+ remappedId = dstPalette.idFor(srcPalette.valueFor(value)) + 1; -+ mappings[value] = (short) remappedId; -+ } -+ -+ out[idx] = (short) (remappedId - 1); -+ bits >>= this.bits; -+ -+ ++idx; -+ -+ if (idx >= this.size) { -+ return; -+ } -+ } -+ } -+ } -+ // Gale end - Lithium - faster chunk serialization -+ - } -diff --git a/src/main/java/net/minecraft/util/ZeroBitStorage.java b/src/main/java/net/minecraft/util/ZeroBitStorage.java -index 6c6ac02129dc7499137da33d8b3d3255b7aa03b6..c5b13e2f49b046664b8586e38ff632ad6adfbef1 100644 ---- a/src/main/java/net/minecraft/util/ZeroBitStorage.java -+++ b/src/main/java/net/minecraft/util/ZeroBitStorage.java -@@ -80,4 +80,6 @@ public class ZeroBitStorage implements BitStorage { - return ret; - } - // Paper end - block counting -+ -+ @Override public void compact(net.minecraft.world.level.chunk.Palette srcPalette, net.minecraft.world.level.chunk.Palette dstPalette, short[] out) {} // Gale - Lithium - faster chunk serialization - } -diff --git a/src/main/java/net/minecraft/world/level/chunk/PaletteResize.java b/src/main/java/net/minecraft/world/level/chunk/PaletteResize.java -index acae3eb30e0689048937f479dc3070f0688abdad..4b79f0474a9013dd4fdb68c6363ca1942ba8b007 100644 ---- a/src/main/java/net/minecraft/world/level/chunk/PaletteResize.java -+++ b/src/main/java/net/minecraft/world/level/chunk/PaletteResize.java -@@ -1,5 +1,5 @@ - package net.minecraft.world.level.chunk; - --interface PaletteResize { -+public interface PaletteResize { // Gale - Lithium - faster chunk serialization - package -> public - int onResize(int newBits, T object); - } -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 8b84bf2272556ac3321cbf16361d7f48a1cc6873..5dfce8eb4d5a3cc6e8564d648e1cd86bfc7feeee 100644 ---- a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java -+++ b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java -@@ -25,6 +25,22 @@ import net.minecraft.util.ThreadingDetector; - import net.minecraft.util.ZeroBitStorage; - - public class PalettedContainer implements PaletteResize, PalettedContainerRO { -+ -+ // Gale start - Lithium - faster chunk serialization -+ private static final ThreadLocal CACHED_ARRAY_4096 = ThreadLocal.withInitial(() -> new short[4096]); -+ private static final ThreadLocal CACHED_ARRAY_64 = ThreadLocal.withInitial(() -> new short[64]); -+ private Optional asOptional(long[] data) { -+ return Optional.of(Arrays.stream(data)); -+ } -+ private short[] getOrCreate(int size) { -+ return switch (size) { -+ case 64 -> CACHED_ARRAY_64.get(); -+ case 4096 -> CACHED_ARRAY_4096.get(); -+ default -> new short[size]; -+ }; -+ } -+ // Gale end - Lithium - faster chunk serialization -+ - private static final int MIN_PALETTE_BITS = 0; - private final PaletteResize dummyPaletteResize = (newSize, added) -> 0; - public final IdMap registry; -@@ -348,28 +364,54 @@ public class PalettedContainer implements PaletteResize, PalettedContainer - public synchronized PalettedContainerRO.PackedData pack(IdMap idList, PalettedContainer.Strategy paletteProvider) { // Paper - synchronize - this.acquire(); - -- PalettedContainerRO.PackedData var12; -+ // Gale start - Lithium - faster chunk serialization -+ Optional data = Optional.empty(); -+ List elements = null; - try { -- HashMapPalette hashMapPalette = new HashMapPalette<>(idList, this.data.storage.getBits(), this.dummyPaletteResize); -- int i = paletteProvider.size(); -- int[] is = new int[i]; -- this.data.storage.unpack(is); -- swapPalette(is, id -> hashMapPalette.idFor(this.data.palette.valueFor(id))); -- int j = paletteProvider.calculateBitsForSerialization(idList, hashMapPalette.getSize()); -- Optional optional; -- if (j != 0) { -- SimpleBitStorage simpleBitStorage = new SimpleBitStorage(j, i, is); -- optional = Optional.of(Arrays.stream(simpleBitStorage.getRaw())); -- } else { -- optional = Optional.empty(); -+ // The palette that will be serialized -+ net.caffeinemc.mods.lithium.common.world.chunk.LithiumHashPalette hashPalette = null; -+ -+ final Palette palette = this.data.palette(); -+ final BitStorage storage = this.data.storage(); -+ if (storage instanceof ZeroBitStorage || palette.getSize() == 1) { -+ // If the palette only contains one entry, don't attempt to repack it. -+ elements = List.of(palette.valueFor(0)); -+ } else if (palette instanceof net.caffeinemc.mods.lithium.common.world.chunk.LithiumHashPalette lithiumHashPalette) { -+ hashPalette = lithiumHashPalette; - } - -- var12 = new PalettedContainerRO.PackedData<>(hashMapPalette.getEntries(), optional); -+ if (elements == null) { -+ net.caffeinemc.mods.lithium.common.world.chunk.LithiumHashPalette compactedPalette = new net.caffeinemc.mods.lithium.common.world.chunk.LithiumHashPalette<>(idList, storage.getBits(), this.dummyPaletteResize); -+ short[] array = this.getOrCreate(paletteProvider.size()); -+ -+ storage.compact(this.data.palette(), compactedPalette, array); -+ -+ // If the palette didn't change during compaction, do a simple copy of the data array -+ if (hashPalette != null && hashPalette.getSize() == compactedPalette.getSize() && storage.getBits() == paletteProvider.calculateBitsForSerialization(idList, hashPalette.getSize())) { // paletteSize can de-sync from palette - see https://github.com/CaffeineMC/lithium-fabric/issues/279 -+ data = this.asOptional(storage.getRaw().clone()); -+ elements = hashPalette.getElements(); -+ } else { -+ int bits = paletteProvider.calculateBitsForSerialization(idList, compactedPalette.getSize()); -+ if (bits != 0) { -+ // Re-pack the integer array as the palette has changed size -+ SimpleBitStorage copy = new SimpleBitStorage(bits, array.length); -+ for (int i = 0; i < array.length; ++i) { -+ copy.set(i, array[i]); -+ } -+ -+ // We don't need to clone the data array as we are the sole owner of it -+ data = this.asOptional(copy.getRaw()); -+ } -+ -+ elements = compactedPalette.getElements(); -+ } -+ } - } finally { - this.release(); - } - -- return var12; -+ return new PalettedContainerRO.PackedData<>(elements, data); -+ // Gale end - Lithium - faster chunk serialization - } - - private static void swapPalette(int[] is, IntUnaryOperator applier) { -@@ -409,13 +451,35 @@ public class PalettedContainer implements PaletteResize, PalettedContainer - - @Override - public void count(PalettedContainer.CountConsumer counter) { -- if (this.data.palette.getSize() == 1) { -- counter.accept(this.data.palette.valueFor(0), this.data.storage.getSize()); -- } else { -- Int2IntOpenHashMap int2IntOpenHashMap = new Int2IntOpenHashMap(); -- this.data.storage.getAll(key -> int2IntOpenHashMap.addTo(key, 1)); -- int2IntOpenHashMap.int2IntEntrySet().forEach(entry -> counter.accept(this.data.palette.valueFor(entry.getIntKey()), entry.getIntValue())); -+ // Gale start - Lithium - faster chunk serialization -+ int len = this.data.palette().getSize(); -+ -+ // Do not allocate huge arrays if we're using a large palette -+ if (len > 4096) { -+ // VanillaCopy -+ if (this.data.palette.getSize() == 1) { -+ counter.accept(this.data.palette.valueFor(0), this.data.storage.getSize()); -+ } else { -+ Int2IntOpenHashMap int2IntOpenHashMap = new Int2IntOpenHashMap(); -+ this.data.storage.getAll((key) -> { -+ int2IntOpenHashMap.addTo(key, 1); -+ }); -+ int2IntOpenHashMap.int2IntEntrySet().forEach((entry) -> counter.accept(this.data.palette.valueFor(entry.getIntKey()), entry.getIntValue())); -+ } -+ } -+ -+ short[] counts = new short[len]; -+ -+ this.data.storage().getAll(i -> counts[i]++); -+ -+ for (int i = 0; i < counts.length; i++) { -+ T obj = this.data.palette().valueFor(i); -+ -+ if (obj != null) { -+ counter.accept(obj, counts[i]); -+ } - } -+ // Gale end - Lithium - faster chunk serialization - } - - static record Configuration(Palette.Factory factory, int bits) { diff --git a/patches/server/0080-Store-mob-counts-in-an-array.patch b/patches/server/0080-Store-mob-counts-in-an-array.patch deleted file mode 100644 index fb3ca29..0000000 --- a/patches/server/0080-Store-mob-counts-in-an-array.patch +++ /dev/null @@ -1,36 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Martijn Muijsers -Date: Wed, 30 Nov 2022 17:46:23 +0100 -Subject: [PATCH] Store mob counts in an array - -License: MIT (https://opensource.org/licenses/MIT) -Gale - https://galemc.org - -This patch is based on the following mixin: -"com/ishland/vmp/mixins/general/spawn_density_cap/MixinSpawnDensityCapperDensityCap.java" -By: ishland -As part of: VMP (https://github.com/RelativityMC/VMP-fabric) -Licensed under: MIT (https://opensource.org/licenses/MIT) - -diff --git a/src/main/java/net/minecraft/world/level/LocalMobCapCalculator.java b/src/main/java/net/minecraft/world/level/LocalMobCapCalculator.java -index 2039b16e5e9bc0797b3f31081d221bb8b34a4dc7..ceab64ea37f69c254680a8bdd6d2a596d94cb7dc 100644 ---- a/src/main/java/net/minecraft/world/level/LocalMobCapCalculator.java -+++ b/src/main/java/net/minecraft/world/level/LocalMobCapCalculator.java -@@ -42,14 +42,14 @@ public class LocalMobCapCalculator { - } - - static class MobCounts { -- private final Object2IntMap counts = new Object2IntOpenHashMap<>(MobCategory.values().length); -+ public final int[] counts = new int[MobCategory.values().length]; // Gale - VMP - store mob counts in an array - - public void add(MobCategory spawnGroup) { -- this.counts.computeInt(spawnGroup, (group, density) -> density == null ? 1 : density + 1); -+ this.counts[spawnGroup.ordinal()]++; // Gale - VMP - store mob counts in an array - } - - public boolean canSpawn(MobCategory spawnGroup) { -- return this.counts.getOrDefault(spawnGroup, 0) < spawnGroup.getMaxInstancesPerChunk(); -+ return this.counts[spawnGroup.ordinal()] < spawnGroup.getMaxInstancesPerChunk(); // Gale - VMP - store mob counts in an array - } - } - } diff --git a/patches/server/0081-Use-linked-map-for-entity-trackers.patch b/patches/server/0081-Use-linked-map-for-entity-trackers.patch deleted file mode 100644 index c661a43..0000000 --- a/patches/server/0081-Use-linked-map-for-entity-trackers.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Martijn Muijsers -Date: Thu, 1 Dec 2022 14:40:03 +0100 -Subject: [PATCH] Use linked map for entity trackers - -License: MIT (https://opensource.org/licenses/MIT) -Gale - https://galemc.org - -This patch is based on the following mixin: -"com/ishland/vmp/mixins/entitytracker/MixinThreadedAnvilChunkStorage.java" -By: ishland -As part of: VMP (https://github.com/RelativityMC/VMP-fabric) -Licensed under: MIT (https://opensource.org/licenses/MIT) - -diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java -index 8b5a51558214c3a900b2e7c942e3c663280fdfb8..c86c839de2a718e0e84089b190e6b3bfaf2d18c8 100644 ---- a/src/main/java/net/minecraft/server/level/ChunkMap.java -+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java -@@ -184,7 +184,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider - this.toDrop = new LongOpenHashSet(); - this.tickingGenerated = new AtomicInteger(); - this.playerMap = new PlayerMap(); -- this.entityMap = new Int2ObjectOpenHashMap(); -+ this.entityMap = new it.unimi.dsi.fastutil.ints.Int2ObjectLinkedOpenHashMap(); // Gale - VMP - use linked map for entity trackers - provides faster iteration - this.chunkTypeCache = new Long2ByteOpenHashMap(); - // Paper - rewrite chunk system - Path path = session.getDimensionPath(world.dimension()); diff --git a/patches/server/0082-Optimize-noise-generation.patch b/patches/server/0082-Optimize-noise-generation.patch deleted file mode 100644 index f8d23fd..0000000 --- a/patches/server/0082-Optimize-noise-generation.patch +++ /dev/null @@ -1,248 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Martijn Muijsers -Date: Wed, 30 Nov 2022 19:49:14 +0100 -Subject: [PATCH] Optimize noise generation - -License: MIT (https://opensource.org/licenses/MIT) -Gale - https://galemc.org - -This patch is based on the following mixins: -* "com/ishland/c2me/opts/math/mixin/MixinOctavePerlinNoiseSampler.java" -* "com/ishland/c2me/opts/math/mixin/MixinPerlinNoiseSampler.java" -By: ishland -As part of: C2ME (https://github.com/RelativityMC/C2ME-fabric) -Licensed under: MIT (https://opensource.org/licenses/MIT) - -diff --git a/src/main/java/net/minecraft/world/level/levelgen/synth/ImprovedNoise.java b/src/main/java/net/minecraft/world/level/levelgen/synth/ImprovedNoise.java -index 9a97e5cd23d839183ac4d243d28df92af3119fe7..0da2d816f0497eae0c055f3929b8194a3473a221 100644 ---- a/src/main/java/net/minecraft/world/level/levelgen/synth/ImprovedNoise.java -+++ b/src/main/java/net/minecraft/world/level/levelgen/synth/ImprovedNoise.java -@@ -11,6 +11,27 @@ public final class ImprovedNoise { - public final double yo; - public final double zo; - -+ // Gale start - C2ME - optimize noise generation -+ private static final double[] FLAT_SIMPLEX_GRAD = new double[]{ -+ 1, 1, 0, 0, -+ -1, 1, 0, 0, -+ 1, -1, 0, 0, -+ -1, -1, 0, 0, -+ 1, 0, 1, 0, -+ -1, 0, 1, 0, -+ 1, 0, -1, 0, -+ -1, 0, -1, 0, -+ 0, 1, 1, 0, -+ 0, -1, 1, 0, -+ 0, 1, -1, 0, -+ 0, -1, -1, 0, -+ 1, 1, 0, 0, -+ 0, -1, 1, 0, -+ -1, 1, 0, 0, -+ 0, -1, -1, 0, -+ }; -+ // Gale end - C2ME - optimize noise generation -+ - public ImprovedNoise(RandomSource random) { - this.xo = random.nextDouble() * 256.0; - this.yo = random.nextDouble() * 256.0; -@@ -38,12 +59,14 @@ public final class ImprovedNoise { - double d = x + this.xo; - double e = y + this.yo; - double f = z + this.zo; -- int i = Mth.floor(d); -- int j = Mth.floor(e); -- int k = Mth.floor(f); -- double g = d - (double)i; -- double h = e - (double)j; -- double l = f - (double)k; -+ // Gale start - C2ME - optimize noise generation - optimize: remove frequent type conversions -+ double i = Math.floor(d); -+ double j = Math.floor(e); -+ double k = Math.floor(f); -+ double g = d - i; -+ double h = e - j; -+ double l = f - k; -+ // Gale end - C2ME - optimize noise generation - optimize: remove frequent type conversions - double o; - if (yScale != 0.0) { - double m; -@@ -53,25 +76,27 @@ public final class ImprovedNoise { - m = h; - } - -- o = (double)Mth.floor(m / yScale + 1.0E-7F) * yScale; -+ o = Math.floor(m / yScale + (double)1.0E-7F) * yScale; // Gale - C2ME - optimize noise generation - optimize: remove frequent type conversions - } else { - o = 0.0; - } - -- return this.sampleAndLerp(i, j, k, g, h - o, l, h); -+ return this.sampleAndLerp((int) i, (int) j, (int) k, g, h - o, l, h); // Gale - C2ME - optimize noise generation - optimize: remove frequent type conversions - } - - public double noiseWithDerivative(double x, double y, double z, double[] ds) { - double d = x + this.xo; - double e = y + this.yo; - double f = z + this.zo; -- int i = Mth.floor(d); -- int j = Mth.floor(e); -- int k = Mth.floor(f); -- double g = d - (double)i; -- double h = e - (double)j; -- double l = f - (double)k; -- return this.sampleWithDerivative(i, j, k, g, h, l, ds); -+ // Gale start - C2ME - optimize noise generation - optimize: remove frequent type conversions -+ double i = Math.floor(d); -+ double j = Math.floor(e); -+ double k = Math.floor(f); -+ double g = d - i; -+ double h = e - j; -+ double l = f - k; -+ return this.sampleWithDerivative((int) i, (int) j, (int) k, g, h, l, ds); -+ // Gale end - C2ME - optimize noise generation - optimize: remove frequent type conversions - } - - private static double gradDot(int hash, double x, double y, double z) { -@@ -83,24 +108,69 @@ public final class ImprovedNoise { - } - - private double sampleAndLerp(int sectionX, int sectionY, int sectionZ, double localX, double localY, double localZ, double fadeLocalY) { -- int i = this.p(sectionX); -- int j = this.p(sectionX + 1); -- int k = this.p(i + sectionY); -- int l = this.p(i + sectionY + 1); -- int m = this.p(j + sectionY); -- int n = this.p(j + sectionY + 1); -- double d = gradDot(this.p(k + sectionZ), localX, localY, localZ); -- double e = gradDot(this.p(m + sectionZ), localX - 1.0, localY, localZ); -- double f = gradDot(this.p(l + sectionZ), localX, localY - 1.0, localZ); -- double g = gradDot(this.p(n + sectionZ), localX - 1.0, localY - 1.0, localZ); -- double h = gradDot(this.p(k + sectionZ + 1), localX, localY, localZ - 1.0); -- double o = gradDot(this.p(m + sectionZ + 1), localX - 1.0, localY, localZ - 1.0); -- double p = gradDot(this.p(l + sectionZ + 1), localX, localY - 1.0, localZ - 1.0); -- double q = gradDot(this.p(n + sectionZ + 1), localX - 1.0, localY - 1.0, localZ - 1.0); -- double r = Mth.smoothstep(localX); -- double s = Mth.smoothstep(fadeLocalY); -- double t = Mth.smoothstep(localZ); -- return Mth.lerp3(r, s, t, d, e, f, g, h, o, p, q); -+ // Gale start - C2ME - optimize noise generation - inline math & small optimization: remove frequent type conversions and redundant ops -+ final int var0 = sectionX & 0xFF; -+ final int var1 = (sectionX + 1) & 0xFF; -+ final int var2 = this.p[var0] & 0xFF; -+ final int var3 = this.p[var1] & 0xFF; -+ final int var4 = (var2 + sectionY) & 0xFF; -+ final int var5 = (var3 + sectionY) & 0xFF; -+ final int var6 = (var2 + sectionY + 1) & 0xFF; -+ final int var7 = (var3 + sectionY + 1) & 0xFF; -+ final int var8 = this.p[var4] & 0xFF; -+ final int var9 = this.p[var5] & 0xFF; -+ final int var10 = this.p[var6] & 0xFF; -+ final int var11 = this.p[var7] & 0xFF; -+ -+ final int var12 = (var8 + sectionZ) & 0xFF; -+ final int var13 = (var9 + sectionZ) & 0xFF; -+ final int var14 = (var10 + sectionZ) & 0xFF; -+ final int var15 = (var11 + sectionZ) & 0xFF; -+ final int var16 = (var8 + sectionZ + 1) & 0xFF; -+ final int var17 = (var9 + sectionZ + 1) & 0xFF; -+ final int var18 = (var10 + sectionZ + 1) & 0xFF; -+ final int var19 = (var11 + sectionZ + 1) & 0xFF; -+ final int var20 = (this.p[var12] & 15) << 2; -+ final int var21 = (this.p[var13] & 15) << 2; -+ final int var22 = (this.p[var14] & 15) << 2; -+ final int var23 = (this.p[var15] & 15) << 2; -+ final int var24 = (this.p[var16] & 15) << 2; -+ final int var25 = (this.p[var17] & 15) << 2; -+ final int var26 = (this.p[var18] & 15) << 2; -+ final int var27 = (this.p[var19] & 15) << 2; -+ final double var60 = localX - 1.0; -+ final double var61 = localY - 1.0; -+ final double var62 = localZ - 1.0; -+ final double var87 = FLAT_SIMPLEX_GRAD[(var20) | 0] * localX + FLAT_SIMPLEX_GRAD[(var20) | 1] * localY + FLAT_SIMPLEX_GRAD[(var20) | 2] * localZ; -+ final double var88 = FLAT_SIMPLEX_GRAD[(var21) | 0] * var60 + FLAT_SIMPLEX_GRAD[(var21) | 1] * localY + FLAT_SIMPLEX_GRAD[(var21) | 2] * localZ; -+ final double var89 = FLAT_SIMPLEX_GRAD[(var22) | 0] * localX + FLAT_SIMPLEX_GRAD[(var22) | 1] * var61 + FLAT_SIMPLEX_GRAD[(var22) | 2] * localZ; -+ final double var90 = FLAT_SIMPLEX_GRAD[(var23) | 0] * var60 + FLAT_SIMPLEX_GRAD[(var23) | 1] * var61 + FLAT_SIMPLEX_GRAD[(var23) | 2] * localZ; -+ final double var91 = FLAT_SIMPLEX_GRAD[(var24) | 0] * localX + FLAT_SIMPLEX_GRAD[(var24) | 1] * localY + FLAT_SIMPLEX_GRAD[(var24) | 2] * var62; -+ final double var92 = FLAT_SIMPLEX_GRAD[(var25) | 0] * var60 + FLAT_SIMPLEX_GRAD[(var25) | 1] * localY + FLAT_SIMPLEX_GRAD[(var25) | 2] * var62; -+ final double var93 = FLAT_SIMPLEX_GRAD[(var26) | 0] * localX + FLAT_SIMPLEX_GRAD[(var26) | 1] * var61 + FLAT_SIMPLEX_GRAD[(var26) | 2] * var62; -+ final double var94 = FLAT_SIMPLEX_GRAD[(var27) | 0] * var60 + FLAT_SIMPLEX_GRAD[(var27) | 1] * var61 + FLAT_SIMPLEX_GRAD[(var27) | 2] * var62; -+ -+ final double var95 = localX * 6.0 - 15.0; -+ final double var96 = fadeLocalY * 6.0 - 15.0; -+ final double var97 = localZ * 6.0 - 15.0; -+ final double var98 = localX * var95 + 10.0; -+ final double var99 = fadeLocalY * var96 + 10.0; -+ final double var100 = localZ * var97 + 10.0; -+ final double var101 = localX * localX * localX * var98; -+ final double var102 = fadeLocalY * fadeLocalY * fadeLocalY * var99; -+ final double var103 = localZ * localZ * localZ * var100; -+ -+ final double var113 = var87 + var101 * (var88 - var87); -+ final double var114 = var93 + var101 * (var94 - var93); -+ final double var115 = var91 + var101 * (var92 - var91); -+ final double var116 = var89 + var101 * (var90 - var89); -+ final double var117 = var114 - var115; -+ final double var118 = var102 * (var116 - var113); -+ final double var119 = var102 * var117; -+ final double var120 = var113 + var118; -+ final double var121 = var115 + var119; -+ return var120 + (var103 * (var121 - var120)); -+ // Gale end - C2ME - optimize noise generation - inline math & small optimization: remove frequent type conversions and redundant ops - } - - private double sampleWithDerivative(int sectionX, int sectionY, int sectionZ, double localX, double localY, double localZ, double[] ds) { -diff --git a/src/main/java/net/minecraft/world/level/levelgen/synth/PerlinNoise.java b/src/main/java/net/minecraft/world/level/levelgen/synth/PerlinNoise.java -index 35820670837376bcad8891241724d5b946fbd31f..022dda9dded1bd96dcaf377b1d1a9711ea9c49e7 100644 ---- a/src/main/java/net/minecraft/world/level/levelgen/synth/PerlinNoise.java -+++ b/src/main/java/net/minecraft/world/level/levelgen/synth/PerlinNoise.java -@@ -26,6 +26,10 @@ public class PerlinNoise { - private final double lowestFreqValueFactor; - private final double lowestFreqInputFactor; - private final double maxValue; -+ // Gale start - C2ME - optimize noise generation -+ private final int octaveSamplersCount; -+ private final double [] amplitudesArray; -+ // Gale end - C2ME - optimize noise generation - - @Deprecated - public static PerlinNoise createLegacyForBlendedNoise(RandomSource random, IntStream octaves) { -@@ -127,6 +131,10 @@ public class PerlinNoise { - this.lowestFreqInputFactor = Math.pow(2.0, (double)(-j)); - this.lowestFreqValueFactor = Math.pow(2.0, (double)(i - 1)) / (Math.pow(2.0, (double)i) - 1.0); - this.maxValue = this.edgeValue(2.0); -+ // Gale start - C2ME - optimize noise generation -+ this.octaveSamplersCount = this.noiseLevels.length; -+ this.amplitudesArray = this.amplitudes.toDoubleArray(); -+ // Gale end - C2ME - optimize noise generation - } - - protected double maxValue() { -@@ -138,7 +146,27 @@ public class PerlinNoise { - } - - public double getValue(double x, double y, double z) { -- return this.getValue(x, y, z, 0.0, 0.0, false); -+ // Gale start - C2ME - optimize noise generation - optimize for common cases -+ double d = 0.0; -+ double e = this.lowestFreqInputFactor; -+ double f = this.lowestFreqValueFactor; -+ -+ for (int i = 0; i < this.octaveSamplersCount; ++i) { -+ ImprovedNoise perlinNoiseSampler = this.noiseLevels[i]; -+ if (perlinNoiseSampler != null) { -+ @SuppressWarnings("deprecation") -+ double g = perlinNoiseSampler.noise( -+ wrap(x * e), wrap(y * e), wrap(z * e), 0.0, 0.0 -+ ); -+ d += this.amplitudesArray[i] * g * f; -+ } -+ -+ e *= 2.0; -+ f /= 2.0; -+ } -+ -+ return d; -+ // Gale end - C2ME - optimize noise generation - optimize for common cases - } - - @Deprecated diff --git a/patches/server/0084-Hide-flames-on-entities-with-fire-resistance.patch b/patches/server/0084-Hide-flames-on-entities-with-fire-resistance.patch deleted file mode 100644 index 256c5cc..0000000 --- a/patches/server/0084-Hide-flames-on-entities-with-fire-resistance.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Martijn Muijsers -Date: Wed, 30 Nov 2022 14:39:27 +0100 -Subject: [PATCH] Hide flames on entities with fire resistance - -License: MIT (https://opensource.org/licenses/MIT) -Gale - https://galemc.org - -This patch is based on the following patch: -"Don't send fire packets if player has Fire Resistance" -By: Cryptite -As part of: Slice (https://github.com/Cryptite/Slice) -Licensed under: MIT (https://opensource.org/licenses/MIT) - -diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 6604efeaf2eddfc109d05b45b4e36378862054c0..ce11e73e7a91c9d45f62552ab1cd7bec47b2a879 100644 ---- a/src/main/java/net/minecraft/world/entity/Entity.java -+++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -946,7 +946,13 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess - - this.checkBelowWorld(); - if (!this.level().isClientSide) { -+ // Gale start - Slice - hide flames on entities with fire resistance -+ if (this instanceof net.minecraft.world.entity.LivingEntity livingEntity) { -+ this.setSharedFlagOnFire(this.remainingFireTicks > 0 && (!this.level.galeConfig().gameplayMechanics.hideFlamesOnEntitiesWithFireResistance || !livingEntity.hasEffect(net.minecraft.world.effect.MobEffects.FIRE_RESISTANCE))); -+ } else { -+ // Gale end - Slice - hide flames on entities with fire resistance - this.setSharedFlagOnFire(this.remainingFireTicks > 0); -+ } // Gale - Slice - hide flames on entities with fire resistance - } - - this.firstTick = false; -diff --git a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -index 1ba7cc5844236cfa75e7efcbf5a377f8e71fbaca..ecd4cf29a03d6f4ee71450b1c0d952209e40be4a 100644 ---- a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -+++ b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -@@ -121,6 +121,7 @@ public class GaleWorldConfiguration extends ConfigurationPart { - - public boolean arrowMovementResetsDespawnCounter = true; // Gale - Purpur - make arrow movement resetting despawn counter configurable - public double entityWakeUpDurationRatioStandardDeviation = 0.2; // Gale - variable entity wake-up duration -+ public boolean hideFlamesOnEntitiesWithFireResistance = false; // Gale - Slice - hide flames on entities with fire resistance - public boolean tryRespawnEnderDragonAfterEndCrystalPlace = true; // Gale - Pufferfish - make ender dragon respawn attempt after placing end crystals configurable - - } diff --git a/patches/server/0086-Reduce-block-destruction-packet-allocations.patch b/patches/server/0086-Reduce-block-destruction-packet-allocations.patch deleted file mode 100644 index 405bc0b..0000000 --- a/patches/server/0086-Reduce-block-destruction-packet-allocations.patch +++ /dev/null @@ -1,46 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Martijn Muijsers -Date: Fri, 23 Dec 2022 20:42:50 +0100 -Subject: [PATCH] Reduce block destruction packet allocations - -License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) -Gale - https://galemc.org - -This patch is based on the following patch: -"Cache block break animation packet" -By: VytskaLT -As part of: SportPaper (https://github.com/Electroid/SportPaper) -Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) - -diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index c36e21be642ad24231cdcd0ff20d22e1e449e18e..c25da6e647401767def8cdbe505964865e8d7820 100644 ---- a/src/main/java/net/minecraft/server/level/ServerLevel.java -+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java -@@ -1618,7 +1618,17 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe - - @Override - public void destroyBlockProgress(int entityId, BlockPos pos, int progress) { -- Iterator iterator = this.server.getPlayerList().getPlayers().iterator(); -+ -+ // Gale start - SportPaper - reduce block destruction packet allocations -+ var players = this.server.getPlayerList().getPlayers(); -+ if (players.isEmpty()) { -+ return; -+ } -+ -+ ClientboundBlockDestructionPacket packet = new ClientboundBlockDestructionPacket(entityId, pos, progress); -+ -+ Iterator iterator = players.iterator(); -+ // Gale end - SportPaper - reduce block destruction packet allocations - - // CraftBukkit start - Player entityhuman = null; -@@ -1652,7 +1662,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe - // CraftBukkit end - - if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) { -- entityplayer.connection.send(new ClientboundBlockDestructionPacket(entityId, pos, progress)); -+ entityplayer.connection.send(packet); // Gale - SportPaper - reduce block destruction packet allocations - } - } - } diff --git a/patches/server/0091-Make-slow-login-timeout-configurable.patch b/patches/server/0091-Make-slow-login-timeout-configurable.patch deleted file mode 100644 index b0a7e49..0000000 --- a/patches/server/0091-Make-slow-login-timeout-configurable.patch +++ /dev/null @@ -1,36 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Martijn Muijsers -Date: Sat, 24 Dec 2022 22:50:13 +0100 -Subject: [PATCH] Make slow login timeout configurable - -License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) -Gale - https://galemc.org - -diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -index 2f494450b5d67f9c6eb6ed6ebb8164257f124274..70534d9d58a209c0c8fd6f4d3ba65773f420f559 100644 ---- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -@@ -126,7 +126,10 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, - this.finishLoginAndWaitForClient(this.authenticatedProfile); - } - -- if (this.tick++ == 600) { -+ // Gale start - make slow login timeout configurable -+ int slowLoginTimeout = org.galemc.gale.configuration.GaleGlobalConfiguration.get().misc.premiumAccountSlowLoginTimeout; -+ if (this.tick++ >= (slowLoginTimeout < 1 ? MAX_TICKS_BEFORE_LOGIN : slowLoginTimeout)) { -+ // Gale end - make slow login timeout configurable - this.disconnect(Component.translatable("multiplayer.disconnect.slow_login")); - } - -diff --git a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -index b2ee56fa4be361e9151389787313594493dd7a2e..c9f19aa7dbf01d6dd295ae9e8d3df06c16ef75b4 100644 ---- a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -+++ b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -@@ -52,6 +52,7 @@ public class GaleGlobalConfiguration extends ConfigurationPart { - public class Misc extends ConfigurationPart { - - public boolean verifyChatOrder = true; // Gale - Pufferfish - make chat order verification configurable -+ public int premiumAccountSlowLoginTimeout = -1; // Gale - make slow login timeout configurable - - public Keepalive keepalive; - public class Keepalive extends ConfigurationPart { diff --git a/patches/server/0092-Don-t-load-chunks-to-spawn-phantoms.patch b/patches/server/0092-Don-t-load-chunks-to-spawn-phantoms.patch deleted file mode 100644 index 6732304..0000000 --- a/patches/server/0092-Don-t-load-chunks-to-spawn-phantoms.patch +++ /dev/null @@ -1,51 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Martijn Muijsers -Date: Sun, 25 Dec 2022 19:31:09 +0100 -Subject: [PATCH] Don't load chunks to spawn phantoms - -License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) -Gale - https://galemc.org - -This patch is based on the following patch: -"Don't load chunks when spawning phantoms" -By: PureGero -As part of: MultiPaper (https://github.com/MultiPaper/MultiPaper) -Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) - -diff --git a/src/main/java/net/minecraft/world/level/levelgen/PhantomSpawner.java b/src/main/java/net/minecraft/world/level/levelgen/PhantomSpawner.java -index 021221da5d0315f6e371380a705ac6b3f6ac18d3..997f80d332b95bb011cbbc27c065b2811a2dddc7 100644 ---- a/src/main/java/net/minecraft/world/level/levelgen/PhantomSpawner.java -+++ b/src/main/java/net/minecraft/world/level/levelgen/PhantomSpawner.java -@@ -70,7 +70,15 @@ public class PhantomSpawner implements CustomSpawner { - - if (randomsource.nextInt(j) >= world.paperConfig().entities.behavior.playerInsomniaStartTicks) { // Paper - Ability to control player's insomnia and phantoms - BlockPos blockposition1 = blockposition.above(20 + randomsource.nextInt(15)).east(-10 + randomsource.nextInt(21)).south(-10 + randomsource.nextInt(21)); -- BlockState iblockdata = world.getBlockState(blockposition1); -+ // Gale start - MultiPaper - don't load chunks to spawn phantoms -+ BlockState iblockdata; -+ if (world.galeConfig().smallOptimizations.loadChunks.toSpawnPhantoms) { -+ iblockdata = world.getBlockState(blockposition1); -+ } else { -+ iblockdata = world.getBlockStateIfLoaded(blockposition1); -+ if (iblockdata == null) continue; -+ } -+ // Gale end - MultiPaper - don't load chunks to spawn phantoms - FluidState fluid = world.getFluidState(blockposition1); - - if (NaturalSpawner.isValidEmptySpawnBlock(world, blockposition1, iblockdata, fluid, EntityType.PHANTOM)) { -diff --git a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -index ecd4cf29a03d6f4ee71450b1c0d952209e40be4a..61d6da8509837bfba30a139a84b0bc452ed4046b 100644 ---- a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -+++ b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -@@ -92,6 +92,11 @@ public class GaleWorldConfiguration extends ConfigurationPart { - - } - -+ public LoadChunks loadChunks; -+ public class LoadChunks extends ConfigurationPart { -+ public boolean toSpawnPhantoms = false; // Gale - MultiPaper - don't load chunks to spawn phantoms -+ } -+ - } - - public GameplayMechanics gameplayMechanics; diff --git a/patches/server/0094-Broadcast-crit-animations-as-the-entity-being-critte.patch b/patches/server/0094-Broadcast-crit-animations-as-the-entity-being-critte.patch deleted file mode 100644 index 641fa94..0000000 --- a/patches/server/0094-Broadcast-crit-animations-as-the-entity-being-critte.patch +++ /dev/null @@ -1,51 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Martijn Muijsers -Date: Sun, 25 Dec 2022 23:33:28 +0100 -Subject: [PATCH] Broadcast crit animations as the entity being critted - -License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) -Gale - https://galemc.org - -This patch is based on the following patch: -"Send crit animations as the entity being critted" -By: PureGero -As part of: MultiPaper (https://github.com/MultiPaper/MultiPaper) -Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) - -diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java -index 61ef647d61a8e2df209f79b7518c802feb85ac66..75c6d238fdbe434ea95db2c84da4461a0078327b 100644 ---- a/src/main/java/net/minecraft/server/level/ServerPlayer.java -+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java -@@ -2399,12 +2399,18 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple - - @Override - public void crit(Entity target) { -- this.serverLevel().getChunkSource().broadcastAndSend(this, new ClientboundAnimatePacket(target, 4)); -+ // Gale start - MultiPaper - broadcast crit animations as the entity being critted -+ var level = this.serverLevel(); -+ level.getChunkSource().broadcastAndSend(level.galeConfig().gameplayMechanics.fixes.broadcastCritAnimationsAsTheEntityBeingCritted ? target : this, new ClientboundAnimatePacket(target, 4)); -+ // Gale end - MultiPaper - broadcast crit animations as the entity being critted - } - - @Override - public void magicCrit(Entity target) { -- this.serverLevel().getChunkSource().broadcastAndSend(this, new ClientboundAnimatePacket(target, 5)); -+ // Gale start - MultiPaper - broadcast crit animations as the entity being critted -+ var level = this.serverLevel(); -+ level.getChunkSource().broadcastAndSend(level.galeConfig().gameplayMechanics.fixes.broadcastCritAnimationsAsTheEntityBeingCritted ? target : this, new ClientboundAnimatePacket(target, 5)); -+ // Gale end - MultiPaper - broadcast crit animations as the entity being critted - } - - @Override -diff --git a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -index e6ffd32986e587f4a8a6f98611ab6c02b96912e2..7ac5b7891963d1b4b3a2ae3ce27a284ccee42a70 100644 ---- a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -+++ b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -@@ -106,6 +106,7 @@ public class GaleWorldConfiguration extends ConfigurationPart { - public Fixes fixes; - public class Fixes extends ConfigurationPart { - -+ public boolean broadcastCritAnimationsAsTheEntityBeingCritted = false; // Gale - MultiPaper - broadcast crit animations as the entity being critted - public boolean keepMooshroomRotationAfterShearing = true; // Gale - Purpur - fix cow rotation when shearing mooshroom - - // Gale start - Purpur - fix MC-238526 diff --git a/patches/server/0095-Ignore-null-legacy-structure-data.patch b/patches/server/0095-Ignore-null-legacy-structure-data.patch deleted file mode 100644 index 28e7ec9..0000000 --- a/patches/server/0095-Ignore-null-legacy-structure-data.patch +++ /dev/null @@ -1,51 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Martijn Muijsers -Date: Sun, 25 Dec 2022 23:39:05 +0100 -Subject: [PATCH] Ignore null legacy structure data - -License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) -Gale - https://galemc.org - -This patch is based on the following patch: -"Add null check in LegacyStructureDataHandler" -By: PureGero -As part of: MultiPaper (https://github.com/MultiPaper/MultiPaper) -Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) - -diff --git a/src/main/java/net/minecraft/world/level/levelgen/structure/LegacyStructureDataHandler.java b/src/main/java/net/minecraft/world/level/levelgen/structure/LegacyStructureDataHandler.java -index 12ec1def8a100aa8400f9ef183b5ef744e2b11aa..9e44bb3d5553392ffcda4ecb81a2eb0fdfa71d48 100644 ---- a/src/main/java/net/minecraft/world/level/levelgen/structure/LegacyStructureDataHandler.java -+++ b/src/main/java/net/minecraft/world/level/levelgen/structure/LegacyStructureDataHandler.java -@@ -171,6 +171,7 @@ public class LegacyStructureDataHandler { - - private void populateCaches(@Nullable DimensionDataStorage persistentStateManager) { - if (persistentStateManager != null) { -+ boolean ignoreNullLegacyStructureData = org.galemc.gale.configuration.GaleGlobalConfiguration.get().misc.ignoreNullLegacyStructureData; // Gale - MultiPaper - ignore null legacy structure data - Iterator iterator = this.legacyKeys.iterator(); - - while (iterator.hasNext()) { -@@ -178,7 +179,11 @@ public class LegacyStructureDataHandler { - CompoundTag nbttagcompound = new CompoundTag(); - - try { -- nbttagcompound = persistentStateManager.readTagFromDisk(s, DataFixTypes.SAVED_DATA_STRUCTURE_FEATURE_INDICES, 1493).getCompound("data").getCompound("Features"); -+ // Gale start - MultiPaper - ignore null legacy structure data -+ CompoundTag tag = persistentStateManager.readTagFromDisk(s, DataFixTypes.SAVED_DATA_STRUCTURE_FEATURE_INDICES, 1493); -+ if (ignoreNullLegacyStructureData && tag == null) continue; -+ nbttagcompound = tag.getCompound("data").getCompound("Features"); -+ // Gale end - MultiPaper - ignore null legacy structure data - if (nbttagcompound.isEmpty()) { - continue; - } -diff --git a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -index c9f19aa7dbf01d6dd295ae9e8d3df06c16ef75b4..16e7e370385fc4c43c1bbac1a5d9c504ffd8877c 100644 ---- a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -+++ b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -@@ -53,6 +53,7 @@ public class GaleGlobalConfiguration extends ConfigurationPart { - - public boolean verifyChatOrder = true; // Gale - Pufferfish - make chat order verification configurable - public int premiumAccountSlowLoginTimeout = -1; // Gale - make slow login timeout configurable -+ public boolean ignoreNullLegacyStructureData = false; // Gale - MultiPaper - ignore null legacy structure data - - public Keepalive keepalive; - public class Keepalive extends ConfigurationPart { diff --git a/patches/server/0097-Prevent-entities-random-strolling-into-non-ticking-c.patch b/patches/server/0097-Prevent-entities-random-strolling-into-non-ticking-c.patch deleted file mode 100644 index fcd56be..0000000 --- a/patches/server/0097-Prevent-entities-random-strolling-into-non-ticking-c.patch +++ /dev/null @@ -1,39 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Martijn Muijsers -Date: Wed, 30 Nov 2022 20:38:15 +0100 -Subject: [PATCH] Prevent entities random strolling into non-ticking chunks - -License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) -Gale - https://galemc.org - -This patch is based on the following patch: -"Don't wander into non-ticking chunks" -By: PureGero -As part of: MultiPaper (https://github.com/MultiPaper/MultiPaper) -Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) - -diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/RandomStrollGoal.java b/src/main/java/net/minecraft/world/entity/ai/goal/RandomStrollGoal.java -index 676e1580849e8942eb41c7a3a80f464138b22764..129591f1bb9cc687a2873855e7bc58f873470d1a 100644 ---- a/src/main/java/net/minecraft/world/entity/ai/goal/RandomStrollGoal.java -+++ b/src/main/java/net/minecraft/world/entity/ai/goal/RandomStrollGoal.java -@@ -49,7 +49,7 @@ public class RandomStrollGoal extends Goal { - } - - Vec3 vec3 = this.getPosition(); -- if (vec3 == null) { -+ if (vec3 == null || (!this.mob.level().galeConfig().gameplayMechanics.entitiesCanRandomStrollIntoNonTickingChunks && !((net.minecraft.server.level.ServerLevel) this.mob.level()).isPositionEntityTicking(net.minecraft.core.BlockPos.containing(vec3)))) { // Gale - MultiPaper - prevent entities random strolling into non-ticking chunks - return false; - } else { - this.wantedX = vec3.x; -diff --git a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -index 7ac5b7891963d1b4b3a2ae3ce27a284ccee42a70..5b9e55bc9c7a67487400f59ba6bfaa9f68c6504a 100644 ---- a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -+++ b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java -@@ -127,6 +127,7 @@ public class GaleWorldConfiguration extends ConfigurationPart { - } - - public boolean arrowMovementResetsDespawnCounter = true; // Gale - Purpur - make arrow movement resetting despawn counter configurable -+ public boolean entitiesCanRandomStrollIntoNonTickingChunks = true; // Gale - MultiPaper - prevent entities random strolling into non-ticking chunks - public double entityWakeUpDurationRatioStandardDeviation = 0.2; // Gale - variable entity wake-up duration - public boolean hideFlamesOnEntitiesWithFireResistance = false; // Gale - Slice - hide flames on entities with fire resistance - public boolean tryRespawnEnderDragonAfterEndCrystalPlace = true; // Gale - Pufferfish - make ender dragon respawn attempt after placing end crystals configurable diff --git a/patches/server/0105-Show-last-tick-time-in-tps-command.patch b/patches/server/0105-Show-last-tick-time-in-tps-command.patch deleted file mode 100644 index 0cac9c4..0000000 --- a/patches/server/0105-Show-last-tick-time-in-tps-command.patch +++ /dev/null @@ -1,89 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Martijn Muijsers -Date: Sat, 26 Nov 2022 21:02:58 +0100 -Subject: [PATCH] Show last tick time in /tps command - -License: MIT (https://opensource.org/licenses/MIT) -Gale - https://galemc.org - -This patch is based on the following patch: -"Add getLastTickMs api" -By: tr7zw -As part of: YAPFA (https://github.com/tr7zw/YAPFA) -Licensed under: MIT (https://opensource.org/licenses/MIT) - -* YAPFA copyright * - -Copyright 2020 tr7zw - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -diff --git a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -index 16e7e370385fc4c43c1bbac1a5d9c504ffd8877c..6f151a15b76827fb0e49c9bbe1d491b5d61516d2 100644 ---- a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -+++ b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -@@ -60,6 +60,14 @@ public class GaleGlobalConfiguration extends ConfigurationPart { - public boolean sendMultiple = true; // Gale - Purpur - send multiple keep-alive packets - } - -+ // Gale start - YAPFA - last tick time - in TPS command -+ public LastTickTimeInTpsCommand lastTickTimeInTpsCommand; -+ public class LastTickTimeInTpsCommand extends ConfigurationPart { -+ public boolean enabled = false; -+ public boolean addOversleep = false; -+ } -+ // Gale end - YAPFA - last tick time - in TPS command -+ - } - - public LogToConsole logToConsole; -diff --git a/src/main/java/org/spigotmc/TicksPerSecondCommand.java b/src/main/java/org/spigotmc/TicksPerSecondCommand.java -index 18f7fe2fd6b9ea5e93193dc8ce64a16fc65a2e72..f98325ac69f62ed576c5ec6b1edeb5e5f038f996 100644 ---- a/src/main/java/org/spigotmc/TicksPerSecondCommand.java -+++ b/src/main/java/org/spigotmc/TicksPerSecondCommand.java -@@ -42,6 +42,24 @@ public class TicksPerSecondCommand extends Command - builder.append(net.kyori.adventure.text.Component.text("TPS from last 5s, 1m, 5m, 15m: ", net.kyori.adventure.text.format.NamedTextColor.GOLD)); // Gale - Purpur - 5 second TPS average - builder.append(net.kyori.adventure.text.Component.join(net.kyori.adventure.text.JoinConfiguration.commas(true), tpsAvg)); - sender.sendMessage(builder.asComponent()); -+ // Gale start - YAPFA - last tick time - in TPS command -+ if (org.galemc.gale.configuration.GaleGlobalConfiguration.get().misc.lastTickTimeInTpsCommand.enabled) { -+ long lastTickProperTime = MinecraftServer.lastTickProperTime; -+ long lastTickOversleepTime = MinecraftServer.lastTickOversleepTime; -+ var lastTickTimeMessage = net.kyori.adventure.text.Component.text("Last tick: ") -+ .append(formatTickTimeDuration(lastTickProperTime, 44, 50, 51)); -+ if (org.galemc.gale.configuration.GaleGlobalConfiguration.get().misc.lastTickTimeInTpsCommand.addOversleep) { -+ lastTickTimeMessage = lastTickTimeMessage.append(net.kyori.adventure.text.Component.text(" self + ")) -+ .append(formatTickTimeDuration(lastTickOversleepTime, Math.max(1, 51 - lastTickProperTime), Math.max(2, 52 - lastTickProperTime), Math.max(3, 53 - lastTickProperTime))) -+ .append(net.kyori.adventure.text.Component.text(" oversleep = ")) -+ .append(formatTickTimeDuration(lastTickProperTime + lastTickOversleepTime, 51, 52, 53)); -+ } -+ lastTickTimeMessage = lastTickTimeMessage.color(net.kyori.adventure.text.format.NamedTextColor.GOLD); -+ sender.sendMessage( -+ lastTickTimeMessage -+ ); -+ } -+ // Gale end - YAPFA - last tick time - in TPS command - if (args.length > 0 && args[0].equals("mem") && sender.hasPermission("bukkit.command.tpsmemory")) { - sender.sendMessage(net.kyori.adventure.text.Component.text() - .append(net.kyori.adventure.text.Component.text("Current Memory Usage: ", net.kyori.adventure.text.format.NamedTextColor.GOLD)) -@@ -66,4 +84,16 @@ public class TicksPerSecondCommand extends Command - return net.kyori.adventure.text.Component.text(amount, color); - // Paper end - } -+ -+ // Gale start - YAPFA - last tick time - in TPS command -+ private static final net.kyori.adventure.text.format.TextColor safeColor = net.kyori.adventure.text.format.NamedTextColor.GREEN; -+ private static final net.kyori.adventure.text.format.TextColor closeColor = net.kyori.adventure.text.format.NamedTextColor.YELLOW; -+ private static final net.kyori.adventure.text.format.TextColor problematicColor = net.kyori.adventure.text.format.TextColor.color(0xf77c1e); -+ private static final net.kyori.adventure.text.format.TextColor severeColor = net.kyori.adventure.text.format.NamedTextColor.RED; -+ public static net.kyori.adventure.text.Component formatTickTimeDuration(long ms, long safeLimit, long closeLimit, long nonSevereLimit) { -+ return net.kyori.adventure.text.Component.text(ms + " ", ms <= safeLimit ? safeColor : ms <= closeLimit ? closeColor : ms <= nonSevereLimit ? problematicColor : severeColor) -+ .append(net.kyori.adventure.text.Component.text("ms", net.kyori.adventure.text.format.NamedTextColor.GOLD)); -+ } -+ // Gale end - YAPFA - last tick time - in TPS command -+ - } diff --git a/patches/server/0109-Optimize-matching-item-checks.patch b/patches/server/0109-Optimize-matching-item-checks.patch deleted file mode 100644 index d1a0d8f..0000000 --- a/patches/server/0109-Optimize-matching-item-checks.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Martijn Muijsers -Date: Sun, 25 Dec 2022 20:51:32 +0100 -Subject: [PATCH] Optimize matching item checks - -License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) -Gale - https://galemc.org - -diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java -index 303b3337b23b6528ed431ba8b6c1c1f3187a4503..9de79c7087d3ce55631f08191a9b7994567f1788 100644 ---- a/src/main/java/net/minecraft/world/item/ItemStack.java -+++ b/src/main/java/net/minecraft/world/item/ItemStack.java -@@ -921,7 +921,7 @@ public final class ItemStack implements DataComponentHolder { - } - - public static boolean matches(ItemStack left, ItemStack right) { -- return left == right ? true : (left.getCount() != right.getCount() ? false : ItemStack.isSameItemSameComponents(left, right)); -+ return left == right || (left.getCount() == right.getCount() && ItemStack.isSameItemSameComponents(left, right)); // Gale - optimize identical item checks - } - - /** @deprecated */ -@@ -941,11 +941,11 @@ public final class ItemStack implements DataComponentHolder { - } - - public static boolean isSameItem(ItemStack left, ItemStack right) { -- return left.is(right.getItem()); -+ return left == right || left.is(right.getItem()); // Gale - optimize identical item checks - } - - public static boolean isSameItemSameComponents(ItemStack stack, ItemStack otherStack) { -- return !stack.is(otherStack.getItem()) ? false : (stack.isEmpty() && otherStack.isEmpty() ? true : Objects.equals(stack.components, otherStack.components)); -+ return stack == otherStack || (stack.is(otherStack.getItem()) && (stack.isEmpty() && otherStack.isEmpty() || Objects.equals(stack.components, otherStack.components))); // Gale - optimize identical item checks - } - - public static MapCodec lenientOptionalFieldOf(String fieldName) { diff --git a/patches/server/0111-Optimize-VarInt-write-and-VarLong-write.patch b/patches/server/0111-Optimize-VarInt-write-and-VarLong-write.patch deleted file mode 100644 index e66b07a..0000000 --- a/patches/server/0111-Optimize-VarInt-write-and-VarLong-write.patch +++ /dev/null @@ -1,273 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Martijn Muijsers -Date: Tue, 22 Aug 2023 21:38:37 +0200 -Subject: [PATCH] Optimize VarInt#write and VarLong#write - -License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) -Gale - https://galemc.org - -This patch is based on the following commit: -"Reapply "Optimize varint writing"" -By: Andrew Steinborn -As part of: Velocity (https://github.com/PaperMC/Velocity) -Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) - -* Velocity description * - -Inspired by the approach described at the bottom of https://richardstartin.github.io/posts/dont-use-protobuf-for-telemetry - -Given that we do a lot of varint writing as well, this should provide a small performance boost for larger/complex packets whilst not regressing hard on smaller packets. - -This includes a test to ensure that the behavior is as expected and fixes the initialization loop so that the correct results will be given. Much thanks to @octylFractal for acting as my duck while trying to figure this out. - -diff --git a/src/main/java/net/minecraft/network/VarInt.java b/src/main/java/net/minecraft/network/VarInt.java -index 74ed47659d3e615c2dae7da98d5a8cf1559625bf..82a8354b5ce503508716af3966b9809a6b4d956c 100644 ---- a/src/main/java/net/minecraft/network/VarInt.java -+++ b/src/main/java/net/minecraft/network/VarInt.java -@@ -51,6 +51,41 @@ public class VarInt { - } - - public static ByteBuf write(ByteBuf buf, int i) { -+ // Gale start - Velocity - optimized VarInt#write -+ if ((i & 0xFFFFFF80) == 0) { -+ buf.writeByte(i); -+ } else if ((i & 0xFFFFC000) == 0) { -+ int w = (i & 0x7F) << 8 -+ | (i >>> 7) -+ | 0x00008000; -+ buf.writeShort(w); -+ } else if ((i & 0xFFE00000) == 0) { -+ int w = (i & 0x7F) << 16 -+ | (i & 0x3F80) << 1 -+ | (i >>> 14) -+ | 0x00808000; -+ buf.writeMedium(w); -+ } else if ((i & 0xF0000000) == 0) { -+ int w = (i & 0x7F) << 24 -+ | ((i & 0x3F80) << 9) -+ | (i & 0x1FC000) >> 6 -+ | (i >>> 21) -+ | 0x80808000; -+ buf.writeInt(w); -+ } else { -+ int w = (i & 0x7F) << 24 -+ | (i & 0x3F80) << 9 -+ | (i & 0x1FC000) >> 6 -+ | ((i >>> 21) & 0x7F) -+ | 0x80808080; -+ buf.writeInt(w); -+ buf.writeByte(i >>> 28); -+ } -+ return buf; -+ } -+ -+ static ByteBuf writeOld(ByteBuf buf, int i) { // public -> package-private -+ // Gale end - Velocity - optimized VarInt#write - // Paper start - Optimize VarInts - // Peel the one and two byte count cases explicitly as they are the most common VarInt sizes - // that the proxy will write, to improve inlining. -@@ -60,11 +95,11 @@ public class VarInt { - int w = (i & 0x7F | 0x80) << 8 | (i >>> 7); - buf.writeShort(w); - } else { -- writeOld(buf, i); -+ writeOld2(buf, i); // rename - } - return buf; - } -- public static ByteBuf writeOld(ByteBuf buf, int i) { -+ public static ByteBuf writeOld2(ByteBuf buf, int i) { // rename - // Paper end - Optimize VarInts - while ((i & -128) != 0) { - buf.writeByte(i & 127 | 128); -diff --git a/src/main/java/net/minecraft/network/VarLong.java b/src/main/java/net/minecraft/network/VarLong.java -index 11339185fc70b1a34130c92d28c397d4b05569cb..c127dd051572177e4fc379bb7e2d40571d0abeed 100644 ---- a/src/main/java/net/minecraft/network/VarLong.java -+++ b/src/main/java/net/minecraft/network/VarLong.java -@@ -51,6 +51,127 @@ public class VarLong { - } - - public static ByteBuf write(ByteBuf buf, long l) { -+ // Gale start - Velocity - optimized VarLong#write -+ if ((l & 0xFFFFFFFFFFFFFF80L) == 0) { -+ buf.writeByte((int) l); -+ } else if (l < 0) { -+ // The case of writing arbitrary longs is common -+ // Here, the number is negative, which has probability 1/2 for arbitrary numbers -+ int least7bits = (int) (l & 0xFFFFFFFL); -+ int w = (least7bits & 0x7F) << 24 -+ | (least7bits & 0x3F80) << 9 -+ | (least7bits & 0x1FC000) >> 6 -+ | ((least7bits >>> 21) & 0x7F) -+ | 0x80808080; -+ long nonLeast7Bits = l >>> 28; -+ int secondLeast7bits = (int) (nonLeast7Bits & 0xFFFFFFFL); -+ int w2 = (secondLeast7bits & 0x7F) << 24 -+ | ((secondLeast7bits & 0x3F80) << 9) -+ | (secondLeast7bits & 0x1FC000) >> 6 -+ | (secondLeast7bits >>> 21) -+ | 0x80808080; -+ int thirdLeast7Bits = (int) (nonLeast7Bits >>> 28); -+ int w3 = (thirdLeast7Bits & 0x7F) << 8 -+ | (thirdLeast7Bits >>> 7) -+ | 0x00008000; -+ buf.writeInt(w); -+ buf.writeInt(w2); -+ buf.writeShort(w3); -+ } else if ((l & 0xFFFFFFFFFFFFC000L) == 0) { -+ int least7bits = (int) l; -+ int w = (least7bits & 0x7F) << 8 -+ | (least7bits >>> 7) -+ | 0x00008000; -+ buf.writeShort(w); -+ } else if ((l & 0xFFFFFFFFFFE00000L) == 0) { -+ int least7bits = (int) l; -+ int w = (least7bits & 0x7F) << 16 -+ | (least7bits & 0x3F80) << 1 -+ | (least7bits >>> 14) -+ | 0x00808000; -+ buf.writeMedium(w); -+ } else if ((l & 0xFFFFFFFFF0000000L) == 0) { -+ int least7bits = (int) l; -+ int w = (least7bits & 0x7F) << 24 -+ | ((least7bits & 0x3F80) << 9) -+ | (least7bits & 0x1FC000) >> 6 -+ | (least7bits >>> 21) -+ | 0x80808000; -+ buf.writeInt(w); -+ } else if ((l & 0xFFFFFFF800000000L) == 0) { -+ int least7bits = (int) (l & 0xFFFFFFFL); -+ int w = (least7bits & 0x7F) << 24 -+ | (least7bits & 0x3F80) << 9 -+ | (least7bits & 0x1FC000) >> 6 -+ | ((least7bits >>> 21) & 0x7F) -+ | 0x80808080; -+ buf.writeInt(w); -+ buf.writeByte((int) (l >>> 28)); -+ } else if ((l & 0xFFFFFC0000000000L) == 0) { -+ int least7bits = (int) (l & 0xFFFFFFFL); -+ int w = (least7bits & 0x7F) << 24 -+ | (least7bits & 0x3F80) << 9 -+ | (least7bits & 0x1FC000) >> 6 -+ | ((least7bits >>> 21) & 0x7F) -+ | 0x80808080; -+ int secondLeast7bits = (int) (l >>> 28); -+ int w2 = (secondLeast7bits & 0x7F) << 8 -+ | (secondLeast7bits >>> 7) -+ | 0x00008000; -+ buf.writeInt(w); -+ buf.writeShort(w2); -+ } else if ((l & 0xFFFE000000000000L) == 0) { -+ int least7bits = (int) (l & 0xFFFFFFFL); -+ int w = (least7bits & 0x7F) << 24 -+ | (least7bits & 0x3F80) << 9 -+ | (least7bits & 0x1FC000) >> 6 -+ | ((least7bits >>> 21) & 0x7F) -+ | 0x80808080; -+ int secondLeast7bits = (int) (l >>> 28); -+ int w2 = (secondLeast7bits & 0x7F) << 16 -+ | (secondLeast7bits & 0x3F80) << 1 -+ | (secondLeast7bits >>> 14) -+ | 0x00808000; -+ buf.writeInt(w); -+ buf.writeMedium(w2); -+ } else if ((l & 0xFF00000000000000L) == 0) { -+ int least7bits = (int) (l & 0xFFFFFFFL); -+ int w = (least7bits & 0x7F) << 24 -+ | (least7bits & 0x3F80) << 9 -+ | (least7bits & 0x1FC000) >> 6 -+ | ((least7bits >>> 21) & 0x7F) -+ | 0x80808080; -+ int secondLeast7bits = (int) (l >>> 28); -+ int w2 = (secondLeast7bits & 0x7F) << 24 -+ | ((secondLeast7bits & 0x3F80) << 9) -+ | (secondLeast7bits & 0x1FC000) >> 6 -+ | (secondLeast7bits >>> 21) -+ | 0x80808000; -+ buf.writeInt(w); -+ buf.writeInt(w2); -+ } else { -+ int least7bits = (int) (l & 0xFFFFFFFL); -+ int w = (least7bits & 0x7F) << 24 -+ | (least7bits & 0x3F80) << 9 -+ | (least7bits & 0x1FC000) >> 6 -+ | ((least7bits >>> 21) & 0x7F) -+ | 0x80808080; -+ long nonLeast7Bits = l >>> 28; -+ int secondLeast7bits = (int) (nonLeast7Bits & 0xFFFFFFFL); -+ int w2 = (secondLeast7bits & 0x7F) << 24 -+ | ((secondLeast7bits & 0x3F80) << 9) -+ | (secondLeast7bits & 0x1FC000) >> 6 -+ | (secondLeast7bits >>> 21) -+ | 0x80808080; -+ buf.writeInt(w); -+ buf.writeInt(w2); -+ buf.writeByte((int) (nonLeast7Bits >>> 28)); -+ } -+ return buf; -+ } -+ -+ static ByteBuf writeOld(ByteBuf buf, long l) { // public -> package-private -+ // Gale end - Velocity - optimized VarLong#write - while ((l & -128L) != 0L) { - buf.writeByte((int)(l & 127L) | 128); - l >>>= 7; -diff --git a/src/test/java/net/minecraft/network/VarIntLongTest.java b/src/test/java/net/minecraft/network/VarIntLongTest.java -index bbea09ffc2180c3c62e15d7dff51f8c220425bfe..0c11670d8d7307307a7cd12be5d0dca40155829d 100644 ---- a/src/test/java/net/minecraft/network/VarIntLongTest.java -+++ b/src/test/java/net/minecraft/network/VarIntLongTest.java -@@ -2,6 +2,7 @@ - - package net.minecraft.network; - -+import io.netty.buffer.Unpooled; - import it.unimi.dsi.fastutil.ints.IntOpenHashSet; - import it.unimi.dsi.fastutil.ints.IntSet; - import it.unimi.dsi.fastutil.longs.LongOpenHashSet; -@@ -156,4 +157,46 @@ public class VarIntLongTest { - } - // Gale end - Velocity - pre-compute VarInt and VarLong sizes - -+ // Gale - Velocity - optimized VarInt#write and VarLong#write -+ @Test -+ public void testWriteVarIntComparedToOld() { -+ integerCases.forEach(value -> { -+ // given -+ int capacity = 5; -+ FriendlyByteBuf buf1 = new FriendlyByteBuf(Unpooled.buffer(capacity)); -+ FriendlyByteBuf buf2 = new FriendlyByteBuf(Unpooled.buffer(capacity)); -+ VarInt.writeOld(buf1, value); -+ -+ // when -+ buf2.writeVarInt(value); -+ -+ // then -+ Assertions.assertEquals(buf1.writerIndex(), buf2.writerIndex(), "Writer index of optimized buffer (" + buf2.writerIndex() + ") is not equal to writer index of original buffer (" + buf1.writerIndex() + ") for test case value " + value + " (binary: " + padStringWithLeadingZeros(Integer.toBinaryString(value), 32) + ")"); -+ for (int i = 0; i < capacity; i++) { -+ Assertions.assertEquals(buf1.getByte(i), buf2.getByte(i), "Buffer byte (at index " + i + ") in optimized buffer (" + buf2.getByte(i) + " (binary: " + padStringWithLeadingZeros(Integer.toBinaryString(Byte.toUnsignedInt(buf2.getByte(i))), 8) + ")) is not equal to the same byte in original buffer (" + buf1.getByte(i) + " (binary: " + padStringWithLeadingZeros(Integer.toBinaryString(Byte.toUnsignedInt(buf1.getByte(i))), 8) + ")) for test case value " + value + " (binary: " + padStringWithLeadingZeros(Integer.toBinaryString(value), 32) + ")"); -+ } -+ }); -+ } -+ -+ @Test -+ public void testWriteVarLongComparedToOld() { -+ longCases.forEach(value -> { -+ // given -+ int capacity = 10; -+ FriendlyByteBuf buf1 = new FriendlyByteBuf(Unpooled.buffer(capacity)); -+ FriendlyByteBuf buf2 = new FriendlyByteBuf(Unpooled.buffer(capacity)); -+ VarLong.writeOld(buf1, value); -+ -+ // when -+ buf2.writeVarLong(value); -+ -+ // then -+ Assertions.assertEquals(buf1.writerIndex(), buf2.writerIndex(), "Writer index of optimized buffer (" + buf2.writerIndex() + ") is not equal to writer index of original buffer (" + buf1.writerIndex() + ") for test case value " + value + " (binary: " + padStringWithLeadingZeros(Long.toBinaryString(value), 64) + ")"); -+ for (int i = 0; i < capacity; i++) { -+ Assertions.assertEquals(buf1.getByte(i), buf2.getByte(i), "Buffer byte (at index " + i + ") in optimized buffer (" + buf2.getByte(i) + " (binary: " + padStringWithLeadingZeros(Integer.toBinaryString(Byte.toUnsignedInt(buf2.getByte(i))), 8) + ")) is not equal to the same byte in original buffer (" + buf1.getByte(i) + " (binary: " + padStringWithLeadingZeros(Integer.toBinaryString(Byte.toUnsignedInt(buf1.getByte(i))), 8) + ")) for test case value " + value + " (binary: " + padStringWithLeadingZeros(Long.toBinaryString(value), 64) + ")"); -+ } -+ }); -+ } -+ // Gale end - Velocity - optimized VarInt#write and VarLong#write -+ - } diff --git a/patches/server/0112-Reduce-RandomSource-instances.patch b/patches/server/0112-Reduce-RandomSource-instances.patch deleted file mode 100644 index ab79901..0000000 --- a/patches/server/0112-Reduce-RandomSource-instances.patch +++ /dev/null @@ -1,132 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Martijn Muijsers -Date: Tue, 29 Nov 2022 00:45:45 +0100 -Subject: [PATCH] Reduce RandomSource instances - -License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) -Gale - https://galemc.org - -This patch is based on the following patch: -"don't create new random instance" -By: foss-mc <69294560+foss-mc@users.noreply.github.com> -As part of: Patina (https://github.com/PatinaMC/Patina) -Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) - -diff --git a/src/main/java/net/minecraft/server/commands/SpreadPlayersCommand.java b/src/main/java/net/minecraft/server/commands/SpreadPlayersCommand.java -index 6f69e74d8662025c4148b36de7a35e789abcd1d2..8c18763ff74a6fbc87eafa1170c4ad9d5f1de22f 100644 ---- a/src/main/java/net/minecraft/server/commands/SpreadPlayersCommand.java -+++ b/src/main/java/net/minecraft/server/commands/SpreadPlayersCommand.java -@@ -66,7 +66,7 @@ public class SpreadPlayersCommand { - if (maxY < j) { - throw SpreadPlayersCommand.ERROR_INVALID_MAX_HEIGHT.create(maxY, j); - } else { -- RandomSource randomsource = RandomSource.create(); -+ RandomSource randomsource = source.getLevel().random; // Gale - Patina - reduce RandomSource instances - double d0 = (double) (center.x - maxRange); - double d1 = (double) (center.y - maxRange); - double d2 = (double) (center.x + maxRange); -diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java -index 75c6d238fdbe434ea95db2c84da4461a0078327b..7e06a80e6deb80df865f7798588a92b88084411b 100644 ---- a/src/main/java/net/minecraft/server/level/ServerPlayer.java -+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java -@@ -524,7 +524,7 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple - long l = k * k; - int i1 = l > 2147483647L ? Integer.MAX_VALUE : (int) l; - int j1 = this.getCoprime(i1); -- int k1 = RandomSource.create().nextInt(i1); -+ int k1 = worldserver.random.nextInt(i1); // Gale - Patina - reduce RandomSource instances - - for (int l1 = 0; l1 < i1; ++l1) { - int i2 = (k1 + j1 * l1) % i1; -@@ -563,7 +563,7 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple - long l = k * k; - int i1 = l > 2147483647L ? Integer.MAX_VALUE : (int) l; - int j1 = this.getCoprime(i1); -- int k1 = RandomSource.create().nextInt(i1); -+ int k1 = world.random.nextInt(i1); // Gale - Patina - reduce RandomSource instances - - for (int l1 = 0; l1 < i1; ++l1) { - int i2 = (k1 + j1 * l1) % i1; -diff --git a/src/main/java/net/minecraft/server/rcon/thread/QueryThreadGs4.java b/src/main/java/net/minecraft/server/rcon/thread/QueryThreadGs4.java -index 0e0867d7add9a024bbe9471f8ff92bbb25996a3d..94ffa65fa99c4c713936f7004d9f46ac94a9fe7a 100644 ---- a/src/main/java/net/minecraft/server/rcon/thread/QueryThreadGs4.java -+++ b/src/main/java/net/minecraft/server/rcon/thread/QueryThreadGs4.java -@@ -341,7 +341,7 @@ public class QueryThreadGs4 extends GenericThread { - this.identBytes[2] = bs[5]; - this.identBytes[3] = bs[6]; - this.ident = new String(this.identBytes, StandardCharsets.UTF_8); -- this.challenge = RandomSource.create().nextInt(16777216); -+ this.challenge = java.util.concurrent.ThreadLocalRandom.current().nextInt(16777216); // Gale - Patina - reduce RandomSource instances - this.challengeBytes = String.format(Locale.ROOT, "\t%s%d\u0000", this.ident, this.challenge).getBytes(StandardCharsets.UTF_8); - } - -diff --git a/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java b/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java -index 4daa69c6be6d48563e30343a7e40e4da9ec7e5ad..d33a3b62ec7d5f82366844b2df66518e7df50700 100644 ---- a/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java -+++ b/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java -@@ -88,7 +88,7 @@ public class FishingHook extends Projectile { - - private FishingHook(EntityType type, Level world, int luckBonus, int waitTimeReductionTicks) { - super(type, world); -- this.syncronizedRandom = RandomSource.create(); -+ this.syncronizedRandom = world.random; // Gale - Patina - reduce RandomSource instances - this.openWater = true; - this.currentState = FishingHook.FishHookState.FLYING; - this.luck = Math.max(0, luckBonus); -diff --git a/src/main/java/net/minecraft/world/entity/raid/Raid.java b/src/main/java/net/minecraft/world/entity/raid/Raid.java -index 4ce08edf6e7a59238b1c4e85acc04eab21b21ee9..3618bbf30d61d7d2c18b9da69125a5f7fefab939 100644 ---- a/src/main/java/net/minecraft/world/entity/raid/Raid.java -+++ b/src/main/java/net/minecraft/world/entity/raid/Raid.java -@@ -116,7 +116,7 @@ public class Raid { - - public Raid(int id, ServerLevel world, BlockPos pos) { - this.raidEvent = new ServerBossEvent(Raid.RAID_NAME_COMPONENT, BossEvent.BossBarColor.RED, BossEvent.BossBarOverlay.NOTCHED_10); -- this.random = RandomSource.create(); -+ this.random = world.random; // Gale - Patina - reduce RandomSource instances - this.waveSpawnPos = Optional.empty(); - this.id = id; - this.level = world; -@@ -130,7 +130,7 @@ public class Raid { - - public Raid(ServerLevel world, CompoundTag nbt) { - this.raidEvent = new ServerBossEvent(Raid.RAID_NAME_COMPONENT, BossEvent.BossBarColor.RED, BossEvent.BossBarOverlay.NOTCHED_10); -- this.random = RandomSource.create(); -+ this.random = world.random; // Gale - Patina - reduce RandomSource instances - this.waveSpawnPos = Optional.empty(); - this.level = world; - this.id = nbt.getInt("Id"); -diff --git a/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java -index 68fd5d3f6553af8af867e34946cb8b3f852da985..c8d2a0ae9da26fb5a3c73ec3388ec503122b4af3 100644 ---- a/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java -+++ b/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java -@@ -268,7 +268,7 @@ public class TheEndGatewayBlockEntity extends TheEndPortalBlockEntity { - } - - private static void spawnGatewayPortal(ServerLevel world, BlockPos pos, EndGatewayConfiguration config) { -- Feature.END_GATEWAY.place(config, world, world.getChunkSource().getGenerator(), RandomSource.create(), pos); -+ Feature.END_GATEWAY.place(config, world, world.getChunkSource().getGenerator(), world.random, pos); // Gale - Patina - reduce RandomSource instances - } - - @Override -diff --git a/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java b/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java -index b331c93c82c27f9456fec208a0c008c5bedfa8c4..3a015cc92b3d9cf869bd1e4c48e0831d40e41b85 100644 ---- a/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java -+++ b/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java -@@ -475,7 +475,7 @@ public class EndDragonFight { - this.level.registryAccess().lookup(Registries.CONFIGURED_FEATURE).flatMap((iregistry) -> { - return iregistry.get(EndFeatures.END_GATEWAY_DELAYED); - }).ifPresent((holder_c) -> { -- ((ConfiguredFeature) holder_c.value()).place(this.level, this.level.getChunkSource().getGenerator(), RandomSource.create(), pos); -+ ((ConfiguredFeature) holder_c.value()).place(this.level, this.level.getChunkSource().getGenerator(), this.level.random, pos); // Gale - Patina - reduce RandomSource instances - }); - } - -@@ -493,7 +493,7 @@ public class EndDragonFight { - this.portalLocation = this.portalLocation.atY(this.level.getMinY() + 1); - } - // Paper end - Prevent "softlocked" exit portal generation -- if (worldgenendtrophy.place(FeatureConfiguration.NONE, this.level, this.level.getChunkSource().getGenerator(), RandomSource.create(), this.portalLocation)) { -+ if (worldgenendtrophy.place(FeatureConfiguration.NONE, this.level, this.level.getChunkSource().getGenerator(), this.level.random, this.portalLocation)) { // Gale - Patina - reduce RandomSource instances - int i = Mth.positiveCeilDiv(4, 16); - - this.level.getChunkSource().chunkMap.waitForLightBeforeSending(new ChunkPos(this.portalLocation), i); diff --git a/patches/server/0113-Add-xor-shift-random.patch b/patches/server/0113-Add-xor-shift-random.patch deleted file mode 100644 index 8cb075d..0000000 --- a/patches/server/0113-Add-xor-shift-random.patch +++ /dev/null @@ -1,562 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Martijn Muijsers -Date: Tue, 8 Aug 2023 21:12:58 +0200 -Subject: [PATCH] Add xor-shift random -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -License: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html) -Gale - https://galemc.org - -This patch is based on the following patch: -"Apply faster random" -By: AlphaKR93 -As part of: Plazma (https://github.com/PlazmaMC/Plazma) -Class `org.plazmamc.plazma.Random` licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html) -Other changes licensed under: MIT (https://opensource.org/licenses/MIT) - -* Plazma copyright * - -The MIT License (MIT) - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -diff --git a/src/main/java/com/destroystokyo/paper/loottable/PaperLootableInventoryData.java b/src/main/java/com/destroystokyo/paper/loottable/PaperLootableInventoryData.java -index 861bff267cb397e13e8e1c79bd0776b130c6e5da..30972bf7889973cf63b5f32ad166afdc9800bee1 100644 ---- a/src/main/java/com/destroystokyo/paper/loottable/PaperLootableInventoryData.java -+++ b/src/main/java/com/destroystokyo/paper/loottable/PaperLootableInventoryData.java -@@ -21,7 +21,7 @@ import org.checkerframework.framework.qual.DefaultQualifier; - @DefaultQualifier(NonNull.class) - public class PaperLootableInventoryData { - -- private static final Random RANDOM = new Random(); -+ public static Random RANDOM; // Gale - xor-shift random - set in GaleGlobalConfiguration - - private long lastFill = -1; - private long nextRefill = -1; -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 3f6d60601cbfc138ab004e38bf442d985192fd3f..370266dfa461432b9e22b3ce35d6094949dc2f49 100644 ---- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java -+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java -@@ -132,7 +132,7 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p - this.defaultBlockState = empty ? VOID_AIR_BLOCKSTATE : AIR_BLOCKSTATE; - // Paper end - get block chunk optimisation - -- this.lightningTick = this.level.simpleRandom.nextInt(100000) << 1; // Gale - Airplane - optimize random calls in chunk ticking - initialize lightning tick -+ this.lightningTick = org.galemc.gale.configuration.GaleGlobalConfiguration.get().smallOptimizations.useXorShiftRandom.lightningRandomTick ? new org.galemc.gale.random.XorShiftRandom().nextInt(100000) << 1 : this.level.simpleRandom.nextInt(100000) << 1; // Gale - Airplane - optimize random calls in chunk ticking - initialize lightning tick // Gale - xor-shift random - } - - // CraftBukkit start -diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java -index 16f07007a0f73ec0c6f421c9b082518e87e8cc7b..b26a5b76cd30c96ce15ced5ac51222a8333bde52 100644 ---- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java -+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java -@@ -109,7 +109,7 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche - } - - private void backupRegionFile() { -- Path backup = this.path.getParent().resolve(this.path.getFileName() + "." + new java.util.Random().nextLong() + ".backup"); -+ Path backup = this.path.getParent().resolve(this.path.getFileName() + "." + new org.galemc.gale.random.XorShiftRandom().nextLong() + ".backup"); // Gale - xor-shift random - this.backupRegionFile(backup); - } - -diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index 57da11c0da7322e74810e7108e9c8000b0c36520..d39a0785f42c72d7b32af5c1c8067b2857f22a48 100644 ---- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -@@ -288,7 +288,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { - } - // Paper end - -- private static final Random rand = new Random(); -+ public static Random rand; // Gale - xor-shift random - set in GaleGlobalConfiguration - - public CraftWorld(ServerLevel world, ChunkGenerator gen, BiomeProvider biomeProvider, Environment env) { - this.world = world; -diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java -index 759b6e54db93792c9862b1f1625118ac6fa49d7a..4b5e9bc33c25ac98c32aff1bd13788edf0eeee8c 100644 ---- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java -+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java -@@ -14,7 +14,7 @@ import org.bukkit.inventory.meta.FireworkMeta; - - public class CraftFirework extends CraftProjectile implements Firework { - -- private final Random random = new Random(); -+ private final Random random = org.galemc.gale.configuration.GaleGlobalConfiguration.get().smallOptimizations.useXorShiftRandom.elytraFireworkSpeed ? new org.galemc.gale.random.XorShiftRandom() : new Random(); // Gale - xor-shift random - not thread-safe but it is not really a concern here - //private CraftItemStack item; // Paper - Remove usage, not accurate representation of current item. - - public CraftFirework(CraftServer server, FireworkRocketEntity entity) { -diff --git a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -index 3e5efa90180308cbfaaa063d96ad788985720b8c..c57ebf0f37aba2d118e54f3c71697f29bb9a57a0 100644 ---- a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -+++ b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java -@@ -10,6 +10,7 @@ import org.spongepowered.configurate.objectmapping.meta.PostProcess; - import org.spongepowered.configurate.objectmapping.meta.Setting; - - import java.util.Locale; -+import java.util.Random; - import java.util.function.Consumer; - - @SuppressWarnings({"CanBeFinal", "FieldCanBeLocal", "FieldMayBeFinal", "NotNullFieldNotInitialized", "InnerClassMayBeStatic"}) -@@ -41,13 +42,27 @@ public class GaleGlobalConfiguration extends ConfigurationPart { - - } - -- // Gale start - Pufferfish - SIMD support -- public Simd simd; -- public class Simd extends ConfigurationPart { -- public boolean warnIfDisabled = true; -- public boolean logVectorSizesToConsole = false; -+ // Gale start - xor-shift random -+ public UseXorShiftRandom useXorShiftRandom; -+ public class UseXorShiftRandom extends ConfigurationPart { -+ -+ public boolean autoReplenishLootableRefill = true; -+ public boolean elytraFireworkSpeed = true; -+ public boolean entityWakeUpDuration = true; -+ public boolean lightningRandomTick = true; -+ -+ @Setting("generate-tree-with-bukkit-api") -+ public boolean generateTreeWithBukkitAPI = true; -+ -+ @PostProcess -+ public void postProcess() { -+ com.destroystokyo.paper.loottable.PaperLootableInventoryData.RANDOM = autoReplenishLootableRefill ? new org.galemc.gale.random.XorShiftRandom() : new Random(); -+ org.spigotmc.ActivationRange.wakeUpDurationRandom = entityWakeUpDuration ? new org.galemc.gale.random.XorShiftRandom() : new java.util.Random(); -+ org.bukkit.craftbukkit.CraftWorld.rand = generateTreeWithBukkitAPI ? new org.galemc.gale.random.XorShiftRandom() : new Random(); -+ } -+ - } -- // Gale end - Pufferfish - SIMD support -+ // Gale end - xor-shift random - - } - -diff --git a/src/main/java/org/galemc/gale/random/XorShiftRandom.java b/src/main/java/org/galemc/gale/random/XorShiftRandom.java -new file mode 100644 -index 0000000000000000000000000000000000000000..60dc2c1deb0749168d03c5d94136e613b09ce534 ---- /dev/null -+++ b/src/main/java/org/galemc/gale/random/XorShiftRandom.java -@@ -0,0 +1,404 @@ -+// Gale - xor-shift random -+ -+package org.galemc.gale.random; -+ -+import java.util.Random; -+ -+/** -+ * A random number generator based on the simple and fast xor-shift pseudo -+ * random number generator (RNG) specified in: -+ *
-+ *     Marsaglia, George. (2003). -+ *
Xorshift RNGs. -+ *
-+ * Code from: -+ *
-+ *     Random.java -+ * by Xyene. -+ *
-+ * Translated from: -+ *
-+ *      -+ * A fast equivalent for System.Random by colgreen. -+ *
-+ * Licensed under GNU Lesser General Public License version 3. -+ */ -+public final class XorShiftRandom extends Random { -+ final double REAL_UNIT_INT = 1.0 / (0x7FFFFFFFL); -+ final double REAL_UNIT_UINT = 1.0 / (0xFFFFFFFFL); -+ final long Y = 842502087L, Z = 3579807591L, W = 273326509L; -+ long x, y, z, w; -+ -+ public XorShiftRandom() { -+ seed((int) System.currentTimeMillis()); -+ } -+ -+ @Override -+ public void setSeed(long seed) { -+ seed((int) seed); -+ } -+ -+ public void seed(int seed) { -+ // The only stipulation stated for the xorshift RNG is that at least one of -+ // the seeds x,y,z,w is non-zero. We fulfill that requirement by only allowing -+ // resetting of the x seed -+ x = seed; -+ y = Y; -+ z = Z; -+ w = W; -+ } -+ -+ long boolBuffer; -+ int boolBufferBits = 0; -+ -+ @Override -+ public boolean nextBoolean() { -+ if (boolBufferBits == 0) { -+ boolBuffer = nextUInt(); -+ boolBufferBits = 32; -+ } -+ boolBuffer >>= 1; -+ boolean bit = (boolBuffer & 1) == 0; -+ --boolBufferBits; -+ return bit; -+ } -+ -+ @Override -+ public void nextBytes(byte[] buffer) { -+ // Fill up the bulk of the buffer in chunks of 4 bytes at a time. -+ long x = this.x, y = this.y, z = this.z, w = this.w; -+ int i = 0; -+ long t; -+ for (int bound = buffer.length - 3; i < bound; ) { -+ // Generate 4 bytes. -+ // Increased performance is achieved by generating 4 random bytes per loop. -+ // Also note that no mask needs to be applied to zero out the higher order bytes before -+ // casting because the cast ignores thos bytes. Thanks to Stefan Trosch黷z for pointing this out. -+ t = (x ^ (x << 11)); -+ x = y; -+ y = z; -+ z = w; -+ w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); -+ -+ buffer[i++] = (byte) w; -+ buffer[i++] = (byte) (w >> 8); -+ buffer[i++] = (byte) (w >> 16); -+ buffer[i++] = (byte) (w >> 24); -+ } -+ -+ // Fill up any remaining bytes in the buffer. -+ if (i < buffer.length) { -+ // Generate 4 bytes. -+ t = (x ^ (x << 11)); -+ x = y; -+ y = z; -+ z = w; -+ w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); -+ -+ buffer[i++] = (byte) w; -+ if (i < buffer.length) { -+ buffer[i++] = (byte) (w >> 8); -+ if (i < buffer.length) { -+ buffer[i++] = (byte) (w >> 16); -+ if (i < buffer.length) { -+ buffer[i] = (byte) (w >> 24); -+ } -+ } -+ } -+ } -+ this.x = x; -+ this.y = y; -+ this.z = z; -+ this.w = w; -+ } -+ -+ @Override -+ public double nextDouble() { -+ long t = (x ^ (x << 11)); -+ x = y; -+ y = z; -+ z = w; -+ -+ // Here we can gain a 2x speed improvement by generating a value that can be cast to -+ // an int instead of the more easily available uint. If we then explicitly cast to an -+ // int the compiler will then cast the int to a double to perform the multiplication, -+ // this final cast is a lot faster than casting from a uint to a double. The extra cast -+ // to an int is very fast (the allocated bits remain the same) and so the overall effect -+ // of the extra cast is a significant performance improvement. -+ // -+ // Also note that the loss of one bit of precision is equivalent to what occurs within -+ // System.Random. -+ return (REAL_UNIT_INT * (int) (0x7FFFFFFF & (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8))))); -+ } -+ -+ public double random() { -+ return nextDouble(); -+ } -+ -+ @Override -+ public float nextFloat() { -+ return (float) nextDouble(); -+ } -+ -+ @Override -+ public int nextInt() { -+ long t = (x ^ (x << 11)); -+ x = y; -+ y = z; -+ z = w; -+ return (int) (0x7FFFFFFF & (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)))); -+ } -+ -+ @Override -+ public int nextInt(int upperBound) { -+ if (upperBound < 0) -+ throw new IllegalArgumentException("upperBound must be >=0"); -+ -+ long t = (x ^ (x << 11)); -+ x = y; -+ y = z; -+ z = w; -+ -+ return (int) ((REAL_UNIT_INT * (int) (0x7FFFFFFF & (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8))))) * upperBound); -+ } -+ -+ public int nextInt(int lowerBound, int upperBound) { -+ if (lowerBound > upperBound) -+ throw new IllegalArgumentException("upperBound must be >=lowerBound"); -+ -+ long t = (x ^ (x << 11)); -+ x = y; -+ y = z; -+ z = w; -+ -+ // The explicit int cast before the first multiplication gives better performance. -+ // See comments in NextDouble. -+ int range = upperBound - lowerBound; -+ if (range < 0) { -+ // If range is <0 then an overflow has occured and must resort to using long integer arithmetic instead (slower). -+ // We also must use all 32 bits of precision, instead of the normal 31, which again is slower. -+ return lowerBound + (int) ((REAL_UNIT_UINT * (double) (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)))) * (double) ((long) upperBound - (long) lowerBound)); -+ } -+ // 31 bits of precision will suffice if range<=int.MaxValue. This allows us to cast to an int and gain -+ // a little more performance. -+ return lowerBound + (int) ((REAL_UNIT_INT * (double) (int) (0x7FFFFFFF & (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8))))) * (double) range); -+ } -+ -+ public long nextUInt() { -+ long t = (x ^ (x << 11)); -+ x = y; -+ y = z; -+ z = w; -+ return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8))) & (0xFFFFFFFFL); -+ } -+ -+ @Override -+ public long nextLong() { -+ return nextUInt() << 32 + nextUInt(); -+ } -+ -+ double gaussNext; -+ boolean hasGaussNext; -+ final double TWOPI = Math.PI * 2; -+ -+ /** -+ * Get a random number in the range [min, max) or [min, max] depending on rounding. -+ * -+ * @param min Low bound -+ * @param max High bound -+ * @return A uniformly distributed double -+ */ -+ public double uniform(double min, double max) { -+ return min + (max - min) * nextDouble(); -+ } -+ -+ /** -+ * Triangular distribution. -+ *

-+ * Continuous distribution bounded by given lower and upper limits, -+ * and having a given mode value in-between. -+ * http://en.wikipedia.org/wiki/Triangular_distribution -+ * -+ * @param low Low bound -+ * @param high High bound -+ * @param mode Mode -+ * @return A number from the triangular distribution specified -+ */ -+ public double triangular(int low, int high, int mode) { -+ double u = nextDouble(); -+ double c = (mode - low) / (high - low); -+ if (u > c) { -+ u = 1.0 - u; -+ c = 1.0 - c; -+ int k = low; -+ low = high; -+ high = k; -+ } -+ return low + (high - low) * Math.sqrt(u * c); -+ } -+ -+ /** -+ * Gaussian distribution, mean is 0 and standard deviation is 1. -+ *

-+ * mu is the mean, and sigma is the standard deviation. -+ * -+ * @return A double in Gaussian distribution -+ */ -+ public double gauss() { -+ return nextGaussian(); -+ } -+ -+ /** -+ * Gaussian distribution, with user-specified mean and standard deviation. -+ *

-+ * mu is the mean, and sigma is the standard deviation. -+ * -+ * @return A double in Gaussian distribution -+ */ -+ public double gauss(double mu, double sigma) { -+ return mu + sigma * nextGaussian(); -+ } -+ -+ public double gaussUnsigned(double mu, double sigma) { -+ double out = gauss(mu, sigma); -+ return out > 1 ? out : 1; -+ } -+ -+ /** -+ * Log normal distribution. -+ *

-+ * If you take the natural logarithm of this distribution, you'll get a -+ * normal distribution with mean mu and standard deviation sigma. -+ * mu can have any value, and sigma must be greater than zero. -+ * -+ * @param mu Mean -+ * @param sigma Standard deviation -+ * @return A number from the log normal distribution specified -+ */ -+ public double logNormal(double mu, double sigma) { -+ return Math.exp(gauss(mu, sigma)); -+ } -+ -+ /** -+ * Exponential distribution. -+ *

-+ * lambda is 1.0 divided by the desired mean. It should be -+ * nonzero. Returned values range from 0 to positive infinity -+ * if lambda is positive, and from negative infinity to 0 -+ * if lambda is negative. -+ * -+ * @param lambda A non-zero value -+ */ -+ public double exponential(double lambda) { -+ return -Math.log(1.0 - random()) / lambda; -+ } -+ -+ /** -+ * Circular data distribution. -+ *

-+ * If kappa is equal to zero, this distribution reduces -+ * to a uniform random angle over the range 0 to 2*pi. -+ * -+ * @param mu the mean angle, expressed in radians between 0 and 2*pi. -+ * @param kappa the concentration parameter, which must be greater than or -+ * equal to zero. -+ * @return A number from the circular data distribution specified -+ */ -+ public double circularData(double mu, double kappa) { -+ if (kappa <= 1e-6) -+ return TWOPI * nextDouble(); -+ -+ double a = 1.0 + Math.sqrt(1.0 + 4.0 * kappa * kappa); -+ double b = (a - Math.sqrt(2.0 * a)) / (2.0 * kappa); -+ double r = (1.0 + b * b) / (2.0 * b); -+ double u1, u2, u3, f, c, z, theta = 0; -+ -+ while (true) { -+ u1 = nextDouble(); -+ -+ z = Math.cos(Math.PI * u1); -+ f = (1.0 + r * z) / (r + z); -+ c = kappa * (r - f); -+ -+ u2 = nextDouble(); -+ -+ if (u2 < c * (2.0 - c) || u2 <= c * Math.exp(1.0 - c)) -+ break; -+ -+ u3 = nextDouble(); -+ if (u3 > 0.5) -+ theta = (mu % TWOPI) + Math.acos(f); -+ else -+ theta = (mu % TWOPI) - Math.acos(f); -+ } -+ return theta; -+ } -+ -+ -+ final double LOG4 = Math.log(4); -+ final double SG_MAGICCONST = 1.0 + Math.log(4.5); -+ -+ /** -+ * Gamma distribution. Not the gamma function! -+ * Conditions on the parameters are alpha > 0 and beta > 0. -+ *

-+ * The probability distribution function is: -+ * pdf(x) = (x ** (alpha - 1) * math.exp(-x / beta)) / (math.gamma(alpha) * beta ** alpha) -+ * -+ * @param alpha Alpha -+ * @param beta Beta -+ * @return A number from the gamma distribution specified -+ */ -+ public double gamma(double alpha, double beta) { -+ if (alpha <= 0.0 || beta <= 0.0) -+ throw new IllegalArgumentException("alpha and beta must be > 0.0"); -+ -+ if (alpha > 1.0) { -+ double ainv = Math.sqrt(2.0 * alpha - 1.0); -+ double bbb = alpha - LOG4; -+ double ccc = alpha + ainv; -+ double u1, u2, v, x, z, r; -+ -+ while (true) { -+ u1 = random(); -+ if (!(1e-7 < u1 && u1 < .9999999)) -+ continue; -+ u2 = 1.0 - random(); -+ v = Math.log(u1 / (1.0 - u1)) / ainv; -+ x = alpha * Math.exp(v); -+ z = u1 * u1 * u2; -+ r = bbb + ccc * v - x; -+ if (r + SG_MAGICCONST - 4.5 * z >= 0.0 || r >= Math.log(z)) -+ return x * beta; -+ } -+ } else if (alpha == 1.0) { -+ // exponential(1) -+ double u; -+ u = random(); -+ while (u <= 1e-7) -+ u = random(); -+ return -Math.log(u) * beta; -+ } else { -+ // alpha is between 0 and 1 (exclusive) -+ // Uses ALGORITHM GS of Statistical Computing -Kennedy & Gentle -+ -+ double u, b, p, x, u1; -+ while (true) { -+ u = random(); -+ b = (Math.E + alpha) / Math.E; -+ p = b * u; -+ if (p <= 1.0) -+ x = Math.pow(p, (1.0 / alpha)); -+ else -+ x = -Math.log((b - p) / alpha); -+ u1 = random(); -+ if (p > 1.0) { -+ if (u1 <= Math.pow(x, (alpha - 1.0))) -+ break; -+ } else if (u1 <= Math.exp(-x)) -+ break; -+ } -+ return x * beta; -+ } -+ } -+} -diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java -index f1581caf54012ce4d4b9aecbc56b5b815c67a423..5d1cc9b9150f84bb84cef5dd741e72787c02f089 100644 ---- a/src/main/java/org/spigotmc/ActivationRange.java -+++ b/src/main/java/org/spigotmc/ActivationRange.java -@@ -92,7 +92,7 @@ public class ActivationRange - // Paper end - - // Gale start - variable entity wake-up duration -- private static final java.util.Random wakeUpDurationRandom = new java.util.Random(); -+ public static java.util.Random wakeUpDurationRandom; // Gale - xor-shift random - set in GaleGlobalConfiguration - - private static int getWakeUpDurationWithVariance(Entity entity, int wakeUpDuration) { - double deviation = entity.level().galeConfig().gameplayMechanics.entityWakeUpDurationRatioStandardDeviation; diff --git a/patches/server/0114-Reduce-skull-ItemStack-lookups-for-reduced-visibilit.patch b/patches/server/0114-Reduce-skull-ItemStack-lookups-for-reduced-visibilit.patch deleted file mode 100644 index c7ff1cf..0000000 --- a/patches/server/0114-Reduce-skull-ItemStack-lookups-for-reduced-visibilit.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Martijn Muijsers -Date: Wed, 30 Aug 2023 20:17:20 +0200 -Subject: [PATCH] Reduce skull ItemStack lookups for reduced visibility - -License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) -Gale - https://galemc.org - -This patch is based on the following patch: -"feat: reduce sensor work" -By: peaches94 -As part of: Petal (https://github.com/Bloom-host/Petal) -Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) - -* Petal description * - -this patch is focused around the sensors used for ai -delete the line of sight cache less often and use a faster nearby comparison - -diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index 9551c2b75687bd036aaabd9593df7d96c062ab90..167d164d07285bfff6eb8076d7abe17ca9543df9 100644 ---- a/src/main/java/net/minecraft/world/entity/LivingEntity.java -+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -1050,10 +1050,9 @@ public abstract class LivingEntity extends Entity implements Attackable { - } - - if (entity != null) { -- ItemStack itemstack = this.getItemBySlot(EquipmentSlot.HEAD); - EntityType entitytypes = entity.getType(); - -- if (entitytypes == EntityType.SKELETON && itemstack.is(Items.SKELETON_SKULL) || entitytypes == EntityType.ZOMBIE && itemstack.is(Items.ZOMBIE_HEAD) || entitytypes == EntityType.PIGLIN && itemstack.is(Items.PIGLIN_HEAD) || entitytypes == EntityType.PIGLIN_BRUTE && itemstack.is(Items.PIGLIN_HEAD) || entitytypes == EntityType.CREEPER && itemstack.is(Items.CREEPER_HEAD)) { -+ if (entitytypes == EntityType.SKELETON && this.getItemBySlot(EquipmentSlot.HEAD).is(Items.SKELETON_SKULL) || entitytypes == EntityType.ZOMBIE && this.getItemBySlot(EquipmentSlot.HEAD).is(Items.ZOMBIE_HEAD) || entitytypes == EntityType.PIGLIN && this.getItemBySlot(EquipmentSlot.HEAD).is(Items.PIGLIN_HEAD) || entitytypes == EntityType.PIGLIN_BRUTE && this.getItemBySlot(EquipmentSlot.HEAD).is(Items.PIGLIN_HEAD) || entitytypes == EntityType.CREEPER && this.getItemBySlot(EquipmentSlot.HEAD).is(Items.CREEPER_HEAD)) { // Gale - Petal - reduce skull ItemStack lookups for reduced visibility - d0 *= 0.5D; - } - } diff --git a/patches/server/0118-Virtual-thread-support.patch b/patches/server/0118-Virtual-thread-support.patch deleted file mode 100644 index 03d1c00..0000000 --- a/patches/server/0118-Virtual-thread-support.patch +++ /dev/null @@ -1,282 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Martijn Muijsers -Date: Wed, 9 Aug 2023 15:04:56 +0200 -Subject: [PATCH] Virtual thread support - -License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) -Gale - https://galemc.org - -diff --git a/src/main/java/com/destroystokyo/paper/Metrics.java b/src/main/java/com/destroystokyo/paper/Metrics.java -index 1f158ed7ed5c115e892311d5f72a9131659f9d65..f21106b0897dd6e373970f32f5dd269418528977 100644 ---- a/src/main/java/com/destroystokyo/paper/Metrics.java -+++ b/src/main/java/com/destroystokyo/paper/Metrics.java -@@ -976,6 +976,22 @@ public class Metrics { - })); - // Gale end - SIMD support - include in metrics - -+ // Gale start - virtual thread support - include in metrics -+ Map> virtualThreadSupportMap = new HashMap<>(2); -+ { -+ Map entry = new HashMap<>(2); -+ boolean isSupported = org.galemc.gale.virtualthread.VirtualThreadService.isSupported(); -+ try { -+ int javaMajorVersion = org.galemc.gale.virtualthread.VirtualThreadService.getJavaMajorVersion(); -+ entry.put(isSupported + " (Java " + javaMajorVersion + ")", 1); -+ } catch (Exception ignored) { -+ entry.put(String.valueOf(isSupported), 1); -+ } -+ virtualThreadSupportMap.put(String.valueOf(isSupported), entry); -+ } -+ metrics.addCustomChart(new Metrics.DrilldownPie("virtual_thread_support", () -> virtualThreadSupportMap)); -+ // Gale end - virtual thread support - include in metrics -+ - } - - } -diff --git a/src/main/java/org/galemc/gale/virtualthread/DirectVirtualThreadService.java b/src/main/java/org/galemc/gale/virtualthread/DirectVirtualThreadService.java -new file mode 100644 -index 0000000000000000000000000000000000000000..38d3b77f3f8d582ce6732afab7e6787d6d0a0ead ---- /dev/null -+++ b/src/main/java/org/galemc/gale/virtualthread/DirectVirtualThreadService.java -@@ -0,0 +1,50 @@ -+// Gale - virtual thread support -+ -+package org.galemc.gale.virtualthread; -+ -+import org.jetbrains.annotations.NotNull; -+ -+import java.util.Objects; -+import java.util.concurrent.ThreadFactory; -+ -+/** -+ * An implementation of {@link VirtualThreadService} that can create virtual threads directly. -+ * -+ * @author Martijn Muijsers -+ */ -+final class DirectVirtualThreadService extends VirtualThreadService { -+ -+ private DirectVirtualThreadService() { -+ super(); -+ } -+ -+ @Override -+ public @NotNull ThreadFactory createFactory() { -+ // Disabled until Minecraft requires servers to have a Java version that can read class files compiled with functionality from Java 19+ on preview / Java 21+ on stable -+ //throw new UnsupportedOperationException(); -+ return Thread.ofVirtual().factory(); -+ } -+ -+ @Override -+ public @NotNull Thread start(@NotNull Runnable task) { -+ // Disabled until Minecraft requires servers to have a Java version that can read class files compiled with functionality from Java 19+ on preview / Java 21+ on stable -+ //throw new UnsupportedOperationException(); -+ Objects.requireNonNull(task, "The task to start a virtual thread cannot be null"); -+ return Thread.ofVirtual().start(task); -+ } -+ -+ /** -+ * @return A functional {@link DirectVirtualThreadService}. -+ * @throws Throwable If creating virtual threads directly is not supported by the current runtime. -+ * This could be any {@link Throwable}, including an {@link Exception} or an {@link Error}. -+ */ -+ static @NotNull DirectVirtualThreadService create() throws Throwable { -+ // Disabled until Minecraft requires servers to have a Java version that can read class files compiled with functionality from Java 19+ on preview / Java 21+ on stable -+ //throw new UnsupportedOperationException(); -+ var service = new DirectVirtualThreadService(); -+ // Run some tests to verify -+ service.runTest(); -+ // If we end up here, it works -+ return service; -+ } -+} -diff --git a/src/main/java/org/galemc/gale/virtualthread/ReflectionVirtualThreadService.java b/src/main/java/org/galemc/gale/virtualthread/ReflectionVirtualThreadService.java -new file mode 100644 -index 0000000000000000000000000000000000000000..19b83cf45034be57d11413361b1b0c8756b12a29 ---- /dev/null -+++ b/src/main/java/org/galemc/gale/virtualthread/ReflectionVirtualThreadService.java -@@ -0,0 +1,75 @@ -+// Gale - virtual thread support -+ -+package org.galemc.gale.virtualthread; -+ -+import org.jetbrains.annotations.NotNull; -+ -+import java.lang.reflect.Method; -+import java.util.Objects; -+import java.util.concurrent.ThreadFactory; -+ -+/** -+ * An implementation of {@link VirtualThreadService} that can create virtual threads using Java reflection. -+ * -+ * @author Martijn Muijsers -+ */ -+final class ReflectionVirtualThreadService extends VirtualThreadService { -+ -+ /** -+ * The {@link Thread}#ofVirtual() method. -+ */ -+ private final @NotNull Method Thread_ofVirtual_method; -+ -+ /** -+ * The {@link Thread}.Builder#factory() method. -+ */ -+ private final @NotNull Method Thread_Builder_factory_method; -+ -+ /** -+ * The {@link Thread}.Builder#start(Runnable) method. -+ */ -+ private final @NotNull Method Thread_Builder_start_method; -+ -+ private ReflectionVirtualThreadService() throws Throwable { -+ this.Thread_ofVirtual_method = Objects.requireNonNull(Thread.class.getMethod("ofVirtual")); -+ // The Thread.Builder class -+ var Thread_Builder_class = Objects.requireNonNull(Class.forName("java.lang.Thread$Builder")); -+ this.Thread_Builder_factory_method = Objects.requireNonNull(Thread_Builder_class.getMethod("factory")); -+ this.Thread_Builder_start_method = Objects.requireNonNull(Thread_Builder_class.getMethod("start", Runnable.class)); -+ } -+ -+ @Override -+ public @NotNull ThreadFactory createFactory() { -+ try { -+ return (ThreadFactory) this.Thread_Builder_factory_method.invoke(this.Thread_ofVirtual_method.invoke(null)); -+ } catch (Exception e) { -+ // This should not be possible because it was tested in create() -+ throw new RuntimeException(e); -+ } -+ } -+ -+ @Override -+ public @NotNull Thread start(@NotNull Runnable task) { -+ Objects.requireNonNull(task, "The task to start a virtual thread cannot be null"); -+ try { -+ return (Thread) this.Thread_Builder_start_method.invoke(this.Thread_ofVirtual_method.invoke(null), task); -+ } catch (Exception e) { -+ // This should not be possible because it was tested in create() -+ throw new RuntimeException(e); -+ } -+ } -+ -+ /** -+ * @return A functional {@link ReflectionVirtualThreadService}. -+ * @throws Throwable If creating virtual threads via reflection is not supported by the current runtime. -+ * This could be any {@link Throwable}, including an {@link Exception} or an {@link Error}. -+ */ -+ static @NotNull ReflectionVirtualThreadService create() throws Throwable { -+ // This will already throw something if the reflection fails -+ var service = new ReflectionVirtualThreadService(); -+ // Run some tests to verify -+ service.runTest(); -+ // If we end up here, it works -+ return service; -+ } -+} -diff --git a/src/main/java/org/galemc/gale/virtualthread/VirtualThreadService.java b/src/main/java/org/galemc/gale/virtualthread/VirtualThreadService.java -new file mode 100644 -index 0000000000000000000000000000000000000000..e9757e8ade7198accb7cf34390ed70628a0f7e33 ---- /dev/null -+++ b/src/main/java/org/galemc/gale/virtualthread/VirtualThreadService.java -@@ -0,0 +1,104 @@ -+// Gale - virtual thread support -+ -+package org.galemc.gale.virtualthread; -+ -+import org.jetbrains.annotations.NotNull; -+import org.jetbrains.annotations.Nullable; -+ -+import java.util.concurrent.ThreadFactory; -+ -+/** -+ * An abstract service to create virtual threads. -+ * -+ * @author Martijn Muijsers -+ */ -+public sealed abstract class VirtualThreadService permits ReflectionVirtualThreadService, DirectVirtualThreadService { -+ -+ /** -+ * @return A {@link ThreadFactory} that produces virtual threads. -+ */ -+ public abstract @NotNull ThreadFactory createFactory(); -+ -+ /** -+ * @param task The runnable for the thread to execute. -+ * @return A virtual thread that has been started with the given task. -+ */ -+ public abstract @NotNull Thread start(Runnable task); -+ -+ /** -+ * Runs a test on the {@link #createFactory} and {@link #start} methods, -+ * which certainly throws some {@link Throwable} if something goes wrong. -+ */ -+ protected void runTest() throws Throwable { -+ // This will definitely throw something if it doesn't work -+ try { -+ this.start(() -> {}).join(); -+ } catch (InterruptedException ignored) {} // Except InterruptedException, we don't care about that one -+ try { -+ var thread = this.createFactory().newThread(() -> {}); -+ thread.start(); -+ thread.join(); -+ } catch (InterruptedException ignored) {} // Except InterruptedException, we don't care about that one -+ // If we end up here, it works -+ } -+ -+ private static boolean initialized = false; -+ -+ /** -+ * The {@link VirtualThreadService} for the current runtime, -+ * or null if virtual threads are not supported, or if not {@link #initialized} yet. -+ */ -+ private static @Nullable VirtualThreadService implementation; -+ -+ /** -+ * @return Whether virtual threads are supported on the current runtime. -+ */ -+ public static boolean isSupported() { -+ return get() != null; -+ } -+ -+ /** -+ * @return The {@link VirtualThreadService} for the current runtime, -+ * or null if virtual threads are not {@linkplain #isSupported() supported}. -+ * -+ * This method is thread-safe only after the first time it has been fully run. -+ */ -+ public static @Nullable VirtualThreadService get() { -+ if (!initialized) { -+ initialized = true; -+ try { -+ implementation = DirectVirtualThreadService.create(); -+ } catch (Throwable ignored) { -+ try { -+ implementation = ReflectionVirtualThreadService.create(); -+ } catch (Throwable ignored2) {} -+ } -+ } -+ return implementation; -+ } -+ -+ /** -+ * The minimum major version of Java that is known to support using virtual threads -+ * (although possibly behind a feature preview flag). -+ */ -+ public static final int minimumJavaMajorVersionWithFeaturePreview = 19; -+ -+ /** -+ * The minimum major version of Java that is known to support using virtual threads -+ * even without any feature preview flags. -+ */ -+ public static final int minimumJavaMajorVersionWithoutFeaturePreview = 21; -+ -+ public static int getJavaMajorVersion() { -+ var version = System.getProperty("java.version"); -+ if (version.startsWith("1.")) { -+ return version.charAt(2) - '0'; -+ } -+ if (version.contains("-")) { -+ version = version.substring(0, version.indexOf("-")); -+ } -+ -+ int dotIndex = version.indexOf("."); -+ return Integer.parseInt(dotIndex == -1 ? version : version.substring(0, dotIndex)); -+ } -+} diff --git a/settings.gradle.kts b/settings.gradle.kts index e2287b5..1bf4074 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -9,7 +9,7 @@ pluginManagement { } plugins { - id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0" + id("org.gradle.toolchains.foojay-resolver-convention") version "0.9.0" } if (!file(".git").exists()) { @@ -24,9 +24,9 @@ if (!file(".git").exists()) { zip from GitHub. Built Gale jars are available for download at - https://github.com/GaleMC/Gale/actions + https://github.com/Dreeam-qwq/Gale/actions - See https://github.com/PaperMC/Paper/blob/master/CONTRIBUTING.md + See https://github.com/PaperMC/Paper/blob/main/CONTRIBUTING.md for further information on building and modifying Paper forks. =================================================== """.trimIndent() @@ -36,8 +36,26 @@ if (!file(".git").exists()) { rootProject.name = "gale" // Gale - build changes -for (name in listOf("gale-api", "gale-server", "paper-api-generator")) { // Gale - build changes +for (name in listOf("gale-api", "gale-server",)) { // Gale - build changes val projName = name.lowercase(Locale.ENGLISH) include(projName) findProject(":$projName")!!.projectDir = file(name) -} \ No newline at end of file +} + +optionalInclude("paper-api-generator") + +fun optionalInclude(name: String, op: (ProjectDescriptor.() -> Unit)? = null) { + val settingsFile = file("$name.settings.gradle.kts") + if (settingsFile.exists()) { + apply(from = settingsFile) + findProject(":$name")?.let { op?.invoke(it) } + } else { + settingsFile.writeText( + """ + // Uncomment to enable the '$name' project + // include(":$name") + + """.trimIndent() + ) + } +}