From f40d34009267483c7262d889a68aa8340125f49a Mon Sep 17 00:00:00 2001 From: violetc <58360096+s-yh-china@users.noreply.github.com> Date: Mon, 20 May 2024 23:03:56 +0800 Subject: [PATCH] 1.20.6 (#216) --------- Co-authored-by: MC_XiaoHei Co-authored-by: Bluemangoo --- .github/workflows/leaves.yml | 169 +++-- .github/workflows/test.yml | 26 +- README.md | 10 +- README_cn.md | 10 +- build.gradle.kts | 72 +- gradle.properties | 13 +- patches/api/0001-Leaves-Server-Config.patch | 4 +- patches/api/0003-Add-fakeplayer-api.patch | 127 ++-- .../api/0004-Player-operation-limiter.patch | 8 +- ...Hide-irrelevant-compilation-warnings.patch | 6 +- patches/api/0006-SIMD-support.patch | 6 +- ...imings.patch => 0007-Delete-Timings.patch} | 20 +- patches/api/0007-Leaves-API-publish.patch | 26 - ... => 0008-Force-peaceful-mode-switch.patch} | 4 +- ...od-API.patch => 0009-Replay-Mod-API.patch} | 61 +- .../0010-Placeholder-for-Bytebuf-API.patch | 15 + patches/server/0001-Build-changes.patch | 117 +-- patches/server/0002-Dev-Fix.patch | 19 + ...imings.patch => 0003-Delete-Timings.patch} | 382 ++++------ ...s.patch => 0004-Leaves-Server-Utils.patch} | 52 +- .../0004-Update-version-fetcher-repo.patch | 134 ---- .../0005-Update-version-fetcher-repo.patch | 173 +++++ ...06-Leaves-Server-Config-And-Command.patch} | 234 +++--- ....patch => 0007-Leaves-Protocol-Core.patch} | 271 ++++--- ...tch => 0008-Fix-gravity-block-duper.patch} | 10 +- ...h => 0009-Fix-trading-with-the-void.patch} | 4 +- ...owball-and-egg-can-knockback-player.patch} | 8 +- ...rt.patch => 0011-Fakeplayer-support.patch} | 707 +++++++++--------- ...ears-in-dispenser-can-unlimited-use.patch} | 14 +- ...atch => 0013-Redstone-Shears-Wrench.patch} | 18 +- ...dd-isShrink-to-EntityResurrectEvent.patch} | 6 +- ...Budding-Amethyst-can-push-by-piston.patch} | 12 +- .../0015-Spectator-dont-get-Advancement.patch | 30 - .../0016-Spectator-dont-get-Advancement.patch | 22 + ...ck-can-change-ArmorStand-arm-status.patch} | 6 +- ...e.patch => 0018-Fix-tripwire-update.patch} | 4 +- ...hat-sign.patch => 0019-No-chat-sign.patch} | 88 +-- ...20-Dont-send-useless-entity-packets.patch} | 10 +- ...0021-Optimize-entity-coordinate-key.patch} | 8 +- ....patch => 0022-Optimize-suffocation.patch} | 8 +- ...heck-for-spooky-season-once-an-hour.patch} | 18 +- ...e-ThreadUnsafeRandom-Initialization.patch} | 8 +- ...imize-random-calls-in-chunk-ticking.patch} | 22 +- ...urn-optimization-for-target-finding.patch} | 4 +- ...read-unsafe-random-for-mob-spawning.patch} | 6 +- ...8-Config-to-disable-method-profiler.patch} | 12 +- ...al-selector-during-inactive-ticking.patch} | 6 +- ...h => 0030-Reduce-entity-allocations.patch} | 18 +- ...31-Remove-lambda-from-ticking-guard.patch} | 6 +- ...e-iterators-from-inventory-contains.patch} | 36 +- ...eams-and-iterators-from-range-check.patch} | 6 +- ...Cache-climbing-check-for-activation.patch} | 6 +- ...-aging-cache-for-biome-temperatures.patch} | 18 +- ...e-entity-fluid-lookups-if-no-fluids.patch} | 12 +- ...> 0037-Reduce-chunk-loading-lookups.patch} | 6 +- ...038-Placeholder-of-PCA-sync-protocol.patch | 15 + .../0039-Placeholder-of-BBOR-Protocol.patch | 15 + ...40-InstantBlockUpdater-Reintroduced.patch} | 10 +- ...dom-flatten-triangular-distribution.patch} | 4 +- .../0042-Placeholder-of-Jade-Protocol.patch | 15 + ...lternative-block-placement-Protocol.patch} | 53 +- ...ch => 0044-Player-operation-limiter.patch} | 31 +- ...ytra.patch => 0045-Renewable-Elytra.patch} | 14 +- ...atch => 0046-Stackable-ShulkerBoxes.patch} | 193 ++--- ...047-Improve-fluid-direction-caching.patch} | 18 +- ... => 0048-MC-Technical-Survival-Mode.patch} | 78 +- ...ch => 0049-Return-nether-portal-fix.patch} | 60 +- ...ol.patch => 0050-Appleskin-Protocol.patch} | 25 +- ...ol.patch => 0051-Xaero-Map-Protocol.patch} | 29 +- ...0052-Leaves-Extra-Yggdrasil-Service.patch} | 39 +- ...h => 0053-Use-vanilla-random-config.patch} | 30 +- ...> 0054-Fix-update-suppression-crash.patch} | 50 +- ...st.patch => 0055-Bedrock-break-list.patch} | 56 +- ....patch => 0056-Fix-trapdoor-feature.patch} | 2 +- ...-Placeholder-for-Syncmatica-Protocol.patch | 15 + ...-distance-check-for-UseItemOnPacket.patch} | 10 +- ... => 0059-No-feather-falling-trample.patch} | 16 +- ...h => 0060-Shared-villager-discounts.patch} | 4 +- ...1-Disable-check-out-of-order-command.patch | 19 - ...ne-wire-dont-connect-if-on-trapdoor.patch} | 12 +- ...2-Disable-check-out-of-order-command.patch | 19 + ...=> 0063-Despawn-enderman-with-block.patch} | 6 +- ...laceholder-for-Leaves-carpet-support.patch | 15 + ....patch => 0065-Creative-fly-no-clip.patch} | 34 +- ...ch => 0066-Optimized-dragon-respawn.patch} | 14 +- ...ment-mending-compatibility-infinity.patch} | 6 +- ...ers.patch => 0068-Shave-snow-layers.patch} | 47 +- ...re-lc.patch => 0069-Spawn-ignore-lc.patch} | 10 +- ...70-Elytra-aeronautics-no-chunk-load.patch} | 51 +- ...dds.patch => 0071-Cache-ignite-odds.patch} | 4 +- ...-riptide.patch => 0072-Lava-riptide.patch} | 14 +- ...tch => 0073-No-block-update-command.patch} | 46 +- ...0073-Raider-die-skip-self-raid-check.patch | 19 - .../0074-Container-open-passthrough.patch | 36 - ...0074-Raider-die-skip-self-raid-check.patch | 19 + .../0075-Container-open-passthrough.patch | 55 ++ ...76-Placeholder-for-Bladeren-Protocol.patch | 15 + ...lder-for-Bladeren-mspt-sync-protocol.patch | 15 + ...-support.patch => 0078-SIMD-support.patch} | 6 +- ...ont-respond-ping-before-start-fully.patch} | 4 +- ... => 0080-Faster-chunk-serialization.patch} | 16 +- ...ld-generation-chunk-and-block-access.patch | 198 ----- ...ld-generation-chunk-and-block-access.patch | 88 +++ ...082-Cache-world-generator-sea-level.patch} | 4 +- ...Skip-secondary-POI-sensor-if-absent.patch} | 4 +- ...84-Cache-CubeVoxelShape-shape-array.patch} | 4 +- ...> 0085-Store-mob-counts-in-an-array.patch} | 6 +- ...> 0086-Cache-BlockStatePairKey-hash.patch} | 8 +- ...h => 0087-Optimize-noise-generation.patch} | 16 +- ....patch => 0088-Disable-packet-limit.patch} | 6 +- ...ch => 0089-Reduce-array-allocations.patch} | 250 ++++--- ...atch => 0090-Optimize-sun-burn-tick.patch} | 22 +- ...-Optional-allocation-in-EntityBased.patch} | 4 +- .../0091-Use-optimized-collection.patch | 169 ----- ...signableFrom-call-in-ClassInstanceMu.patch | 4 +- .../0093-Optimized-CubePointRange.patch | 6 +- ...ck-frozen-ticks-before-landing-block.patch | 8 +- .../0095-Cache-ominous-banner-item.patch | 81 -- ...kip-entity-move-if-movement-is-zero.patch} | 10 +- ...6-Skip-cloning-advancement-criteria.patch} | 6 +- ...ible-planar-movement-multiplication.patch} | 8 +- ...8-Fix-villagers-dont-release-memory.patch} | 6 +- ...h => 0099-Avoid-anvil-too-expensive.patch} | 6 +- patches/server/0100-Bow-infinity-fix.patch | 20 + patches/server/0101-Bow-infinity-fix.patch | 19 - ...ants.patch => 0101-Zero-tick-plants.patch} | 28 +- ...patch => 0102-Leaves-update-command.patch} | 34 +- ... => 0103-Force-peaceful-mode-switch.patch} | 46 +- ...atch => 0104-Add-Leaves-Auto-Update.patch} | 12 +- ...od-API.patch => 0105-Replay-Mod-API.patch} | 328 ++++---- ...Fix-vehicle-teleport-by-end-gateway.patch} | 4 +- ...aves-I18n.patch => 0107-Leaves-I18n.patch} | 8 +- ...raft-hopper-not-work-without-player.patch} | 4 +- ...r.patch => 0109-Wool-Hopper-Counter.patch} | 111 +-- ...G-Fishing.patch => 0110-RNG-Fishing.patch} | 16 +- ...patch => 0111-Leaves-Reload-Command.patch} | 30 +- ...=> 0112-Spider-jockeys-drop-gapples.patch} | 10 +- ...rade.patch => 0113-Force-Void-Trade.patch} | 73 +- ...0114-Placeholder-for-Servux-Protocol.patch | 15 + ...=> 0115-Villager-infinite-discounts.patch} | 12 +- ...atch => 0116-CCE-update-suppression.patch} | 14 +- ...7-Disable-offline-warn-if-use-proxy.patch} | 4 +- ...118-Disable-moved-wrongly-threshold.patch} | 18 +- ...r-stand-cant-kill-by-mob-projectile.patch} | 6 +- ...atch => 0120-Make-Item-tick-vanilla.patch} | 6 +- ...atch => 0121-Copper-Bulb-1-gt-delay.patch} | 12 +- patches/server/0122-Crafter-1-gt-delay.patch | 28 + patches/server/0123-Crafter-1-gt-delay.patch | 45 -- ...h => 0123-Linear-region-file-format.patch} | 336 ++++----- ...g.patch => 0124-Protection-stacking.patch} | 6 +- ...e.patch => 0125-No-TNT-place-update.patch} | 8 +- ...ed-hopper-no-longer-send-NC-updates.patch} | 4 +- ...e.patch => 0127-Renewable-deepslate.patch} | 10 +- ...ges.patch => 0128-Renewable-sponges.patch} | 10 +- ...coral.patch => 0129-Renewable-coral.patch} | 28 +- ...st-resume.patch => 0130-Fast-resume.patch} | 28 +- ...hopper.patch => 0131-Vanilla-hopper.patch} | 8 +- ...tch => 0132-Force-minecraft-command.patch} | 17 +- ...-Fix-falling-block-s-block-location.patch} | 6 +- ...4-Fix-NPE-during-creating-GUI-graph.patch} | 0 patches/server/0136-Fix-next-steps.patch | 32 - .../api/0011-Bytebuf-API.patch | 12 +- .../server/0037-PCA-sync-protocol.patch | 84 +-- .../server/0038-BBOR-Protocol.patch | 20 +- .../server/0041-Jade-Protocol.patch | 14 +- .../server/0056-Syncmatica-Protocol.patch | 206 ++--- .../server/0063-Leaves-carpet-support.patch | 16 +- .../server/0075-Bladeren-Protocol.patch | 14 +- .../0076-Bladeren-mspt-sync-protocol.patch | 14 +- .../server/0115-Servux-Protocol.patch | 18 +- .../server/0137-Bytebuf-API.patch | 0 scripts/GetBuildNumber.sh | 14 + scripts/GetReleaseInfo.sh | 5 + settings.gradle.kts | 4 + 174 files changed, 3532 insertions(+), 3561 deletions(-) rename patches/api/{0008-Delete-Timings.patch => 0007-Delete-Timings.patch} (99%) delete mode 100644 patches/api/0007-Leaves-API-publish.patch rename patches/api/{0009-Force-peaceful-mode-switch.patch => 0008-Force-peaceful-mode-switch.patch} (83%) rename patches/api/{0010-Replay-Mod-API.patch => 0009-Replay-Mod-API.patch} (62%) create mode 100644 patches/api/0010-Placeholder-for-Bytebuf-API.patch create mode 100644 patches/server/0002-Dev-Fix.patch rename patches/server/{0002-Delete-Timings.patch => 0003-Delete-Timings.patch} (86%) rename patches/server/{0003-Leaves-Server-Utils.patch => 0004-Leaves-Server-Utils.patch} (81%) delete mode 100644 patches/server/0004-Update-version-fetcher-repo.patch create mode 100644 patches/server/0005-Update-version-fetcher-repo.patch rename patches/server/{0005-Leaves-Server-Config-And-Command.patch => 0006-Leaves-Server-Config-And-Command.patch} (88%) rename patches/server/{0006-Leaves-Protocol-Core.patch => 0007-Leaves-Protocol-Core.patch} (67%) rename patches/server/{0007-Fix-gravity-block-duper.patch => 0008-Fix-gravity-block-duper.patch} (85%) rename patches/server/{0008-Fix-trading-with-the-void.patch => 0009-Fix-trading-with-the-void.patch} (91%) rename patches/server/{0009-Make-snowball-and-egg-can-knockback-player.patch => 0010-Make-snowball-and-egg-can-knockback-player.patch} (89%) rename patches/server/{0010-Fakeplayer-support.patch => 0011-Fakeplayer-support.patch} (82%) rename patches/server/{0011-Make-shears-in-dispenser-can-unlimited-use.patch => 0012-Make-shears-in-dispenser-can-unlimited-use.patch} (63%) rename patches/server/{0012-Redstone-Shears-Wrench.patch => 0013-Redstone-Shears-Wrench.patch} (92%) rename patches/server/{0013-Add-isShrink-to-EntityResurrectEvent.patch => 0014-Add-isShrink-to-EntityResurrectEvent.patch} (87%) rename patches/server/{0014-Budding-Amethyst-can-push-by-piston.patch => 0015-Budding-Amethyst-can-push-by-piston.patch} (84%) delete mode 100644 patches/server/0015-Spectator-dont-get-Advancement.patch create mode 100644 patches/server/0016-Spectator-dont-get-Advancement.patch rename patches/server/{0016-Stick-can-change-ArmorStand-arm-status.patch => 0017-Stick-can-change-ArmorStand-arm-status.patch} (82%) rename patches/server/{0017-Fix-tripwire-update.patch => 0018-Fix-tripwire-update.patch} (88%) rename patches/server/{0018-No-chat-sign.patch => 0019-No-chat-sign.patch} (71%) rename patches/server/{0019-Dont-send-useless-entity-packets.patch => 0020-Dont-send-useless-entity-packets.patch} (89%) rename patches/server/{0020-Optimize-entity-coordinate-key.patch => 0021-Optimize-entity-coordinate-key.patch} (83%) rename patches/server/{0021-Optimize-suffocation.patch => 0022-Optimize-suffocation.patch} (86%) rename patches/server/{0022-Only-check-for-spooky-season-once-an-hour.patch => 0023-Only-check-for-spooky-season-once-an-hour.patch} (79%) rename patches/server/{0023-Move-ThreadUnsafeRandom-Initialization.patch => 0024-Move-ThreadUnsafeRandom-Initialization.patch} (90%) rename patches/server/{0024-Optimize-random-calls-in-chunk-ticking.patch => 0025-Optimize-random-calls-in-chunk-ticking.patch} (85%) rename patches/server/{0025-Early-return-optimization-for-target-finding.patch => 0026-Early-return-optimization-for-target-finding.patch} (92%) rename patches/server/{0026-Use-thread-unsafe-random-for-mob-spawning.patch => 0027-Use-thread-unsafe-random-for-mob-spawning.patch} (90%) rename patches/server/{0027-Config-to-disable-method-profiler.patch => 0028-Config-to-disable-method-profiler.patch} (76%) rename patches/server/{0028-Throttle-goal-selector-during-inactive-ticking.patch => 0029-Throttle-goal-selector-during-inactive-ticking.patch} (81%) rename patches/server/{0029-Reduce-entity-allocations.patch => 0030-Reduce-entity-allocations.patch} (68%) rename patches/server/{0030-Remove-lambda-from-ticking-guard.patch => 0031-Remove-lambda-from-ticking-guard.patch} (91%) rename patches/server/{0031-Remove-iterators-from-inventory-contains.patch => 0032-Remove-iterators-from-inventory-contains.patch} (66%) rename patches/server/{0032-Remove-streams-and-iterators-from-range-check.patch => 0033-Remove-streams-and-iterators-from-range-check.patch} (92%) rename patches/server/{0033-Cache-climbing-check-for-activation.patch => 0034-Cache-climbing-check-for-activation.patch} (90%) rename patches/server/{0034-Use-aging-cache-for-biome-temperatures.patch => 0035-Use-aging-cache-for-biome-temperatures.patch} (92%) rename patches/server/{0035-Reduce-entity-fluid-lookups-if-no-fluids.patch => 0036-Reduce-entity-fluid-lookups-if-no-fluids.patch} (95%) rename patches/server/{0036-Reduce-chunk-loading-lookups.patch => 0037-Reduce-chunk-loading-lookups.patch} (91%) create mode 100644 patches/server/0038-Placeholder-of-PCA-sync-protocol.patch create mode 100644 patches/server/0039-Placeholder-of-BBOR-Protocol.patch rename patches/server/{0039-InstantBlockUpdater-Reintroduced.patch => 0040-InstantBlockUpdater-Reintroduced.patch} (82%) rename patches/server/{0040-Random-flatten-triangular-distribution.patch => 0041-Random-flatten-triangular-distribution.patch} (87%) create mode 100644 patches/server/0042-Placeholder-of-Jade-Protocol.patch rename patches/server/{0042-Alternative-block-placement-Protocol.patch => 0043-Alternative-block-placement-Protocol.patch} (91%) rename patches/server/{0043-Player-operation-limiter.patch => 0044-Player-operation-limiter.patch} (85%) rename patches/server/{0044-Renewable-Elytra.patch => 0045-Renewable-Elytra.patch} (78%) rename patches/server/{0045-Stackable-ShulkerBoxes.patch => 0046-Stackable-ShulkerBoxes.patch} (68%) rename patches/server/{0046-Improve-fluid-direction-caching.patch => 0047-Improve-fluid-direction-caching.patch} (93%) rename patches/server/{0047-MC-Technical-Survival-Mode.patch => 0048-MC-Technical-Survival-Mode.patch} (79%) rename patches/server/{0048-Return-nether-portal-fix.patch => 0049-Return-nether-portal-fix.patch} (86%) rename patches/server/{0049-Appleskin-Protocol.patch => 0050-Appleskin-Protocol.patch} (83%) rename patches/server/{0050-Xaero-Map-Protocol.patch => 0051-Xaero-Map-Protocol.patch} (73%) rename patches/server/{0051-Leaves-Extra-Yggdrasil-Service.patch => 0052-Leaves-Extra-Yggdrasil-Service.patch} (87%) rename patches/server/{0052-Use-vanilla-random-config.patch => 0053-Use-vanilla-random-config.patch} (79%) rename patches/server/{0053-Fix-update-suppression-crash.patch => 0054-Fix-update-suppression-crash.patch} (71%) rename patches/server/{0054-Bedrock-break-list.patch => 0055-Bedrock-break-list.patch} (82%) rename patches/server/{0055-Fix-trapdoor-feature.patch => 0056-Fix-trapdoor-feature.patch} (94%) create mode 100644 patches/server/0057-Placeholder-for-Syncmatica-Protocol.patch rename patches/server/{0057-Disable-distance-check-for-UseItemOnPacket.patch => 0058-Disable-distance-check-for-UseItemOnPacket.patch} (58%) rename patches/server/{0058-No-feather-falling-trample.patch => 0059-No-feather-falling-trample.patch} (66%) rename patches/server/{0059-Shared-villager-discounts.patch => 0060-Shared-villager-discounts.patch} (90%) delete mode 100644 patches/server/0061-Disable-check-out-of-order-command.patch rename patches/server/{0060-Redstone-wire-dont-connect-if-on-trapdoor.patch => 0061-Redstone-wire-dont-connect-if-on-trapdoor.patch} (75%) create mode 100644 patches/server/0062-Disable-check-out-of-order-command.patch rename patches/server/{0062-Despawn-enderman-with-block.patch => 0063-Despawn-enderman-with-block.patch} (79%) create mode 100644 patches/server/0064-Placeholder-for-Leaves-carpet-support.patch rename patches/server/{0064-Creative-fly-no-clip.patch => 0065-Creative-fly-no-clip.patch} (88%) rename patches/server/{0065-Optimized-dragon-respawn.patch => 0066-Optimized-dragon-respawn.patch} (93%) rename patches/server/{0066-Enchantment-mending-compatibility-infinity.patch => 0067-Enchantment-mending-compatibility-infinity.patch} (79%) rename patches/server/{0067-Shave-snow-layers.patch => 0068-Shave-snow-layers.patch} (52%) rename patches/server/{0068-Spawn-ignore-lc.patch => 0069-Spawn-ignore-lc.patch} (89%) rename patches/server/{0069-Elytra-aeronautics-no-chunk-load.patch => 0070-Elytra-aeronautics-no-chunk-load.patch} (81%) rename patches/server/{0070-Cache-ignite-odds.patch => 0071-Cache-ignite-odds.patch} (95%) rename patches/server/{0071-Lava-riptide.patch => 0072-Lava-riptide.patch} (67%) rename patches/server/{0072-No-block-update-command.patch => 0073-No-block-update-command.patch} (79%) delete mode 100644 patches/server/0073-Raider-die-skip-self-raid-check.patch delete mode 100644 patches/server/0074-Container-open-passthrough.patch create mode 100644 patches/server/0074-Raider-die-skip-self-raid-check.patch create mode 100644 patches/server/0075-Container-open-passthrough.patch create mode 100644 patches/server/0076-Placeholder-for-Bladeren-Protocol.patch create mode 100644 patches/server/0077-Placeholder-for-Bladeren-mspt-sync-protocol.patch rename patches/server/{0077-SIMD-support.patch => 0078-SIMD-support.patch} (79%) rename patches/server/{0078-Dont-respond-ping-before-start-fully.patch => 0079-Dont-respond-ping-before-start-fully.patch} (89%) rename patches/server/{0079-Faster-chunk-serialization.patch => 0080-Faster-chunk-serialization.patch} (96%) delete mode 100644 patches/server/0080-Optimize-world-generation-chunk-and-block-access.patch create mode 100644 patches/server/0081-Optimize-world-generation-chunk-and-block-access.patch rename patches/server/{0081-Cache-world-generator-sea-level.patch => 0082-Cache-world-generator-sea-level.patch} (93%) rename patches/server/{0082-Skip-secondary-POI-sensor-if-absent.patch => 0083-Skip-secondary-POI-sensor-if-absent.patch} (89%) rename patches/server/{0083-Cache-CubeVoxelShape-shape-array.patch => 0084-Cache-CubeVoxelShape-shape-array.patch} (91%) rename patches/server/{0084-Store-mob-counts-in-an-array.patch => 0085-Store-mob-counts-in-an-array.patch} (89%) rename patches/server/{0085-Cache-BlockStatePairKey-hash.patch => 0086-Cache-BlockStatePairKey-hash.patch} (87%) rename patches/server/{0086-Optimize-noise-generation.patch => 0087-Optimize-noise-generation.patch} (95%) rename patches/server/{0087-Disable-packet-limit.patch => 0088-Disable-packet-limit.patch} (78%) rename patches/server/{0088-Reduce-array-allocations.patch => 0089-Reduce-array-allocations.patch} (75%) rename patches/server/{0089-Optimize-sun-burn-tick.patch => 0090-Optimize-sun-burn-tick.patch} (88%) rename patches/server/{0090-Reduce-lambda-and-Optional-allocation-in-EntityBased.patch => 0091-Reduce-lambda-and-Optional-allocation-in-EntityBased.patch} (92%) delete mode 100644 patches/server/0091-Use-optimized-collection.patch delete mode 100644 patches/server/0095-Cache-ominous-banner-item.patch rename patches/server/{0096-Skip-entity-move-if-movement-is-zero.patch => 0095-Skip-entity-move-if-movement-is-zero.patch} (79%) rename patches/server/{0097-Skip-cloning-advancement-criteria.patch => 0096-Skip-cloning-advancement-criteria.patch} (83%) rename patches/server/{0098-Skip-negligible-planar-movement-multiplication.patch => 0097-Skip-negligible-planar-movement-multiplication.patch} (83%) rename patches/server/{0099-Fix-villagers-dont-release-memory.patch => 0098-Fix-villagers-dont-release-memory.patch} (85%) rename patches/server/{0100-Avoid-anvil-too-expensive.patch => 0099-Avoid-anvil-too-expensive.patch} (81%) create mode 100644 patches/server/0100-Bow-infinity-fix.patch delete mode 100644 patches/server/0101-Bow-infinity-fix.patch rename patches/server/{0102-Zero-tick-plants.patch => 0101-Zero-tick-plants.patch} (75%) rename patches/server/{0103-Leaves-update-command.patch => 0102-Leaves-update-command.patch} (90%) rename patches/server/{0104-Force-peaceful-mode-switch.patch => 0103-Force-peaceful-mode-switch.patch} (86%) rename patches/server/{0105-Add-Leaves-Auto-Update.patch => 0104-Add-Leaves-Auto-Update.patch} (89%) rename patches/server/{0106-Replay-Mod-API.patch => 0105-Replay-Mod-API.patch} (83%) rename patches/server/{0107-Fix-vehicle-teleport-by-end-gateway.patch => 0106-Fix-vehicle-teleport-by-end-gateway.patch} (88%) rename patches/server/{0108-Leaves-I18n.patch => 0107-Leaves-I18n.patch} (99%) rename patches/server/{0109-Fix-minecraft-hopper-not-work-without-player.patch => 0108-Fix-minecraft-hopper-not-work-without-player.patch} (84%) rename patches/server/{0110-Wool-Hopper-Counter.patch => 0109-Wool-Hopper-Counter.patch} (83%) rename patches/server/{0111-RNG-Fishing.patch => 0110-RNG-Fishing.patch} (83%) rename patches/server/{0112-Leaves-Reload-Command.patch => 0111-Leaves-Reload-Command.patch} (59%) rename patches/server/{0113-Spider-jockeys-drop-gapples.patch => 0112-Spider-jockeys-drop-gapples.patch} (78%) rename patches/server/{0114-Force-Void-Trade.patch => 0113-Force-Void-Trade.patch} (78%) create mode 100644 patches/server/0114-Placeholder-for-Servux-Protocol.patch rename patches/server/{0116-Villager-infinite-discounts.patch => 0115-Villager-infinite-discounts.patch} (75%) rename patches/server/{0117-CCE-update-suppression.patch => 0116-CCE-update-suppression.patch} (76%) rename patches/server/{0118-Disable-offline-warn-if-use-proxy.patch => 0117-Disable-offline-warn-if-use-proxy.patch} (89%) rename patches/server/{0119-Disable-moved-wrongly-threshold.patch => 0118-Disable-moved-wrongly-threshold.patch} (87%) rename patches/server/{0120-Armor-stand-cant-kill-by-mob-projectile.patch => 0119-Armor-stand-cant-kill-by-mob-projectile.patch} (84%) rename patches/server/{0121-Make-Item-tick-vanilla.patch => 0120-Make-Item-tick-vanilla.patch} (83%) rename patches/server/{0122-Copper-Bulb-1-gt-delay.patch => 0121-Copper-Bulb-1-gt-delay.patch} (78%) create mode 100644 patches/server/0122-Crafter-1-gt-delay.patch delete mode 100644 patches/server/0123-Crafter-1-gt-delay.patch rename patches/server/{0124-Linear-region-file-format.patch => 0123-Linear-region-file-format.patch} (75%) rename patches/server/{0125-Protection-stacking.patch => 0124-Protection-stacking.patch} (82%) rename patches/server/{0126-No-TNT-place-update.patch => 0125-No-TNT-place-update.patch} (78%) rename patches/server/{0127-Placing-locked-hopper-no-longer-send-NC-updates.patch => 0126-Placing-locked-hopper-no-longer-send-NC-updates.patch} (90%) rename patches/server/{0128-Renewable-deepslate.patch => 0127-Renewable-deepslate.patch} (83%) rename patches/server/{0129-Renewable-sponges.patch => 0128-Renewable-sponges.patch} (83%) rename patches/server/{0130-Renewable-coral.patch => 0129-Renewable-coral.patch} (84%) rename patches/server/{0131-Fast-resume.patch => 0130-Fast-resume.patch} (90%) rename patches/server/{0132-Vanilla-hopper.patch => 0131-Vanilla-hopper.patch} (93%) rename patches/server/{0133-Force-minecraft-command.patch => 0132-Force-minecraft-command.patch} (59%) rename patches/server/{0134-Fix-falling-block-s-block-location.patch => 0133-Fix-falling-block-s-block-location.patch} (80%) rename patches/server/{0135-Fix-NPE-during-creating-GUI-graph.patch => 0134-Fix-NPE-during-creating-GUI-graph.patch} (100%) delete mode 100644 patches/server/0136-Fix-next-steps.patch rename patches/{ => unapplied}/api/0011-Bytebuf-API.patch (94%) rename patches/{ => unapplied}/server/0037-PCA-sync-protocol.patch (91%) rename patches/{ => unapplied}/server/0038-BBOR-Protocol.patch (94%) rename patches/{ => unapplied}/server/0041-Jade-Protocol.patch (98%) rename patches/{ => unapplied}/server/0056-Syncmatica-Protocol.patch (90%) rename patches/{ => unapplied}/server/0063-Leaves-carpet-support.patch (89%) rename patches/{ => unapplied}/server/0075-Bladeren-Protocol.patch (92%) rename patches/{ => unapplied}/server/0076-Bladeren-mspt-sync-protocol.patch (85%) rename patches/{ => unapplied}/server/0115-Servux-Protocol.patch (93%) rename patches/{ => unapplied}/server/0137-Bytebuf-API.patch (100%) create mode 100644 scripts/GetBuildNumber.sh diff --git a/.github/workflows/leaves.yml b/.github/workflows/leaves.yml index 77f40c3b..a2f75b19 100644 --- a/.github/workflows/leaves.yml +++ b/.github/workflows/leaves.yml @@ -10,85 +10,90 @@ jobs: runs-on: ubuntu-latest if: github.event.pull_request.merged || github.event_name == 'push' || github.event_name == 'workflow_dispatch' steps: - - name: Get repository - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Get JDK 17 - uses: actions/setup-java@v3 - with: - java-version: '17' - distribution: 'zulu' - - name: Setup Git Config - run: | - git config --global user.email "ci@leavesmc.top" - git config --global user.name "Leaves CI" - - name: Apply Patches - uses: gradle/gradle-build-action@937999e9cc2425eddc7fd62d1053baf041147db7 - with: - arguments: applyPatches - - name: Create Paperclip Jar - uses: gradle/gradle-build-action@937999e9cc2425eddc7fd62d1053baf041147db7 - with: - arguments: createReobfPaperclipJar - - name: Publish API - continue-on-error: true - uses: gradle/gradle-build-action@937999e9cc2425eddc7fd62d1053baf041147db7 - with: - arguments: publish -PleavesUsername=${{ secrets.REPO_USERNAME }} -PleavesPassword=${{ secrets.REPO_PASSWORD }} - - name: Create Configuration - continue-on-error: true - uses: gradle/gradle-build-action@937999e9cc2425eddc7fd62d1053baf041147db7 - with: - arguments: createLeavesConfig - - name: Push Configuration - continue-on-error: true - run: | - mkdir --parents "$HOME/.ssh" - ssh-keyscan -H "github.com" > "$HOME/.ssh/known_hosts" - echo "${{ secrets.CONFIG_DEPLOY_KEY }}" > "$HOME/.ssh/deploy.key" - chmod 400 "$HOME/.ssh/deploy.key" - export GIT_SSH_COMMAND="ssh -i $HOME/.ssh/deploy.key" - git clone git@github.com:LeavesMC/Configuration.git configuration -b Leaves - cp run/leaves.yml configuration/leaves.yml -f - cd configuration - git add leaves.yml - git commit leaves.yml -m "$(date -u +"%Y-%m-%dT%H:%M:%SZ") - https://github.com/LeavesMC/Leaves/commit/$(cd .. && git rev-parse HEAD)" - git push origin HEAD:Leaves - - name: Get Release Info - run: sh scripts/GetReleaseInfo.sh - - name: Create Release - if: "!contains(github.event.commits[0].message, '[release-skip]')" - uses: ncipollo/release-action@v1.12.0 - with: - artifacts: ${{ env.jar }} - bodyFile: ${{ env.info }} - tag: ${{ env.tag }} - name: ${{ env.name }} - prerelease: ${{ env.pre }} - token: ${{ secrets.GITHUB_TOKEN }} - makeLatest: ${{ env.make_latest }} - - name: Delete Draft Releases - uses: hugo19941994/delete-draft-releases@v1.0.0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Github Releases To Discord - continue-on-error: true - uses: tsickert/discord-webhook@v5.3.0 - with: - webhook-url: ${{ secrets.DISCORD_WEBHOOK }} - raw-data: ${{ env.discordmes }} - - name: Upload Artifact - uses: actions/upload-artifact@v2 - with: - name: ${{ env.jar }} - path: ${{ env.jar }} - - name: Push to Api - continue-on-error: true - if: "!contains(github.event.commits[0].message, '[release-skip]')" - env: - secret: ${{ secrets.API_PUSH_TOKEN }} - secret_v2: ${{ secrets.API_V2_PUSH_TOKEN }} - tag: ${{ env.tag }} - run: sh scripts/PushToAPI.sh + - name: Get repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Get JDK 17 + uses: actions/setup-java@v4 + with: + java-version: "21" + distribution: "zulu" + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 + with: + add-job-summary: never + generate-job-summary: false + cache-read-only: false + - name: Setup Git Config + run: | + git config --global user.email "ci@leavesmc.org" + git config --global user.name "Leaves CI" + - name: Get Build Number + run: sh scripts/GetBuildNumber.sh + - name: Apply Patches + run: ./gradlew applyPatches + - name: Create Leavesclip Jar + run: ./gradlew createMojmapLeavesclipJar + env: + BUILD_NUMBER: ${{ env.BUILD_NUMBER }} + - name: Publish API + continue-on-error: true + run: ./gradlew publish + env: + LEAVES_USERNAME: ${{ secrets.NEW_REPO_USERNAME }} + LEAVES_PASSWORD: ${{ secrets.NEW_REPO_PASSWORD }} + - name: Create Configuration + continue-on-error: true + run: ./gradlew createLeavesConfig + - name: Push Configuration + continue-on-error: true + run: | + mkdir --parents "$HOME/.ssh" + ssh-keyscan -H "github.com" > "$HOME/.ssh/known_hosts" + echo "${{ secrets.CONFIG_DEPLOY_KEY }}" > "$HOME/.ssh/deploy.key" + chmod 400 "$HOME/.ssh/deploy.key" + export GIT_SSH_COMMAND="ssh -i $HOME/.ssh/deploy.key" + git clone git@github.com:LeavesMC/Configuration.git configuration -b Leaves + cp run/leaves.yml configuration/leaves.yml -f + cd configuration + git add leaves.yml + git commit leaves.yml -m "$(date -u +"%Y-%m-%dT%H:%M:%SZ") + https://github.com/LeavesMC/Leaves/commit/$(cd .. && git rev-parse HEAD)" + git push origin HEAD:Leaves + - name: Get Release Info + run: sh scripts/GetReleaseInfo.sh + - name: Create Release + if: "!contains(github.event.commits[0].message, '[release-skip]')" + uses: ncipollo/release-action@v1 + with: + artifacts: ${{ env.jar }} + bodyFile: ${{ env.info }} + tag: ${{ env.tag }} + name: ${{ env.name }} + prerelease: ${{ env.pre }} + token: ${{ secrets.GITHUB_TOKEN }} + makeLatest: ${{ env.make_latest }} + - name: Delete Draft Releases + uses: hugo19941994/delete-draft-releases@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Github Releases To Discord + continue-on-error: true + uses: tsickert/discord-webhook@v6 + with: + webhook-url: ${{ secrets.DISCORD_WEBHOOK }} + raw-data: ${{ env.discordmes }} + - name: Upload Artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ env.jar }} + path: ${{ env.jar }} + - name: Push to Api + continue-on-error: true + if: "!contains(github.event.commits[0].message, '[release-skip]')" + env: + secret: ${{ secrets.API_PUSH_TOKEN }} + secret_v2: ${{ secrets.API_V2_PUSH_TOKEN }} + tag: ${{ env.tag }} + run: sh scripts/PushToAPI.sh diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1e4e16dc..726b5c89 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,30 +21,32 @@ jobs: runs-on: ubuntu-latest steps: - name: Get repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Get JDK 17 - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: - java-version: '17' - distribution: 'zulu' + java-version: "21" + distribution: "zulu" + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 + with: + add-job-summary: never + generate-job-summary: false + cache-read-only: false - name: Setup Git Config run: | - git config --global user.email "ci@leavesmc.top" + git config --global user.email "ci@leavesmc.org" git config --global user.name "Leaves CI" - name: Apply Patches - uses: gradle/gradle-build-action@937999e9cc2425eddc7fd62d1053baf041147db7 - with: - arguments: applyPatches + run: ./gradlew applyPatches - name: Create Paperclip Jar - uses: gradle/gradle-build-action@937999e9cc2425eddc7fd62d1053baf041147db7 - with: - arguments: createReobfPaperclipJar + run: ./gradlew createReobfPaperclipJar - name: Get Release Info run: sh scripts/GetReleaseInfo.sh - name: Archive Leaves - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ${{ env.jar }} path: ${{ env.jar }} diff --git a/README.md b/README.md index a0774f38..a14bfc73 100644 --- a/README.md +++ b/README.md @@ -26,11 +26,11 @@ Leaves-API: ```kotlin maven { name = 'leavesmc-repo' - url = 'https://repo.leavesmc.top/snapshots/' + url = 'https://repo.leavesmc.org/snapshots/' } dependencies { - compileOnly("top.leavesmc.leaves:leaves-api:1.20.4-R0.1-SNAPSHOT") + compileOnly("org.leavesmc.leaves:leaves-api:1.20.6-R0.1-SNAPSHOT") } ``` @@ -40,15 +40,15 @@ Each time you want to update your dependency, you must re-build Leaves. Leaves-Server: ```kotlin dependencies { - compileOnly("top.leavesmc.leaves:leaves:1.20.4-R0.1-SNAPSHOT") + compileOnly("org.leavesmc.leaves:leaves:1.20.6-R0.1-SNAPSHOT") } ``` ## Building -You need JDK 17 and good Internet conditions +You need JDK 21 and good Internet conditions -Clone this repo, run `./gradlew applyPatches`, then run `./gradlew createReobfBundlerJar` in your terminal. +Clone this repo, run `./gradlew applyPatches`, then run `./gradlew createMojmapLeavesclipJar` in your terminal. You can find the jars in the `build/libs` directory. diff --git a/README_cn.md b/README_cn.md index 374f1ab0..b3a5455d 100644 --- a/README_cn.md +++ b/README_cn.md @@ -26,11 +26,11 @@ Leaves-API: ```kotlin maven { name = 'leavesmc-repo' - url = 'https://repo.leavesmc.top/snapshots/' + url = 'https://repo.leavesmc.org/snapshots/' } dependencies { - compileOnly("top.leavesmc.leaves:leaves-api:1.20.4-R0.1-SNAPSHOT") + compileOnly("org.leavesmc.leaves:leaves-api:1.20.6-R0.1-SNAPSHOT") } ``` @@ -39,15 +39,15 @@ dependencies { Leaves-Server: ```kotlin dependencies { - compileOnly("top.leavesmc.leaves:leaves:1.20.4-R0.1-SNAPSHOT") + compileOnly("org.leavesmc.leaves:leaves:1.20.6-R0.1-SNAPSHOT") } ``` ## 自行构建 -你需要最低 JDK 17 和一个可以正常访问各种 git/maven 库的网络 +你需要最低 JDK 21 和一个可以正常访问各种 git/maven 库的网络 -首先克隆此储存库,然后在你的终端里依次执行 `./gradlew applyPatches` 和 `./gradlew createReobfBundlerJar` +首先克隆此储存库,然后在你的终端里依次执行 `./gradlew applyPatches` 和 `./gradlew createMojmapLeavesclipJar` 最后 你可以在 `build/libs` 文件夹里找到对应的jar文件 diff --git a/build.gradle.kts b/build.gradle.kts index 6e101cd6..31fb2548 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -4,35 +4,32 @@ import kotlin.io.path.* plugins { java `maven-publish` - id("com.github.johnrengelman.shadow") version "8.1.1" apply false - id("io.papermc.paperweight.patcher") version "1.5.13" + id("io.papermc.paperweight.patcher") version "1.7.1" } -repositories { - mavenCentral() - maven("https://repo.leavesmc.top/releases") { - content { onlyForConfigurations("paperclip") } +allprojects { + apply(plugin = "java") + apply(plugin = "maven-publish") + + java { + toolchain { + languageVersion = JavaLanguageVersion.of(21) + } } } -dependencies { - remapper("net.fabricmc:tiny-remapper:0.10.1:fat") - decompiler("net.minecraftforge:forgeflower:2.0.627.2") - paperclip("top.leavesmc:leavesclip:1.0.2") -} - subprojects { apply(plugin = "java") java { toolchain { - languageVersion.set(JavaLanguageVersion.of(17)) + languageVersion.set(JavaLanguageVersion.of(21)) } } tasks.withType { options.encoding = Charsets.UTF_8.name() - options.release.set(17) + options.release.set(21) } tasks.withType { options.encoding = Charsets.UTF_8.name() @@ -54,6 +51,19 @@ subprojects { } } +repositories { + mavenCentral() + maven("https://repo.leavesmc.org/releases") { + content { onlyForConfigurations("paperclip") } + } +} + +dependencies { + remapper("net.fabricmc:tiny-remapper:0.10.2:fat") + decompiler("org.vineflower:vineflower:1.10.1") + paperclip("org.leavesmc:leavesclip:2.0.0") +} + paperweight { serverProject.set(project(":leaves-server")) @@ -78,6 +88,20 @@ paperweight { } } +allprojects { + publishing { + repositories { + maven("https://repo.leavesmc.org/snapshots") { + name = "leaves" + credentials(PasswordCredentials::class) { + username = System.getenv("LEAVES_USERNAME") + password = System.getenv("LEAVES_PASSWORD") + } + } + } + } +} + if (providers.gradleProperty("updatingMinecraft").getOrElse("false").toBoolean()) { tasks.withType().configureEach { @@ -90,3 +114,23 @@ if (providers.gradleProperty("updatingMinecraft").getOrElse("false").toBoolean() filterPatches = false } } + +tasks.register("createMojmapLeavesclipJar") { + group = "paperweight" + dependsOn("createMojmapPaperclipJar") + doLast { + file("build/libs/leaves-paperclip-${project.version}-mojmap.jar").renameTo( + file("build/libs/leaves-leavesclip-${project.version}-mojmap.jar") + ) + } +} + +tasks.register("createReobfLeavesclipJar") { + group = "paperweight" + dependsOn("createReobfPaperclipJar") + doLast { + file("build/libs/leaves-paperclip-${project.version}-reobf.jar").renameTo( + file("build/libs/leaves-leavesclip-${project.version}-reobf.jar") + ) + } +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 2cd7f8eb..4067f439 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,9 +1,8 @@ -group=top.leavesmc.leaves -version=1.20.4-R0.1-SNAPSHOT +group=org.leavesmc.leaves +version=1.20.6-R0.1-SNAPSHOT -mcVersion=1.20.4 -packageVersion=1_20_R3 +mcVersion=1.20.6 org.gradle.jvmargs=-Xmx2G -paperRef=f4c7d373e4a1aff23539fe099745bf29a28559b9 -preVersion=false -updatingMinecraft=false \ No newline at end of file +paperRef=f17519338bc589c045e0b32bfc37e048b23544d5 +preVersion=true +updatingMinecraft=true \ No newline at end of file diff --git a/patches/api/0001-Leaves-Server-Config.patch b/patches/api/0001-Leaves-Server-Config.patch index 0268ce06..4f703330 100644 --- a/patches/api/0001-Leaves-Server-Config.patch +++ b/patches/api/0001-Leaves-Server-Config.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Leaves Server Config diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java -index 4ff1b38eb65f97344257204cf018f176f247ed36..cc119de8e5912eae124be1d6c94f73b77682de41 100644 +index c8595ffcfcbdd79794d464415287d46acef72b72..99d754d3d06accbe13363f729b284e0eab67f2aa 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java -@@ -2234,6 +2234,14 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi +@@ -2256,6 +2256,14 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi throw new UnsupportedOperationException("Not supported yet."); } // Paper end diff --git a/patches/api/0003-Add-fakeplayer-api.patch b/patches/api/0003-Add-fakeplayer-api.patch index 13445bca..993d2863 100644 --- a/patches/api/0003-Add-fakeplayer-api.patch +++ b/patches/api/0003-Add-fakeplayer-api.patch @@ -4,19 +4,20 @@ Date: Wed, 27 Jul 2022 15:30:34 +0800 Subject: [PATCH] Add fakeplayer api +diff --git a/.gitignore b/.gitignore +index 97e78e27ee0eea2c8b24886eeb19164d552323fe..9764fa643039f215627c20a33ca70c9e36b2d599 100644 +--- a/.gitignore ++++ b/.gitignore +@@ -38,3 +38,4 @@ + # vs code + /.vscode + /.factorypath ++ diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java -index 9a428153f34291bdc026a71f7e60e285b7794b0c..824982037eb064d536ac09c303d3bdd225355a6a 100644 +index 71f1c361ebccbe83193c37ec3a90faa4085001c3..0bfaeca0b1e1fadfaeed486c94dac19447062575 100644 --- a/src/main/java/org/bukkit/Bukkit.java +++ b/src/main/java/org/bukkit/Bukkit.java -@@ -59,6 +59,7 @@ import org.jetbrains.annotations.Contract; - import org.jetbrains.annotations.NotNull; - import org.jetbrains.annotations.Nullable; - import io.papermc.paper.util.JarManifests; // Paper -+import top.leavesmc.leaves.entity.BotManager; - - /** - * Represents the Bukkit core, for version and Server singleton handling -@@ -2880,6 +2881,17 @@ public final class Bukkit { +@@ -2903,6 +2903,17 @@ public final class Bukkit { } // Paper end - Folia region threading API @@ -26,7 +27,7 @@ index 9a428153f34291bdc026a71f7e60e285b7794b0c..824982037eb064d536ac09c303d3bdd2 + * + * @return Bot Manager + */ -+ public static @NotNull BotManager getBotManager() { ++ public static @NotNull org.leavesmc.leaves.entity.BotManager getBotManager() { + return server.getBotManager(); + } + // Leaves end - Bot API @@ -35,18 +36,18 @@ index 9a428153f34291bdc026a71f7e60e285b7794b0c..824982037eb064d536ac09c303d3bdd2 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 cc119de8e5912eae124be1d6c94f73b77682de41..34196590f64f1c65c691b305b402b888b524c1d7 100644 +index 99d754d3d06accbe13363f729b284e0eab67f2aa..5e60df867b3111c203c0fe249b09e8c6333d1255 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java -@@ -59,6 +59,7 @@ import org.bukkit.util.CachedServerIcon; +@@ -61,6 +61,7 @@ import org.bukkit.util.CachedServerIcon; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -+import top.leavesmc.leaves.entity.BotManager; ++import org.leavesmc.leaves.entity.BotManager; /** * Represents a server implementation. -@@ -2526,4 +2527,13 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi +@@ -2550,4 +2551,13 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi */ boolean isOwnedByCurrentRegion(@NotNull Entity entity); // Paper end - Folia region threading API @@ -60,18 +61,18 @@ index cc119de8e5912eae124be1d6c94f73b77682de41..34196590f64f1c65c691b305b402b888 + @NotNull BotManager getBotManager(); + // Leaves end - Bot API } -diff --git a/src/main/java/top/leavesmc/leaves/entity/Bot.java b/src/main/java/top/leavesmc/leaves/entity/Bot.java +diff --git a/src/main/java/org/leavesmc/leaves/entity/Bot.java b/src/main/java/org/leavesmc/leaves/entity/Bot.java new file mode 100644 -index 0000000000000000000000000000000000000000..02815077dcd6d5c1b155ef3ca5cd6e3a9c45c0b5 +index 0000000000000000000000000000000000000000..922ca5b27bc0dd443d635646f37f879559cc0252 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/entity/Bot.java ++++ b/src/main/java/org/leavesmc/leaves/entity/Bot.java @@ -0,0 +1,51 @@ -+package top.leavesmc.leaves.entity; ++package org.leavesmc.leaves.entity; + +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; -+import top.leavesmc.leaves.entity.botaction.LeavesBotAction; ++import org.leavesmc.leaves.entity.botaction.LeavesBotAction; + +import java.util.UUID; + @@ -117,19 +118,19 @@ index 0000000000000000000000000000000000000000..02815077dcd6d5c1b155ef3ca5cd6e3a + */ + public boolean setBotAction(@NotNull LeavesBotAction action, @NotNull Player player, @NotNull String[] args); +} -diff --git a/src/main/java/top/leavesmc/leaves/entity/BotManager.java b/src/main/java/top/leavesmc/leaves/entity/BotManager.java +diff --git a/src/main/java/org/leavesmc/leaves/entity/BotManager.java b/src/main/java/org/leavesmc/leaves/entity/BotManager.java new file mode 100644 -index 0000000000000000000000000000000000000000..f2258027b2ed4bfcf7feda2e9075b1a1a05a85b6 +index 0000000000000000000000000000000000000000..7662b8bb1bb47f7a85705709548e00a3918d0502 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/entity/BotManager.java ++++ b/src/main/java/org/leavesmc/leaves/entity/BotManager.java @@ -0,0 +1,107 @@ -+package top.leavesmc.leaves.entity; ++package org.leavesmc.leaves.entity; + +import org.bukkit.Location; +import org.bukkit.util.Consumer; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; -+import top.leavesmc.leaves.entity.botaction.CustomBotAction; ++import org.leavesmc.leaves.entity.botaction.CustomBotAction; + +import java.util.Collection; +import java.util.UUID; @@ -230,18 +231,18 @@ index 0000000000000000000000000000000000000000..f2258027b2ed4bfcf7feda2e9075b1a1 + */ + public boolean unregisterCustomBotAction(String name); +} -diff --git a/src/main/java/top/leavesmc/leaves/entity/botaction/CustomBotAction.java b/src/main/java/top/leavesmc/leaves/entity/botaction/CustomBotAction.java +diff --git a/src/main/java/org/leavesmc/leaves/entity/botaction/CustomBotAction.java b/src/main/java/org/leavesmc/leaves/entity/botaction/CustomBotAction.java new file mode 100644 -index 0000000000000000000000000000000000000000..7abf4eef22e40468929e724ebc07a97b0b2a05f3 +index 0000000000000000000000000000000000000000..0b1648013d5f03d064c0719c231981082ab563be --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/entity/botaction/CustomBotAction.java ++++ b/src/main/java/org/leavesmc/leaves/entity/botaction/CustomBotAction.java @@ -0,0 +1,52 @@ -+package top.leavesmc.leaves.entity.botaction; ++package org.leavesmc.leaves.entity.botaction; + +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; -+import top.leavesmc.leaves.entity.Bot; ++import org.leavesmc.leaves.entity.Bot; + +import java.util.List; + @@ -288,13 +289,13 @@ index 0000000000000000000000000000000000000000..7abf4eef22e40468929e724ebc07a97b + */ + public int getNumber(); +} -diff --git a/src/main/java/top/leavesmc/leaves/entity/botaction/LeavesBotAction.java b/src/main/java/top/leavesmc/leaves/entity/botaction/LeavesBotAction.java +diff --git a/src/main/java/org/leavesmc/leaves/entity/botaction/LeavesBotAction.java b/src/main/java/org/leavesmc/leaves/entity/botaction/LeavesBotAction.java new file mode 100644 -index 0000000000000000000000000000000000000000..e298722319ff0cfd52e531693ea3767e5f9a3d52 +index 0000000000000000000000000000000000000000..b239acd298b299e338ae56aa6507570942ce44e2 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/entity/botaction/LeavesBotAction.java ++++ b/src/main/java/org/leavesmc/leaves/entity/botaction/LeavesBotAction.java @@ -0,0 +1,32 @@ -+package top.leavesmc.leaves.entity.botaction; ++package org.leavesmc.leaves.entity.botaction; + +/** + * A Leaves bot action enum @@ -326,18 +327,18 @@ index 0000000000000000000000000000000000000000..e298722319ff0cfd52e531693ea3767e + return name; + } +} -diff --git a/src/main/java/top/leavesmc/leaves/event/bot/BotActionEvent.java b/src/main/java/top/leavesmc/leaves/event/bot/BotActionEvent.java +diff --git a/src/main/java/org/leavesmc/leaves/event/bot/BotActionEvent.java b/src/main/java/org/leavesmc/leaves/event/bot/BotActionEvent.java new file mode 100644 -index 0000000000000000000000000000000000000000..b18587ad3b813b71f5f3cde2a90f204603bdb180 +index 0000000000000000000000000000000000000000..91ea5540387b7d7e1be5b6368a2f02b3b784614a --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/event/bot/BotActionEvent.java ++++ b/src/main/java/org/leavesmc/leaves/event/bot/BotActionEvent.java @@ -0,0 +1,49 @@ -+package top.leavesmc.leaves.event.bot; ++package org.leavesmc.leaves.event.bot; + +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; -+import top.leavesmc.leaves.entity.Bot; ++import org.leavesmc.leaves.entity.Bot; + +public class BotActionEvent extends BotEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); @@ -381,18 +382,18 @@ index 0000000000000000000000000000000000000000..b18587ad3b813b71f5f3cde2a90f2046 + return handlers; + } +} -diff --git a/src/main/java/top/leavesmc/leaves/event/bot/BotConfigModifyEvent.java b/src/main/java/top/leavesmc/leaves/event/bot/BotConfigModifyEvent.java +diff --git a/src/main/java/org/leavesmc/leaves/event/bot/BotConfigModifyEvent.java b/src/main/java/org/leavesmc/leaves/event/bot/BotConfigModifyEvent.java new file mode 100644 -index 0000000000000000000000000000000000000000..b395eba4734703cc99d04941e20e053b9527b1e1 +index 0000000000000000000000000000000000000000..5e55759fd3d7891e8e1d5d6a306dc8144d366469 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/event/bot/BotConfigModifyEvent.java ++++ b/src/main/java/org/leavesmc/leaves/event/bot/BotConfigModifyEvent.java @@ -0,0 +1,49 @@ -+package top.leavesmc.leaves.event.bot; ++package org.leavesmc.leaves.event.bot; + +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; -+import top.leavesmc.leaves.entity.Bot; ++import org.leavesmc.leaves.entity.Bot; + +public class BotConfigModifyEvent extends BotEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); @@ -436,13 +437,13 @@ index 0000000000000000000000000000000000000000..b395eba4734703cc99d04941e20e053b + return handlers; + } +} -diff --git a/src/main/java/top/leavesmc/leaves/event/bot/BotCreateEvent.java b/src/main/java/top/leavesmc/leaves/event/bot/BotCreateEvent.java +diff --git a/src/main/java/org/leavesmc/leaves/event/bot/BotCreateEvent.java b/src/main/java/org/leavesmc/leaves/event/bot/BotCreateEvent.java new file mode 100644 -index 0000000000000000000000000000000000000000..7cf1eb4eb3d2fe9310f9272ec53208632b87b49b +index 0000000000000000000000000000000000000000..c093f68e5f1749c792255220f39bdbdffb78f0f9 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/event/bot/BotCreateEvent.java ++++ b/src/main/java/org/leavesmc/leaves/event/bot/BotCreateEvent.java @@ -0,0 +1,106 @@ -+package top.leavesmc.leaves.event.bot; ++package org.leavesmc.leaves.event.bot; + +import org.bukkit.Location; +import org.bukkit.event.Cancellable; @@ -548,17 +549,17 @@ index 0000000000000000000000000000000000000000..7cf1eb4eb3d2fe9310f9272ec5320863 + return handlers; + } +} -diff --git a/src/main/java/top/leavesmc/leaves/event/bot/BotEvent.java b/src/main/java/top/leavesmc/leaves/event/bot/BotEvent.java +diff --git a/src/main/java/org/leavesmc/leaves/event/bot/BotEvent.java b/src/main/java/org/leavesmc/leaves/event/bot/BotEvent.java new file mode 100644 -index 0000000000000000000000000000000000000000..4a4fe07ce965d4a97e0d8105a91310dac7d1343c +index 0000000000000000000000000000000000000000..ad358081f1e1da4075243d7ca0a01c1f7b00631b --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/event/bot/BotEvent.java ++++ b/src/main/java/org/leavesmc/leaves/event/bot/BotEvent.java @@ -0,0 +1,31 @@ -+package top.leavesmc.leaves.event.bot; ++package org.leavesmc.leaves.event.bot; + +import org.bukkit.event.Event; +import org.jetbrains.annotations.NotNull; -+import top.leavesmc.leaves.entity.Bot; ++import org.leavesmc.leaves.entity.Bot; + +/** + * Represents a fakeplayer related event @@ -585,20 +586,20 @@ index 0000000000000000000000000000000000000000..4a4fe07ce965d4a97e0d8105a91310da + return bot; + } +} -diff --git a/src/main/java/top/leavesmc/leaves/event/bot/BotInventoryOpenEvent.java b/src/main/java/top/leavesmc/leaves/event/bot/BotInventoryOpenEvent.java +diff --git a/src/main/java/org/leavesmc/leaves/event/bot/BotInventoryOpenEvent.java b/src/main/java/org/leavesmc/leaves/event/bot/BotInventoryOpenEvent.java new file mode 100644 -index 0000000000000000000000000000000000000000..e889f7e98ec9cb6a3b95d8ea865e25fffea662a1 +index 0000000000000000000000000000000000000000..a369b468d4793b36dd0944a1368a70e07b9fc10f --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/event/bot/BotInventoryOpenEvent.java ++++ b/src/main/java/org/leavesmc/leaves/event/bot/BotInventoryOpenEvent.java @@ -0,0 +1,46 @@ -+package top.leavesmc.leaves.event.bot; ++package org.leavesmc.leaves.event.bot; + +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; -+import top.leavesmc.leaves.entity.Bot; ++import org.leavesmc.leaves.entity.Bot; + +public class BotInventoryOpenEvent extends BotEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); @@ -637,17 +638,17 @@ index 0000000000000000000000000000000000000000..e889f7e98ec9cb6a3b95d8ea865e25ff + return handlers; + } +} -diff --git a/src/main/java/top/leavesmc/leaves/event/bot/BotJoinEvent.java b/src/main/java/top/leavesmc/leaves/event/bot/BotJoinEvent.java +diff --git a/src/main/java/org/leavesmc/leaves/event/bot/BotJoinEvent.java b/src/main/java/org/leavesmc/leaves/event/bot/BotJoinEvent.java new file mode 100644 -index 0000000000000000000000000000000000000000..10afa5c7fd4ee8a4e72d64f8ca9bf8731ec2ad61 +index 0000000000000000000000000000000000000000..7500652b01a4ed3c8d59ca003a644a9e024f6512 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/event/bot/BotJoinEvent.java ++++ b/src/main/java/org/leavesmc/leaves/event/bot/BotJoinEvent.java @@ -0,0 +1,27 @@ -+package top.leavesmc.leaves.event.bot; ++package org.leavesmc.leaves.event.bot; + +import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; -+import top.leavesmc.leaves.entity.Bot; ++import org.leavesmc.leaves.entity.Bot; + +/** + * Called when a fakeplayer joins a server diff --git a/patches/api/0004-Player-operation-limiter.patch b/patches/api/0004-Player-operation-limiter.patch index f4a87920..d0a9c98f 100644 --- a/patches/api/0004-Player-operation-limiter.patch +++ b/patches/api/0004-Player-operation-limiter.patch @@ -4,13 +4,13 @@ Date: Sun, 11 Dec 2022 18:43:36 +0800 Subject: [PATCH] Player operation limiter -diff --git a/src/main/java/top/leavesmc/leaves/event/player/PlayerOperationLimitEvent.java b/src/main/java/top/leavesmc/leaves/event/player/PlayerOperationLimitEvent.java +diff --git a/src/main/java/org/leavesmc/leaves/event/player/PlayerOperationLimitEvent.java b/src/main/java/org/leavesmc/leaves/event/player/PlayerOperationLimitEvent.java new file mode 100644 -index 0000000000000000000000000000000000000000..7c55d8e105aebb269b05f9df68daaf48352391cb +index 0000000000000000000000000000000000000000..1f5852eb6d53db5774db0ab4eba50bcb8733cfd6 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/event/player/PlayerOperationLimitEvent.java ++++ b/src/main/java/org/leavesmc/leaves/event/player/PlayerOperationLimitEvent.java @@ -0,0 +1,56 @@ -+package top.leavesmc.leaves.event.player; ++package org.leavesmc.leaves.event.player; + +import org.bukkit.block.Block; +import org.bukkit.entity.Player; diff --git a/patches/api/0005-Hide-irrelevant-compilation-warnings.patch b/patches/api/0005-Hide-irrelevant-compilation-warnings.patch index adc2937e..d05d59cf 100644 --- a/patches/api/0005-Hide-irrelevant-compilation-warnings.patch +++ b/patches/api/0005-Hide-irrelevant-compilation-warnings.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Hide irrelevant compilation warnings diff --git a/build.gradle.kts b/build.gradle.kts -index 04853c43b99951bf0d4c96ef73724625bdaf018f..e9e580d777534a56866413d6ca48f4aa269ec33f 100644 +index fd39ed209b20c927054b8482c400beeeeab460a3..d83f2d45849411afd91e27721f73189ed2a8bca5 100644 --- a/build.gradle.kts +++ b/build.gradle.kts -@@ -109,6 +109,15 @@ val generateApiVersioningFile by tasks.registering { +@@ -130,6 +130,15 @@ val generateApiVersioningFile by tasks.registering { } } @@ -24,7 +24,7 @@ index 04853c43b99951bf0d4c96ef73724625bdaf018f..e9e580d777534a56866413d6ca48f4aa tasks.jar { from(generateApiVersioningFile.map { it.outputs.files.singleFile }) { into("META-INF/maven/${project.group}/${project.name}") -@@ -166,6 +175,8 @@ tasks.withType { +@@ -187,6 +196,8 @@ tasks.withType { into("build/docs/javadoc") } } diff --git a/patches/api/0006-SIMD-support.patch b/patches/api/0006-SIMD-support.patch index b10c71f5..935e5832 100644 --- a/patches/api/0006-SIMD-support.patch +++ b/patches/api/0006-SIMD-support.patch @@ -5,10 +5,10 @@ Subject: [PATCH] SIMD support diff --git a/build.gradle.kts b/build.gradle.kts -index e9e580d777534a56866413d6ca48f4aa269ec33f..e0f2438944bda900f3a6391797e7842647b844be 100644 +index d83f2d45849411afd91e27721f73189ed2a8bca5..a42ee9d752eac9b895d9e7c29994c9f630805311 100644 --- a/build.gradle.kts +++ b/build.gradle.kts -@@ -115,6 +115,7 @@ tasks.withType { +@@ -136,6 +136,7 @@ tasks.withType { compilerArgs.add("-Xlint:-module") compilerArgs.add("-Xlint:-removal") compilerArgs.add("-Xlint:-dep-ann") @@ -16,7 +16,7 @@ index e9e580d777534a56866413d6ca48f4aa269ec33f..e0f2438944bda900f3a6391797e78426 } // Leaves end - hide irrelevant compilation warnings -@@ -177,6 +178,7 @@ tasks.withType { +@@ -198,6 +199,7 @@ tasks.withType { } options.addStringOption("Xdoclint:none", "-quiet") // Leaves - hide irrelevant compilation warnings diff --git a/patches/api/0008-Delete-Timings.patch b/patches/api/0007-Delete-Timings.patch similarity index 99% rename from patches/api/0008-Delete-Timings.patch rename to patches/api/0007-Delete-Timings.patch index 56014d4d..ffd82f83 100644 --- a/patches/api/0008-Delete-Timings.patch +++ b/patches/api/0007-Delete-Timings.patch @@ -2090,7 +2090,7 @@ index 632c4961515f5052551f841cfa840e60bba7a257..00000000000000000000000000000000 - } -} diff --git a/src/main/java/org/bukkit/command/Command.java b/src/main/java/org/bukkit/command/Command.java -index b791358f90fe92bc2264d9a26492245763813af3..17fd039363e909492d31ddb0f6cf941e0ae9969d 100644 +index c7cdc2ad8a2c43e8c0fcaa1761d3b81726c5ebcb..3ab75d571be4032e1bcfc5bb38168b81af63f0ad 100644 --- a/src/main/java/org/bukkit/command/Command.java +++ b/src/main/java/org/bukkit/command/Command.java @@ -33,7 +33,6 @@ public abstract class Command { @@ -2102,7 +2102,7 @@ index b791358f90fe92bc2264d9a26492245763813af3..17fd039363e909492d31ddb0f6cf941e protected Command(@NotNull String name) { diff --git a/src/main/java/org/bukkit/command/FormattedCommandAlias.java b/src/main/java/org/bukkit/command/FormattedCommandAlias.java -index 9d4f553c04784cca63901a56a7aea62a5cae1d72..46cc7bb2dc761d2de13993ff6fb9286e30ab58c2 100644 +index abe256e1e45ce28036da4aa1586715bc8a1a3414..b359306500e640f4b0761ae9aa996cf64e4fe63f 100644 --- a/src/main/java/org/bukkit/command/FormattedCommandAlias.java +++ b/src/main/java/org/bukkit/command/FormattedCommandAlias.java @@ -12,7 +12,6 @@ public class FormattedCommandAlias extends Command { @@ -2114,10 +2114,10 @@ index 9d4f553c04784cca63901a56a7aea62a5cae1d72..46cc7bb2dc761d2de13993ff6fb9286e } diff --git a/src/main/java/org/bukkit/command/SimpleCommandMap.java b/src/main/java/org/bukkit/command/SimpleCommandMap.java -index ac9a28922f8a556944a4c3649d74c32c622f0cb0..e4e64756d10b2f2eeba2903fd12f6e0dff2ed638 100644 +index c3a9cf65db73ed534bf20996c7f05b5eb0aaebe1..014f9c30440981d251e54b289682015baae1fe90 100644 --- a/src/main/java/org/bukkit/command/SimpleCommandMap.java +++ b/src/main/java/org/bukkit/command/SimpleCommandMap.java -@@ -34,7 +34,6 @@ public class SimpleCommandMap implements CommandMap { +@@ -38,7 +38,6 @@ public class SimpleCommandMap implements CommandMap { register("bukkit", new VersionCommand("version")); register("bukkit", new ReloadCommand("reload")); //register("bukkit", new PluginsCommand("plugins")); // Paper @@ -2125,7 +2125,7 @@ index ac9a28922f8a556944a4c3649d74c32c622f0cb0..e4e64756d10b2f2eeba2903fd12f6e0d } public void setFallbackCommands() { -@@ -66,7 +65,6 @@ public class SimpleCommandMap implements CommandMap { +@@ -70,7 +69,6 @@ public class SimpleCommandMap implements CommandMap { */ @Override public boolean register(@NotNull String label, @NotNull String fallbackPrefix, @NotNull Command command) { @@ -2133,7 +2133,7 @@ index ac9a28922f8a556944a4c3649d74c32c622f0cb0..e4e64756d10b2f2eeba2903fd12f6e0d label = label.toLowerCase(java.util.Locale.ENGLISH).trim(); fallbackPrefix = fallbackPrefix.toLowerCase(java.util.Locale.ENGLISH).trim(); boolean registered = register(label, command, false, fallbackPrefix); -@@ -143,17 +141,9 @@ public class SimpleCommandMap implements CommandMap { +@@ -152,17 +150,9 @@ public class SimpleCommandMap implements CommandMap { return false; } @@ -2152,10 +2152,10 @@ index ac9a28922f8a556944a4c3649d74c32c622f0cb0..e4e64756d10b2f2eeba2903fd12f6e0d server.getPluginManager().callEvent(new com.destroystokyo.paper.event.server.ServerExceptionEvent(new com.destroystokyo.paper.exception.ServerCommandException(ex, target, sender, args))); // Paper //target.timings.stopTiming(); // Spigot // Paper diff --git a/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/src/main/java/org/bukkit/plugin/SimplePluginManager.java -index fc2dae69165776d08274e34a69962cc70445f411..47e654e1ca66fd9ee79aaae839d4f5e907a4e29a 100644 +index 07a9c9e254188c251165ca84c8e961fccda01175..9eb02f8fb4d581349c4752ccb396dc4fdbd940c3 100644 --- a/src/main/java/org/bukkit/plugin/SimplePluginManager.java +++ b/src/main/java/org/bukkit/plugin/SimplePluginManager.java -@@ -707,12 +707,7 @@ public final class SimplePluginManager implements PluginManager { +@@ -719,12 +719,7 @@ public final class SimplePluginManager implements PluginManager { throw new IllegalPluginAccessException("Plugin attempted to register " + event + " while not enabled"); } @@ -2169,7 +2169,7 @@ index fc2dae69165776d08274e34a69962cc70445f411..47e654e1ca66fd9ee79aaae839d4f5e9 } @NotNull -@@ -942,8 +937,7 @@ public final class SimplePluginManager implements PluginManager { +@@ -954,8 +949,7 @@ public final class SimplePluginManager implements PluginManager { @Override public boolean useTimings() { @@ -2179,7 +2179,7 @@ index fc2dae69165776d08274e34a69962cc70445f411..47e654e1ca66fd9ee79aaae839d4f5e9 } /** -@@ -952,7 +946,6 @@ public final class SimplePluginManager implements PluginManager { +@@ -964,7 +958,6 @@ public final class SimplePluginManager implements PluginManager { * @param use True if per event timing code should be used */ public void useTimings(boolean use) { diff --git a/patches/api/0007-Leaves-API-publish.patch b/patches/api/0007-Leaves-API-publish.patch deleted file mode 100644 index fb83dded..00000000 --- a/patches/api/0007-Leaves-API-publish.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: violetc <58360096+s-yh-china@users.noreply.github.com> -Date: Sat, 22 Jul 2023 02:33:52 +0800 -Subject: [PATCH] Leaves API publish - - -diff --git a/build.gradle.kts b/build.gradle.kts -index e0f2438944bda900f3a6391797e7842647b844be..bb020dc0ad0cbc1d342966dbf5fce9d11547f56e 100644 ---- a/build.gradle.kts -+++ b/build.gradle.kts -@@ -212,3 +212,14 @@ tasks.check { - dependsOn(scanJarForOldGeneratedCode) - } - // Paper end -+ -+// Leaves start - publish api -+publishing { -+ repositories { -+ maven("https://repo.leavesmc.top/snapshots") { -+ name = "leaves" -+ credentials(PasswordCredentials::class) -+ } -+ } -+} -+// Leaves end - publish api -\ No newline at end of file diff --git a/patches/api/0009-Force-peaceful-mode-switch.patch b/patches/api/0008-Force-peaceful-mode-switch.patch similarity index 83% rename from patches/api/0009-Force-peaceful-mode-switch.patch rename to patches/api/0008-Force-peaceful-mode-switch.patch index 13433529..483f41eb 100644 --- a/patches/api/0009-Force-peaceful-mode-switch.patch +++ b/patches/api/0008-Force-peaceful-mode-switch.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Force peaceful mode switch diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java -index e6f66d70d024cf4f0536a5bf8e51bf7b306335df..fd81bf0631e57cdcbec7c0cb95c595510ce0df3d 100644 +index 97f97ea5c6aa513c439f86a9c82821e0f7d9cd1e..14d0e02673a37cd991c5c8cd34dd45b7cadde53a 100644 --- a/src/main/java/org/bukkit/World.java +++ b/src/main/java/org/bukkit/World.java -@@ -4301,6 +4301,12 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient +@@ -4317,6 +4317,12 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient void setSendViewDistance(int viewDistance); // Paper end - view distance api diff --git a/patches/api/0010-Replay-Mod-API.patch b/patches/api/0009-Replay-Mod-API.patch similarity index 62% rename from patches/api/0010-Replay-Mod-API.patch rename to patches/api/0009-Replay-Mod-API.patch index 0515cb47..b1c394fe 100644 --- a/patches/api/0010-Replay-Mod-API.patch +++ b/patches/api/0009-Replay-Mod-API.patch @@ -4,24 +4,25 @@ Date: Sat, 5 Aug 2023 09:10:59 +0800 Subject: [PATCH] Replay Mod API +diff --git a/.gitignore b/.gitignore +index 9764fa643039f215627c20a33ca70c9e36b2d599..97e78e27ee0eea2c8b24886eeb19164d552323fe 100644 +--- a/.gitignore ++++ b/.gitignore +@@ -38,4 +38,3 @@ + # vs code + /.vscode + /.factorypath +- diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java -index 824982037eb064d536ac09c303d3bdd225355a6a..7e92a652d47042dec050e4be08b57e2121ccd0bb 100644 +index 0bfaeca0b1e1fadfaeed486c94dac19447062575..3c2b252243c1fa0d3adcc9c860c24af73165de33 100644 --- a/src/main/java/org/bukkit/Bukkit.java +++ b/src/main/java/org/bukkit/Bukkit.java -@@ -60,6 +60,7 @@ import org.jetbrains.annotations.NotNull; - import org.jetbrains.annotations.Nullable; - import io.papermc.paper.util.JarManifests; // Paper - import top.leavesmc.leaves.entity.BotManager; -+import top.leavesmc.leaves.entity.PhotographerManager; - - /** - * Represents the Bukkit core, for version and Server singleton handling -@@ -2891,6 +2892,11 @@ public final class Bukkit { +@@ -2913,6 +2913,11 @@ public final class Bukkit { return server.getBotManager(); } // Leaves end - Bot API + // Leaves start - Photographer API -+ public static @NotNull PhotographerManager getPhotographerManager() { ++ public static @NotNull org.leavesmc.leaves.entity.PhotographerManager getPhotographerManager() { + return server.getPhotographerManager(); + } + // Leaves end - Photographer API @@ -29,18 +30,18 @@ index 824982037eb064d536ac09c303d3bdd225355a6a..7e92a652d47042dec050e4be08b57e21 @NotNull public static Server.Spigot spigot() { diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java -index 34196590f64f1c65c691b305b402b888b524c1d7..d465633aab75def37a2b4a9f2a034071970c1dfa 100644 +index 5e60df867b3111c203c0fe249b09e8c6333d1255..4a03044938630e4a0e701bc481f15da5a3323115 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java -@@ -60,6 +60,7 @@ import org.jetbrains.annotations.Contract; +@@ -62,6 +62,7 @@ import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; - import top.leavesmc.leaves.entity.BotManager; -+import top.leavesmc.leaves.entity.PhotographerManager; + import org.leavesmc.leaves.entity.BotManager; ++import org.leavesmc.leaves.entity.PhotographerManager; /** * Represents a server implementation. -@@ -2536,4 +2537,7 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi +@@ -2560,4 +2561,7 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi */ @NotNull BotManager getBotManager(); // Leaves end - Bot API @@ -48,13 +49,13 @@ index 34196590f64f1c65c691b305b402b888b524c1d7..d465633aab75def37a2b4a9f2a034071 + @NotNull PhotographerManager getPhotographerManager(); + // Leaves end - Photographer API } -diff --git a/src/main/java/top/leavesmc/leaves/entity/Photographer.java b/src/main/java/top/leavesmc/leaves/entity/Photographer.java +diff --git a/src/main/java/org/leavesmc/leaves/entity/Photographer.java b/src/main/java/org/leavesmc/leaves/entity/Photographer.java new file mode 100644 -index 0000000000000000000000000000000000000000..bfa6fe2a0ca095170aa5e073251402cf83a53ba0 +index 0000000000000000000000000000000000000000..cc4226c59aa9f5942bd90e270c5bcd8b354139dd --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/entity/Photographer.java ++++ b/src/main/java/org/leavesmc/leaves/entity/Photographer.java @@ -0,0 +1,27 @@ -+package top.leavesmc.leaves.entity; ++package org.leavesmc.leaves.entity; + +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; @@ -81,20 +82,20 @@ index 0000000000000000000000000000000000000000..bfa6fe2a0ca095170aa5e073251402cf + + public void setFollowPlayer(@Nullable Player player); +} -diff --git a/src/main/java/top/leavesmc/leaves/entity/PhotographerManager.java b/src/main/java/top/leavesmc/leaves/entity/PhotographerManager.java +diff --git a/src/main/java/org/leavesmc/leaves/entity/PhotographerManager.java b/src/main/java/org/leavesmc/leaves/entity/PhotographerManager.java new file mode 100644 -index 0000000000000000000000000000000000000000..4c2ef73e9668918d45d9e3ad250c7c20b1fb5dd1 +index 0000000000000000000000000000000000000000..492414e9328b3a0cde2157068f00e60eb5e978c6 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/entity/PhotographerManager.java ++++ b/src/main/java/org/leavesmc/leaves/entity/PhotographerManager.java @@ -0,0 +1,33 @@ -+package top.leavesmc.leaves.entity; ++package org.leavesmc.leaves.entity; + +import org.bukkit.Location; +import org.bukkit.util.Consumer; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; -+import top.leavesmc.leaves.entity.botaction.CustomBotAction; -+import top.leavesmc.leaves.replay.BukkitRecorderOption; ++import org.leavesmc.leaves.entity.botaction.CustomBotAction; ++import org.leavesmc.leaves.replay.BukkitRecorderOption; + +import java.util.Collection; +import java.util.UUID; @@ -120,13 +121,13 @@ index 0000000000000000000000000000000000000000..4c2ef73e9668918d45d9e3ad250c7c20 + + public Collection getPhotographers(); +} -diff --git a/src/main/java/top/leavesmc/leaves/replay/BukkitRecorderOption.java b/src/main/java/top/leavesmc/leaves/replay/BukkitRecorderOption.java +diff --git a/src/main/java/org/leavesmc/leaves/replay/BukkitRecorderOption.java b/src/main/java/org/leavesmc/leaves/replay/BukkitRecorderOption.java new file mode 100644 -index 0000000000000000000000000000000000000000..3df4a6055b91c28e273d6fb2697b608778f40a9c +index 0000000000000000000000000000000000000000..320e8bc0516580d946fa43671bd71094eade0422 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/replay/BukkitRecorderOption.java ++++ b/src/main/java/org/leavesmc/leaves/replay/BukkitRecorderOption.java @@ -0,0 +1,18 @@ -+package top.leavesmc.leaves.replay; ++package org.leavesmc.leaves.replay; + +public class BukkitRecorderOption { + diff --git a/patches/api/0010-Placeholder-for-Bytebuf-API.patch b/patches/api/0010-Placeholder-for-Bytebuf-API.patch new file mode 100644 index 00000000..4a069c17 --- /dev/null +++ b/patches/api/0010-Placeholder-for-Bytebuf-API.patch @@ -0,0 +1,15 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: MC_XiaoHei +Date: Sat, 11 May 2024 00:00:18 +0800 +Subject: [PATCH] Placeholder for Bytebuf-API + + +diff --git a/.gitignore b/.gitignore +index 97e78e27ee0eea2c8b24886eeb19164d552323fe..9764fa643039f215627c20a33ca70c9e36b2d599 100644 +--- a/.gitignore ++++ b/.gitignore +@@ -38,3 +38,4 @@ + # vs code + /.vscode + /.factorypath ++ diff --git a/patches/server/0001-Build-changes.patch b/patches/server/0001-Build-changes.patch index 1eeaa546..35ed3722 100644 --- a/patches/server/0001-Build-changes.patch +++ b/patches/server/0001-Build-changes.patch @@ -5,29 +5,22 @@ Subject: [PATCH] Build changes diff --git a/build.gradle.kts b/build.gradle.kts -index bcfe59b6efb628ee1e7f9d60667360d4d885fb6a..dc25ca9011a4fa0fcb642aa7371b0693c294dc9b 100644 +index 4998aff0b7cb084dcda15c6a18bbe45e99b6000a..16b742b5131376ceca04570dd4c088caff62e677 100644 --- a/build.gradle.kts +++ b/build.gradle.kts -@@ -13,8 +13,12 @@ configurations.named(log4jPlugins.compileClasspathConfigurationName) { +@@ -13,7 +13,7 @@ configurations.named(log4jPlugins.compileClasspathConfigurationName) { val alsoShade: Configuration by configurations.creating dependencies { - implementation(project(":paper-api")) -- implementation(project(":paper-mojangapi")) -+ // Leaves start -+ implementation(project(":leaves-api")) -+ implementation("io.papermc.paper:paper-mojangapi:1.20.4-R0.1-SNAPSHOT") { -+ exclude("io.papermc.paper", "paper-api") -+ } -+ // Leaves end ++ implementation(project(":leaves-api")) // Leaves - build change // Paper start implementation("org.jline:jline-terminal-jansi:3.21.0") implementation("net.minecrell:terminalconsoleappender:1.3.0") -@@ -59,19 +63,29 @@ dependencies { +@@ -67,6 +67,15 @@ paperweight { + craftBukkitPackageVersion.set("v1_20_R4") // also needs to be updated in MappingEnvironment } - val craftbukkitPackageVersion = "1_20_R3" // Paper -+ +// Leaves start - hide irrelevant compilation warnings +tasks.withType { + val compilerArgs = options.compilerArgs @@ -40,22 +33,27 @@ index bcfe59b6efb628ee1e7f9d60667360d4d885fb6a..dc25ca9011a4fa0fcb642aa7371b0693 tasks.jar { archiveClassifier.set("dev") - manifest { - val git = Git(rootProject.layout.projectDirectory.path) - val gitHash = git("rev-parse", "--short=7", "HEAD").getText().trim() -- val implementationVersion = System.getenv("BUILD_NUMBER") ?: "\"$gitHash\"" -+ val implementationVersion = /* System.getenv("BUILD_NUMBER") ?: */ "\"$gitHash\"" // Leaves we dont have CI - val date = git("show", "-s", "--format=%ci", gitHash).getText().trim() // Paper +@@ -80,14 +89,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 "CraftBukkit", -- "Implementation-Version" to "git-Paper-$implementationVersion", -+ "Implementation-Version" to "git-Leaves-$implementationVersion", +- "Implementation-Title" to "Paper", ++ "Implementation-Title" to "Leaves", // Leaves + "Implementation-Version" to implementationVersion, "Implementation-Vendor" to date, // Paper - "Specification-Title" to "Bukkit", +- "Specification-Title" to "Paper", ++ "Specification-Title" to "Leaves", // Leaves "Specification-Version" to project.version, -@@ -150,7 +164,7 @@ fun TaskContainer.registerRunTask( +- "Specification-Vendor" to "Paper Team", +- "Brand-Id" to "papermc:paper", +- "Brand-Name" to "Paper", ++ "Specification-Vendor" to "Leaves Team", // Leaves ++ "Brand-Id" to "leavesmc:leaves", // Leaves ++ "Brand-Name" to "Leaves", // Leaves + "Build-Number" to (build ?: ""), + "Build-Time" to Instant.now().toString(), + "Git-Branch" to gitBranch, // Paper +@@ -144,7 +153,7 @@ fun TaskContainer.registerRunTask( name: String, block: JavaExec.() -> Unit ): TaskProvider = register(name) { @@ -65,7 +63,7 @@ index bcfe59b6efb628ee1e7f9d60667360d4d885fb6a..dc25ca9011a4fa0fcb642aa7371b0693 standardInput = System.`in` workingDir = rootProject.layout.projectDirectory diff --git a/src/main/java/com/destroystokyo/paper/Metrics.java b/src/main/java/com/destroystokyo/paper/Metrics.java -index 4b002e8b75d117b726b0de274a76d3596fce015b..9ce4d3d96d2d5fbde1f0af599209c6c55038fb58 100644 +index 4b002e8b75d117b726b0de274a76d3596fce015b..03373e5a37a5f90d31434aab921ec8c6b6efef70 100644 --- a/src/main/java/com/destroystokyo/paper/Metrics.java +++ b/src/main/java/com/destroystokyo/paper/Metrics.java @@ -593,7 +593,8 @@ public class Metrics { @@ -91,7 +89,7 @@ index 4b002e8b75d117b726b0de274a76d3596fce015b..9ce4d3d96d2d5fbde1f0af599209c6c5 + return "unknown"; + })); + -+ if (top.leavesmc.leaves.LeavesConfig.bstatsPrivacyMode) { ++ if (org.leavesmc.leaves.LeavesConfig.bstatsPrivacyMode) { + return; + } + @@ -152,54 +150,75 @@ index 4b002e8b75d117b726b0de274a76d3596fce015b..9ce4d3d96d2d5fbde1f0af599209c6c5 } } } +diff --git a/src/main/java/io/papermc/paper/ServerBuildInfoImpl.java b/src/main/java/io/papermc/paper/ServerBuildInfoImpl.java +index 790bad0494454ca12ee152e3de6da3da634d9b20..c060857cb0551fff8f5033553b887f3a6b8f935a 100644 +--- a/src/main/java/io/papermc/paper/ServerBuildInfoImpl.java ++++ b/src/main/java/io/papermc/paper/ServerBuildInfoImpl.java +@@ -30,7 +30,7 @@ public record ServerBuildInfoImpl( + private static final String ATTRIBUTE_GIT_BRANCH = "Git-Branch"; + private static final String ATTRIBUTE_GIT_COMMIT = "Git-Commit"; + +- private static final String BRAND_PAPER_NAME = "Paper"; ++ private static final String BRAND_PAPER_NAME = "Leaves"; // Leaves - Paper -> Leaves + + private static final String BUILD_DEV = "DEV"; + diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index c8772c773f9933ed1d1debfe707af4373c458152..f9e5f9f309133ea5b540530dc7da96d085b89ac0 100644 +index dbc86b8d4d2af6e5f7e678f2bb77fd39b85c04c5..9719199b7dc98e5f04706bd420af5f14d8b9724c 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -1865,7 +1865,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop //Paper +- return io.papermc.paper.ServerBuildInfo.buildInfo().brandName(); // Paper ++ return org.leavesmc.leaves.LeavesConfig.serverModName; // Leaves - Custom // Paper } public SystemReport fillSystemReport(SystemReport details) { diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -index 68d268b6fff126e8645b6deec3fb549ea2286b77..1363d76e5546d1bb57f06fceb57196da459f962e 100644 +index 2eb9c584cc77237f1c82d880a51a3f8b51008d73..559649d0a134c29215f3783996fd80d81c149bec 100644 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -@@ -218,10 +218,11 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -231,9 +231,10 @@ 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 - com.destroystokyo.paper.Metrics.PaperMetrics.startMetrics(); // Paper - start metrics com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // Paper - load version history now - io.papermc.paper.brigadier.PaperBrigadierProviderImpl.INSTANCE.getClass(); // Paper - init PaperBrigadierProvider + com.destroystokyo.paper.Metrics.PaperMetrics.startMetrics(); // Paper - start metrics // Leaves - down + this.setPvpAllowed(dedicatedserverproperties.pvp); this.setFlightAllowed(dedicatedserverproperties.allowFlight); this.setMotd(dedicatedserverproperties.motd); -diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index c490a29bcf7410bc54959ee71375605964379ed5..367975d5e0c9846e5ce6d9cbdc3a977c8ab26b97 100644 ---- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java -+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -266,7 +266,7 @@ import javax.annotation.Nullable; // Paper - import javax.annotation.Nonnull; // Paper +diff --git a/src/main/java/net/minecraft/server/gui/MinecraftServerGui.java b/src/main/java/net/minecraft/server/gui/MinecraftServerGui.java +index 759062d219ff490a3cb19e710c4d18e3e08288e0..3952428c02fe87477f4139f4fa98381500b7e076 100644 +--- a/src/main/java/net/minecraft/server/gui/MinecraftServerGui.java ++++ b/src/main/java/net/minecraft/server/gui/MinecraftServerGui.java +@@ -118,7 +118,7 @@ public class MinecraftServerGui extends JComponent { - public final class CraftServer implements Server { -- private final String serverName = "Paper"; // Paper -+ private final String serverName = "Leaves"; // Leaves // Paper - private final String serverVersion; - private final String bukkitVersion = Versioning.getBukkitVersion(); - private final Logger logger = Logger.getLogger("Minecraft"); + // Paper start - Add onboarding message for initial server start + private JComponent buildOnboardingPanel() { +- String onboardingLink = "https://docs.papermc.io/paper/next-steps"; ++ String onboardingLink = "https://docs.leavesmc.org/leaves/guides/next-steps"; // Leaves - change + JPanel jPanel = new JPanel(); + + javax.swing.JLabel jLabel = new javax.swing.JLabel("If you need help setting up your server you can visit:"); diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java -index 8d626fadcd4743b6472a2954d2b1b2ec89669814..1068ed383232a71f6ada6677f4872267cc565325 100644 +index e02102280ed1dc300191d19bbca8f00e17701753..9164d33b564970d83d11c6544db5697ff9eff32f 100644 --- a/src/main/java/org/bukkit/craftbukkit/Main.java +++ b/src/main/java/org/bukkit/craftbukkit/Main.java -@@ -301,7 +301,7 @@ public class Main { +@@ -303,7 +303,7 @@ public class Main { if (buildDate.before(deadline.getTime())) { // Paper start - This is some stupid bullshit System.err.println("*** Warning, you've not updated in a while! ***"); @@ -209,7 +228,7 @@ index 8d626fadcd4743b6472a2954d2b1b2ec89669814..1068ed383232a71f6ada6677f4872267 //Thread.sleep(TimeUnit.SECONDS.toMillis(20)); // Paper end diff --git a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java b/src/main/java/org/bukkit/craftbukkit/util/Versioning.java -index 774556a62eb240da42e84db4502e2ed43495be17..ca166161ef919c559de9cc02bdf435cbfcc972df 100644 +index 774556a62eb240da42e84db4502e2ed43495be17..fdef98a7796d84c7b0ee61241859e10cc514534c 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java +++ b/src/main/java/org/bukkit/craftbukkit/util/Versioning.java @@ -11,7 +11,7 @@ public final class Versioning { @@ -217,12 +236,12 @@ index 774556a62eb240da42e84db4502e2ed43495be17..ca166161ef919c559de9cc02bdf435cb String result = "Unknown-Version"; - InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/io.papermc.paper/paper-api/pom.properties"); -+ InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/top.leavesmc.leaves/leaves-api/pom.properties"); // Leaves ++ InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/org.leavesmc.leaves/leaves-api/pom.properties"); // Leaves Properties properties = new Properties(); if (stream != null) { diff --git a/src/main/java/org/spigotmc/WatchdogThread.java b/src/main/java/org/spigotmc/WatchdogThread.java -index 9e638f72f180ff5ef63ec3dd6cf548c53f7bd4a5..9bd93cae47ed209b39fe90f9c36e55964e24967e 100644 +index 6db566e3111ec08a99aa429624979cb83a85e272..824679785bbe0ac038c4d529b4cbe857e2e102ca 100644 --- a/src/main/java/org/spigotmc/WatchdogThread.java +++ b/src/main/java/org/spigotmc/WatchdogThread.java @@ -155,14 +155,14 @@ public final class WatchdogThread extends io.papermc.paper.util.TickThread // Pa diff --git a/patches/server/0002-Dev-Fix.patch b/patches/server/0002-Dev-Fix.patch new file mode 100644 index 00000000..38ab6228 --- /dev/null +++ b/patches/server/0002-Dev-Fix.patch @@ -0,0 +1,19 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: violetc <58360096+s-yh-china@users.noreply.github.com> +Date: Mon, 20 May 2024 17:15:18 +0800 +Subject: [PATCH] Dev Fix + + +diff --git a/src/main/java/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java b/src/main/java/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java +index bc885d2cc95572ec68f1df62555fdba7998b1d93..0211311b3b63bcdea7ebf7bcb24629674c771402 100644 +--- a/src/main/java/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java ++++ b/src/main/java/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java +@@ -34,7 +34,7 @@ public interface CustomPacketPayload { + + private void writeCap(B value, CustomPacketPayload.Type id, CustomPacketPayload payload) { + value.writeResourceLocation(id.id()); +- StreamCodec streamCodec = this.findCodec(id.id); ++ StreamCodec streamCodec = (StreamCodec) this.findCodec(id.id); // Leaves - dev fix + streamCodec.encode(value, (T)payload); + } + diff --git a/patches/server/0002-Delete-Timings.patch b/patches/server/0003-Delete-Timings.patch similarity index 86% rename from patches/server/0002-Delete-Timings.patch rename to patches/server/0003-Delete-Timings.patch index ca97f015..2ee1363a 100644 --- a/patches/server/0002-Delete-Timings.patch +++ b/patches/server/0003-Delete-Timings.patch @@ -746,7 +746,7 @@ index 6bc7c6f16a1649fc9e24e7cf90fca401e5bd4875..5b446e6ac151f99f64f0c442d0b40b5e private static final ThreadLocal> CURRENT_TICKET_UPDATE_SCHEDULING = new ThreadLocal<>(); diff --git a/src/main/java/io/papermc/paper/chunk/system/scheduling/NewChunkHolder.java b/src/main/java/io/papermc/paper/chunk/system/scheduling/NewChunkHolder.java -index b66a7d4aab887309579154815a0d4abf9de506b0..e4d3f280b35d977f28233b1db1dc855cb252e827 100644 +index 56b07a3306e5735816c8d89601b519cb0db6379a..e932998bb1d833d782e1f6c7f576f521e8ace071 100644 --- a/src/main/java/io/papermc/paper/chunk/system/scheduling/NewChunkHolder.java +++ b/src/main/java/io/papermc/paper/chunk/system/scheduling/NewChunkHolder.java @@ -1779,19 +1779,17 @@ public final class NewChunkHolder { @@ -780,8 +780,40 @@ index b66a7d4aab887309579154815a0d4abf9de506b0..e4d3f280b35d977f28233b1db1dc855c } } +diff --git a/src/main/java/io/papermc/paper/command/brigadier/bukkit/BukkitCommandNode.java b/src/main/java/io/papermc/paper/command/brigadier/bukkit/BukkitCommandNode.java +index 10a113b057b0a4d27cce3bae975e1108aaa7b517..2076b4f00e008cc162458fff8dac1647f7487057 100644 +--- a/src/main/java/io/papermc/paper/command/brigadier/bukkit/BukkitCommandNode.java ++++ b/src/main/java/io/papermc/paper/command/brigadier/bukkit/BukkitCommandNode.java +@@ -1,6 +1,5 @@ + package io.papermc.paper.command.brigadier.bukkit; + +-import co.aikar.timings.Timing; + import com.mojang.brigadier.arguments.StringArgumentType; + import com.mojang.brigadier.builder.RequiredArgumentBuilder; + import com.mojang.brigadier.context.CommandContext; +@@ -73,18 +72,11 @@ public class BukkitCommandNode extends LiteralCommandNode { + public int run(CommandContext context) throws CommandSyntaxException { + CommandSender sender = context.getSource().getSender(); + +- // Plugins do weird things to workaround normal registration +- if (this.command.timings == null) { +- this.command.timings = co.aikar.timings.TimingsManager.getCommandTiming(null, this.command); +- } +- + String content = context.getRange().get(context.getInput()); + String[] args = org.apache.commons.lang3.StringUtils.split(content, ' '); // fix adjacent spaces (from console/plugins) causing empty array elements + +- try (Timing ignored = this.command.timings.startTiming()) { +- // Note: we don't return the result of target.execute as thats success / failure, we return handled (true) or not handled (false) +- this.command.execute(sender, this.literal, Arrays.copyOfRange(args, 1, args.length)); +- } ++ // Note: we don't return the result of target.execute as thats success / failure, we return handled (true) or not handled (false) ++ this.command.execute(sender, this.literal, Arrays.copyOfRange(args, 1, args.length)); + + // return true as command was handled + return 1; diff --git a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java -index 30fe1c0645a07d663b08c0f988a1ab3a750bf7c4..47408dbce3a627236694c0d0f956c7f87a898b86 100644 +index 2874bc3001c4e7d9191e47ba512c5a68369c21f1..0cb47b5fee85230989293d430c02e53391e0ef67 100644 --- a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java +++ b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java @@ -1,6 +1,5 @@ @@ -828,10 +860,10 @@ index 7ce9ebba8ce304d1f3f21d4f15ee5f3560d7700b..a1c9726d25479b5326fe2fa2b0f5a98d } return ret; diff --git a/src/main/java/io/papermc/paper/plugin/manager/PaperPluginManagerImpl.java b/src/main/java/io/papermc/paper/plugin/manager/PaperPluginManagerImpl.java -index dab211c458311869c61779305580a1c7da830f71..193a527c8ebd3b8772820883046de7e98ad4a76a 100644 +index 097500a59336db1bbfffcd1aa4cff7a8586e46ec..35b00c139864dd7925d46a2d6a317d7e3aae9638 100644 --- a/src/main/java/io/papermc/paper/plugin/manager/PaperPluginManagerImpl.java +++ b/src/main/java/io/papermc/paper/plugin/manager/PaperPluginManagerImpl.java -@@ -227,7 +227,7 @@ public class PaperPluginManagerImpl implements PluginManager, DependencyContext +@@ -232,7 +232,7 @@ public class PaperPluginManagerImpl implements PluginManager, DependencyContext @Override public boolean useTimings() { @@ -841,10 +873,10 @@ index dab211c458311869c61779305580a1c7da830f71..193a527c8ebd3b8772820883046de7e9 @Override diff --git a/src/main/java/net/minecraft/network/protocol/PacketUtils.java b/src/main/java/net/minecraft/network/protocol/PacketUtils.java -index 83302c252f54481f239522e5c6861ccfe233070a..070231080052ef3d0da179a8ed8b754ed6f8dd11 100644 +index 57e76b53e5e314c3e6b8856010f7a84188121582..d6daa27a8d7aca00b181e90d789f4249e8437d29 100644 --- a/src/main/java/net/minecraft/network/protocol/PacketUtils.java +++ b/src/main/java/net/minecraft/network/protocol/PacketUtils.java -@@ -49,8 +49,7 @@ public class PacketUtils { +@@ -50,8 +50,7 @@ public class PacketUtils { try { // Paper - detailed watchdog information if (listener instanceof ServerCommonPacketListenerImpl serverCommonPacketListener && serverCommonPacketListener.processedDisconnect) return; // CraftBukkit - Don't handle sync packets for kicked players if (listener.shouldHandleMessage(packet)) { @@ -853,9 +885,9 @@ index 83302c252f54481f239522e5c6861ccfe233070a..070231080052ef3d0da179a8ed8b754e + try { packet.handle(listener); } catch (Exception exception) { - label25: + if (exception instanceof ReportedException) { diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 65a342698c98eb91f5f9156885afd7cc56967114..f7f9fd5e591aad8bd6b3ed4ffcb2ca7aaa6548f3 100644 +index 9719199b7dc98e5f04706bd420af5f14d8b9724c..025e1a22d7344fc7de2baca5c29a6a6dacd2c88e 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -3,9 +3,6 @@ package net.minecraft.server; @@ -868,7 +900,7 @@ index 65a342698c98eb91f5f9156885afd7cc56967114..f7f9fd5e591aad8bd6b3ed4ffcb2ca7a import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; -@@ -189,8 +186,6 @@ import org.bukkit.craftbukkit.Main; +@@ -190,8 +187,6 @@ import org.bukkit.craftbukkit.CraftRegistry; import org.bukkit.event.server.ServerLoadEvent; // CraftBukkit end @@ -877,7 +909,7 @@ index 65a342698c98eb91f5f9156885afd7cc56967114..f7f9fd5e591aad8bd6b3ed4ffcb2ca7a public abstract class MinecraftServer extends ReentrantBlockableEventLoop implements ServerInfo, CommandSource, AutoCloseable { private static MinecraftServer SERVER; // Paper -@@ -968,7 +963,6 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { entityplayer.connection.suspendFlushing(); }); @@ -986,7 +1018,7 @@ index 65a342698c98eb91f5f9156885afd7cc56967114..f7f9fd5e591aad8bd6b3ed4ffcb2ca7a // Paper start - Folia scheduler API ((io.papermc.paper.threadedregions.scheduler.FoliaGlobalRegionScheduler) Bukkit.getGlobalRegionScheduler()).tick(); getAllLevels().forEach(level -> { -@@ -1661,21 +1644,16 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop list = Lists.newArrayList(); List list1 = this.level.players(); ObjectIterator objectiterator = this.entityMap.values().iterator(); @@ -1248,7 +1203,7 @@ index 12109446fc76a39faee6cda042ca48b3fd3809f4..295edf4e84699fc555048b7e59aebee8 ChunkMap.TrackedEntity playerchunkmap_entitytracker; -@@ -1198,17 +1169,14 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1214,17 +1198,14 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider playerchunkmap_entitytracker.serverEntity.sendChanges(); } } @@ -1267,10 +1222,10 @@ index 12109446fc76a39faee6cda042ca48b3fd3809f4..295edf4e84699fc555048b7e59aebee8 } diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index 366c0c9b45a819f7f94ebe3e49b8ab7f9edf9ce7..2a19a45e9c7ac4646ce89c566b5fec21281c45b9 100644 +index b99f50604bafecbc68835974c9ed0caa91911a40..256ad83f10e6df5d32959d38eeabc126b9b7b190 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -@@ -278,10 +278,8 @@ public class ServerChunkCache extends ChunkSource { +@@ -274,10 +274,8 @@ public class ServerChunkCache extends ChunkSource { if (!completablefuture.isDone()) { // Paper io.papermc.paper.chunk.system.scheduling.ChunkTaskScheduler.pushChunkWait(this.level, x1, z1); // Paper - rewrite chunk system com.destroystokyo.paper.io.SyncLoadFinder.logSyncLoad(this.level, x, z); // Paper - Add debug for sync chunk loads @@ -1279,9 +1234,9 @@ index 366c0c9b45a819f7f94ebe3e49b8ab7f9edf9ce7..2a19a45e9c7ac4646ce89c566b5fec21 io.papermc.paper.chunk.system.scheduling.ChunkTaskScheduler.popChunkWait(); // Paper - rewrite chunk system - this.level.timings.syncChunkLoad.stopTiming(); // Paper } // Paper - ichunkaccess = (ChunkAccess) ((Either) completablefuture.join()).map((ichunkaccess1) -> { - return ichunkaccess1; -@@ -430,17 +428,13 @@ public class ServerChunkCache extends ChunkSource { + ChunkResult chunkresult = (ChunkResult) completablefuture.join(); + ChunkAccess ichunkaccess1 = (ChunkAccess) chunkresult.orElse(null); // CraftBukkit - decompile error +@@ -425,17 +423,13 @@ public class ServerChunkCache extends ChunkSource { public void save(boolean flush) { this.runDistanceManagerUpdates(); @@ -1300,12 +1255,16 @@ index 366c0c9b45a819f7f94ebe3e49b8ab7f9edf9ce7..2a19a45e9c7ac4646ce89c566b5fec21 } // Paper end - Incremental chunk and player saving -@@ -477,23 +471,17 @@ public class ServerChunkCache extends ChunkSource { +@@ -472,26 +466,21 @@ public class ServerChunkCache extends ChunkSource { @Override public void tick(BooleanSupplier shouldKeepTicking, boolean tickChunks) { this.level.getProfiler().push("purge"); - this.level.timings.doChunkMap.startTiming(); // Spigot - this.distanceManager.purgeStaleTickets(); ++ // this.level.timings.doChunkMap.startTiming(); // Spigot // Leaves - delete Timings + if (this.level.tickRateManager().runsNormally() || !tickChunks) { + this.distanceManager.purgeStaleTickets(); + } + this.runDistanceManagerUpdates(); - this.level.timings.doChunkMap.stopTiming(); // Spigot this.level.getProfiler().popPush("chunks"); @@ -1324,7 +1283,7 @@ index 366c0c9b45a819f7f94ebe3e49b8ab7f9edf9ce7..2a19a45e9c7ac4646ce89c566b5fec21 this.level.getProfiler().pop(); this.clearCache(); } -@@ -509,13 +497,11 @@ public class ServerChunkCache extends ChunkSource { +@@ -507,13 +496,11 @@ public class ServerChunkCache extends ChunkSource { gameprofilerfiller.push("pollingChunks"); gameprofilerfiller.push("filteringLoadedChunks"); // Paper - optimise chunk tick iteration @@ -1332,13 +1291,13 @@ index 366c0c9b45a819f7f94ebe3e49b8ab7f9edf9ce7..2a19a45e9c7ac4646ce89c566b5fec21 // Paper - optimise chunk tick iteration - if (this.level.getServer().tickRateManager().runsNormally()) { + if (this.level.tickRateManager().runsNormally()) { gameprofilerfiller.popPush("naturalSpawnCount"); - this.level.timings.countNaturalMobs.startTiming(); // Paper - timings int k = this.distanceManager.getNaturalSpawnChunkCount(); // Paper start - Optional per player mob spawns int naturalSpawnChunkCount = k; -@@ -540,7 +526,6 @@ public class ServerChunkCache extends ChunkSource { +@@ -538,7 +525,6 @@ public class ServerChunkCache extends ChunkSource { spawnercreature_d = NaturalSpawner.createState(naturalSpawnChunkCount, this.level.getAllEntities(), this::getFullChunk, !this.level.paperConfig().entities.spawning.perPlayerMobSpawns ? new LocalMobCapCalculator(this.chunkMap) : null, false); } // Paper end - Optional per player mob spawns @@ -1346,7 +1305,7 @@ index 366c0c9b45a819f7f94ebe3e49b8ab7f9edf9ce7..2a19a45e9c7ac4646ce89c566b5fec21 this.lastSpawnState = spawnercreature_d; gameprofilerfiller.popPush("spawnAndTick"); -@@ -649,19 +634,14 @@ public class ServerChunkCache extends ChunkSource { +@@ -647,19 +633,14 @@ public class ServerChunkCache extends ChunkSource { } } // Paper end - optimise chunk tick iteration @@ -1366,7 +1325,7 @@ index 366c0c9b45a819f7f94ebe3e49b8ab7f9edf9ce7..2a19a45e9c7ac4646ce89c566b5fec21 // Paper start - optimise chunk tick iteration if (!this.chunkMap.needsChangeBroadcasting.isEmpty()) { it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet copy = this.chunkMap.needsChangeBroadcasting.clone(); -@@ -675,8 +655,6 @@ public class ServerChunkCache extends ChunkSource { +@@ -673,8 +654,6 @@ public class ServerChunkCache extends ChunkSource { } } // Paper end - optimise chunk tick iteration @@ -1376,7 +1335,7 @@ index 366c0c9b45a819f7f94ebe3e49b8ab7f9edf9ce7..2a19a45e9c7ac4646ce89c566b5fec21 gameprofilerfiller.pop(); } diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index 502bdc726b7890b00ee36871d905dea44e8719e3..ccc645f225bb0cf898dbc2ee7abb21b53ff8660b 100644 +index ca56a0b596976448da6bb2a0e82b3d5cd4133e12..92805a3311bc1f21df9512b14b209e1d51174ac5 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java @@ -1,7 +1,6 @@ @@ -1387,7 +1346,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..ccc645f225bb0cf898dbc2ee7abb21b5 import com.google.common.collect.Lists; import com.mojang.datafixers.DataFixer; import com.mojang.datafixers.util.Pair; -@@ -845,7 +844,6 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -851,7 +850,6 @@ public class ServerLevel extends Level implements WorldGenLevel { } gameprofilerfiller.popPush("tickPending"); @@ -1395,7 +1354,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..ccc645f225bb0cf898dbc2ee7abb21b5 if (!this.isDebug() && flag) { j = this.getGameTime(); gameprofilerfiller.push("blockTicks"); -@@ -854,24 +852,17 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -860,24 +858,17 @@ public class ServerLevel extends Level implements WorldGenLevel { this.fluidTicks.tick(j, paperConfig().environment.maxFluidTicks, this::tickFluid); // Paper - configurable max fluid ticks gameprofilerfiller.pop(); } @@ -1420,7 +1379,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..ccc645f225bb0cf898dbc2ee7abb21b5 } this.handlingTick = false; -@@ -884,7 +875,6 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -890,7 +881,6 @@ public class ServerLevel extends Level implements WorldGenLevel { if (flag1 || this.emptyTime++ < 300) { gameprofilerfiller.push("entities"); @@ -1428,7 +1387,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..ccc645f225bb0cf898dbc2ee7abb21b5 if (this.dragonFight != null && flag) { gameprofilerfiller.push("dragonFight"); this.dragonFight.tick(); -@@ -892,7 +882,6 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -898,7 +888,6 @@ public class ServerLevel extends Level implements WorldGenLevel { } org.spigotmc.ActivationRange.activateEntities(this); // Spigot @@ -1436,7 +1395,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..ccc645f225bb0cf898dbc2ee7abb21b5 this.entityTickList.forEach((entity) -> { if (!entity.isRemoved()) { if (false && this.shouldDiscardEntity(entity)) { // CraftBukkit - We prevent spawning in general, so this butchering is not needed -@@ -919,8 +908,6 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -925,8 +914,6 @@ public class ServerLevel extends Level implements WorldGenLevel { } } }); @@ -1445,7 +1404,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..ccc645f225bb0cf898dbc2ee7abb21b5 gameprofilerfiller.pop(); this.tickBlockEntities(); } -@@ -1033,7 +1020,6 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1039,7 +1026,6 @@ public class ServerLevel extends Level implements WorldGenLevel { } // Paper - Option to disable ice and snow gameprofilerfiller.popPush("tickBlocks"); @@ -1453,7 +1412,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..ccc645f225bb0cf898dbc2ee7abb21b5 if (randomTickSpeed > 0) { // Paper start - optimize random block ticking LevelChunkSection[] sections = chunk.getSections(); -@@ -1067,7 +1053,6 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1073,7 +1059,6 @@ public class ServerLevel extends Level implements WorldGenLevel { } // Paper end - optimise random block ticking @@ -1461,7 +1420,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..ccc645f225bb0cf898dbc2ee7abb21b5 gameprofilerfiller.pop(); } -@@ -1380,9 +1365,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1386,9 +1371,7 @@ public class ServerLevel extends Level implements WorldGenLevel { currentlyTickingEntity.lazySet(entity); } // Paper end - log detailed entity tick information @@ -1471,7 +1430,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..ccc645f225bb0cf898dbc2ee7abb21b5 /*if (!org.spigotmc.ActivationRange.checkIfActive(entity)) { // Paper - comment out - EAR 2, reimplement below entity.tickCount++; timer = entity.getType().inactiveTickTimer.startTiming(); try { // Paper - timings -@@ -1391,11 +1374,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1397,11 +1380,7 @@ public class ServerLevel extends Level implements WorldGenLevel { return; }*/ // Paper - comment out EAR 2 // Spigot end @@ -1483,7 +1442,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..ccc645f225bb0cf898dbc2ee7abb21b5 entity.setOldPosAndRot(); ProfilerFiller gameprofilerfiller = this.getProfiler(); -@@ -1405,12 +1384,10 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1411,12 +1390,10 @@ public class ServerLevel extends Level implements WorldGenLevel { }); gameprofilerfiller.incrementCounter("tickNonPassenger"); if (isActive) { // Paper - EAR 2 @@ -1496,7 +1455,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..ccc645f225bb0cf898dbc2ee7abb21b5 Iterator iterator = entity.getPassengers().iterator(); while (iterator.hasNext()) { -@@ -1433,8 +1410,6 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1439,8 +1416,6 @@ public class ServerLevel extends Level implements WorldGenLevel { if (passenger instanceof Player || this.entityTickList.contains(passenger)) { // Paper - EAR 2 final boolean isActive = org.spigotmc.ActivationRange.checkIfActive(passenger); @@ -1505,7 +1464,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..ccc645f225bb0cf898dbc2ee7abb21b5 // Paper end passenger.setOldPosAndRot(); ++passenger.tickCount; -@@ -1463,8 +1438,6 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1469,8 +1444,6 @@ public class ServerLevel extends Level implements WorldGenLevel { this.tickPassenger(passenger, entity2); } @@ -1514,7 +1473,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..ccc645f225bb0cf898dbc2ee7abb21b5 } } else { passenger.stopRiding(); -@@ -1484,26 +1457,22 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1490,26 +1463,22 @@ public class ServerLevel extends Level implements WorldGenLevel { org.bukkit.Bukkit.getPluginManager().callEvent(new org.bukkit.event.world.WorldSaveEvent(getWorld())); } @@ -1541,19 +1500,19 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..ccc645f225bb0cf898dbc2ee7abb21b5 + ServerLevel worldserver1 = this; - this.serverLevelData.setWorldBorder(worldserver1.getWorldBorder().createSettings()); -- this.serverLevelData.setCustomBossEvents(this.server.getCustomBossEvents().save()); +- this.serverLevelData.setCustomBossEvents(this.server.getCustomBossEvents().save(this.registryAccess())); - this.convertable.saveDataTag(this.server.registryAccess(), this.serverLevelData, this.server.getPlayerList().getSingleplayerData()); - } - // CraftBukkit end + this.serverLevelData.setWorldBorder(worldserver1.getWorldBorder().createSettings()); -+ this.serverLevelData.setCustomBossEvents(this.server.getCustomBossEvents().save()); ++ this.serverLevelData.setCustomBossEvents(this.server.getCustomBossEvents().save(this.registryAccess())); + this.convertable.saveDataTag(this.server.registryAccess(), this.serverLevelData, this.server.getPlayerList().getSingleplayerData()); } + // CraftBukkit end } // Paper end - Incremental chunk and player saving -@@ -1517,7 +1486,6 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1523,7 +1492,6 @@ public class ServerLevel extends Level implements WorldGenLevel { if (!savingDisabled) { org.bukkit.Bukkit.getPluginManager().callEvent(new org.bukkit.event.world.WorldSaveEvent(this.getWorld())); // CraftBukkit @@ -1561,7 +1520,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..ccc645f225bb0cf898dbc2ee7abb21b5 if (progressListener != null) { progressListener.progressStartNoAbort(Component.translatable("menu.savingLevel")); } -@@ -1527,11 +1495,8 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1533,11 +1501,8 @@ public class ServerLevel extends Level implements WorldGenLevel { progressListener.progressStage(Component.translatable("menu.savingChunks")); } @@ -1573,42 +1532,8 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..ccc645f225bb0cf898dbc2ee7abb21b5 // Paper - rewrite chunk system - entity saving moved into ChunkHolder } else if (close) { chunkproviderserver.close(false); } // Paper - rewrite chunk system -diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index fe2ef36ab5dc4b933abf24dbfd0e811c53239cf0..03eba1b13288dfaaeca9a3eef68a1e0d3d71ccb6 100644 ---- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -2394,7 +2394,6 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl - - public void handleCommand(String s) { // Paper - private -> public - org.spigotmc.AsyncCatcher.catchOp("Command Dispatched Async: " + s); // Paper - Add async catcher -- co.aikar.timings.MinecraftTimings.playerCommandTimer.startTiming(); // Paper - if ( org.spigotmc.SpigotConfig.logCommands ) // Spigot - this.LOGGER.info(this.player.getScoreboardName() + " issued server command: " + s); - -@@ -2404,20 +2403,14 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl - this.cserver.getPluginManager().callEvent(event); - - if (event.isCancelled()) { -- co.aikar.timings.MinecraftTimings.playerCommandTimer.stopTiming(); // Paper - return; - } - - try { -- if (this.cserver.dispatchCommand(event.getPlayer(), event.getMessage().substring(1))) { -- return; -- } -+ this.cserver.dispatchCommand(event.getPlayer(), event.getMessage().substring(1)); - } catch (org.bukkit.command.CommandException ex) { - player.sendMessage(org.bukkit.ChatColor.RED + "An internal error occurred while attempting to perform this command"); - java.util.logging.Logger.getLogger(ServerGamePacketListenerImpl.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); -- return; -- } finally { -- co.aikar.timings.MinecraftTimings.playerCommandTimer.stopTiming(); // Paper - } - } - // CraftBukkit end diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index 1e5f709115007ff19901c0a6c3cf884d9e4d3a6c..aa7eb1f037875293b03588f5bc5d2df70237b45e 100644 +index a2142930b4d4b05987c90496fb9d733d99040aa0..6957cbfbea51d6a3b57e1c5bfcebd52a25cde8d5 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java @@ -1,6 +1,5 @@ @@ -1618,7 +1543,7 @@ index 1e5f709115007ff19901c0a6c3cf884d9e4d3a6c..aa7eb1f037875293b03588f5bc5d2df7 import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; -@@ -1236,7 +1235,6 @@ public abstract class PlayerList { +@@ -1235,7 +1234,6 @@ public abstract class PlayerList { public void saveAll(int interval) { io.papermc.paper.util.MCUtil.ensureMain("Save Players" , () -> { // Paper - Ensure main @@ -1626,7 +1551,7 @@ index 1e5f709115007ff19901c0a6c3cf884d9e4d3a6c..aa7eb1f037875293b03588f5bc5d2df7 int numSaved = 0; long now = MinecraftServer.currentTick; for (int i = 0; i < this.players.size(); ++i) { -@@ -1247,7 +1245,6 @@ public abstract class PlayerList { +@@ -1246,7 +1244,6 @@ public abstract class PlayerList { } // Paper end - Incremental chunk and player saving } @@ -1635,13 +1560,13 @@ index 1e5f709115007ff19901c0a6c3cf884d9e4d3a6c..aa7eb1f037875293b03588f5bc5d2df7 } diff --git a/src/main/java/net/minecraft/world/entity/EntityType.java b/src/main/java/net/minecraft/world/entity/EntityType.java -index 09e8445a3f8c6b3ebc852a75a9a25b41a51ba659..22d19f1ca47a79be2c41775c5564535b8adcfcec 100644 +index a46bf73c608641bf1f00fd55242de71a0f2ee06e..9b15a2a966de203ada8894a9354ff8e0e737ef75 100644 --- a/src/main/java/net/minecraft/world/entity/EntityType.java +++ b/src/main/java/net/minecraft/world/entity/EntityType.java -@@ -331,10 +331,6 @@ public class EntityType implements FeatureElement, EntityTypeT - this(factory, spawnGroup, saveable, summonable, fireImmune, spawnableFarFromPlayer, canSpawnInside, dimensions, maxTrackDistance, trackTickInterval, requiredFeatures, "custom"); +@@ -343,10 +343,6 @@ public class EntityType implements FeatureElement, EntityTypeT + this(factory, spawnGroup, saveable, summonable, fireImmune, spawnableFarFromPlayer, canSpawnInside, dimensions, spawnBoxScale, maxTrackDistance, trackTickInterval, requiredFeatures, "custom"); } - public EntityType(EntityType.EntityFactory factory, MobCategory spawnGroup, boolean saveable, boolean summonable, boolean fireImmune, boolean spawnableFarFromPlayer, ImmutableSet canSpawnInside, EntityDimensions dimensions, int maxTrackDistance, int trackTickInterval, FeatureFlagSet requiredFeatures, String id) { + public EntityType(EntityType.EntityFactory factory, MobCategory spawnGroup, boolean saveable, boolean summonable, boolean fireImmune, boolean spawnableFarFromPlayer, ImmutableSet canSpawnInside, EntityDimensions dimensions, float spawnBoxScale, int maxTrackDistance, int trackTickInterval, FeatureFlagSet requiredFeatures, String id) { - this.tickTimer = co.aikar.timings.MinecraftTimings.getEntityTimings(id, "tick"); - this.inactiveTickTimer = co.aikar.timings.MinecraftTimings.getEntityTimings(id, "inactiveTick"); - this.passengerTickTimer = co.aikar.timings.MinecraftTimings.getEntityTimings(id, "passengerTick"); @@ -1649,7 +1574,7 @@ index 09e8445a3f8c6b3ebc852a75a9a25b41a51ba659..22d19f1ca47a79be2c41775c5564535b // Paper end this.builtInRegistryHolder = BuiltInRegistries.ENTITY_TYPE.createIntrusiveHolder(this); this.factory = factory; -@@ -691,12 +687,6 @@ public class EntityType implements FeatureElement, EntityTypeT +@@ -700,12 +696,6 @@ public class EntityType implements FeatureElement, EntityTypeT return this.updateInterval; } @@ -1663,10 +1588,10 @@ index 09e8445a3f8c6b3ebc852a75a9a25b41a51ba659..22d19f1ca47a79be2c41775c5564535b return this != EntityType.PLAYER && this != EntityType.LLAMA_SPIT && this != EntityType.WITHER && this != EntityType.BAT && this != EntityType.ITEM_FRAME && this != EntityType.GLOW_ITEM_FRAME && this != EntityType.LEASH_KNOT && this != EntityType.PAINTING && this != EntityType.END_CRYSTAL && this != EntityType.EVOKER_FANGS; } diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index e9bb7feb591032904516d1b9374f486d8a7d066c..04771be6128491bc7b9e6a0a400dfd3253659cce 100644 +index 517e10c3d8b1549cd30fd0e7cf2bcb35e88eb8ed..e8a472f7e90dfb39b16521f75521d60b532af5cc 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -143,7 +143,6 @@ import org.bukkit.event.entity.EntityTeleportEvent; +@@ -150,7 +150,6 @@ import org.bukkit.event.entity.EntityTeleportEvent; import org.bukkit.event.player.PlayerItemConsumeEvent; // CraftBukkit end @@ -1675,7 +1600,7 @@ index e9bb7feb591032904516d1b9374f486d8a7d066c..04771be6128491bc7b9e6a0a400dfd32 public abstract class LivingEntity extends Entity implements Attackable { diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/Behavior.java b/src/main/java/net/minecraft/world/entity/ai/behavior/Behavior.java -index 03092417cd8ab5c6d266f3af9f20f47b34cfaba3..9d720df44cab753533bf1c2f7d07fc41cded1ed2 100644 +index 9379dd4056018b52c93ed4888dcdc94579bd9691..ba951cc1aaa94b58ee7985f197d41cc8be747fc8 100644 --- a/src/main/java/net/minecraft/world/entity/ai/behavior/Behavior.java +++ b/src/main/java/net/minecraft/world/entity/ai/behavior/Behavior.java @@ -16,7 +16,6 @@ public abstract class Behavior implements BehaviorContro @@ -1719,7 +1644,7 @@ index 03092417cd8ab5c6d266f3af9f20f47b34cfaba3..9d720df44cab753533bf1c2f7d07fc41 protected void tick(ServerLevel world, E entity, long time) { diff --git a/src/main/java/net/minecraft/world/entity/ai/sensing/Sensor.java b/src/main/java/net/minecraft/world/entity/ai/sensing/Sensor.java -index 9e90cb2f51d1bacacb287e912d14ab9152523205..06fab5e6b38d7b5509cc175d3921f500dee6443c 100644 +index 85b4b24361e785acf75571ff98f924c00ae80748..1f3e0392f88a7cb3fb5c0767cdd1b4bc4ffcae4e 100644 --- a/src/main/java/net/minecraft/world/entity/ai/sensing/Sensor.java +++ b/src/main/java/net/minecraft/world/entity/ai/sensing/Sensor.java @@ -28,7 +28,6 @@ public abstract class Sensor { @@ -1750,53 +1675,10 @@ index 9e90cb2f51d1bacacb287e912d14ab9152523205..06fab5e6b38d7b5509cc175d3921f500 } diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index ca89d1593bf1b46c79a882db528cbca1359dc9d4..74b446d9d39642c315d2e62f11a63278bb95e266 100644 +index b4ef3ad2c17168085372f1fe46809f02d9dfe74a..34654d0f7d5c159ceaf76b327a3f86bd4f82c175 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -12,7 +12,6 @@ import java.util.function.Supplier; - import javax.annotation.Nullable; - import net.minecraft.CrashReport; - import net.minecraft.CrashReportCategory; --import net.minecraft.ReportedException; - import net.minecraft.core.BlockPos; - import net.minecraft.core.Direction; - import net.minecraft.core.Holder; -@@ -33,7 +32,6 @@ import net.minecraft.server.level.ServerLevel; - import net.minecraft.sounds.SoundEvent; - import net.minecraft.sounds.SoundEvents; - import net.minecraft.sounds.SoundSource; --import net.minecraft.util.AbortableIterationConsumer; - import net.minecraft.util.Mth; - import net.minecraft.util.RandomSource; - import net.minecraft.util.profiling.ProfilerFiller; -@@ -42,8 +40,6 @@ import net.minecraft.world.TickRateManager; - import net.minecraft.world.damagesource.DamageSource; - import net.minecraft.world.damagesource.DamageSources; - import net.minecraft.world.entity.Entity; --import net.minecraft.world.entity.boss.EnderDragonPart; --import net.minecraft.world.entity.boss.enderdragon.EnderDragon; - import net.minecraft.world.entity.item.ItemEntity; - import net.minecraft.world.entity.player.Player; - import net.minecraft.world.item.ItemStack; -@@ -89,17 +85,14 @@ import net.minecraft.network.protocol.game.ClientboundSetBorderSizePacket; - import net.minecraft.network.protocol.game.ClientboundSetBorderWarningDelayPacket; - import net.minecraft.network.protocol.game.ClientboundSetBorderWarningDistancePacket; - import org.bukkit.Bukkit; --import org.bukkit.Location; - import org.bukkit.craftbukkit.CraftServer; - import org.bukkit.craftbukkit.CraftWorld; - import org.bukkit.craftbukkit.block.CapturedBlockState; - import org.bukkit.craftbukkit.block.CraftBlockState; - import org.bukkit.craftbukkit.block.data.CraftBlockData; - import org.bukkit.craftbukkit.util.CraftSpawnCategory; --import org.bukkit.craftbukkit.util.CraftNamespacedKey; - import org.bukkit.entity.SpawnCategory; - import org.bukkit.event.block.BlockPhysicsEvent; --import org.bukkit.event.world.GenericGameEvent; - // CraftBukkit end - - public abstract class Level implements LevelAccessor, AutoCloseable { -@@ -173,7 +166,6 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -170,7 +170,6 @@ public abstract class Level implements LevelAccessor, AutoCloseable { // Paper end - add paper world config public final com.destroystokyo.paper.antixray.ChunkPacketBlockController chunkPacketBlockController; // Paper - Anti-Xray @@ -1804,15 +1686,15 @@ index ca89d1593bf1b46c79a882db528cbca1359dc9d4..74b446d9d39642c315d2e62f11a63278 public static BlockPos lastPhysicsProblem; // Spigot private org.spigotmc.TickLimiter entityLimiter; private org.spigotmc.TickLimiter tileLimiter; -@@ -298,7 +290,6 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -292,7 +291,6 @@ public abstract class Level implements LevelAccessor, AutoCloseable { public void onBorderSetDamageSafeZOne(WorldBorder border, double safeZoneRadius) {} }); // CraftBukkit end - this.timings = new co.aikar.timings.WorldTimingsHandler(this); // Paper - code below can generate new world and access timings - this.keepSpawnInMemory = this.paperConfig().spawn.keepSpawnLoaded; // Paper - Option to keep spawn chunks loaded this.entityLimiter = new org.spigotmc.TickLimiter(this.spigotConfig.entityMaxTickTime); this.tileLimiter = new org.spigotmc.TickLimiter(this.spigotConfig.tileMaxTickTime); -@@ -1269,15 +1260,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable { + this.chunkPacketBlockController = this.paperConfig().anticheat.antiXray.enabled ? new com.destroystokyo.paper.antixray.ChunkPacketBlockControllerAntiXray(this, executor) : com.destroystokyo.paper.antixray.ChunkPacketBlockController.NO_OPERATION_INSTANCE; // Paper - Anti-Xray +@@ -1260,15 +1258,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable { ProfilerFiller gameprofilerfiller = this.getProfiler(); gameprofilerfiller.push("blockEntities"); @@ -1828,7 +1710,7 @@ index ca89d1593bf1b46c79a882db528cbca1359dc9d4..74b446d9d39642c315d2e62f11a63278 // Spigot start // Iterator iterator = this.blockEntityTickers.iterator(); boolean flag = this.tickRateManager().runsNormally(); -@@ -1306,9 +1294,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1297,9 +1292,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { } this.blockEntityTickers.removeAll(toRemove); // Paper - Fix MC-117075 @@ -1839,10 +1721,10 @@ index ca89d1593bf1b46c79a882db528cbca1359dc9d4..74b446d9d39642c315d2e62f11a63278 this.spigotConfig.currentPrimedTnt = 0; // Spigot } diff --git a/src/main/java/net/minecraft/world/level/NaturalSpawner.java b/src/main/java/net/minecraft/world/level/NaturalSpawner.java -index da7489986848316fed029b71d1bc4e1248c9c9a8..140c9e6c7bd5e2e52c586ab6954edbc790e6e02b 100644 +index ed8032495af9ce9c23419224814b8d27e4a97c17..189a6bd4967aba72e12170e091dbb5b779e752a0 100644 --- a/src/main/java/net/minecraft/world/level/NaturalSpawner.java +++ b/src/main/java/net/minecraft/world/level/NaturalSpawner.java -@@ -133,7 +133,6 @@ public final class NaturalSpawner { +@@ -128,7 +128,6 @@ public final class NaturalSpawner { public static void spawnForChunk(ServerLevel world, LevelChunk chunk, NaturalSpawner.SpawnState info, boolean spawnAnimals, boolean spawnMonsters, boolean rareSpawn) { world.getProfiler().push("spawner"); @@ -1850,7 +1732,7 @@ index da7489986848316fed029b71d1bc4e1248c9c9a8..140c9e6c7bd5e2e52c586ab6954edbc7 MobCategory[] aenumcreaturetype = NaturalSpawner.SPAWNING_CATEGORIES; int i = aenumcreaturetype.length; -@@ -186,7 +185,6 @@ public final class NaturalSpawner { +@@ -181,7 +180,6 @@ public final class NaturalSpawner { } } @@ -1859,7 +1741,7 @@ index da7489986848316fed029b71d1bc4e1248c9c9a8..140c9e6c7bd5e2e52c586ab6954edbc7 } 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 22036ed3ea0629bc12981a8d91a03e55cc2117d6..3212771ac19044ca37bf60e231eac5615a9c240e 100644 +index cf8b8c8efd1c9c81eb5f02d75bd75875eb66771f..555d255a79c6136d0df3504218a0bc4681a5489f 100644 --- a/src/main/java/net/minecraft/world/level/block/Block.java +++ b/src/main/java/net/minecraft/world/level/block/Block.java @@ -103,13 +103,6 @@ public class Block extends BlockBehaviour implements ItemLike { @@ -1877,10 +1759,10 @@ index 22036ed3ea0629bc12981a8d91a03e55cc2117d6..3212771ac19044ca37bf60e231eac561 @Nullable private String descriptionId; diff --git a/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java -index 9ea74d37cd951e0dc76d20ed8234b5871035566c..fc55527c36c33f12760e1cf4cde7cfd3913b0fa8 100644 +index 6349f2e0a5ba30d250f5ffe43771f325c0999a76..f6935dc39b878b2463a8c3febc1f0da458d947b4 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java -@@ -21,14 +21,9 @@ import org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry; +@@ -33,14 +33,9 @@ import org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry; import org.bukkit.inventory.InventoryHolder; // CraftBukkit end @@ -1896,7 +1778,7 @@ index 9ea74d37cd951e0dc76d20ed8234b5871035566c..fc55527c36c33f12760e1cf4cde7cfd3 private static final CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new CraftPersistentDataTypeRegistry(); public CraftPersistentDataContainer persistentDataContainer; 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 465458e8a7dbaf9afb32709a71c7b2620d1e1fd2..8ea72a149d89ab05bf97ac0f36f50d94ff917184 100644 +index 2a8609e33716949ff1877b6d10f64a9d7a7c81e9..96490c90697ad42565c465a5ed1d956fc1c73f73 100644 --- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java +++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java @@ -785,7 +785,6 @@ public class LevelChunk extends ChunkAccess { @@ -1915,7 +1797,7 @@ index 465458e8a7dbaf9afb32709a71c7b2620d1e1fd2..8ea72a149d89ab05bf97ac0f36f50d94 } } } -@@ -1163,7 +1161,6 @@ public class LevelChunk extends ChunkAccess { +@@ -1161,7 +1159,6 @@ public class LevelChunk extends ChunkAccess { ProfilerFiller gameprofilerfiller = LevelChunk.this.level.getProfiler(); gameprofilerfiller.push(this::getType); @@ -1923,7 +1805,7 @@ index 465458e8a7dbaf9afb32709a71c7b2620d1e1fd2..8ea72a149d89ab05bf97ac0f36f50d94 BlockState iblockdata = LevelChunk.this.getBlockState(blockposition); if (this.blockEntity.getType().isValid(iblockdata)) { -@@ -1189,9 +1186,6 @@ public class LevelChunk extends ChunkAccess { +@@ -1187,9 +1184,6 @@ public class LevelChunk extends ChunkAccess { LevelChunk.this.removeBlockEntity(this.getPos()); // Paper end - Prevent block entity and entity crashes // Spigot start @@ -1934,10 +1816,10 @@ index 465458e8a7dbaf9afb32709a71c7b2620d1e1fd2..8ea72a149d89ab05bf97ac0f36f50d94 } } diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java -index 1068ed383232a71f6ada6677f4872267cc565325..a30365e430fe492075398af90351e692b1ef671c 100644 +index 9164d33b564970d83d11c6544db5697ff9eff32f..361763f59b33fdacbfe2523eb7a0fa0840fa7439 100644 --- a/src/main/java/org/bukkit/craftbukkit/Main.java +++ b/src/main/java/org/bukkit/craftbukkit/Main.java -@@ -344,8 +344,8 @@ public class Main { +@@ -346,8 +346,8 @@ public class Main { tryPreloadClass("org.jline.terminal.impl.MouseSupport"); tryPreloadClass("org.jline.terminal.impl.MouseSupport$1"); tryPreloadClass("org.jline.terminal.Terminal$MouseTracking"); @@ -1948,7 +1830,7 @@ index 1068ed383232a71f6ada6677f4872267cc565325..a30365e430fe492075398af90351e692 tryPreloadClass("io.netty.channel.AbstractChannelHandlerContext"); tryPreloadClass("io.netty.channel.AbstractChannelHandlerContext$11"); tryPreloadClass("io.netty.channel.AbstractChannelHandlerContext$12"); -@@ -358,7 +358,7 @@ public class Main { +@@ -360,7 +360,7 @@ public class Main { tryPreloadClass("org.bukkit.craftbukkit.scheduler.CraftScheduler$1"); tryPreloadClass("org.bukkit.craftbukkit.scheduler.CraftScheduler$2"); tryPreloadClass("org.bukkit.craftbukkit.scheduler.CraftScheduler$3"); @@ -2092,10 +1974,10 @@ index b3e1adeb932da9b3bed16acd94e2f16da48a7c72..e9798517b9211c50a20ea5c69603aab3 } } diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -index 3c7a771c48cc2732cc038ca11bb93ec5f8c2d667..aa3a2fd9c8bea586ab7108ff0eef894f8b593b5e 100644 +index 5a382907285a288f2a223189e690d3dbdf45594c..129aa57a01877c9339541f0e10933573bd438fe6 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -@@ -217,7 +217,6 @@ public final class CraftMagicNumbers implements UnsafeValues { +@@ -219,7 +219,6 @@ public final class CraftMagicNumbers implements UnsafeValues { // Paper start @Override public void reportTimings() { diff --git a/patches/server/0003-Leaves-Server-Utils.patch b/patches/server/0004-Leaves-Server-Utils.patch similarity index 81% rename from patches/server/0003-Leaves-Server-Utils.patch rename to patches/server/0004-Leaves-Server-Utils.patch index 2d92ae3f..c39a03c6 100644 --- a/patches/server/0003-Leaves-Server-Utils.patch +++ b/patches/server/0004-Leaves-Server-Utils.patch @@ -31,10 +31,10 @@ index 46954db7ecd35ac4018fdf476df7c8020d7ce6c8..044c51ebb058fc36074fd178929e3279 public PlayerAreaMap() { super(); diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 45439b0cc4ea69e409fd41d4684403c0e0feab12..e44178458aee648ce088c0a10f05b9f9eed91820 100644 +index 2bc85351e6e52f90da5fdb29d8d042a06132d742..1d8be1e7b71db074b7616d0a5e0c5075f09877ac 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -424,6 +424,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -426,6 +426,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess private UUID originWorld; public boolean freezeLocked = false; // Paper - Freeze Tick Lock API public boolean fixedPose = false; // Paper - Expand Pose API @@ -42,7 +42,7 @@ index 45439b0cc4ea69e409fd41d4684403c0e0feab12..e44178458aee648ce088c0a10f05b9f9 public void setOrigin(@javax.annotation.Nonnull Location location) { this.origin = location.toVector(); -@@ -2496,6 +2497,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -2555,6 +2556,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess nbttagcompound.putBoolean("Paper.FreezeLock", true); } // Paper end @@ -50,7 +50,7 @@ index 45439b0cc4ea69e409fd41d4684403c0e0feab12..e44178458aee648ce088c0a10f05b9f9 return nbttagcompound; } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT"); -@@ -2643,6 +2645,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -2702,6 +2704,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess freezeLocked = nbt.getBoolean("Paper.FreezeLock"); } // Paper end @@ -62,7 +62,7 @@ index 45439b0cc4ea69e409fd41d4684403c0e0feab12..e44178458aee648ce088c0a10f05b9f9 } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Loading entity NBT"); -@@ -4936,4 +4943,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -4995,4 +5002,10 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess return ((net.minecraft.server.level.ServerChunkCache) level.getChunkSource()).isPositionTicking(this); } // Paper end - Expose entity id counter @@ -73,13 +73,13 @@ index 45439b0cc4ea69e409fd41d4684403c0e0feab12..e44178458aee648ce088c0a10f05b9f9 + } + // Leaves end - leaves ex data } -diff --git a/src/main/java/top/leavesmc/leaves/LeavesLogger.java b/src/main/java/top/leavesmc/leaves/LeavesLogger.java +diff --git a/src/main/java/org/leavesmc/leaves/LeavesLogger.java b/src/main/java/org/leavesmc/leaves/LeavesLogger.java new file mode 100644 -index 0000000000000000000000000000000000000000..890b91a95719f18a75bc2c2176ef5cb9f2bf4274 +index 0000000000000000000000000000000000000000..730174b8c26375510c919fd841dc9371446ae8f2 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/LeavesLogger.java ++++ b/src/main/java/org/leavesmc/leaves/LeavesLogger.java @@ -0,0 +1,16 @@ -+package top.leavesmc.leaves; ++package org.leavesmc.leaves; + +import org.bukkit.Bukkit; + @@ -95,16 +95,16 @@ index 0000000000000000000000000000000000000000..890b91a95719f18a75bc2c2176ef5cb9 + setLevel(Level.ALL); + } +} -diff --git a/src/main/java/top/leavesmc/leaves/util/AsyncExecutor.java b/src/main/java/top/leavesmc/leaves/util/AsyncExecutor.java +diff --git a/src/main/java/org/leavesmc/leaves/util/AsyncExecutor.java b/src/main/java/org/leavesmc/leaves/util/AsyncExecutor.java new file mode 100644 -index 0000000000000000000000000000000000000000..0c03f3f051eff7abaacfaa8adb992811f934b9c8 +index 0000000000000000000000000000000000000000..067e351f6e96f2ac1a46d78dc952b2e845c1efef --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/util/AsyncExecutor.java ++++ b/src/main/java/org/leavesmc/leaves/util/AsyncExecutor.java @@ -0,0 +1,76 @@ -+package top.leavesmc.leaves.util; ++package org.leavesmc.leaves.util; + +import com.google.common.collect.Queues; -+import top.leavesmc.leaves.LeavesLogger; ++import org.leavesmc.leaves.LeavesLogger; + +import java.util.Queue; +import java.util.concurrent.locks.Condition; @@ -177,13 +177,13 @@ index 0000000000000000000000000000000000000000..0c03f3f051eff7abaacfaa8adb992811 + } + } +} -diff --git a/src/main/java/top/leavesmc/leaves/util/AsyncPlayerAreaMap.java b/src/main/java/top/leavesmc/leaves/util/AsyncPlayerAreaMap.java +diff --git a/src/main/java/org/leavesmc/leaves/util/AsyncPlayerAreaMap.java b/src/main/java/org/leavesmc/leaves/util/AsyncPlayerAreaMap.java new file mode 100644 -index 0000000000000000000000000000000000000000..4ccc1b3b29e9d62526b2d7c56ef06db77704bf80 +index 0000000000000000000000000000000000000000..0a2d58901b25fd771701e45aab6239626681ed4f --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/util/AsyncPlayerAreaMap.java ++++ b/src/main/java/org/leavesmc/leaves/util/AsyncPlayerAreaMap.java @@ -0,0 +1,32 @@ -+package top.leavesmc.leaves.util; ++package org.leavesmc.leaves.util; + +import com.destroystokyo.paper.util.misc.PlayerAreaMap; +import com.destroystokyo.paper.util.misc.PooledLinkedHashSets; @@ -215,13 +215,13 @@ index 0000000000000000000000000000000000000000..4ccc1b3b29e9d62526b2d7c56ef06db7 + this.areaMap = new Long2ObjectOpenHashMapWrapper<>(new ConcurrentHashMap<>(1024, 0.7f)); + } +} -diff --git a/src/main/java/top/leavesmc/leaves/util/IterableWrapper.java b/src/main/java/top/leavesmc/leaves/util/IterableWrapper.java +diff --git a/src/main/java/org/leavesmc/leaves/util/IterableWrapper.java b/src/main/java/org/leavesmc/leaves/util/IterableWrapper.java new file mode 100644 -index 0000000000000000000000000000000000000000..0dc58b78c84a825ec7025534cd0fc7be9c4610ad +index 0000000000000000000000000000000000000000..a07feaf53905df87e45e8414b1dca02d4e8411d5 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/util/IterableWrapper.java ++++ b/src/main/java/org/leavesmc/leaves/util/IterableWrapper.java @@ -0,0 +1,21 @@ -+package top.leavesmc.leaves.util; ++package org.leavesmc.leaves.util; + +import org.jetbrains.annotations.NotNull; + @@ -242,13 +242,13 @@ index 0000000000000000000000000000000000000000..0dc58b78c84a825ec7025534cd0fc7be + return iterator; + } +} -diff --git a/src/main/java/top/leavesmc/leaves/util/Long2ObjectOpenHashMapWrapper.java b/src/main/java/top/leavesmc/leaves/util/Long2ObjectOpenHashMapWrapper.java +diff --git a/src/main/java/org/leavesmc/leaves/util/Long2ObjectOpenHashMapWrapper.java b/src/main/java/org/leavesmc/leaves/util/Long2ObjectOpenHashMapWrapper.java new file mode 100644 -index 0000000000000000000000000000000000000000..b684d8f576acbc5de8d06b0ff779c257198bc32d +index 0000000000000000000000000000000000000000..440c4d903e145229bc54eb5b6f3578fdd8bcfb84 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/util/Long2ObjectOpenHashMapWrapper.java ++++ b/src/main/java/org/leavesmc/leaves/util/Long2ObjectOpenHashMapWrapper.java @@ -0,0 +1,41 @@ -+package top.leavesmc.leaves.util; ++package org.leavesmc.leaves.util; + +import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; +import org.jetbrains.annotations.Nullable; diff --git a/patches/server/0004-Update-version-fetcher-repo.patch b/patches/server/0004-Update-version-fetcher-repo.patch deleted file mode 100644 index cad7967b..00000000 --- a/patches/server/0004-Update-version-fetcher-repo.patch +++ /dev/null @@ -1,134 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: violetc <58360096+s-yh-china@users.noreply.github.com> -Date: Tue, 26 Oct 2021 14:13:50 +0800 -Subject: [PATCH] Update version fetcher repo - - -diff --git a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java -index 9d687da5bdf398bb3f6c84cdf1249a7213d09f2e..fa446ff1b7284b58ee88566cbbe39d81545121ea 100644 ---- a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java -+++ b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java -@@ -38,7 +38,7 @@ public class PaperVersionFetcher implements VersionFetcher { - return history != null ? TextComponent.ofChildren(updateMessage, Component.newline(), history) : updateMessage; - } - -- private static @Nullable String getMinecraftVersion() { -+ protected static @Nullable String getMinecraftVersion() { // Leaves - private -> protected - if (mcVer == null) { - java.util.regex.Matcher matcher = VER_PATTERN.matcher(org.bukkit.Bukkit.getBukkitVersion()); - if (matcher.find()) { -@@ -106,7 +106,7 @@ public class PaperVersionFetcher implements VersionFetcher { - } - - // Contributed by Techcable in GH-65 -- private static int fetchDistanceFromGitHub(@Nonnull String repo, @Nonnull String branch, @Nonnull String hash) { -+ protected static int fetchDistanceFromGitHub(@Nonnull String repo, @Nonnull String branch, @Nonnull String hash) { // Leaves - private -> protected - try { - HttpURLConnection connection = (HttpURLConnection) new URL("https://api.github.com/repos/" + repo + "/compare/" + branch + "..." + hash).openConnection(); - connection.connect(); -@@ -133,7 +133,7 @@ public class PaperVersionFetcher implements VersionFetcher { - } - - @Nullable -- private Component getHistory() { -+ protected Component getHistory() { // Leaves - private -> protected - final VersionHistoryManager.VersionData data = VersionHistoryManager.INSTANCE.getVersionData(); - if (data == null) { - return null; -diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -index aa3a2fd9c8bea586ab7108ff0eef894f8b593b5e..b0115c38f6fd0edc13eb87c657ce541cdc8aa3af 100644 ---- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -@@ -501,7 +501,7 @@ public final class CraftMagicNumbers implements UnsafeValues { - - @Override - public com.destroystokyo.paper.util.VersionFetcher getVersionFetcher() { -- return new com.destroystokyo.paper.PaperVersionFetcher(); -+ return new top.leavesmc.leaves.util.LeavesVersionFetcher(); // Leaves - Leaves version fetcher - } - - @Override -diff --git a/src/main/java/top/leavesmc/leaves/util/LeavesVersionFetcher.java b/src/main/java/top/leavesmc/leaves/util/LeavesVersionFetcher.java -new file mode 100644 -index 0000000000000000000000000000000000000000..18d104d4dc1da05affc67acbfc3c81c981d2a75b ---- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/util/LeavesVersionFetcher.java -@@ -0,0 +1,78 @@ -+package top.leavesmc.leaves.util; -+ -+import com.destroystokyo.paper.PaperVersionFetcher; -+import com.google.common.base.Charsets; -+import com.google.common.io.Resources; -+import com.google.gson.Gson; -+import com.google.gson.JsonArray; -+import com.google.gson.JsonObject; -+import com.google.gson.JsonSyntaxException; -+import net.kyori.adventure.text.Component; -+import net.kyori.adventure.text.TextComponent; -+import net.kyori.adventure.text.event.ClickEvent; -+import net.kyori.adventure.text.format.NamedTextColor; -+ -+import javax.annotation.Nonnull; -+import javax.annotation.Nullable; -+import java.io.BufferedReader; -+import java.io.IOException; -+import java.net.URL; -+import java.util.stream.StreamSupport; -+ -+public class LeavesVersionFetcher extends PaperVersionFetcher { -+ -+ private static final String DOWNLOAD_PAGE = "https://leavesmc.org/downloads/leaves"; -+ private static final String GITHUB_BRANCH_NAME = "master"; -+ -+ @Nonnull -+ @Override -+ public Component getVersionMessage(@Nonnull String serverVersion) { -+ String[] parts = serverVersion.substring("git-Leaves-".length()).split("[-\\s]"); -+ final Component updateMessage = getUpdateStatusMessage("LeavesMC/Leaves", GITHUB_BRANCH_NAME, parts[0]); -+ final Component history = getHistory(); -+ -+ return history != null ? TextComponent.ofChildren(updateMessage, Component.newline(), history) : updateMessage; -+ } -+ -+ private static int fetchDistanceFromLeavesApiV2(String mcVersion, String hash) { -+ try { -+ try (BufferedReader reader = Resources.asCharSource( -+ new URL("https://api.leavesmc.org/v2/projects/leaves/versions/" + mcVersion + "/differ/" + hash), -+ Charsets.UTF_8 -+ ).openBufferedStream()) { -+ return Integer.parseInt(reader.readLine()); -+ } -+ } catch (IOException e) { -+ e.printStackTrace(); -+ throw new NumberFormatException(); -+ } -+ } -+ -+ private static Component getUpdateStatusMessage(@Nonnull String repo, @Nonnull String branch, @Nonnull String versionInfo) { -+ int distance; -+ -+ versionInfo = versionInfo.replace("\"", ""); -+ try { -+ distance = fetchDistanceFromLeavesApiV2(getMinecraftVersion(), versionInfo); -+ } catch (NumberFormatException ignored) { -+ distance = fetchDistanceFromGitHub(repo, branch, versionInfo); -+ } -+ -+ switch (distance) { -+ case -1: -+ return Component.text("Error obtaining version information", NamedTextColor.YELLOW); -+ case 0: -+ return Component.text("You are running the latest version", NamedTextColor.GREEN); -+ case -2: -+ return Component.text("Unknown version", NamedTextColor.YELLOW); -+ default: -+ return Component.text("You are " + distance + " version(s) behind", NamedTextColor.YELLOW) -+ .append(Component.newline()) -+ .append(Component.text("Download the new version at: ") -+ .append(Component.text(DOWNLOAD_PAGE, NamedTextColor.GOLD) -+ .hoverEvent(Component.text("Click to open", NamedTextColor.WHITE)) -+ .clickEvent(ClickEvent.openUrl(DOWNLOAD_PAGE)))); -+ -+ } -+ } -+} diff --git a/patches/server/0005-Update-version-fetcher-repo.patch b/patches/server/0005-Update-version-fetcher-repo.patch new file mode 100644 index 00000000..13aee92a --- /dev/null +++ b/patches/server/0005-Update-version-fetcher-repo.patch @@ -0,0 +1,173 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: violetc <58360096+s-yh-china@users.noreply.github.com> +Date: Tue, 26 Oct 2021 14:13:50 +0800 +Subject: [PATCH] Update version fetcher repo + + +diff --git a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java +index 532306cacd52579cdf37e4aca25887b1ed3ba6a1..917ffaae401f3374d07d7fb7c024234a43ee54e4 100644 +--- a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java ++++ b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java +@@ -107,7 +107,7 @@ public class PaperVersionFetcher implements VersionFetcher { + } + + // Contributed by Techcable in GH-65 +- private static int fetchDistanceFromGitHub(final String repo, final String branch, final String hash) { ++ protected static int fetchDistanceFromGitHub(final String repo, final String branch, final String hash) { // Leaves - private -> protected + try { + final HttpURLConnection connection = (HttpURLConnection) URI.create("https://api.github.com/repos/%s/compare/%s...%s".formatted(repo, branch, hash)).toURL().openConnection(); + connection.connect(); +@@ -130,7 +130,7 @@ public class PaperVersionFetcher implements VersionFetcher { + } + } + +- private @Nullable Component getHistory() { ++ protected @Nullable Component getHistory() { // Leaves - private -> protected + final VersionHistoryManager.@Nullable VersionData data = VersionHistoryManager.INSTANCE.getVersionData(); + if (data == null) { + return null; +diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +index 129aa57a01877c9339541f0e10933573bd438fe6..99c7711447ac70fe4219fc55c3ba9fbd45924a90 100644 +--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java ++++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +@@ -510,7 +510,7 @@ public final class CraftMagicNumbers implements UnsafeValues { + + @Override + public com.destroystokyo.paper.util.VersionFetcher getVersionFetcher() { +- return new com.destroystokyo.paper.PaperVersionFetcher(); ++ return new org.leavesmc.leaves.util.LeavesVersionFetcher(); // Leaves - Leaves version fetcher + } + + @Override +diff --git a/src/main/java/org/leavesmc/leaves/util/LeavesVersionFetcher.java b/src/main/java/org/leavesmc/leaves/util/LeavesVersionFetcher.java +new file mode 100644 +index 0000000000000000000000000000000000000000..b102e2f5cf541b8ced87cf1ec7469ea90da4bb72 +--- /dev/null ++++ b/src/main/java/org/leavesmc/leaves/util/LeavesVersionFetcher.java +@@ -0,0 +1,126 @@ ++package org.leavesmc.leaves.util; ++ ++import com.destroystokyo.paper.PaperVersionFetcher; ++import com.google.common.base.Charsets; ++import com.google.common.io.Resources; ++import com.google.gson.Gson; ++import com.google.gson.JsonArray; ++import com.google.gson.JsonElement; ++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 org.checkerframework.checker.nullness.qual.Nullable; ++import org.jetbrains.annotations.NotNull; ++import org.slf4j.Logger; ++ ++import java.io.BufferedReader; ++import java.io.IOException; ++import java.net.URI; ++import java.util.Optional; ++import java.util.OptionalInt; ++import java.util.stream.StreamSupport; ++ ++import static net.kyori.adventure.text.Component.text; ++import static net.kyori.adventure.text.format.TextColor.color; ++ ++public class LeavesVersionFetcher extends PaperVersionFetcher { ++ ++ private static final Logger LOGGER = LogUtils.getClassLogger(); ++ ++ private static final int DISTANCE_ERROR = -1; ++ private static final int DISTANCE_UNKNOWN = -2; ++ private static final String DOWNLOAD_PAGE = "https://leavesmc.org/downloads/leaves"; ++ ++ @NotNull ++ @Override ++ public Component getVersionMessage(@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("LeavesMC/Leaves", build); ++ } ++ final @Nullable Component history = this.getHistory(); ++ ++ return history != null ? Component.textOfChildren(updateMessage, Component.newline(), history) : updateMessage; ++ } ++ ++ private static Component getUpdateStatusMessage(@NotNull final String repo, @NotNull final ServerBuildInfo build) { ++ int distance = fetchDistanceFromLeavesApiV2Build(build); ++ ++ if (distance == DISTANCE_ERROR) { ++ distance = fetchDistanceFromLeavesApiV2Hash(build); ++ } ++ ++ if (distance == DISTANCE_ERROR) { ++ final Optional gitBranch = build.gitBranch(); ++ final Optional gitCommit = build.gitCommit(); ++ if (gitBranch.isPresent() && gitCommit.isPresent()) { ++ distance = fetchDistanceFromGitHub(repo, gitBranch.get(), gitCommit.get()); ++ } ++ } ++ ++ return switch (distance) { ++ case DISTANCE_ERROR -> Component.text("Error obtaining version information", NamedTextColor.YELLOW); ++ case 0 -> Component.text("You are running the latest version", NamedTextColor.GREEN); ++ case DISTANCE_UNKNOWN -> Component.text("Unknown version", NamedTextColor.YELLOW); ++ default -> Component.text("You are " + distance + " version(s) behind", NamedTextColor.YELLOW) ++ .append(Component.newline()) ++ .append(Component.text("Download the new version at: ") ++ .append(Component.text(DOWNLOAD_PAGE, NamedTextColor.GOLD) ++ .hoverEvent(Component.text("Click to open", NamedTextColor.WHITE)) ++ .clickEvent(ClickEvent.openUrl(DOWNLOAD_PAGE)))); ++ }; ++ } ++ ++ private static int fetchDistanceFromLeavesApiV2Build(final ServerBuildInfo build) { ++ OptionalInt buildNumber = build.buildNumber(); ++ if (buildNumber.isEmpty()) { ++ return DISTANCE_ERROR; ++ } ++ ++ try { ++ try (final BufferedReader reader = Resources.asCharSource( ++ URI.create("https://api.leavesmc.org/v2/projects/leaves/versions/" + build.minecraftVersionId()).toURL(), ++ Charsets.UTF_8 ++ ).openBufferedStream()) { ++ final JsonObject json = new Gson().fromJson(reader, JsonObject.class); ++ final JsonArray builds = json.getAsJsonArray("builds"); ++ final int latest = StreamSupport.stream(builds.spliterator(), false) ++ .mapToInt(JsonElement::getAsInt) ++ .max() ++ .orElseThrow(); ++ return latest - buildNumber.getAsInt(); ++ } catch (final JsonSyntaxException ex) { ++ LOGGER.error("Error parsing json from Leaves's downloads API", ex); ++ return DISTANCE_ERROR; ++ } ++ } catch (final IOException e) { ++ LOGGER.error("Error while parsing version", e); ++ return DISTANCE_ERROR; ++ } ++ } ++ ++ private static int fetchDistanceFromLeavesApiV2Hash(final ServerBuildInfo build) { ++ if (build.gitCommit().isEmpty()) { ++ return DISTANCE_ERROR; ++ } ++ ++ try { ++ try (BufferedReader reader = Resources.asCharSource( ++ URI.create("https://api.leavesmc.org/v2/projects/leaves/versions/" + build.minecraftVersionId() + "/differ/" + build.gitCommit()).toURL(), ++ Charsets.UTF_8 ++ ).openBufferedStream()) { ++ return Integer.parseInt(reader.readLine()); ++ } ++ } catch (IOException e) { ++ LOGGER.error("Error while parsing version", e); ++ return DISTANCE_ERROR; ++ } ++ } ++} diff --git a/patches/server/0005-Leaves-Server-Config-And-Command.patch b/patches/server/0006-Leaves-Server-Config-And-Command.patch similarity index 88% rename from patches/server/0005-Leaves-Server-Config-And-Command.patch rename to patches/server/0006-Leaves-Server-Config-And-Command.patch index 4a202e37..077f8a15 100644 --- a/patches/server/0005-Leaves-Server-Config-And-Command.patch +++ b/patches/server/0006-Leaves-Server-Config-And-Command.patch @@ -5,61 +5,63 @@ Subject: [PATCH] Leaves Server Config And Command diff --git a/build.gradle.kts b/build.gradle.kts -index dc25ca9011a4fa0fcb642aa7371b0693c294dc9b..a2441f300345c3936bce69d6d3f21fdd6626136d 100644 +index 16b742b5131376ceca04570dd4c088caff62e677..fe1f6f1a97ab35c44f596596d16765b8b81753a9 100644 --- a/build.gradle.kts +++ b/build.gradle.kts -@@ -218,3 +218,11 @@ tasks.registerRunTask("runDev") { - classpath(sourceSets.main.map { it.runtimeClasspath }) +@@ -212,6 +212,14 @@ tasks.registerRunTask("runDevServer") { jvmArgs("-DPaper.pushPaperAssetsRoot=true") } -+ + +// Leaves start - create config file +tasks.registerRunTask("createLeavesConfig") { + description = "Create a new leaves.yml" -+ mainClass = "top.leavesmc.leaves.config.GlobalConfigCreator" ++ mainClass = "org.leavesmc.leaves.config.GlobalConfigCreator" + classpath(sourceSets.main.map { it.runtimeClasspath }) +} +// Leaves end - create config file -\ No newline at end of file ++ + tasks.registerRunTask("runBundler") { + description = "Spin up a test server from the Mojang mapped bundler jar" + classpath(rootProject.tasks.named("createMojmapBundlerJar").flatMap { it.outputZip }) diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 5db905f820a13c876fd9c9003610e1b3c42f0364..6538dfd5a0d62912ee67de8e414c4443538c32c2 100644 +index 025e1a22d7344fc7de2baca5c29a6a6dacd2c88e..624c28d63aba34e9d4677c538b84bebbda7d706a 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -1142,6 +1142,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { + @Override + public String check(Enum old, Enum value) { -+ CarpetRules.register(CarpetRule.of("carpet", "renewableCoral", value)); ++// CarpetRules.register(CarpetRule.of("carpet", "renewableCoral", value)); // Leaves - remove protocol temporarily + return null; + } + } @@ -622,7 +624,7 @@ index 0000000000000000000000000000000000000000..cb427686bf77366ddc9ad133b08f42b6 + @GlobalConfig(name = "inventory-contains-iterators", category = {"performance", "remove"}) + public static boolean removeInventoryContainsIterators = true; + -+ @GlobalConfig(name = "get-nearby-players-streams", category = {"performance", "remove"}) ++ @RemovedConfig(name = "get-nearby-players-streams", category = {"performance", "remove"}) + public static boolean removeGetNearPlayerStreams = true; + + @GlobalConfig(name = "range-check-streams-and-iterators", category = {"performance", "remove"}) @@ -645,7 +647,7 @@ index 0000000000000000000000000000000000000000..cb427686bf77366ddc9ad133b08f42b6 + @GlobalConfig(name = "enable-suffocation-optimization", category = "performance") + public static boolean enableSuffocationOptimization = true; + -+ @GlobalConfig(name = "strip-raytracing-for-entity", category = "performance") ++ @RemovedConfig(name = "strip-raytracing-for-entity", category = "performance") + public static boolean entityStripRaytracing = true; + + @GlobalConfig(name = "check-spooky-season-once-an-hour", category = "performance") @@ -654,7 +656,7 @@ index 0000000000000000000000000000000000000000..cb427686bf77366ddc9ad133b08f42b6 + @GlobalConfig(name = "optimize-chunk-ticking", category = "performance", lock = true) + public static boolean optimizeChunkTicking = true; + -+ @GlobalConfig(name = "skip-poi-find-in-vehicle", category = "performance") ++ @RemovedConfig(name = "skip-poi-find-in-vehicle", category = "performance") + public static boolean skipPOIFindingInVehicle = true; + + @GlobalConfig(name = "entity-target-find-optimization", category = "performance") @@ -714,18 +716,12 @@ index 0000000000000000000000000000000000000000..cb427686bf77366ddc9ad133b08f42b6 + @GlobalConfig(name = "optimize-sun-burn-tick", category = "performance") + public static boolean optimizeSunBurnTick = true; + -+ @GlobalConfig(name = "use-optimized-collection", category = "performance") -+ public static boolean useOptimizedCollection = true; -+ + @GlobalConfig(name = "optimized-CubePointRange", category = "performance") + public static boolean optimizedCubePointRange = true; + + @GlobalConfig(name = "check-frozen-ticks-before-landing-block", category = "performance") + public static boolean checkFrozenTicksBeforeLandingBlock = true; + -+ @GlobalConfig(name = "cache-ominous-banner-item", category = "performance") -+ public static boolean cacheOminousBannerItem = true; -+ + @GlobalConfig(name = "skip-entity-move-if-movement-is-zero", category = "performance") + public static boolean skipEntityMoveIfMovementIsZero = true; + @@ -740,6 +736,12 @@ index 0000000000000000000000000000000000000000..cb427686bf77366ddc9ad133b08f42b6 + + // Leaves start - performance - removed + ++ @RemovedConfig(name = "cache-ominous-banner-item", category = "performance") ++ public static boolean cacheOminousBannerItem = true; ++ ++ @RemovedConfig(name = "use-optimized-collection", category = "performance") ++ public static boolean useOptimizedCollection = true; ++ + @RemovedConfig(name = "async-pathfinding", category = "performance") + public static boolean asyncPathfinding = false; + @@ -772,7 +774,7 @@ index 0000000000000000000000000000000000000000..cb427686bf77366ddc9ad133b08f42b6 + private static class MSPTSyncVerify extends ConfigVerify.BooleanConfigVerify { + @Override + public String check(Boolean old, Boolean value) { -+ LeavesFeatureSet.register(LeavesFeature.of("mspt_sync", value)); ++// LeavesFeatureSet.register(LeavesFeature.of("mspt_sync", value)); // Leaves - remove protocol temporarily + return null; + } + } @@ -804,7 +806,7 @@ index 0000000000000000000000000000000000000000..cb427686bf77366ddc9ad133b08f42b6 + @Override + public String check(Boolean old, Boolean value) { + if (value) { -+ top.leavesmc.leaves.protocol.syncmatica.SyncmaticaProtocol.init(); ++// org.leavesmc.leaves.protocol.syncmatica.SyncmaticaProtocol.init(); // Leaves - remove protocol temporarily + } + return null; + } @@ -879,7 +881,7 @@ index 0000000000000000000000000000000000000000..cb427686bf77366ddc9ad133b08f42b6 + private static class AutoUpdateVerify extends ConfigVerify.BooleanConfigVerify { + @Override + public void runAfterLoader(Boolean value) { -+ top.leavesmc.leaves.util.LeavesUpdateHelper.init(); ++ org.leavesmc.leaves.util.LeavesUpdateHelper.init(); + if (value) { + LeavesLogger.LOGGER.warning("Auto-Update is not completely safe. Enabling it may cause data security problems!"); + } @@ -916,7 +918,7 @@ index 0000000000000000000000000000000000000000..cb427686bf77366ddc9ad133b08f42b6 + public static class ExtraYggdrasilUrlsVerify extends ConfigVerify.ListConfigVerify { + @Override + public String check(List old, List value) { -+ top.leavesmc.leaves.profile.LeavesMinecraftSessionService.initExtraYggdrasilList(); ++// org.leavesmc.leaves.profile.LeavesMinecraftSessionService.initExtraYggdrasilList(); // Leaves - remove protocol temporarily + return null; + } + } @@ -960,15 +962,15 @@ index 0000000000000000000000000000000000000000..cb427686bf77366ddc9ad133b08f42b6 + + // Leaves start - region + -+ public static top.leavesmc.leaves.region.RegionFileFormat regionFormatName = top.leavesmc.leaves.region.RegionFileFormat.ANVIL; ++ public static org.leavesmc.leaves.region.RegionFileFormat regionFormatName = org.leavesmc.leaves.region.RegionFileFormat.ANVIL; + @GlobalConfig(name = "format", category = "region", lock = true, verify = RegionFormatVerify.class) + public static String regionFormat = "ANVIL"; + + private static class RegionFormatVerify extends ConfigVerify.StringConfigVerify { + @Override + public String check(String old, String value) { -+ top.leavesmc.leaves.region.RegionFileFormat format = top.leavesmc.leaves.region.RegionFileFormat.fromString(value); -+ if (format == top.leavesmc.leaves.region.RegionFileFormat.INVALID) { ++ org.leavesmc.leaves.region.RegionFileFormat format = org.leavesmc.leaves.region.RegionFileFormat.fromString(value); ++ if (format == org.leavesmc.leaves.region.RegionFileFormat.INVALID) { + return "Unknown region format " + value; + } + regionFormatName = format; @@ -1006,7 +1008,7 @@ index 0000000000000000000000000000000000000000..cb427686bf77366ddc9ad133b08f42b6 + } + } + -+ @GlobalConfig(name = "crash-on-broken-symlink", category = {"region", "linear"}, lock = true) ++ @RemovedConfig(name = "crash-on-broken-symlink", category = {"region", "linear"}) + public static boolean linearCrashOnBrokenSymlink = true; + + // Leaves end - region @@ -1018,13 +1020,13 @@ index 0000000000000000000000000000000000000000..cb427686bf77366ddc9ad133b08f42b6 + + // Leaves end - region +} -diff --git a/src/main/java/top/leavesmc/leaves/command/CommandArgument.java b/src/main/java/top/leavesmc/leaves/command/CommandArgument.java +diff --git a/src/main/java/org/leavesmc/leaves/command/CommandArgument.java b/src/main/java/org/leavesmc/leaves/command/CommandArgument.java new file mode 100644 -index 0000000000000000000000000000000000000000..eadc6d168fb13299348b0c275ae352ee2f1e1ea2 +index 0000000000000000000000000000000000000000..381cd8b33137a5b7dc688306b56805f35c57012a --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/command/CommandArgument.java ++++ b/src/main/java/org/leavesmc/leaves/command/CommandArgument.java @@ -0,0 +1,43 @@ -+package top.leavesmc.leaves.command; ++package org.leavesmc.leaves.command; + +import org.jetbrains.annotations.NotNull; + @@ -1067,13 +1069,13 @@ index 0000000000000000000000000000000000000000..eadc6d168fb13299348b0c275ae352ee + return new CommandArgumentResult(new ArrayList<>(Arrays.asList(result))); + } +} -diff --git a/src/main/java/top/leavesmc/leaves/command/CommandArgumentResult.java b/src/main/java/top/leavesmc/leaves/command/CommandArgumentResult.java +diff --git a/src/main/java/org/leavesmc/leaves/command/CommandArgumentResult.java b/src/main/java/org/leavesmc/leaves/command/CommandArgumentResult.java new file mode 100644 -index 0000000000000000000000000000000000000000..340eaca64c96180b895a075ce9e44402cd104eed +index 0000000000000000000000000000000000000000..e50ca0473ab4d40e2623ab15f8566276cc14f4e7 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/command/CommandArgumentResult.java ++++ b/src/main/java/org/leavesmc/leaves/command/CommandArgumentResult.java @@ -0,0 +1,62 @@ -+package top.leavesmc.leaves.command; ++package org.leavesmc.leaves.command; + +import net.minecraft.core.BlockPos; +import org.bukkit.util.Vector; @@ -1135,13 +1137,13 @@ index 0000000000000000000000000000000000000000..340eaca64c96180b895a075ce9e44402 + } + +} -diff --git a/src/main/java/top/leavesmc/leaves/command/CommandArgumentType.java b/src/main/java/top/leavesmc/leaves/command/CommandArgumentType.java +diff --git a/src/main/java/org/leavesmc/leaves/command/CommandArgumentType.java b/src/main/java/org/leavesmc/leaves/command/CommandArgumentType.java new file mode 100644 -index 0000000000000000000000000000000000000000..edf12195c7224ca2fb5d3c2ac3fcf485d3049d07 +index 0000000000000000000000000000000000000000..dccd32714b86d1fa3e0a9b10a23f765fc54a2c66 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/command/CommandArgumentType.java ++++ b/src/main/java/org/leavesmc/leaves/command/CommandArgumentType.java @@ -0,0 +1,37 @@ -+package top.leavesmc.leaves.command; ++package org.leavesmc.leaves.command; + +import org.jetbrains.annotations.NotNull; + @@ -1178,13 +1180,13 @@ index 0000000000000000000000000000000000000000..edf12195c7224ca2fb5d3c2ac3fcf485 + + public abstract E pasre(@NotNull String arg); +} -diff --git a/src/main/java/top/leavesmc/leaves/command/LeavesCommand.java b/src/main/java/top/leavesmc/leaves/command/LeavesCommand.java +diff --git a/src/main/java/org/leavesmc/leaves/command/LeavesCommand.java b/src/main/java/org/leavesmc/leaves/command/LeavesCommand.java new file mode 100644 -index 0000000000000000000000000000000000000000..9b6fb546a672fa5b27047fec638e42b2b5dbf533 +index 0000000000000000000000000000000000000000..b9e2bdb034dcd5119680ddea44a1eda11a0189b2 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/command/LeavesCommand.java ++++ b/src/main/java/org/leavesmc/leaves/command/LeavesCommand.java @@ -0,0 +1,118 @@ -+package top.leavesmc.leaves.command; ++package org.leavesmc.leaves.command; + +import io.papermc.paper.command.CommandUtil; +import it.unimi.dsi.fastutil.Pair; @@ -1198,7 +1200,7 @@ index 0000000000000000000000000000000000000000..9b6fb546a672fa5b27047fec638e42b2 +import org.bukkit.plugin.PluginManager; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.jetbrains.annotations.NotNull; -+import top.leavesmc.leaves.command.subcommands.ConfigCommand; ++import org.leavesmc.leaves.command.subcommands.ConfigCommand; + +import java.util.ArrayList; +import java.util.Arrays; @@ -1302,13 +1304,13 @@ index 0000000000000000000000000000000000000000..9b6fb546a672fa5b27047fec638e42b2 + return null; + } +} -diff --git a/src/main/java/top/leavesmc/leaves/command/LeavesSubcommand.java b/src/main/java/top/leavesmc/leaves/command/LeavesSubcommand.java +diff --git a/src/main/java/org/leavesmc/leaves/command/LeavesSubcommand.java b/src/main/java/org/leavesmc/leaves/command/LeavesSubcommand.java new file mode 100644 -index 0000000000000000000000000000000000000000..7ba1b573c8e49cc0838c25bc26687d14841a9e7f +index 0000000000000000000000000000000000000000..4b61fccc71d98a7b69bb7f88fb88ea0a55ca1ed2 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/command/LeavesSubcommand.java ++++ b/src/main/java/org/leavesmc/leaves/command/LeavesSubcommand.java @@ -0,0 +1,18 @@ -+package top.leavesmc.leaves.command; ++package org.leavesmc.leaves.command; + +import org.bukkit.command.CommandSender; + @@ -1326,21 +1328,21 @@ index 0000000000000000000000000000000000000000..7ba1b573c8e49cc0838c25bc26687d14 + return true; + } +} -diff --git a/src/main/java/top/leavesmc/leaves/command/subcommands/ConfigCommand.java b/src/main/java/top/leavesmc/leaves/command/subcommands/ConfigCommand.java +diff --git a/src/main/java/org/leavesmc/leaves/command/subcommands/ConfigCommand.java b/src/main/java/org/leavesmc/leaves/command/subcommands/ConfigCommand.java new file mode 100644 -index 0000000000000000000000000000000000000000..205e563ed4b3f59e294c2866952c73d22bd367b0 +index 0000000000000000000000000000000000000000..4b937f9626e89f2de1ae990151ca241573380e46 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/command/subcommands/ConfigCommand.java ++++ b/src/main/java/org/leavesmc/leaves/command/subcommands/ConfigCommand.java @@ -0,0 +1,86 @@ -+package top.leavesmc.leaves.command.subcommands; ++package org.leavesmc.leaves.command.subcommands; + +import io.papermc.paper.command.CommandUtil; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.JoinConfiguration; +import net.kyori.adventure.text.format.NamedTextColor; +import org.bukkit.command.CommandSender; -+import top.leavesmc.leaves.command.LeavesSubcommand; -+import top.leavesmc.leaves.config.GlobalConfigManager; ++import org.leavesmc.leaves.command.LeavesSubcommand; ++import org.leavesmc.leaves.config.GlobalConfigManager; + +import java.util.ArrayList; +import java.util.Collections; @@ -1418,26 +1420,26 @@ index 0000000000000000000000000000000000000000..205e563ed4b3f59e294c2866952c73d2 + return Collections.emptyList(); + } +} -diff --git a/src/main/java/top/leavesmc/leaves/config/ConfigConvert.java b/src/main/java/top/leavesmc/leaves/config/ConfigConvert.java +diff --git a/src/main/java/org/leavesmc/leaves/config/ConfigConvert.java b/src/main/java/org/leavesmc/leaves/config/ConfigConvert.java new file mode 100644 -index 0000000000000000000000000000000000000000..7053897b5fe7774cb4a28462ef88f6eebd35f171 +index 0000000000000000000000000000000000000000..3ddeff82e31178c9c1bb1737c9a28a81e70f71e5 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/config/ConfigConvert.java ++++ b/src/main/java/org/leavesmc/leaves/config/ConfigConvert.java @@ -0,0 +1,7 @@ -+package top.leavesmc.leaves.config; ++package org.leavesmc.leaves.config; + +public interface ConfigConvert { + + E convert(String value); + +} -diff --git a/src/main/java/top/leavesmc/leaves/config/ConfigVerify.java b/src/main/java/top/leavesmc/leaves/config/ConfigVerify.java +diff --git a/src/main/java/org/leavesmc/leaves/config/ConfigVerify.java b/src/main/java/org/leavesmc/leaves/config/ConfigVerify.java new file mode 100644 -index 0000000000000000000000000000000000000000..b345b7da3f861bcf205e2b2cbd462f69da5fa7b6 +index 0000000000000000000000000000000000000000..08ffa951d8fd835f075c45021f56cec19f03e7fc --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/config/ConfigVerify.java ++++ b/src/main/java/org/leavesmc/leaves/config/ConfigVerify.java @@ -0,0 +1,90 @@ -+package top.leavesmc.leaves.config; ++package org.leavesmc.leaves.config; + +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; @@ -1527,13 +1529,13 @@ index 0000000000000000000000000000000000000000..b345b7da3f861bcf205e2b2cbd462f69 + } + } +} -diff --git a/src/main/java/top/leavesmc/leaves/config/GlobalConfig.java b/src/main/java/top/leavesmc/leaves/config/GlobalConfig.java +diff --git a/src/main/java/org/leavesmc/leaves/config/GlobalConfig.java b/src/main/java/org/leavesmc/leaves/config/GlobalConfig.java new file mode 100644 -index 0000000000000000000000000000000000000000..f6b946e5dfb5e3a2c169f88e8fb54718b0ca84ea +index 0000000000000000000000000000000000000000..1f18e2a32b937c71ddf68546c10a298b9baf8e1a --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/config/GlobalConfig.java ++++ b/src/main/java/org/leavesmc/leaves/config/GlobalConfig.java @@ -0,0 +1,19 @@ -+package top.leavesmc.leaves.config; ++package org.leavesmc.leaves.config; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; @@ -1552,16 +1554,16 @@ index 0000000000000000000000000000000000000000..f6b946e5dfb5e3a2c169f88e8fb54718 + + Class> verify() default ConfigVerify.BooleanConfigVerify.class; +} -diff --git a/src/main/java/top/leavesmc/leaves/config/GlobalConfigCreator.java b/src/main/java/top/leavesmc/leaves/config/GlobalConfigCreator.java +diff --git a/src/main/java/org/leavesmc/leaves/config/GlobalConfigCreator.java b/src/main/java/org/leavesmc/leaves/config/GlobalConfigCreator.java new file mode 100644 -index 0000000000000000000000000000000000000000..8186cbdd5ce98131670be16ae1757b16d6d7012d +index 0000000000000000000000000000000000000000..67d4365d25714c3732274e5ab21981a31e0299a6 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/config/GlobalConfigCreator.java ++++ b/src/main/java/org/leavesmc/leaves/config/GlobalConfigCreator.java @@ -0,0 +1,56 @@ -+package top.leavesmc.leaves.config; ++package org.leavesmc.leaves.config; + +import org.bukkit.configuration.file.YamlConfiguration; -+import top.leavesmc.leaves.LeavesConfig; ++import org.leavesmc.leaves.LeavesConfig; + +import java.io.File; +import java.io.IOException; @@ -1614,17 +1616,17 @@ index 0000000000000000000000000000000000000000..8186cbdd5ce98131670be16ae1757b16 + } + } +} -diff --git a/src/main/java/top/leavesmc/leaves/config/GlobalConfigManager.java b/src/main/java/top/leavesmc/leaves/config/GlobalConfigManager.java +diff --git a/src/main/java/org/leavesmc/leaves/config/GlobalConfigManager.java b/src/main/java/org/leavesmc/leaves/config/GlobalConfigManager.java new file mode 100644 -index 0000000000000000000000000000000000000000..fb5fd1396f6df55b2b065a36c308456f016f343d +index 0000000000000000000000000000000000000000..828bbd8b048df8e48ef007d2c1eefe1458b4b2c3 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/config/GlobalConfigManager.java ++++ b/src/main/java/org/leavesmc/leaves/config/GlobalConfigManager.java @@ -0,0 +1,188 @@ -+package top.leavesmc.leaves.config; ++package org.leavesmc.leaves.config; + +import org.bukkit.Bukkit; -+import top.leavesmc.leaves.LeavesConfig; -+import top.leavesmc.leaves.LeavesLogger; ++import org.leavesmc.leaves.LeavesConfig; ++import org.leavesmc.leaves.LeavesLogger; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; @@ -1808,13 +1810,13 @@ index 0000000000000000000000000000000000000000..fb5fd1396f6df55b2b065a36c308456f + } + } +} -diff --git a/src/main/java/top/leavesmc/leaves/config/RemovedConfig.java b/src/main/java/top/leavesmc/leaves/config/RemovedConfig.java +diff --git a/src/main/java/org/leavesmc/leaves/config/RemovedConfig.java b/src/main/java/org/leavesmc/leaves/config/RemovedConfig.java new file mode 100644 -index 0000000000000000000000000000000000000000..0d6371d7f249495c738f1a11288d3abe3e61135c +index 0000000000000000000000000000000000000000..90137a284acaf9036334ee2fe6ab34025acb4f4d --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/config/RemovedConfig.java ++++ b/src/main/java/org/leavesmc/leaves/config/RemovedConfig.java @@ -0,0 +1,19 @@ -+package top.leavesmc.leaves.config; ++package org.leavesmc.leaves.config; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; diff --git a/patches/server/0006-Leaves-Protocol-Core.patch b/patches/server/0007-Leaves-Protocol-Core.patch similarity index 67% rename from patches/server/0006-Leaves-Protocol-Core.patch rename to patches/server/0007-Leaves-Protocol-Core.patch index 8a34b886..66c26167 100644 --- a/patches/server/0006-Leaves-Protocol-Core.patch +++ b/patches/server/0007-Leaves-Protocol-Core.patch @@ -4,105 +4,161 @@ Date: Tue, 26 Sep 2023 19:00:41 +0800 Subject: [PATCH] Leaves Protocol Core -diff --git a/src/main/java/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java b/src/main/java/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java -index af86f752c33a2990405fea058b7c41c437ba9d46..bada9fae1e7178162429e1f5a1608b9c4a680a6c 100644 ---- a/src/main/java/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java -+++ b/src/main/java/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java -@@ -20,7 +20,12 @@ public record ServerboundCustomPayloadPacket(CustomPacketPayload payload) implem +diff --git a/.gitignore b/.gitignore +index 3811c0d849a3eb028ed1a6b7a2d4747f7f570448..1ad93453221244f880855b510e888e759275b640 100644 +--- a/.gitignore ++++ b/.gitignore +@@ -46,3 +46,4 @@ dependency-reduced-pom.xml + # vs code + /.vscode + /.factorypath ++ +diff --git a/src/main/java/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java b/src/main/java/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java +index 0211311b3b63bcdea7ebf7bcb24629674c771402..c05a72f4928ee2cec28a61ed06a9079d52634900 100644 +--- a/src/main/java/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java ++++ b/src/main/java/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java +@@ -40,13 +40,23 @@ public interface CustomPacketPayload { - private static CustomPacketPayload readPayload(ResourceLocation id, FriendlyByteBuf buf) { - FriendlyByteBuf.Reader packetdataserializer_a = (FriendlyByteBuf.Reader) ServerboundCustomPayloadPacket.KNOWN_TYPES.get(id); -- -+ // Leaves start - protocol -+ CustomPacketPayload leavesPayload = top.leavesmc.leaves.protocol.core.LeavesProtocolManager.getPayload(id, buf); -+ if (leavesPayload != null) { -+ return leavesPayload; -+ } -+ // Leaves end - protocol - return (CustomPacketPayload) (packetdataserializer_a != null ? (CustomPacketPayload) packetdataserializer_a.apply(buf) : readUnknownPayload(id, buf)); + @Override + public void encode(B friendlyByteBuf, CustomPacketPayload customPacketPayload) { ++ // Leaves start - protocol core ++ if (customPacketPayload instanceof org.leavesmc.leaves.protocol.core.LeavesCustomPayload leavesCustomPayload) { ++ friendlyByteBuf.writeResourceLocation(leavesCustomPayload.id()); ++ leavesCustomPayload.write(friendlyByteBuf); ++ return; ++ } ++ // Leaves end - protocol core + this.writeCap(friendlyByteBuf, customPacketPayload.type(), customPacketPayload); + } + + @Override + public CustomPacketPayload decode(B friendlyByteBuf) { + ResourceLocation resourceLocation = friendlyByteBuf.readResourceLocation(); +- return (CustomPacketPayload)this.findCodec(resourceLocation).decode(friendlyByteBuf); ++ // Leaves start - protocol core ++ var leavesCustomPayload = org.leavesmc.leaves.protocol.core.LeavesProtocolManager.decode(resourceLocation, friendlyByteBuf); ++ return java.util.Objects.requireNonNullElseGet(leavesCustomPayload, () -> (CustomPacketPayload) this.findCodec(resourceLocation).decode(friendlyByteBuf)); ++ // Leaves end - protocol core + } + }; } - diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 9f3a57c0bb687fc867cede617fd95b2f001060e5..21a6a955dde5c13aeb466792b4bca786c2fec722 100644 +index 624c28d63aba34e9d4677c538b84bebbda7d706a..4a9b4e9c0db3cf86134b857ee1318fa4463c80a1 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -1727,6 +1727,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop leavesPayload) { ++ org.leavesmc.leaves.protocol.core.LeavesProtocolManager.handlePayload(player, leavesPayload); ++ } ++ // Leaves end - protocol // Paper start - Brand support if (packet.payload() instanceof net.minecraft.network.protocol.common.custom.BrandPayload brandPayload) { this.player.clientBrandName = brandPayload.brand(); -@@ -133,6 +134,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack +@@ -165,6 +170,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack String channels = payload.toString(com.google.common.base.Charsets.UTF_8); for (String channel : channels.split("\0")) { this.getCraftPlayer().addChannel(channel); -+ top.leavesmc.leaves.protocol.core.LeavesProtocolManager.handleMinecraftRegister(channel, player); // Leaves - protocol ++ org.leavesmc.leaves.protocol.core.LeavesProtocolManager.handleMinecraftRegister(channel, player); // Leaves - protocol } } catch (Exception ex) { ServerGamePacketListenerImpl.LOGGER.error("Couldn\'t register custom payload", ex); diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index aa7eb1f037875293b03588f5bc5d2df70237b45e..62d89e49dfcbb00651df7f89be482b9cbc173b0a 100644 +index 6957cbfbea51d6a3b57e1c5bfcebd52a25cde8d5..11d73647d2d94c8131c5e3eeef490fb3472fe0a4 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java -@@ -347,6 +347,8 @@ public abstract class PlayerList { +@@ -349,6 +349,8 @@ public abstract class PlayerList { return; } -+ top.leavesmc.leaves.protocol.core.LeavesProtocolManager.handlePlayerJoin(player); // Leaves - protocol ++ org.leavesmc.leaves.protocol.core.LeavesProtocolManager.handlePlayerJoin(player); // Leaves - protocol + final net.kyori.adventure.text.Component jm = playerJoinEvent.joinMessage(); if (jm != null && !jm.equals(net.kyori.adventure.text.Component.empty())) { // Paper - Adventure -@@ -597,6 +599,7 @@ public abstract class PlayerList { +@@ -595,6 +597,7 @@ public abstract class PlayerList { return this.remove(entityplayer, net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW, io.papermc.paper.configuration.GlobalConfiguration.get().messages.useDisplayNameInQuitMessage ? entityplayer.getBukkitEntity().displayName() : io.papermc.paper.adventure.PaperAdventure.asAdventure(entityplayer.getDisplayName()))); } public net.kyori.adventure.text.Component remove(ServerPlayer entityplayer, net.kyori.adventure.text.Component leaveMessage) { -+ top.leavesmc.leaves.protocol.core.LeavesProtocolManager.handlePlayerLeave(entityplayer); // Leaves - protocol ++ org.leavesmc.leaves.protocol.core.LeavesProtocolManager.handlePlayerLeave(entityplayer); // Leaves - protocol // Paper end - Fix kick event leave message not being sent ServerLevel worldserver = entityplayer.serverLevel(); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index a50a52b53f66366b3c810bdc2cad22af47a01578..79874b67f7edb9afd41633f5bc4bacee5cb0046b 100644 +index b65d405c6f5884c739bebd7e79ba431a8b0056e4..3fbf31ef07489ffb7d0c0f5317fa967db740494d 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -465,6 +465,7 @@ public final class CraftServer implements Server { - MapPalette.setMapColorCache(new CraftMapColorCache(this.logger)); +@@ -468,6 +468,7 @@ public final class CraftServer implements Server { } + this.potionBrewer = new io.papermc.paper.potion.PaperPotionBrewer(console); // Paper - custom potion mixes datapackManager = new io.papermc.paper.datapack.PaperDatapackManager(console.getPackRepository()); // Paper -+ top.leavesmc.leaves.protocol.core.LeavesProtocolManager.init(); // Leaves - protocol ++ org.leavesmc.leaves.protocol.core.LeavesProtocolManager.init(); // Leaves - protocol } public boolean getCommandBlockOverride(String command) { -@@ -1087,6 +1088,7 @@ public final class CraftServer implements Server { +@@ -1067,6 +1068,7 @@ public final class CraftServer implements Server { io.papermc.paper.command.PaperCommands.registerCommands(this.console); // Paper this.overrideAllCommandBlockCommands = this.commandsConfiguration.getStringList("command-block-overrides").contains("*"); this.ignoreVanillaPermissions = this.commandsConfiguration.getBoolean("ignore-vanilla-permissions"); -+ top.leavesmc.leaves.protocol.core.LeavesProtocolManager.handleServerReload(); // Leaves - protocol ++ org.leavesmc.leaves.protocol.core.LeavesProtocolManager.handleServerReload(); // Leaves - protocol int pollCount = 0; -diff --git a/src/main/java/top/leavesmc/leaves/protocol/core/LeavesProtocol.java b/src/main/java/top/leavesmc/leaves/protocol/core/LeavesProtocol.java +diff --git a/src/main/java/org/leavesmc/leaves/protocol/core/LeavesCustomPayload.java b/src/main/java/org/leavesmc/leaves/protocol/core/LeavesCustomPayload.java new file mode 100644 -index 0000000000000000000000000000000000000000..f884f54f5a1f0665c290e014f088aae857cecef8 +index 0000000000000000000000000000000000000000..243a8d77d67b9634d6442b60e481d18831367a74 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/protocol/core/LeavesProtocol.java ++++ b/src/main/java/org/leavesmc/leaves/protocol/core/LeavesCustomPayload.java +@@ -0,0 +1,26 @@ ++package org.leavesmc.leaves.protocol.core; ++ ++import net.minecraft.network.FriendlyByteBuf; ++import net.minecraft.network.protocol.common.custom.CustomPacketPayload; ++import net.minecraft.resources.ResourceLocation; ++import org.jetbrains.annotations.NotNull; ++ ++import java.lang.annotation.Retention; ++import java.lang.annotation.RetentionPolicy; ++ ++public interface LeavesCustomPayload> extends CustomPacketPayload { ++ ++ @Retention(RetentionPolicy.RUNTIME) ++ @interface New { ++ } ++ ++ void write(FriendlyByteBuf buf); ++ ++ ResourceLocation id(); ++ ++ @Override ++ @NotNull ++ default Type type() { ++ return new CustomPacketPayload.Type<>(id()); ++ } ++} +diff --git a/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocol.java b/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocol.java +new file mode 100644 +index 0000000000000000000000000000000000000000..986d2a6641ff8017dddf3e5f2655adfc2866c119 +--- /dev/null ++++ b/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocol.java @@ -0,0 +1,12 @@ -+package top.leavesmc.leaves.protocol.core; ++package org.leavesmc.leaves.protocol.core; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; @@ -114,22 +170,21 @@ index 0000000000000000000000000000000000000000..f884f54f5a1f0665c290e014f088aae8 +public @interface LeavesProtocol { + String[] namespace(); +} -diff --git a/src/main/java/top/leavesmc/leaves/protocol/core/LeavesProtocolManager.java b/src/main/java/top/leavesmc/leaves/protocol/core/LeavesProtocolManager.java +diff --git a/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocolManager.java b/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocolManager.java new file mode 100644 -index 0000000000000000000000000000000000000000..be939521c6c4f9ca1f960611473d68ac379d3331 +index 0000000000000000000000000000000000000000..eb9e9d3a0dbb17eb68940685d4a6dea5b33a61f1 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/protocol/core/LeavesProtocolManager.java -@@ -0,0 +1,359 @@ -+package top.leavesmc.leaves.protocol.core; ++++ b/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocolManager.java +@@ -0,0 +1,365 @@ ++package org.leavesmc.leaves.protocol.core; + +import net.minecraft.network.FriendlyByteBuf; -+import net.minecraft.network.protocol.common.ServerboundCustomPayloadPacket; -+import net.minecraft.network.protocol.common.custom.CustomPacketPayload; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.level.ServerPlayer; +import org.apache.commons.lang.ArrayUtils; +import org.bukkit.event.player.PlayerKickEvent; +import org.jetbrains.annotations.NotNull; ++import org.leavesmc.leaves.LeavesLogger; + +import java.io.File; +import java.io.IOException; @@ -156,7 +211,9 @@ index 0000000000000000000000000000000000000000..be939521c6c4f9ca1f960611473d68ac + +public class LeavesProtocolManager { + -+ private static final Map>> KNOWN_TYPES = new HashMap<>(); ++ private static final LeavesLogger LOGGER = LeavesLogger.LOGGER; ++ ++ private static final Map>>> KNOWN_TYPES = new HashMap<>(); + private static final Map> KNOW_RECEIVERS = new HashMap<>(); + + private static final List TICKERS = new ArrayList<>(); @@ -166,7 +223,7 @@ index 0000000000000000000000000000000000000000..be939521c6c4f9ca1f960611473d68ac + private static final Map> MINECRAFT_REGISTER = new HashMap<>(); + + public static void init() { -+ for (Class clazz : getClasses("top.leavesmc.leaves.protocol")) { ++ for (Class clazz : getClasses("org.leavesmc.leaves.protocol")) { + final LeavesProtocol protocol = clazz.getAnnotation(LeavesProtocol.class); + if (protocol != null) { + Set methods; @@ -176,12 +233,12 @@ index 0000000000000000000000000000000000000000..be939521c6c4f9ca1f960611473d68ac + methods = new HashSet<>(publicMethods.length + privateMethods.length, 1.0f); + Collections.addAll(methods, publicMethods); + Collections.addAll(methods, privateMethods); -+ } catch (NoClassDefFoundError e) { -+ e.printStackTrace(); ++ } catch (NoClassDefFoundError error) { ++ LOGGER.severe("Failed to load class " + clazz.getName() + " due to missing dependencies, " + error.getMessage()); + return; + } + -+ Map> map = KNOWN_TYPES.getOrDefault(protocol, new HashMap<>()); ++ Map>> map = KNOWN_TYPES.getOrDefault(protocol, new HashMap<>()); + for (final Method method : methods) { + if (method.isBridge() || method.isSynthetic() || !Modifier.isStatic(method.getModifiers())) { + continue; @@ -193,8 +250,8 @@ index 0000000000000000000000000000000000000000..be939521c6c4f9ca1f960611473d68ac + if (init != null) { + try { + method.invoke(null); -+ } catch (InvocationTargetException | IllegalAccessException e) { -+ e.printStackTrace(); ++ } catch (InvocationTargetException | IllegalAccessException exception) { ++ LOGGER.severe("Failed to invoke init method " + method.getName() + " in " + clazz.getName() + ", " + exception.getMessage()); + } + continue; + } @@ -202,9 +259,16 @@ index 0000000000000000000000000000000000000000..be939521c6c4f9ca1f960611473d68ac + final ProtocolHandler.PayloadReceiver receiver = method.getAnnotation(ProtocolHandler.PayloadReceiver.class); + if (receiver != null) { + try { -+ map.put(receiver, receiver.payload().getConstructor(ResourceLocation.class, FriendlyByteBuf.class)); -+ } catch (NoSuchMethodException e) { -+ e.printStackTrace(); ++ Constructor> constructor = receiver.payload().getConstructor(ResourceLocation.class, FriendlyByteBuf.class); ++ constructor.setAccessible(true); ++ ++ if (constructor.getAnnotation(LeavesCustomPayload.New.class) == null) { ++ LOGGER.warning("Failed to find new annotation for " + receiver.payload().getName()); ++ } ++ ++ map.put(receiver, constructor); ++ } catch (NoSuchMethodException exception) { ++ LOGGER.severe("Failed to find constructor for " + receiver.payload().getName() + ", " + exception.getMessage()); + continue; + } + @@ -254,19 +318,19 @@ index 0000000000000000000000000000000000000000..be939521c6c4f9ca1f960611473d68ac + } + } + -+ public static CustomPacketPayload getPayload(ResourceLocation id, FriendlyByteBuf buf) { ++ public static LeavesCustomPayload decode(ResourceLocation id, FriendlyByteBuf buf) { + for (LeavesProtocol protocol : KNOWN_TYPES.keySet()) { + if (!ArrayUtils.contains(protocol.namespace(), id.getNamespace())) { + continue; + } + -+ Map> map = KNOWN_TYPES.get(protocol); ++ Map>> map = KNOWN_TYPES.get(protocol); + for (ProtocolHandler.PayloadReceiver receiver : map.keySet()) { + if (receiver.ignoreId() || ArrayUtils.contains(receiver.payloadId(), id.getPath())) { + try { + return map.get(receiver).newInstance(id, buf); -+ } catch (InvocationTargetException | InstantiationException | IllegalAccessException e) { -+ e.printStackTrace(); ++ } catch (InvocationTargetException | InstantiationException | IllegalAccessException exception) { ++ LOGGER.warning("Failed to create payload for " + id + " in " + ArrayUtils.toString(protocol.namespace()) + ", " + exception.getMessage()); + buf.readBytes(buf.readableBytes()); + return new ErrorPayload(id, protocol.namespace(), receiver.payloadId()); + } @@ -276,29 +340,25 @@ index 0000000000000000000000000000000000000000..be939521c6c4f9ca1f960611473d68ac + return null; + } + -+ public static void handlePayload(ServerPlayer player, CustomPacketPayload payload) { -+ if (payload instanceof ServerboundCustomPayloadPacket.UnknownPayload) { -+ return; -+ } -+ ++ public static void handlePayload(ServerPlayer player, LeavesCustomPayload payload) { + if (payload instanceof ErrorPayload errorPayload) { + player.connection.disconnect("Payload " + Arrays.toString(errorPayload.packetID) + " from " + Arrays.toString(errorPayload.protocolID) + " error", PlayerKickEvent.Cause.INVALID_PAYLOAD); + return; + } + + for (LeavesProtocol protocol : KNOW_RECEIVERS.keySet()) { -+ if (!ArrayUtils.contains(protocol.namespace(), payload.id().getNamespace())) { ++ if (!ArrayUtils.contains(protocol.namespace(), payload.type().id().getNamespace())) { + continue; + } + + Map map = KNOW_RECEIVERS.get(protocol); + for (ProtocolHandler.PayloadReceiver receiver : map.keySet()) { + if (payload.getClass() == receiver.payload()) { -+ if (receiver.ignoreId() || ArrayUtils.contains(receiver.payloadId(), payload.id().getPath())) { ++ if (receiver.ignoreId() || ArrayUtils.contains(receiver.payloadId(), payload.type().id().getPath())) { + try { + map.get(receiver).invoke(null, player, payload); -+ } catch (InvocationTargetException | IllegalAccessException e) { -+ e.printStackTrace(); ++ } catch (InvocationTargetException | IllegalAccessException exception) { ++ LOGGER.warning("Failed to handle payload " + payload.type().id() + " in " + ArrayUtils.toString(protocol.namespace()) + ", " + exception.getMessage()); + } + } + } @@ -312,8 +372,8 @@ index 0000000000000000000000000000000000000000..be939521c6c4f9ca1f960611473d68ac + for (Method method : TICKERS) { + method.invoke(null); + } -+ } catch (InvocationTargetException | IllegalAccessException e) { -+ e.printStackTrace(); ++ } catch (InvocationTargetException | IllegalAccessException exception) { ++ LOGGER.warning("Failed to tick, " + exception.getMessage()); + } + } + } @@ -324,8 +384,8 @@ index 0000000000000000000000000000000000000000..be939521c6c4f9ca1f960611473d68ac + for (Method method : PLAYER_JOIN) { + method.invoke(null, player); + } -+ } catch (InvocationTargetException | IllegalAccessException e) { -+ e.printStackTrace(); ++ } catch (InvocationTargetException | IllegalAccessException exception) { ++ LOGGER.warning("Failed to handle player join, " + exception.getMessage()); + } + } + } @@ -336,8 +396,8 @@ index 0000000000000000000000000000000000000000..be939521c6c4f9ca1f960611473d68ac + for (Method method : PLAYER_LEAVE) { + method.invoke(null, player); + } -+ } catch (InvocationTargetException | IllegalAccessException e) { -+ e.printStackTrace(); ++ } catch (InvocationTargetException | IllegalAccessException exception) { ++ LOGGER.warning("Failed to handle player leave, " + exception.getMessage()); + } + } + } @@ -348,8 +408,8 @@ index 0000000000000000000000000000000000000000..be939521c6c4f9ca1f960611473d68ac + for (Method method : RELOAD_SERVER) { + method.invoke(null); + } -+ } catch (InvocationTargetException | IllegalAccessException e) { -+ e.printStackTrace(); ++ } catch (InvocationTargetException | IllegalAccessException exception) { ++ LOGGER.warning("Failed to handle server reload, " + exception.getMessage()); + } + } + } @@ -367,8 +427,8 @@ index 0000000000000000000000000000000000000000..be939521c6c4f9ca1f960611473d68ac + ArrayUtils.contains(register.channelIds(), channel[1])) { + try { + map.get(register).invoke(null, player); -+ } catch (InvocationTargetException | IllegalAccessException e) { -+ e.printStackTrace(); ++ } catch (InvocationTargetException | IllegalAccessException exception) { ++ LOGGER.warning("Failed to handle minecraft register, " + exception.getMessage()); + } + } + } @@ -393,13 +453,13 @@ index 0000000000000000000000000000000000000000..be939521c6c4f9ca1f960611473d68ac + jar = ((JarURLConnection) url.openConnection()).getJarFile(); + Enumeration entries = jar.entries(); + findClassesInPackageByJar(pack, entries, packageDirName, classes); -+ } catch (IOException e) { -+ e.printStackTrace(); ++ } catch (IOException exception) { ++ LOGGER.warning("Failed to load jar file, " + exception.getMessage()); + } + } + } -+ } catch (IOException e) { -+ e.printStackTrace(); ++ } catch (IOException exception) { ++ LOGGER.warning("Failed to load classes, " + exception.getMessage()); + } + return classes; + } @@ -418,8 +478,8 @@ index 0000000000000000000000000000000000000000..be939521c6c4f9ca1f960611473d68ac + String className = file.getName().substring(0, file.getName().length() - 6); + try { + classes.add(Class.forName(packageName + '.' + className)); -+ } catch (ClassNotFoundException e) { -+ e.printStackTrace(); ++ } catch (ClassNotFoundException exception) { ++ LOGGER.warning("Failed to load class " + className + ", " + exception.getMessage()); + } + } + } @@ -442,22 +502,23 @@ index 0000000000000000000000000000000000000000..be939521c6c4f9ca1f960611473d68ac + String className = name.substring(packageName.length() + 1, name.length() - 6); + try { + classes.add(Class.forName(packageName + '.' + className)); -+ } catch (ClassNotFoundException e) { -+ e.printStackTrace(); ++ } catch (ClassNotFoundException exception) { ++ LOGGER.warning("Failed to load class " + className + ", " + exception.getMessage()); + } + } + } + } + } + -+ public record ErrorPayload(ResourceLocation id, String[] protocolID, String[] packetID) implements CustomPacketPayload { ++ public record ErrorPayload(ResourceLocation id, String[] protocolID, String[] packetID) implements LeavesCustomPayload { + @Override + public void write(@NotNull FriendlyByteBuf buf) { + } + } + -+ public record EmptyPayload(ResourceLocation id) implements CustomPacketPayload { ++ public record EmptyPayload(ResourceLocation id) implements LeavesCustomPayload { + ++ @LeavesCustomPayload.New + public EmptyPayload(ResourceLocation location, FriendlyByteBuf buf) { + this(location); + } @@ -467,8 +528,9 @@ index 0000000000000000000000000000000000000000..be939521c6c4f9ca1f960611473d68ac + } + } + -+ public record LeavesPayload(FriendlyByteBuf data, ResourceLocation id) implements CustomPacketPayload { ++ public record LeavesPayload(FriendlyByteBuf data, ResourceLocation id) implements LeavesCustomPayload { + ++ @LeavesCustomPayload.New + public LeavesPayload(ResourceLocation location, FriendlyByteBuf buf) { + this(new FriendlyByteBuf(buf.readBytes(buf.readableBytes())), location); + } @@ -479,15 +541,13 @@ index 0000000000000000000000000000000000000000..be939521c6c4f9ca1f960611473d68ac + } + } +} -diff --git a/src/main/java/top/leavesmc/leaves/protocol/core/ProtocolHandler.java b/src/main/java/top/leavesmc/leaves/protocol/core/ProtocolHandler.java +diff --git a/src/main/java/org/leavesmc/leaves/protocol/core/ProtocolHandler.java b/src/main/java/org/leavesmc/leaves/protocol/core/ProtocolHandler.java new file mode 100644 -index 0000000000000000000000000000000000000000..92ad6e9b1c0d9640b80c1ebe739c613d989eec21 +index 0000000000000000000000000000000000000000..f9dc0a60ca4287e5ec91dd3fc1ae315e2826da34 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/protocol/core/ProtocolHandler.java -@@ -0,0 +1,63 @@ -+package top.leavesmc.leaves.protocol.core; -+ -+import net.minecraft.network.protocol.common.custom.CustomPacketPayload; ++++ b/src/main/java/org/leavesmc/leaves/protocol/core/ProtocolHandler.java +@@ -0,0 +1,61 @@ ++package org.leavesmc.leaves.protocol.core; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; @@ -506,7 +566,7 @@ index 0000000000000000000000000000000000000000..92ad6e9b1c0d9640b80c1ebe739c613d + @Retention(RetentionPolicy.RUNTIME) + public @interface PayloadReceiver { + -+ Class payload(); ++ Class> payload(); + + String[] payloadId(); + @@ -548,13 +608,13 @@ index 0000000000000000000000000000000000000000..92ad6e9b1c0d9640b80c1ebe739c613d + boolean ignoreId() default false; + } +} -diff --git a/src/main/java/top/leavesmc/leaves/protocol/core/ProtocolUtils.java b/src/main/java/top/leavesmc/leaves/protocol/core/ProtocolUtils.java +diff --git a/src/main/java/org/leavesmc/leaves/protocol/core/ProtocolUtils.java b/src/main/java/org/leavesmc/leaves/protocol/core/ProtocolUtils.java new file mode 100644 -index 0000000000000000000000000000000000000000..5282c5ad3d26d06ab685ddaaf6fd9a4d49559717 +index 0000000000000000000000000000000000000000..562f3d515679965571597945e8682712e1e1f0b9 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/protocol/core/ProtocolUtils.java -@@ -0,0 +1,36 @@ -+package top.leavesmc.leaves.protocol.core; ++++ b/src/main/java/org/leavesmc/leaves/protocol/core/ProtocolUtils.java +@@ -0,0 +1,37 @@ ++package org.leavesmc.leaves.protocol.core; + +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket; @@ -571,8 +631,9 @@ index 0000000000000000000000000000000000000000..5282c5ad3d26d06ab685ddaaf6fd9a4d + player.connection.send(new ClientboundCustomPayloadPacket(new LeavesProtocolManager.EmptyPayload(id))); + } + -+ public static void sendPayloadPacket(ServerPlayer player, ResourceLocation id, Consumer consumer) { -+ player.connection.send(new ClientboundCustomPayloadPacket(new CustomPacketPayload() { ++ @SuppressWarnings("all") ++ public static void sendPayloadPacket(@NotNull ServerPlayer player, ResourceLocation id, Consumer consumer) { ++ player.connection.send(new ClientboundCustomPayloadPacket(new LeavesCustomPayload() { + @Override + public void write(@NotNull FriendlyByteBuf buf) { + consumer.accept(buf); diff --git a/patches/server/0007-Fix-gravity-block-duper.patch b/patches/server/0008-Fix-gravity-block-duper.patch similarity index 85% rename from patches/server/0007-Fix-gravity-block-duper.patch rename to patches/server/0008-Fix-gravity-block-duper.patch index c9ff5da6..e3d18599 100644 --- a/patches/server/0007-Fix-gravity-block-duper.patch +++ b/patches/server/0008-Fix-gravity-block-duper.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Fix gravity block duper diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index dcd8ab90212237764cc64a71321d739bd857a34a..87b0eead81c06afa276b74bf1c7fce573027702f 100644 +index 1d8be1e7b71db074b7616d0a5e0c5075f09877ac..96ad6c4ae0a9f3745e4a6503e6010d9278d8eb54 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -441,6 +441,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -443,6 +443,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess return this.originWorld; } // Paper end - Entity origin API @@ -16,7 +16,7 @@ index dcd8ab90212237764cc64a71321d739bd857a34a..87b0eead81c06afa276b74bf1c7fce57 // Paper start - make end portalling safe public BlockPos portalBlock; public ServerLevel portalWorld; -@@ -471,6 +472,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -473,6 +474,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess this.teleportTo(worldserver, null); } // Paper end - make end portalling safe @@ -24,7 +24,7 @@ index dcd8ab90212237764cc64a71321d739bd857a34a..87b0eead81c06afa276b74bf1c7fce57 // Paper start - optimise entity tracking final org.spigotmc.TrackingRange.TrackingRangeType trackingRangeType = org.spigotmc.TrackingRange.getTrackingRangeType(this); -@@ -3199,7 +3201,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -3260,7 +3262,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess } this.processPortalCooldown(); @@ -34,7 +34,7 @@ index dcd8ab90212237764cc64a71321d739bd857a34a..87b0eead81c06afa276b74bf1c7fce57 } diff --git a/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java b/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java -index 4ba24bced9a2de4616a0418857d3738e0e322ea0..6482c2456d9dc9b4983f691f388b7ec045d2cab6 100644 +index 7272d70c672b54dcf595beafd7a2ed33c96e35cb..d8d355b4ee4869fa9a5d7b4dcd81a3375dd976ba 100644 --- a/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java +++ b/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java @@ -61,15 +61,19 @@ public class EndPortalBlock extends BaseEntityBlock { diff --git a/patches/server/0008-Fix-trading-with-the-void.patch b/patches/server/0009-Fix-trading-with-the-void.patch similarity index 91% rename from patches/server/0008-Fix-trading-with-the-void.patch rename to patches/server/0009-Fix-trading-with-the-void.patch index 431940ad..44d93f8e 100644 --- a/patches/server/0008-Fix-trading-with-the-void.patch +++ b/patches/server/0009-Fix-trading-with-the-void.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Fix trading with the void diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index ccc645f225bb0cf898dbc2ee7abb21b53ff8660b..a15e1d95da33bf543df96e9b97b79d84583332bd 100644 +index 92805a3311bc1f21df9512b14b209e1d51174ac5..c93d0fbb921309a63c21ba7775fdf44aaa7985c4 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java -@@ -2800,11 +2800,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2751,11 +2751,7 @@ public class ServerLevel extends Level implements WorldGenLevel { // Spigot end // Spigot Start if (entity.getBukkitEntity() instanceof org.bukkit.inventory.InventoryHolder && (!(entity instanceof ServerPlayer) || entity.getRemovalReason() != Entity.RemovalReason.KILLED)) { // SPIGOT-6876: closeInventory clears death message diff --git a/patches/server/0009-Make-snowball-and-egg-can-knockback-player.patch b/patches/server/0010-Make-snowball-and-egg-can-knockback-player.patch similarity index 89% rename from patches/server/0009-Make-snowball-and-egg-can-knockback-player.patch rename to patches/server/0010-Make-snowball-and-egg-can-knockback-player.patch index 87146f81..d0bd5cd9 100644 --- a/patches/server/0009-Make-snowball-and-egg-can-knockback-player.patch +++ b/patches/server/0010-Make-snowball-and-egg-can-knockback-player.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Make snowball and egg can knockback player diff --git a/src/main/java/net/minecraft/world/entity/projectile/Snowball.java b/src/main/java/net/minecraft/world/entity/projectile/Snowball.java -index 5e82549ea2e80b3968b793b7b4b685c4891e9a91..14c14d12b7ae34a6631828e8dcc531b62b9aa1ed 100644 +index 2b4d206c0d31ba38d7b2af654bd420e85145d441..21b1244a51aa96e769bb568ff7e682e4a583269d 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/Snowball.java +++ b/src/main/java/net/minecraft/world/entity/projectile/Snowball.java @@ -3,6 +3,7 @@ package net.minecraft.world.entity.projectile; @@ -22,7 +22,7 @@ index 5e82549ea2e80b3968b793b7b4b685c4891e9a91..14c14d12b7ae34a6631828e8dcc531b6 entity.hurt(this.damageSources().thrown(this, this.getOwner()), (float) i); + + // Leaves start - make snowball can knockback player -+ if (top.leavesmc.leaves.LeavesConfig.snowballAndEggCanKnockback && entity instanceof ServerPlayer) { ++ if (org.leavesmc.leaves.LeavesConfig.snowballAndEggCanKnockback && entity instanceof ServerPlayer) { + entity.hurt(this.damageSources().thrown(this, this.getOwner()), 0.0000001F); + ((ServerPlayer) entity).knockback(0.4000000059604645D, this.getX() - entity.getX(), this.getZ() - entity.getZ(), this, org.bukkit.event.entity.EntityKnockbackEvent.KnockbackCause.DAMAGE); + } @@ -31,7 +31,7 @@ index 5e82549ea2e80b3968b793b7b4b685c4891e9a91..14c14d12b7ae34a6631828e8dcc531b6 @Override diff --git a/src/main/java/net/minecraft/world/entity/projectile/ThrownEgg.java b/src/main/java/net/minecraft/world/entity/projectile/ThrownEgg.java -index 82bb8004635865f5202578d5a6f520048e7269d5..f6524889953ad540f5e6a66ff748f4d8582e1c1b 100644 +index 82bb8004635865f5202578d5a6f520048e7269d5..2b8d8330e7edfd23344c31b064c12348206dec48 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/ThrownEgg.java +++ b/src/main/java/net/minecraft/world/entity/projectile/ThrownEgg.java @@ -46,7 +46,14 @@ public class ThrownEgg extends ThrowableItemProjectile { @@ -41,7 +41,7 @@ index 82bb8004635865f5202578d5a6f520048e7269d5..f6524889953ad540f5e6a66ff748f4d8 + Entity entity = entityHitResult.getEntity(); // Leaves - make egg can knockback player entityHitResult.getEntity().hurt(this.damageSources().thrown(this, this.getOwner()), 0.0F); + // Leaves start - make egg can knockback player -+ if (top.leavesmc.leaves.LeavesConfig.snowballAndEggCanKnockback && entity instanceof ServerPlayer) { ++ if (org.leavesmc.leaves.LeavesConfig.snowballAndEggCanKnockback && entity instanceof ServerPlayer) { + entity.hurt(this.damageSources().thrown(this, this.getOwner()), 0.0000001F); + ((ServerPlayer) entity).knockback(0.4000000059604645D, this.getX() - entity.getX(), this.getZ() - entity.getZ(), this, org.bukkit.event.entity.EntityKnockbackEvent.KnockbackCause.DAMAGE); + } diff --git a/patches/server/0010-Fakeplayer-support.patch b/patches/server/0011-Fakeplayer-support.patch similarity index 82% rename from patches/server/0010-Fakeplayer-support.patch rename to patches/server/0011-Fakeplayer-support.patch index 3e139339..52c71c45 100644 --- a/patches/server/0010-Fakeplayer-support.patch +++ b/patches/server/0011-Fakeplayer-support.patch @@ -4,8 +4,17 @@ Date: Thu, 3 Feb 2022 12:28:15 +0800 Subject: [PATCH] Fakeplayer support +diff --git a/.gitignore b/.gitignore +index 1ad93453221244f880855b510e888e759275b640..3811c0d849a3eb028ed1a6b7a2d4747f7f570448 100644 +--- a/.gitignore ++++ b/.gitignore +@@ -46,4 +46,3 @@ dependency-reduced-pom.xml + # vs code + /.vscode + /.factorypath +- diff --git a/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java b/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java -index a1c9726d25479b5326fe2fa2b0f5a98d6b2da4c5..ee17f012497fa75e152bc279cb3f7778342c49d4 100644 +index a1c9726d25479b5326fe2fa2b0f5a98d6b2da4c5..0724bd95143cb5dc69b5f1eb2e67ecd679e09a99 100644 --- a/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java +++ b/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java @@ -41,6 +41,12 @@ class PaperEventManager { @@ -13,7 +22,7 @@ index a1c9726d25479b5326fe2fa2b0f5a98d6b2da4c5..ee17f012497fa75e152bc279cb3f7778 } + // Leaves start - skip bot -+ if (event instanceof org.bukkit.event.player.PlayerEvent playerEvent && playerEvent.getPlayer() instanceof top.leavesmc.leaves.entity.Bot) { ++ if (event instanceof org.bukkit.event.player.PlayerEvent playerEvent && playerEvent.getPlayer() instanceof org.leavesmc.leaves.entity.Bot) { + return; + } + // Leaves end - skip bot @@ -22,22 +31,22 @@ index a1c9726d25479b5326fe2fa2b0f5a98d6b2da4c5..ee17f012497fa75e152bc279cb3f7778 RegisteredListener[] listeners = handlers.getRegisteredListeners(); diff --git a/src/main/java/net/minecraft/advancements/critereon/SimpleCriterionTrigger.java b/src/main/java/net/minecraft/advancements/critereon/SimpleCriterionTrigger.java -index 35772110e9318df46a2729dbc0b5879b290011b7..0d4ad3666efaa7cc8df81b1c698e4a45586d3795 100644 +index 35772110e9318df46a2729dbc0b5879b290011b7..f26989a44cdda9baabf337d573436c6c115c9884 100644 --- a/src/main/java/net/minecraft/advancements/critereon/SimpleCriterionTrigger.java +++ b/src/main/java/net/minecraft/advancements/critereon/SimpleCriterionTrigger.java @@ -39,6 +39,7 @@ public abstract class SimpleCriterionTrigger predicate) { -+ if (player instanceof top.leavesmc.leaves.bot.ServerBot) return; // Leaves - bot skip ++ if (player instanceof org.leavesmc.leaves.bot.ServerBot) return; // Leaves - bot skip PlayerAdvancements playerAdvancements = player.getAdvancements(); Set> set = (Set) playerAdvancements.criterionData.get(this); // Paper - fix AdvancementDataPlayer leak if (set != null && !set.isEmpty()) { diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java -index a536ebcf29d8ef0ed32863bd8d5e70f7a0636e8d..35d03c7128e0cc9b3e0a9ecf109c17dab927c4a4 100644 +index 02833deaa2bb7e5abc655bc1bdbe15c4b3ac7119..53c23d5bbbc5c74a35dafec99bcf13f9fa7552ac 100644 --- a/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java -@@ -340,6 +340,14 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -391,6 +391,14 @@ public class Connection extends SimpleChannelInboundHandler> { } } @@ -53,28 +62,28 @@ index a536ebcf29d8ef0ed32863bd8d5e70f7a0636e8d..35d03c7128e0cc9b3e0a9ecf109c17da if (this.packetListener != null) { throw new IllegalStateException("Listener already set"); diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index f7a3a8933b9714ca65e48dd92c979bcef9535172..2841d4f57c39a52bf11023500a91bc51019ac172 100644 +index 4a9b4e9c0db3cf86134b857ee1318fa4463c80a1..d8ac4b133c52c46494518a93884f715108dc8f17 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -663,6 +663,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop loot = new java.util.ArrayList<>(this.getInventory().getContainerSize()); // Paper - Restore vanilla drops behavior boolean keepInventory = this.level().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) || this.isSpectator(); @@ -176,12 +185,12 @@ index b3781efbd3edcf102fe1bda5d6149915dc1127c6..f0d8c75c921364564b30c8dca457a61e for (ItemStack item : this.getInventory().getContents()) { if (!item.isEmpty() && !EnchantmentHelper.hasVanishingCurse(item)) { loot.add(new DefaultDrop(item, stack -> this.drop(stack, true, false, false))); // Paper - Restore vanilla drops behavior; drop function taken from Inventory#dropAll (don't fire drop event) -@@ -1272,6 +1277,13 @@ public class ServerPlayer extends Player { +@@ -1349,6 +1354,13 @@ public class ServerPlayer extends Player { this.lastSentHealth = -1.0F; this.lastSentFood = -1; + // Leaves start - bot support -+ if (top.leavesmc.leaves.LeavesConfig.fakeplayerSupport) { ++ if (org.leavesmc.leaves.LeavesConfig.fakeplayerSupport) { + ServerBot.getBots().forEach(bot1 -> + bot1.sendFakeDataIfNeed(this, true)); // Leaves - render bot + } @@ -190,44 +199,25 @@ index b3781efbd3edcf102fe1bda5d6149915dc1127c6..f0d8c75c921364564b30c8dca457a61e // CraftBukkit start PlayerChangedWorldEvent changeEvent = new PlayerChangedWorldEvent(this.getBukkitEntity(), worldserver1.getWorld()); this.level().getCraftServer().getPluginManager().callEvent(changeEvent); -diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 03eba1b13288dfaaeca9a3eef68a1e0d3d71ccb6..81bcbb426b75bdd1151fb26ed504217165f4935e 100644 ---- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -297,7 +297,13 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl - public ServerGamePacketListenerImpl(MinecraftServer server, Connection connection, ServerPlayer player, CommonListenerCookie clientData) { - super(server, connection, clientData, player); // CraftBukkit - this.chunkSender = new PlayerChunkSender(connection.isMemoryConnection()); -- connection.setListener(this); -+ // Leaves start - fakeplayer -+ if (player instanceof top.leavesmc.leaves.bot.ServerBot) { -+ connection.setListenerForce(this); -+ } else { -+ connection.setListener(this); -+ } -+ // Leaves end - fakeplayer - this.player = player; - player.connection = this; - player.getTextFilter().join(); diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index 62d89e49dfcbb00651df7f89be482b9cbc173b0a..44b354431a9c21166211e6d1de1ce573b9f7253c 100644 +index 11d73647d2d94c8131c5e3eeef490fb3472fe0a4..ef719bf410912b24d57de422d1fa3fb2bcef5105 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java -@@ -121,6 +121,8 @@ import org.bukkit.event.player.PlayerRespawnEvent.RespawnReason; +@@ -123,6 +123,8 @@ import org.bukkit.event.player.PlayerRespawnEvent.RespawnReason; import org.bukkit.event.player.PlayerSpawnChangeEvent; // CraftBukkit end -+import top.leavesmc.leaves.bot.ServerBot; ++import org.leavesmc.leaves.bot.ServerBot; + public abstract class PlayerList { public static final File USERBANLIST_FILE = new File("banned-players.json"); -@@ -349,6 +351,21 @@ public abstract class PlayerList { +@@ -351,6 +353,21 @@ public abstract class PlayerList { - top.leavesmc.leaves.protocol.core.LeavesProtocolManager.handlePlayerJoin(player); // Leaves - protocol + org.leavesmc.leaves.protocol.core.LeavesProtocolManager.handlePlayerJoin(player); // Leaves - protocol + // Leaves start - bot support -+ if (top.leavesmc.leaves.LeavesConfig.fakeplayerSupport) { ++ if (org.leavesmc.leaves.LeavesConfig.fakeplayerSupport) { + ServerBot bot = ServerBot.getBot(player.getScoreboardName().toLowerCase(java.util.Locale.ROOT)); + if (bot != null) { + bot.die(bot.damageSources().fellOutOfWorld()); // Leaves - remove bot with the same name @@ -244,12 +234,12 @@ index 62d89e49dfcbb00651df7f89be482b9cbc173b0a..44b354431a9c21166211e6d1de1ce573 final net.kyori.adventure.text.Component jm = playerJoinEvent.joinMessage(); if (jm != null && !jm.equals(net.kyori.adventure.text.Component.empty())) { // Paper - Adventure -@@ -1000,6 +1017,13 @@ public abstract class PlayerList { +@@ -999,6 +1016,13 @@ public abstract class PlayerList { } // Paper end - Add PlayerPostRespawnEvent + // Leaves start - bot support -+ if (top.leavesmc.leaves.LeavesConfig.fakeplayerSupport) { ++ if (org.leavesmc.leaves.LeavesConfig.fakeplayerSupport) { + ServerBot.getBots().forEach(bot1 -> + bot1.sendFakeDataIfNeed(entityplayer1, true)); // Leaves - render bot + } @@ -258,7 +248,7 @@ index 62d89e49dfcbb00651df7f89be482b9cbc173b0a..44b354431a9c21166211e6d1de1ce573 // CraftBukkit end return entityplayer1; } -@@ -1116,11 +1140,16 @@ public abstract class PlayerList { +@@ -1115,11 +1139,16 @@ public abstract class PlayerList { } public String[] getPlayerNamesArray() { @@ -276,9 +266,9 @@ index 62d89e49dfcbb00651df7f89be482b9cbc173b0a..44b354431a9c21166211e6d1de1ce573 return astring; } -@@ -1599,4 +1628,16 @@ public abstract class PlayerList { - public boolean isAllowCheatsForAllPlayers() { - return this.allowCheatsForAllPlayers; +@@ -1598,4 +1627,16 @@ public abstract class PlayerList { + public boolean isAllowCommandsForAllPlayers() { + return this.allowCommandsForAllPlayers; } + + // Leaves start - fakeplayer support @@ -294,10 +284,10 @@ index 62d89e49dfcbb00651df7f89be482b9cbc173b0a..44b354431a9c21166211e6d1de1ce573 + // Leaves end - fakeplayer support } diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index ae37474ca2c0484d974364e9758f73e92ce8a39a..98bab45b0dbd053ec1a0b87e3446b00da04ef300 100644 +index 96ad6c4ae0a9f3745e4a6503e6010d9278d8eb54..082b484df1bd3d6a87413e3ab9a07a8f5401c65d 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -1469,7 +1469,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -1511,7 +1511,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess return offsetFactor; } @@ -307,7 +297,7 @@ index ae37474ca2c0484d974364e9758f73e92ce8a39a..98bab45b0dbd053ec1a0b87e3446b00d final boolean xZero = movement.x == 0.0; final boolean yZero = movement.y == 0.0; 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 91497f5e6c07fcf1b05eca6846c51e1a15ed3bc0..c4e09998ed133e74dcf488869d82d9154a18d3de 100644 +index 35299affb699d745804a3b60cb78b9323f3e068e..f959f1819181b867dfabd19005e730069dffda4d 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java +++ b/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java @@ -62,7 +62,7 @@ public class FishingHook extends Projectile { @@ -317,10 +307,10 @@ index 91497f5e6c07fcf1b05eca6846c51e1a15ed3bc0..c4e09998ed133e74dcf488869d82d915 - private int nibble; + public int nibble; // Leaves - private -> public public int timeUntilLured; - private int timeUntilHooked; + public int timeUntilHooked; private float fishAngle; diff --git a/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java b/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java -index 48f634a7521d31c1e9dfd3cfc83139d428dbd37a..7cef5c518207752f7e1bfdd5bbec55fe9fafca6b 100644 +index 32910f677b0522ac8ec513fa0d00b714b52cfae4..961a7193fda00fa62acea9c39fda1c93f7fbe412 100644 --- a/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java +++ b/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java @@ -406,6 +406,8 @@ public abstract class AbstractContainerMenu { @@ -332,7 +322,7 @@ index 48f634a7521d31c1e9dfd3cfc83139d428dbd37a..7cef5c518207752f7e1bfdd5bbec55fe if (actionType == ClickType.QUICK_CRAFT) { int i1 = this.quickcraftStatus; -@@ -680,6 +682,23 @@ public abstract class AbstractContainerMenu { +@@ -680,6 +682,22 @@ public abstract class AbstractContainerMenu { } @@ -344,10 +334,9 @@ index 48f634a7521d31c1e9dfd3cfc83139d428dbd37a..7cef5c518207752f7e1bfdd5bbec55fe + + Slot slot = getSlot(slotIndex); + ItemStack itemStack = slot.getItem(); -+ if (itemStack.getTag() != null) { -+ if (itemStack.getTag().get("Leaves.Gui.Placeholder") != null) { -+ return !itemStack.getTag().getBoolean("Leaves.Gui.Placeholder"); -+ } ++ net.minecraft.world.item.component.CustomData customData = itemStack.get(net.minecraft.core.component.DataComponents.CUSTOM_DATA); ++ if (customData != null && customData.contains("Leaves.Gui.Placeholder")) { ++ return !customData.copyTag().getBoolean("Leaves.Gui.Placeholder"); + } + return true; + } @@ -357,15 +346,15 @@ index 48f634a7521d31c1e9dfd3cfc83139d428dbd37a..7cef5c518207752f7e1bfdd5bbec55fe FeatureFlagSet featureflagset = player.level().enabledFeatures(); 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 ed80960777b18faca2d6a99783e53daf5fa19e09..9d492a2a45a2088f4bf28c85f04c22fa70a2996a 100644 +index 1b1b475ca27e799e251d6f8a8c9fe1a4fd8bae83..bb9d8cb957f5be517d3ae2959e0406af0d072a1c 100644 --- a/src/main/java/net/minecraft/world/level/levelgen/PhantomSpawner.java +++ b/src/main/java/net/minecraft/world/level/levelgen/PhantomSpawner.java -@@ -68,6 +68,11 @@ public class PhantomSpawner implements CustomSpawner { +@@ -67,6 +67,11 @@ public class PhantomSpawner implements CustomSpawner { ServerStatsCounter serverstatisticmanager = entityplayer.getStats(); int j = Mth.clamp(serverstatisticmanager.getValue(Stats.CUSTOM.get(Stats.TIME_SINCE_REST)), 1, Integer.MAX_VALUE); boolean flag2 = true; + // Leaves start - fakeplayer spawn -+ if (entityplayer instanceof top.leavesmc.leaves.bot.ServerBot bot && bot.spawnPhantom) { ++ if (entityplayer instanceof org.leavesmc.leaves.bot.ServerBot bot && bot.spawnPhantom) { + j = bot.notSleepTicks; + } + // Leaves end - fakeplayer spawn @@ -373,47 +362,39 @@ index ed80960777b18faca2d6a99783e53daf5fa19e09..9d492a2a45a2088f4bf28c85f04c22fa 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)); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 79874b67f7edb9afd41633f5bc4bacee5cb0046b..79c10c26e9a27b120070b408e261a26bb66a5082 100644 +index 3fbf31ef07489ffb7d0c0f5317fa967db740494d..87bb3ecfbc1fc48a0c276261ea438ba43f8e9e50 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -261,6 +261,7 @@ import org.yaml.snakeyaml.constructor.SafeConstructor; - import org.yaml.snakeyaml.error.MarkedYAMLException; - - import net.md_5.bungee.api.chat.BaseComponent; // Spigot -+import top.leavesmc.leaves.entity.CraftBotManager; - - import javax.annotation.Nullable; // Paper - import javax.annotation.Nonnull; // Paper -@@ -307,6 +308,7 @@ public final class CraftServer implements Server { +@@ -305,6 +305,7 @@ public final class CraftServer implements Server { public static Exception excessiveVelEx; // Paper - Velocity warnings private final io.papermc.paper.logging.SysoutCatcher sysoutCatcher = new io.papermc.paper.logging.SysoutCatcher(); // Paper - private final CraftPotionBrewer potionBrewer = new CraftPotionBrewer(); // Paper - Custom Potion Mixes -+ private final CraftBotManager botManager = new CraftBotManager(); + private final io.papermc.paper.potion.PaperPotionBrewer potionBrewer; // Paper - Custom Potion Mixes ++ private final org.leavesmc.leaves.entity.CraftBotManager botManager = new org.leavesmc.leaves.entity.CraftBotManager(); // Leaves // Paper start - Folia region threading API private final io.papermc.paper.threadedregions.scheduler.FallbackRegionScheduler regionizedScheduler = new io.papermc.paper.threadedregions.scheduler.FallbackRegionScheduler(); -@@ -3270,4 +3272,11 @@ public final class CraftServer implements Server { +@@ -3275,4 +3276,11 @@ public final class CraftServer implements Server { + return this.potionBrewer; } - // Paper end + + // Leaves start - Bot API + @Override -+ public CraftBotManager getBotManager() { ++ public org.leavesmc.leaves.entity.CraftBotManager getBotManager() { + return botManager; + } + // Leaves end - Bot API } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java -index e8e4489bcd64fde1b3226bdc7a7cc612508bda3f..12f8ed45dc280a9ad7e975b1922cc9309c3d53b8 100644 +index a2d336ceb52b63db5c03432ee7bc94dc6a742b82..ff4563be301d237bb2f431e424687891e95b2b4f 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -55,6 +55,8 @@ import org.bukkit.plugin.Plugin; import org.bukkit.util.BoundingBox; import org.bukkit.util.NumberConversions; import org.bukkit.util.Vector; -+import top.leavesmc.leaves.bot.ServerBot; -+import top.leavesmc.leaves.entity.CraftBot; ++import org.leavesmc.leaves.bot.ServerBot; ++import org.leavesmc.leaves.entity.CraftBot; import net.md_5.bungee.api.chat.BaseComponent; // Spigot @@ -439,10 +420,10 @@ index bb9383f1a457433f9db3e78d7913616280925200..55b41ca7630db143d70137324a9de871 /** * The start ID for the counter. */ -diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java -index cb427686bf77366ddc9ad133b08f42b6b34fb0f5..19ee86e42d92c33cb7e35ba07927883d4c979913 100644 ---- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java -+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java +diff --git a/src/main/java/org/leavesmc/leaves/LeavesConfig.java b/src/main/java/org/leavesmc/leaves/LeavesConfig.java +index 78d00c27d00561911d089660db0051fa4dd6f59a..021d7bd9940ec2dc63126af1facdc89086801bed 100644 +--- a/src/main/java/org/leavesmc/leaves/LeavesConfig.java ++++ b/src/main/java/org/leavesmc/leaves/LeavesConfig.java @@ -204,6 +204,12 @@ public final class LeavesConfig { } } @@ -456,13 +437,13 @@ index cb427686bf77366ddc9ad133b08f42b6b34fb0f5..19ee86e42d92c33cb7e35ba07927883d // Leaves end - modify - fakeplayer // Leaves start - modify - minecraft-old -diff --git a/src/main/java/top/leavesmc/leaves/bot/BotCommand.java b/src/main/java/top/leavesmc/leaves/bot/BotCommand.java +diff --git a/src/main/java/org/leavesmc/leaves/bot/BotCommand.java b/src/main/java/org/leavesmc/leaves/bot/BotCommand.java new file mode 100644 -index 0000000000000000000000000000000000000000..82f29d2ead96315df1b3747ff0e5bc0ee016131b +index 0000000000000000000000000000000000000000..4b31cd0407d46c3405506470f70568a1c6162262 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/bot/BotCommand.java ++++ b/src/main/java/org/leavesmc/leaves/bot/BotCommand.java @@ -0,0 +1,405 @@ -+package top.leavesmc.leaves.bot; ++package org.leavesmc.leaves.bot; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; @@ -478,13 +459,13 @@ index 0000000000000000000000000000000000000000..82f29d2ead96315df1b3747ff0e5bc0e +import org.bukkit.permissions.PermissionDefault; +import org.bukkit.plugin.PluginManager; +import org.jetbrains.annotations.NotNull; -+import top.leavesmc.leaves.LeavesConfig; -+import top.leavesmc.leaves.bot.agent.Actions; -+import top.leavesmc.leaves.bot.agent.BotAction; -+import top.leavesmc.leaves.bot.agent.actions.CraftCustomBotAction; -+import top.leavesmc.leaves.entity.Bot; -+import top.leavesmc.leaves.event.bot.BotActionEvent; -+import top.leavesmc.leaves.event.bot.BotConfigModifyEvent; ++import org.leavesmc.leaves.LeavesConfig; ++import org.leavesmc.leaves.bot.agent.Actions; ++import org.leavesmc.leaves.bot.agent.BotAction; ++import org.leavesmc.leaves.bot.agent.actions.CraftCustomBotAction; ++import org.leavesmc.leaves.entity.Bot; ++import org.leavesmc.leaves.event.bot.BotActionEvent; ++import org.leavesmc.leaves.event.bot.BotConfigModifyEvent; + +import java.util.ArrayList; +import java.util.HashMap; @@ -637,12 +618,12 @@ index 0000000000000000000000000000000000000000..82f29d2ead96315df1b3747ff0e5bc0e + return false; + } + -+ if (top.leavesmc.leaves.LeavesConfig.unableFakeplayerNames.contains(name)) { ++ if (org.leavesmc.leaves.LeavesConfig.unableFakeplayerNames.contains(name)) { + sender.sendMessage(ChatColor.RED + "This name is not allowed"); + return false; + } + -+ if (ServerBot.getBots().size() >= top.leavesmc.leaves.LeavesConfig.fakeplayerLimit) { ++ if (ServerBot.getBots().size() >= org.leavesmc.leaves.LeavesConfig.fakeplayerLimit) { + sender.sendMessage(ChatColor.RED + "Fakeplayer limit is full"); + return false; + } @@ -834,7 +815,7 @@ index 0000000000000000000000000000000000000000..82f29d2ead96315df1b3747ff0e5bc0e + botMap.get(bukkitBot.getWorld()).add(bukkitBot.getName()); + } + -+ sender.sendMessage("Total number: (" + ServerBot.getBots().size() + "/" + top.leavesmc.leaves.LeavesConfig.fakeplayerLimit + ")"); ++ sender.sendMessage("Total number: (" + ServerBot.getBots().size() + "/" + org.leavesmc.leaves.LeavesConfig.fakeplayerLimit + ")"); + for (World world : botMap.keySet()) { + sender.sendMessage(world.getName() + "(" + botMap.get(world).size() + "): " + formatPlayerNameList(botMap.get(world))); + } @@ -867,23 +848,27 @@ index 0000000000000000000000000000000000000000..82f29d2ead96315df1b3747ff0e5bc0e + return string.substring(1, string.length() - 1); + } +} -diff --git a/src/main/java/top/leavesmc/leaves/bot/BotInventoryContainer.java b/src/main/java/top/leavesmc/leaves/bot/BotInventoryContainer.java +diff --git a/src/main/java/org/leavesmc/leaves/bot/BotInventoryContainer.java b/src/main/java/org/leavesmc/leaves/bot/BotInventoryContainer.java new file mode 100644 -index 0000000000000000000000000000000000000000..b83ad5bf2a338d589eb200d3f3b3153571ba2cad +index 0000000000000000000000000000000000000000..4f5e6e5c1b9d8bd38c98e97fd31b38338f35faa6 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/bot/BotInventoryContainer.java -@@ -0,0 +1,180 @@ -+package top.leavesmc.leaves.bot; ++++ b/src/main/java/org/leavesmc/leaves/bot/BotInventoryContainer.java +@@ -0,0 +1,191 @@ ++package org.leavesmc.leaves.bot; + +import com.google.common.collect.ImmutableList; +import com.mojang.datafixers.util.Pair; +import net.minecraft.core.NonNullList; ++import net.minecraft.core.component.DataComponentPatch; ++import net.minecraft.core.component.DataComponents; ++import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.chat.Component; +import net.minecraft.world.ContainerHelper; +import net.minecraft.world.SimpleContainer; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; ++import net.minecraft.world.item.component.CustomData; + +import javax.annotation.Nonnull; +import java.util.List; @@ -964,8 +949,8 @@ index 0000000000000000000000000000000000000000..b83ad5bf2a338d589eb200d3f3b31535 + return new Pair<>(buttons, slot - 5); + } + case 18, 19, 20, 21, 22, 23, 24, 25, 26, -+ 27, 28, 29, 30, 31, 32, 33, 34, 35, -+ 36, 37, 38, 39, 40, 41, 42, 43, 44 -> { ++ 27, 28, 29, 30, 31, 32, 33, 34, 35, ++ 36, 37, 38, 39, 40, 41, 42, 43, 44 -> { + return new Pair<>(items, slot - 9); + } + case 45, 46, 47, 48, 49, 50, 51, 52, 53 -> { @@ -1045,21 +1030,28 @@ index 0000000000000000000000000000000000000000..b83ad5bf2a338d589eb200d3f3b31535 + } + + private void createButton() { ++ CompoundTag customData = new CompoundTag(); ++ customData.putBoolean("Leaves.Gui.Placeholder", true); ++ ++ DataComponentPatch patch = DataComponentPatch.builder() ++ .set(DataComponents.CUSTOM_NAME, Component.empty()) ++ .set(DataComponents.CUSTOM_DATA, CustomData.of(customData)) ++ .build(); ++ + for (int i = 0; i < 13; i++) { + ItemStack button = new ItemStack(Items.STRUCTURE_VOID); -+ button.setHoverName(Component.empty()); -+ button.getOrCreateTag().putBoolean("Leaves.Gui.Placeholder", true); ++ button.applyComponents(patch); + buttons.set(i, button); + } + } +} -diff --git a/src/main/java/top/leavesmc/leaves/bot/BotStatsCounter.java b/src/main/java/top/leavesmc/leaves/bot/BotStatsCounter.java +diff --git a/src/main/java/org/leavesmc/leaves/bot/BotStatsCounter.java b/src/main/java/org/leavesmc/leaves/bot/BotStatsCounter.java new file mode 100644 -index 0000000000000000000000000000000000000000..c3f114fba0759221b5fea0ccc4862f0579260cef +index 0000000000000000000000000000000000000000..5bd34353b6ea86cd15ff48b8d6570167f35d75f0 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/bot/BotStatsCounter.java ++++ b/src/main/java/org/leavesmc/leaves/bot/BotStatsCounter.java @@ -0,0 +1,38 @@ -+package top.leavesmc.leaves.bot; ++package org.leavesmc.leaves.bot; + +import com.mojang.datafixers.DataFixer; +import net.minecraft.server.MinecraftServer; @@ -1097,13 +1089,13 @@ index 0000000000000000000000000000000000000000..c3f114fba0759221b5fea0ccc4862f05 + return 0; + } +} -diff --git a/src/main/java/top/leavesmc/leaves/bot/BotUtil.java b/src/main/java/top/leavesmc/leaves/bot/BotUtil.java +diff --git a/src/main/java/org/leavesmc/leaves/bot/BotUtil.java b/src/main/java/org/leavesmc/leaves/bot/BotUtil.java new file mode 100644 -index 0000000000000000000000000000000000000000..b0ad5ed3d2a179001312733b780dd532d3b4a001 +index 0000000000000000000000000000000000000000..e63bdf65183fb2c55df865b0adc2e207ac50071a --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/bot/BotUtil.java ++++ b/src/main/java/org/leavesmc/leaves/bot/BotUtil.java @@ -0,0 +1,183 @@ -+package top.leavesmc.leaves.bot; ++package org.leavesmc.leaves.bot; + +import com.google.common.base.Charsets; +import com.google.gson.JsonArray; @@ -1121,8 +1113,8 @@ index 0000000000000000000000000000000000000000..b0ad5ed3d2a179001312733b780dd532 +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.jetbrains.annotations.NotNull; -+import top.leavesmc.leaves.bot.agent.Actions; -+import top.leavesmc.leaves.bot.agent.BotAction; ++import org.leavesmc.leaves.bot.agent.Actions; ++import org.leavesmc.leaves.bot.agent.BotAction; + +import java.io.File; +import java.io.IOException; @@ -1140,7 +1132,7 @@ index 0000000000000000000000000000000000000000..b0ad5ed3d2a179001312733b780dd532 + continue; + } + -+ if (ItemStack.isSameItemSameTags(itemStack1, itemStack)) { ++ if (ItemStack.isSameItemSameComponents(itemStack1, itemStack)) { + if (itemStack1.getCount() > count) { + itemStack.setCount(itemStack.getCount() + count); + itemStack1.setCount(itemStack1.getCount() - count); @@ -1286,13 +1278,13 @@ index 0000000000000000000000000000000000000000..b0ad5ed3d2a179001312733b780dd532 + return UUID.nameUUIDFromBytes(("Fakeplayer:" + state.getRealName()).getBytes(Charsets.UTF_8)); + } +} -diff --git a/src/main/java/top/leavesmc/leaves/bot/MojangAPI.java b/src/main/java/top/leavesmc/leaves/bot/MojangAPI.java +diff --git a/src/main/java/org/leavesmc/leaves/bot/MojangAPI.java b/src/main/java/org/leavesmc/leaves/bot/MojangAPI.java new file mode 100644 -index 0000000000000000000000000000000000000000..daaece30b2a3983f1cc9ee9a851e8f373974d5ec +index 0000000000000000000000000000000000000000..0db337866c71283464d026a4f230016b31d1a8cd --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/bot/MojangAPI.java ++++ b/src/main/java/org/leavesmc/leaves/bot/MojangAPI.java @@ -0,0 +1,41 @@ -+package top.leavesmc.leaves.bot; ++package org.leavesmc.leaves.bot; + +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; @@ -1333,13 +1325,13 @@ index 0000000000000000000000000000000000000000..daaece30b2a3983f1cc9ee9a851e8f37 + } + } +} -diff --git a/src/main/java/top/leavesmc/leaves/bot/ServerBot.java b/src/main/java/top/leavesmc/leaves/bot/ServerBot.java +diff --git a/src/main/java/org/leavesmc/leaves/bot/ServerBot.java b/src/main/java/org/leavesmc/leaves/bot/ServerBot.java new file mode 100644 -index 0000000000000000000000000000000000000000..a2dbfe898adf918a52ae639b0e0985e756ca826a +index 0000000000000000000000000000000000000000..73d5148108d7a7dd52d061cb778b2c98a71f456e --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/bot/ServerBot.java ++++ b/src/main/java/org/leavesmc/leaves/bot/ServerBot.java @@ -0,0 +1,716 @@ -+package top.leavesmc.leaves.bot; ++package org.leavesmc.leaves.bot; + +import com.google.common.collect.Lists; +import com.google.gson.Gson; @@ -1394,15 +1386,15 @@ index 0000000000000000000000000000000000000000..a2dbfe898adf918a52ae639b0e0985e7 +import org.bukkit.event.entity.EntityKnockbackEvent; +import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; -+import top.leavesmc.leaves.LeavesConfig; -+import top.leavesmc.leaves.bot.agent.BotAction; -+import top.leavesmc.leaves.bot.agent.actions.StopAction; -+import top.leavesmc.leaves.entity.Bot; -+import top.leavesmc.leaves.entity.CraftBot; -+import top.leavesmc.leaves.event.bot.BotCreateEvent; -+import top.leavesmc.leaves.event.bot.BotInventoryOpenEvent; -+import top.leavesmc.leaves.event.bot.BotJoinEvent; -+import top.leavesmc.leaves.util.MathUtils; ++import org.leavesmc.leaves.LeavesConfig; ++import org.leavesmc.leaves.bot.agent.BotAction; ++import org.leavesmc.leaves.bot.agent.actions.StopAction; ++import org.leavesmc.leaves.entity.Bot; ++import org.leavesmc.leaves.entity.CraftBot; ++import org.leavesmc.leaves.event.bot.BotCreateEvent; ++import org.leavesmc.leaves.event.bot.BotInventoryOpenEvent; ++import org.leavesmc.leaves.event.bot.BotJoinEvent; ++import org.leavesmc.leaves.util.MathUtils; + +import javax.annotation.Nullable; +import java.io.BufferedReader; @@ -1502,7 +1494,7 @@ index 0000000000000000000000000000000000000000..a2dbfe898adf918a52ae639b0e0985e7 + @Override + public void send(@NotNull Packet packet, @Nullable PacketSendListener callbacks, boolean flush) { + } -+ }, bot, CommonListenerCookie.createInitial(profile)); ++ }, bot, CommonListenerCookie.createInitial(profile, false)); + bot.isRealPlayer = true; + bot.createState = state; + @@ -1534,11 +1526,11 @@ index 0000000000000000000000000000000000000000..a2dbfe898adf918a52ae639b0e0985e7 + return false; + } + -+ if (top.leavesmc.leaves.LeavesConfig.unableFakeplayerNames.contains(name)) { ++ if (org.leavesmc.leaves.LeavesConfig.unableFakeplayerNames.contains(name)) { + return false; + } + -+ return ServerBot.getBots().size() < top.leavesmc.leaves.LeavesConfig.fakeplayerLimit; ++ return ServerBot.getBots().size() < org.leavesmc.leaves.LeavesConfig.fakeplayerLimit; + } + + public void renderAll() { @@ -2055,21 +2047,23 @@ index 0000000000000000000000000000000000000000..a2dbfe898adf918a52ae639b0e0985e7 + } + } +} -diff --git a/src/main/java/top/leavesmc/leaves/bot/ServerBotGameMode.java b/src/main/java/top/leavesmc/leaves/bot/ServerBotGameMode.java +diff --git a/src/main/java/org/leavesmc/leaves/bot/ServerBotGameMode.java b/src/main/java/org/leavesmc/leaves/bot/ServerBotGameMode.java new file mode 100644 -index 0000000000000000000000000000000000000000..289894276faefac6c8410f5c78b5dafc15df5b4f +index 0000000000000000000000000000000000000000..d626ac47af400d01993c358fa5a93671dce9abe9 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/bot/ServerBotGameMode.java -@@ -0,0 +1,130 @@ -+package top.leavesmc.leaves.bot; ++++ b/src/main/java/org/leavesmc/leaves/bot/ServerBotGameMode.java +@@ -0,0 +1,139 @@ ++package org.leavesmc.leaves.bot; + +import net.kyori.adventure.text.Component; ++import net.minecraft.advancements.CriteriaTriggers; +import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.server.level.ServerPlayerGameMode; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; ++import net.minecraft.world.ItemInteractionResult; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.GameType; @@ -2173,10 +2167,17 @@ index 0000000000000000000000000000000000000000..289894276faefac6c8410f5c78b5dafc + boolean flag1 = player.isSecondaryUseActive() && flag; + + if (!flag1) { -+ enuminteractionresult = iblockdata.use(world, player, hand, hitResult); ++ ItemInteractionResult iteminteractionresult = iblockdata.useItemOn(player.getItemInHand(hand), world, player, hand, hitResult); + -+ if (enuminteractionresult.consumesAction()) { -+ return enuminteractionresult; ++ if (iteminteractionresult.consumesAction()) { ++ return iteminteractionresult.result(); ++ } ++ ++ if (iteminteractionresult == ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION && hand == InteractionHand.MAIN_HAND) { ++ enuminteractionresult = iblockdata.useWithoutItem(world, player, hitResult); ++ if (enuminteractionresult.consumesAction()) { ++ return enuminteractionresult; ++ } + } + } + @@ -2191,17 +2192,17 @@ index 0000000000000000000000000000000000000000..289894276faefac6c8410f5c78b5dafc + public void setLevel(@NotNull ServerLevel world) { + } +} -diff --git a/src/main/java/top/leavesmc/leaves/bot/agent/Actions.java b/src/main/java/top/leavesmc/leaves/bot/agent/Actions.java +diff --git a/src/main/java/org/leavesmc/leaves/bot/agent/Actions.java b/src/main/java/org/leavesmc/leaves/bot/agent/Actions.java new file mode 100644 -index 0000000000000000000000000000000000000000..a7e98848e400641077ac567d9ea9a58c32123c98 +index 0000000000000000000000000000000000000000..92fc24b187979d5db4b2a316f066ac01a8890879 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/bot/agent/Actions.java ++++ b/src/main/java/org/leavesmc/leaves/bot/agent/Actions.java @@ -0,0 +1,66 @@ -+package top.leavesmc.leaves.bot.agent; ++package org.leavesmc.leaves.bot.agent; + +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; -+import top.leavesmc.leaves.bot.agent.actions.*; ++import org.leavesmc.leaves.bot.agent.actions.*; + +import java.util.Collection; +import java.util.HashMap; @@ -2263,19 +2264,19 @@ index 0000000000000000000000000000000000000000..a7e98848e400641077ac567d9ea9a58c + return actions.get(name); + } +} -diff --git a/src/main/java/top/leavesmc/leaves/bot/agent/BotAction.java b/src/main/java/top/leavesmc/leaves/bot/agent/BotAction.java +diff --git a/src/main/java/org/leavesmc/leaves/bot/agent/BotAction.java b/src/main/java/org/leavesmc/leaves/bot/agent/BotAction.java new file mode 100644 -index 0000000000000000000000000000000000000000..20ba4904219d015903cd3a5b2e1693eaba6088d8 +index 0000000000000000000000000000000000000000..9abcb8852ac031abaa991881a7cd6b33bc523b26 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/bot/agent/BotAction.java ++++ b/src/main/java/org/leavesmc/leaves/bot/agent/BotAction.java @@ -0,0 +1,93 @@ -+package top.leavesmc.leaves.bot.agent; ++package org.leavesmc.leaves.bot.agent; + +import net.minecraft.server.level.ServerPlayer; +import org.jetbrains.annotations.NotNull; -+import top.leavesmc.leaves.bot.ServerBot; -+import top.leavesmc.leaves.command.CommandArgument; -+import top.leavesmc.leaves.command.CommandArgumentResult; ++import org.leavesmc.leaves.bot.ServerBot; ++import org.leavesmc.leaves.command.CommandArgument; ++import org.leavesmc.leaves.command.CommandArgumentResult; + +import java.util.List; + @@ -2362,22 +2363,22 @@ index 0000000000000000000000000000000000000000..20ba4904219d015903cd3a5b2e1693ea + + public abstract boolean doTick(@NotNull ServerBot bot); +} -diff --git a/src/main/java/top/leavesmc/leaves/bot/agent/actions/AttackAction.java b/src/main/java/top/leavesmc/leaves/bot/agent/actions/AttackAction.java +diff --git a/src/main/java/org/leavesmc/leaves/bot/agent/actions/AttackAction.java b/src/main/java/org/leavesmc/leaves/bot/agent/actions/AttackAction.java new file mode 100644 -index 0000000000000000000000000000000000000000..609605b21cfe5af8876f76ea4922e379c5dd166e +index 0000000000000000000000000000000000000000..584ebd1e369467440009fe12518609a713102717 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/bot/agent/actions/AttackAction.java ++++ b/src/main/java/org/leavesmc/leaves/bot/agent/actions/AttackAction.java @@ -0,0 +1,36 @@ -+package top.leavesmc.leaves.bot.agent.actions; ++package org.leavesmc.leaves.bot.agent.actions; + +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.phys.EntityHitResult; +import org.jetbrains.annotations.NotNull; -+import top.leavesmc.leaves.bot.ServerBot; -+import top.leavesmc.leaves.bot.agent.BotAction; -+import top.leavesmc.leaves.command.CommandArgument; -+import top.leavesmc.leaves.command.CommandArgumentResult; -+import top.leavesmc.leaves.command.CommandArgumentType; ++import org.leavesmc.leaves.bot.ServerBot; ++import org.leavesmc.leaves.bot.agent.BotAction; ++import org.leavesmc.leaves.command.CommandArgument; ++import org.leavesmc.leaves.command.CommandArgumentResult; ++import org.leavesmc.leaves.command.CommandArgumentType; + +import java.util.List; + @@ -2404,23 +2405,23 @@ index 0000000000000000000000000000000000000000..609605b21cfe5af8876f76ea4922e379 + return false; + } +} -diff --git a/src/main/java/top/leavesmc/leaves/bot/agent/actions/AttackSelfAction.java b/src/main/java/top/leavesmc/leaves/bot/agent/actions/AttackSelfAction.java +diff --git a/src/main/java/org/leavesmc/leaves/bot/agent/actions/AttackSelfAction.java b/src/main/java/org/leavesmc/leaves/bot/agent/actions/AttackSelfAction.java new file mode 100644 -index 0000000000000000000000000000000000000000..8543709b07ea4e598764d20b3ea4a6409496c890 +index 0000000000000000000000000000000000000000..193446c68f4617f0542817f13df3bce0fa667c61 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/bot/agent/actions/AttackSelfAction.java ++++ b/src/main/java/org/leavesmc/leaves/bot/agent/actions/AttackSelfAction.java @@ -0,0 +1,39 @@ -+package top.leavesmc.leaves.bot.agent.actions; ++package org.leavesmc.leaves.bot.agent.actions; + +import com.google.common.base.Predicates; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.Entity; +import org.jetbrains.annotations.NotNull; -+import top.leavesmc.leaves.bot.ServerBot; -+import top.leavesmc.leaves.bot.agent.BotAction; -+import top.leavesmc.leaves.command.CommandArgument; -+import top.leavesmc.leaves.command.CommandArgumentResult; -+import top.leavesmc.leaves.command.CommandArgumentType; ++import org.leavesmc.leaves.bot.ServerBot; ++import org.leavesmc.leaves.bot.agent.BotAction; ++import org.leavesmc.leaves.command.CommandArgument; ++import org.leavesmc.leaves.command.CommandArgumentResult; ++import org.leavesmc.leaves.command.CommandArgumentType; + +import java.util.List; + @@ -2449,13 +2450,13 @@ index 0000000000000000000000000000000000000000..8543709b07ea4e598764d20b3ea4a640 + return false; + } +} -diff --git a/src/main/java/top/leavesmc/leaves/bot/agent/actions/BreakBlockAction.java b/src/main/java/top/leavesmc/leaves/bot/agent/actions/BreakBlockAction.java +diff --git a/src/main/java/org/leavesmc/leaves/bot/agent/actions/BreakBlockAction.java b/src/main/java/org/leavesmc/leaves/bot/agent/actions/BreakBlockAction.java new file mode 100644 -index 0000000000000000000000000000000000000000..12af5b8f2bb1a2c8718e3e26e17189609bb5268f +index 0000000000000000000000000000000000000000..adcce8f8c39b0a1e445f5552ce74436053b604e7 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/bot/agent/actions/BreakBlockAction.java ++++ b/src/main/java/org/leavesmc/leaves/bot/agent/actions/BreakBlockAction.java @@ -0,0 +1,105 @@ -+package top.leavesmc.leaves.bot.agent.actions; ++package org.leavesmc.leaves.bot.agent.actions; + +import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerPlayer; @@ -2464,11 +2465,11 @@ index 0000000000000000000000000000000000000000..12af5b8f2bb1a2c8718e3e26e1718960 +import org.bukkit.block.Block; +import org.bukkit.craftbukkit.block.CraftBlock; +import org.jetbrains.annotations.NotNull; -+import top.leavesmc.leaves.bot.ServerBot; -+import top.leavesmc.leaves.bot.agent.BotAction; -+import top.leavesmc.leaves.command.CommandArgument; -+import top.leavesmc.leaves.command.CommandArgumentResult; -+import top.leavesmc.leaves.command.CommandArgumentType; ++import org.leavesmc.leaves.bot.ServerBot; ++import org.leavesmc.leaves.bot.agent.BotAction; ++import org.leavesmc.leaves.command.CommandArgument; ++import org.leavesmc.leaves.command.CommandArgumentResult; ++import org.leavesmc.leaves.command.CommandArgumentType; + +import java.util.List; + @@ -2560,22 +2561,22 @@ index 0000000000000000000000000000000000000000..12af5b8f2bb1a2c8718e3e26e1718960 + return f; + } +} -diff --git a/src/main/java/top/leavesmc/leaves/bot/agent/actions/CraftCustomBotAction.java b/src/main/java/top/leavesmc/leaves/bot/agent/actions/CraftCustomBotAction.java +diff --git a/src/main/java/org/leavesmc/leaves/bot/agent/actions/CraftCustomBotAction.java b/src/main/java/org/leavesmc/leaves/bot/agent/actions/CraftCustomBotAction.java new file mode 100644 -index 0000000000000000000000000000000000000000..89a361249179d7a0a84768e715ced05aafc13272 +index 0000000000000000000000000000000000000000..f9b48f38a9b530125849f30eeab497895da77a21 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/bot/agent/actions/CraftCustomBotAction.java ++++ b/src/main/java/org/leavesmc/leaves/bot/agent/actions/CraftCustomBotAction.java @@ -0,0 +1,48 @@ -+package top.leavesmc.leaves.bot.agent.actions; ++package org.leavesmc.leaves.bot.agent.actions; + +import net.minecraft.server.level.ServerPlayer; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; -+import top.leavesmc.leaves.bot.ServerBot; -+import top.leavesmc.leaves.bot.agent.BotAction; -+import top.leavesmc.leaves.command.CommandArgument; -+import top.leavesmc.leaves.command.CommandArgumentResult; -+import top.leavesmc.leaves.entity.botaction.CustomBotAction; ++import org.leavesmc.leaves.bot.ServerBot; ++import org.leavesmc.leaves.bot.agent.BotAction; ++import org.leavesmc.leaves.command.CommandArgument; ++import org.leavesmc.leaves.command.CommandArgumentResult; ++import org.leavesmc.leaves.entity.botaction.CustomBotAction; + +public class CraftCustomBotAction extends BotAction { + @@ -2614,20 +2615,20 @@ index 0000000000000000000000000000000000000000..89a361249179d7a0a84768e715ced05a + return realAction.doTick(bot.getBukkitPlayer()); + } +} -diff --git a/src/main/java/top/leavesmc/leaves/bot/agent/actions/DropAction.java b/src/main/java/top/leavesmc/leaves/bot/agent/actions/DropAction.java +diff --git a/src/main/java/org/leavesmc/leaves/bot/agent/actions/DropAction.java b/src/main/java/org/leavesmc/leaves/bot/agent/actions/DropAction.java new file mode 100644 -index 0000000000000000000000000000000000000000..cc72960b8490a72aca5db3e834c71f97e3742f7d +index 0000000000000000000000000000000000000000..c534e5f5a51021a5f08bae2e4bce55fcedf93cf0 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/bot/agent/actions/DropAction.java ++++ b/src/main/java/org/leavesmc/leaves/bot/agent/actions/DropAction.java @@ -0,0 +1,26 @@ -+package top.leavesmc.leaves.bot.agent.actions; ++package org.leavesmc.leaves.bot.agent.actions; + +import net.minecraft.server.level.ServerPlayer; +import org.jetbrains.annotations.NotNull; -+import top.leavesmc.leaves.bot.ServerBot; -+import top.leavesmc.leaves.bot.agent.BotAction; -+import top.leavesmc.leaves.command.CommandArgument; -+import top.leavesmc.leaves.command.CommandArgumentResult; ++import org.leavesmc.leaves.bot.ServerBot; ++import org.leavesmc.leaves.bot.agent.BotAction; ++import org.leavesmc.leaves.command.CommandArgument; ++import org.leavesmc.leaves.command.CommandArgumentResult; + +public class DropAction extends BotAction { + @@ -2646,13 +2647,13 @@ index 0000000000000000000000000000000000000000..cc72960b8490a72aca5db3e834c71f97 + return true; + } +} -diff --git a/src/main/java/top/leavesmc/leaves/bot/agent/actions/FishAction.java b/src/main/java/top/leavesmc/leaves/bot/agent/actions/FishAction.java +diff --git a/src/main/java/org/leavesmc/leaves/bot/agent/actions/FishAction.java b/src/main/java/org/leavesmc/leaves/bot/agent/actions/FishAction.java new file mode 100644 -index 0000000000000000000000000000000000000000..d92ea54770bce73c2f10f1ebcb0dff5b9532e0e9 +index 0000000000000000000000000000000000000000..18b2f81f9edcfc2f30dde82c832a899b84c8cd3a --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/bot/agent/actions/FishAction.java ++++ b/src/main/java/org/leavesmc/leaves/bot/agent/actions/FishAction.java @@ -0,0 +1,70 @@ -+package top.leavesmc.leaves.bot.agent.actions; ++package org.leavesmc.leaves.bot.agent.actions; + +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.InteractionHand; @@ -2660,11 +2661,11 @@ index 0000000000000000000000000000000000000000..d92ea54770bce73c2f10f1ebcb0dff5b +import net.minecraft.world.item.FishingRodItem; +import net.minecraft.world.item.ItemStack; +import org.jetbrains.annotations.NotNull; -+import top.leavesmc.leaves.bot.ServerBot; -+import top.leavesmc.leaves.bot.agent.BotAction; -+import top.leavesmc.leaves.command.CommandArgument; -+import top.leavesmc.leaves.command.CommandArgumentResult; -+import top.leavesmc.leaves.command.CommandArgumentType; ++import org.leavesmc.leaves.bot.ServerBot; ++import org.leavesmc.leaves.bot.agent.BotAction; ++import org.leavesmc.leaves.command.CommandArgument; ++import org.leavesmc.leaves.command.CommandArgumentResult; ++import org.leavesmc.leaves.command.CommandArgumentType; + +import java.util.List; + @@ -2722,21 +2723,21 @@ index 0000000000000000000000000000000000000000..d92ea54770bce73c2f10f1ebcb0dff5b + return false; + } +} -diff --git a/src/main/java/top/leavesmc/leaves/bot/agent/actions/JumpAction.java b/src/main/java/top/leavesmc/leaves/bot/agent/actions/JumpAction.java +diff --git a/src/main/java/org/leavesmc/leaves/bot/agent/actions/JumpAction.java b/src/main/java/org/leavesmc/leaves/bot/agent/actions/JumpAction.java new file mode 100644 -index 0000000000000000000000000000000000000000..d99f667992e45e85c0fe0bd74682d563fe1315eb +index 0000000000000000000000000000000000000000..de4c2aaf8f2f212e346ed41a514c803aa4fe7ac6 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/bot/agent/actions/JumpAction.java ++++ b/src/main/java/org/leavesmc/leaves/bot/agent/actions/JumpAction.java @@ -0,0 +1,35 @@ -+package top.leavesmc.leaves.bot.agent.actions; ++package org.leavesmc.leaves.bot.agent.actions; + +import net.minecraft.server.level.ServerPlayer; +import org.jetbrains.annotations.NotNull; -+import top.leavesmc.leaves.bot.ServerBot; -+import top.leavesmc.leaves.bot.agent.BotAction; -+import top.leavesmc.leaves.command.CommandArgument; -+import top.leavesmc.leaves.command.CommandArgumentResult; -+import top.leavesmc.leaves.command.CommandArgumentType; ++import org.leavesmc.leaves.bot.ServerBot; ++import org.leavesmc.leaves.bot.agent.BotAction; ++import org.leavesmc.leaves.command.CommandArgument; ++import org.leavesmc.leaves.command.CommandArgumentResult; ++import org.leavesmc.leaves.command.CommandArgumentType; + +import java.util.List; + @@ -2763,22 +2764,22 @@ index 0000000000000000000000000000000000000000..d99f667992e45e85c0fe0bd74682d563 + } + } +} -diff --git a/src/main/java/top/leavesmc/leaves/bot/agent/actions/LookAction.java b/src/main/java/top/leavesmc/leaves/bot/agent/actions/LookAction.java +diff --git a/src/main/java/org/leavesmc/leaves/bot/agent/actions/LookAction.java b/src/main/java/org/leavesmc/leaves/bot/agent/actions/LookAction.java new file mode 100644 -index 0000000000000000000000000000000000000000..5432e61c156a1a6d49dcf4b24e3bcfcc6c1aa7bb +index 0000000000000000000000000000000000000000..bd8a62fb4385a00a7f532835f7d75e47ae45405b --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/bot/agent/actions/LookAction.java ++++ b/src/main/java/org/leavesmc/leaves/bot/agent/actions/LookAction.java @@ -0,0 +1,49 @@ -+package top.leavesmc.leaves.bot.agent.actions; ++package org.leavesmc.leaves.bot.agent.actions; + +import net.minecraft.server.level.ServerPlayer; +import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; -+import top.leavesmc.leaves.bot.ServerBot; -+import top.leavesmc.leaves.bot.agent.BotAction; -+import top.leavesmc.leaves.command.CommandArgument; -+import top.leavesmc.leaves.command.CommandArgumentResult; -+import top.leavesmc.leaves.command.CommandArgumentType; ++import org.leavesmc.leaves.bot.ServerBot; ++import org.leavesmc.leaves.bot.agent.BotAction; ++import org.leavesmc.leaves.command.CommandArgument; ++import org.leavesmc.leaves.command.CommandArgumentResult; ++import org.leavesmc.leaves.command.CommandArgumentType; + +import java.util.List; + @@ -2818,20 +2819,20 @@ index 0000000000000000000000000000000000000000..5432e61c156a1a6d49dcf4b24e3bcfcc + return true; + } +} -diff --git a/src/main/java/top/leavesmc/leaves/bot/agent/actions/RotateAction.java b/src/main/java/top/leavesmc/leaves/bot/agent/actions/RotateAction.java +diff --git a/src/main/java/org/leavesmc/leaves/bot/agent/actions/RotateAction.java b/src/main/java/org/leavesmc/leaves/bot/agent/actions/RotateAction.java new file mode 100644 -index 0000000000000000000000000000000000000000..1e5be54b33467591924cb2400639fb593dc50ec6 +index 0000000000000000000000000000000000000000..fe872cad0cbf9ede825e0561cdb4ecb24df32821 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/bot/agent/actions/RotateAction.java ++++ b/src/main/java/org/leavesmc/leaves/bot/agent/actions/RotateAction.java @@ -0,0 +1,33 @@ -+package top.leavesmc.leaves.bot.agent.actions; ++package org.leavesmc.leaves.bot.agent.actions; + +import net.minecraft.server.level.ServerPlayer; +import org.jetbrains.annotations.NotNull; -+import top.leavesmc.leaves.bot.ServerBot; -+import top.leavesmc.leaves.bot.agent.BotAction; -+import top.leavesmc.leaves.command.CommandArgument; -+import top.leavesmc.leaves.command.CommandArgumentResult; ++import org.leavesmc.leaves.bot.ServerBot; ++import org.leavesmc.leaves.bot.agent.BotAction; ++import org.leavesmc.leaves.command.CommandArgument; ++import org.leavesmc.leaves.command.CommandArgumentResult; + +public class RotateAction extends BotAction { + @@ -2857,21 +2858,21 @@ index 0000000000000000000000000000000000000000..1e5be54b33467591924cb2400639fb59 + return true; + } +} -diff --git a/src/main/java/top/leavesmc/leaves/bot/agent/actions/SneakAction.java b/src/main/java/top/leavesmc/leaves/bot/agent/actions/SneakAction.java +diff --git a/src/main/java/org/leavesmc/leaves/bot/agent/actions/SneakAction.java b/src/main/java/org/leavesmc/leaves/bot/agent/actions/SneakAction.java new file mode 100644 -index 0000000000000000000000000000000000000000..18e276c0252fa867b2cdc9770e3a7ed0b9cc63de +index 0000000000000000000000000000000000000000..9b4406bc0b418abc6a253e047c504b4ad15f059a --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/bot/agent/actions/SneakAction.java ++++ b/src/main/java/org/leavesmc/leaves/bot/agent/actions/SneakAction.java @@ -0,0 +1,27 @@ -+package top.leavesmc.leaves.bot.agent.actions; ++package org.leavesmc.leaves.bot.agent.actions; + +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.Pose; +import org.jetbrains.annotations.NotNull; -+import top.leavesmc.leaves.bot.ServerBot; -+import top.leavesmc.leaves.bot.agent.BotAction; -+import top.leavesmc.leaves.command.CommandArgument; -+import top.leavesmc.leaves.command.CommandArgumentResult; ++import org.leavesmc.leaves.bot.ServerBot; ++import org.leavesmc.leaves.bot.agent.BotAction; ++import org.leavesmc.leaves.command.CommandArgument; ++import org.leavesmc.leaves.command.CommandArgumentResult; + +public class SneakAction extends BotAction { + @@ -2890,20 +2891,20 @@ index 0000000000000000000000000000000000000000..18e276c0252fa867b2cdc9770e3a7ed0 + return true; + } +} -diff --git a/src/main/java/top/leavesmc/leaves/bot/agent/actions/StopAction.java b/src/main/java/top/leavesmc/leaves/bot/agent/actions/StopAction.java +diff --git a/src/main/java/org/leavesmc/leaves/bot/agent/actions/StopAction.java b/src/main/java/org/leavesmc/leaves/bot/agent/actions/StopAction.java new file mode 100644 -index 0000000000000000000000000000000000000000..36d199269afc46783b0815e3887842cd82b6e813 +index 0000000000000000000000000000000000000000..bd02fe0e6b1f1b6048d56ab9c9379808dcf227c4 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/bot/agent/actions/StopAction.java ++++ b/src/main/java/org/leavesmc/leaves/bot/agent/actions/StopAction.java @@ -0,0 +1,26 @@ -+package top.leavesmc.leaves.bot.agent.actions; ++package org.leavesmc.leaves.bot.agent.actions; + +import net.minecraft.server.level.ServerPlayer; +import org.jetbrains.annotations.NotNull; -+import top.leavesmc.leaves.bot.ServerBot; -+import top.leavesmc.leaves.bot.agent.BotAction; -+import top.leavesmc.leaves.command.CommandArgument; -+import top.leavesmc.leaves.command.CommandArgumentResult; ++import org.leavesmc.leaves.bot.ServerBot; ++import org.leavesmc.leaves.bot.agent.BotAction; ++import org.leavesmc.leaves.command.CommandArgument; ++import org.leavesmc.leaves.command.CommandArgumentResult; + +public class StopAction extends BotAction { + @@ -2922,20 +2923,20 @@ index 0000000000000000000000000000000000000000..36d199269afc46783b0815e3887842cd + return true; + } +} -diff --git a/src/main/java/top/leavesmc/leaves/bot/agent/actions/SwimAction.java b/src/main/java/top/leavesmc/leaves/bot/agent/actions/SwimAction.java +diff --git a/src/main/java/org/leavesmc/leaves/bot/agent/actions/SwimAction.java b/src/main/java/org/leavesmc/leaves/bot/agent/actions/SwimAction.java new file mode 100644 -index 0000000000000000000000000000000000000000..58c815bd0ebfd455fcf4903ee5ced6b81be00982 +index 0000000000000000000000000000000000000000..c91ca987eb5922b8dbcd271deb33f80be5e1a9af --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/bot/agent/actions/SwimAction.java ++++ b/src/main/java/org/leavesmc/leaves/bot/agent/actions/SwimAction.java @@ -0,0 +1,26 @@ -+package top.leavesmc.leaves.bot.agent.actions; ++package org.leavesmc.leaves.bot.agent.actions; + +import net.minecraft.server.level.ServerPlayer; +import org.jetbrains.annotations.NotNull; -+import top.leavesmc.leaves.bot.ServerBot; -+import top.leavesmc.leaves.bot.agent.BotAction; -+import top.leavesmc.leaves.command.CommandArgument; -+import top.leavesmc.leaves.command.CommandArgumentResult; ++import org.leavesmc.leaves.bot.ServerBot; ++import org.leavesmc.leaves.bot.agent.BotAction; ++import org.leavesmc.leaves.command.CommandArgument; ++import org.leavesmc.leaves.command.CommandArgumentResult; + +public class SwimAction extends BotAction { + @@ -2954,22 +2955,22 @@ index 0000000000000000000000000000000000000000..58c815bd0ebfd455fcf4903ee5ced6b8 + return true; + } +} -diff --git a/src/main/java/top/leavesmc/leaves/bot/agent/actions/UseItemAction.java b/src/main/java/top/leavesmc/leaves/bot/agent/actions/UseItemAction.java +diff --git a/src/main/java/org/leavesmc/leaves/bot/agent/actions/UseItemAction.java b/src/main/java/org/leavesmc/leaves/bot/agent/actions/UseItemAction.java new file mode 100644 -index 0000000000000000000000000000000000000000..eb81cdc139814d3374f97ed368c4a59676ca25e5 +index 0000000000000000000000000000000000000000..acc28becb88b691ecfb8cd15d86031086cba3ba3 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/bot/agent/actions/UseItemAction.java ++++ b/src/main/java/org/leavesmc/leaves/bot/agent/actions/UseItemAction.java @@ -0,0 +1,33 @@ -+package top.leavesmc.leaves.bot.agent.actions; ++package org.leavesmc.leaves.bot.agent.actions; + +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.InteractionHand; +import org.jetbrains.annotations.NotNull; -+import top.leavesmc.leaves.bot.ServerBot; -+import top.leavesmc.leaves.bot.agent.BotAction; -+import top.leavesmc.leaves.command.CommandArgument; -+import top.leavesmc.leaves.command.CommandArgumentResult; -+import top.leavesmc.leaves.command.CommandArgumentType; ++import org.leavesmc.leaves.bot.ServerBot; ++import org.leavesmc.leaves.bot.agent.BotAction; ++import org.leavesmc.leaves.command.CommandArgument; ++import org.leavesmc.leaves.command.CommandArgumentResult; ++import org.leavesmc.leaves.command.CommandArgumentType; + +import java.util.List; + @@ -2993,22 +2994,22 @@ index 0000000000000000000000000000000000000000..eb81cdc139814d3374f97ed368c4a596 + return bot.gameMode.useItem(bot, bot.level(), bot.getItemInHand(InteractionHand.MAIN_HAND), InteractionHand.MAIN_HAND).consumesAction(); + } +} -diff --git a/src/main/java/top/leavesmc/leaves/bot/agent/actions/UseItemOffHandAction.java b/src/main/java/top/leavesmc/leaves/bot/agent/actions/UseItemOffHandAction.java +diff --git a/src/main/java/org/leavesmc/leaves/bot/agent/actions/UseItemOffHandAction.java b/src/main/java/org/leavesmc/leaves/bot/agent/actions/UseItemOffHandAction.java new file mode 100644 -index 0000000000000000000000000000000000000000..00c85bae0a278d3aad793635aa80859d94101f49 +index 0000000000000000000000000000000000000000..475bf440d40ac35720b01da18440cf0d35166a5c --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/bot/agent/actions/UseItemOffHandAction.java ++++ b/src/main/java/org/leavesmc/leaves/bot/agent/actions/UseItemOffHandAction.java @@ -0,0 +1,33 @@ -+package top.leavesmc.leaves.bot.agent.actions; ++package org.leavesmc.leaves.bot.agent.actions; + +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.InteractionHand; +import org.jetbrains.annotations.NotNull; -+import top.leavesmc.leaves.bot.ServerBot; -+import top.leavesmc.leaves.bot.agent.BotAction; -+import top.leavesmc.leaves.command.CommandArgument; -+import top.leavesmc.leaves.command.CommandArgumentResult; -+import top.leavesmc.leaves.command.CommandArgumentType; ++import org.leavesmc.leaves.bot.ServerBot; ++import org.leavesmc.leaves.bot.agent.BotAction; ++import org.leavesmc.leaves.command.CommandArgument; ++import org.leavesmc.leaves.command.CommandArgumentResult; ++import org.leavesmc.leaves.command.CommandArgumentType; + +import java.util.List; + @@ -3032,13 +3033,13 @@ index 0000000000000000000000000000000000000000..00c85bae0a278d3aad793635aa80859d + return bot.gameMode.useItem(bot, bot.level(), bot.getItemInHand(InteractionHand.OFF_HAND), InteractionHand.OFF_HAND).consumesAction(); + } +} -diff --git a/src/main/java/top/leavesmc/leaves/bot/agent/actions/UseItemOnAction.java b/src/main/java/top/leavesmc/leaves/bot/agent/actions/UseItemOnAction.java +diff --git a/src/main/java/org/leavesmc/leaves/bot/agent/actions/UseItemOnAction.java b/src/main/java/org/leavesmc/leaves/bot/agent/actions/UseItemOnAction.java new file mode 100644 -index 0000000000000000000000000000000000000000..9731e1c3717c344d3a739e90f28a5d24243f7661 +index 0000000000000000000000000000000000000000..fe8c4ba7aff74dc297bdf4e271a2d7f1229c357d --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/bot/agent/actions/UseItemOnAction.java ++++ b/src/main/java/org/leavesmc/leaves/bot/agent/actions/UseItemOnAction.java @@ -0,0 +1,56 @@ -+package top.leavesmc.leaves.bot.agent.actions; ++package org.leavesmc.leaves.bot.agent.actions; + +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.InteractionHand; @@ -3052,11 +3053,11 @@ index 0000000000000000000000000000000000000000..9731e1c3717c344d3a739e90f28a5d24 +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.scheduler.CraftScheduler; +import org.jetbrains.annotations.NotNull; -+import top.leavesmc.leaves.bot.ServerBot; -+import top.leavesmc.leaves.bot.agent.BotAction; -+import top.leavesmc.leaves.command.CommandArgument; -+import top.leavesmc.leaves.command.CommandArgumentResult; -+import top.leavesmc.leaves.command.CommandArgumentType; ++import org.leavesmc.leaves.bot.ServerBot; ++import org.leavesmc.leaves.bot.agent.BotAction; ++import org.leavesmc.leaves.command.CommandArgument; ++import org.leavesmc.leaves.command.CommandArgumentResult; ++import org.leavesmc.leaves.command.CommandArgumentType; + +import java.util.List; + @@ -3094,13 +3095,13 @@ index 0000000000000000000000000000000000000000..9731e1c3717c344d3a739e90f28a5d24 + return false; + } +} -diff --git a/src/main/java/top/leavesmc/leaves/bot/agent/actions/UseItemOnOffhandAction.java b/src/main/java/top/leavesmc/leaves/bot/agent/actions/UseItemOnOffhandAction.java +diff --git a/src/main/java/org/leavesmc/leaves/bot/agent/actions/UseItemOnOffhandAction.java b/src/main/java/org/leavesmc/leaves/bot/agent/actions/UseItemOnOffhandAction.java new file mode 100644 -index 0000000000000000000000000000000000000000..f3104e0a4ee367ac4af0e093bcbbff2c997fc734 +index 0000000000000000000000000000000000000000..a69ede01e5e5df31a144f98e9871183793f5f377 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/bot/agent/actions/UseItemOnOffhandAction.java ++++ b/src/main/java/org/leavesmc/leaves/bot/agent/actions/UseItemOnOffhandAction.java @@ -0,0 +1,56 @@ -+package top.leavesmc.leaves.bot.agent.actions; ++package org.leavesmc.leaves.bot.agent.actions; + +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.InteractionHand; @@ -3114,11 +3115,11 @@ index 0000000000000000000000000000000000000000..f3104e0a4ee367ac4af0e093bcbbff2c +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.scheduler.CraftScheduler; +import org.jetbrains.annotations.NotNull; -+import top.leavesmc.leaves.bot.ServerBot; -+import top.leavesmc.leaves.bot.agent.BotAction; -+import top.leavesmc.leaves.command.CommandArgument; -+import top.leavesmc.leaves.command.CommandArgumentResult; -+import top.leavesmc.leaves.command.CommandArgumentType; ++import org.leavesmc.leaves.bot.ServerBot; ++import org.leavesmc.leaves.bot.agent.BotAction; ++import org.leavesmc.leaves.command.CommandArgument; ++import org.leavesmc.leaves.command.CommandArgumentResult; ++import org.leavesmc.leaves.command.CommandArgumentType; + +import java.util.List; + @@ -3156,23 +3157,23 @@ index 0000000000000000000000000000000000000000..f3104e0a4ee367ac4af0e093bcbbff2c + return false; + } +} -diff --git a/src/main/java/top/leavesmc/leaves/bot/agent/actions/UseItemToAction.java b/src/main/java/top/leavesmc/leaves/bot/agent/actions/UseItemToAction.java +diff --git a/src/main/java/org/leavesmc/leaves/bot/agent/actions/UseItemToAction.java b/src/main/java/org/leavesmc/leaves/bot/agent/actions/UseItemToAction.java new file mode 100644 -index 0000000000000000000000000000000000000000..f9a2da353114cfb8a5fd70671c0baefd9aaac627 +index 0000000000000000000000000000000000000000..e961c89510a676a04305f0aa2749620a96054d67 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/bot/agent/actions/UseItemToAction.java ++++ b/src/main/java/org/leavesmc/leaves/bot/agent/actions/UseItemToAction.java @@ -0,0 +1,38 @@ -+package top.leavesmc.leaves.bot.agent.actions; ++package org.leavesmc.leaves.bot.agent.actions; + +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.phys.EntityHitResult; +import org.jetbrains.annotations.NotNull; -+import top.leavesmc.leaves.bot.ServerBot; -+import top.leavesmc.leaves.bot.agent.BotAction; -+import top.leavesmc.leaves.command.CommandArgument; -+import top.leavesmc.leaves.command.CommandArgumentResult; -+import top.leavesmc.leaves.command.CommandArgumentType; ++import org.leavesmc.leaves.bot.ServerBot; ++import org.leavesmc.leaves.bot.agent.BotAction; ++import org.leavesmc.leaves.command.CommandArgument; ++import org.leavesmc.leaves.command.CommandArgumentResult; ++import org.leavesmc.leaves.command.CommandArgumentType; + +import java.util.List; + @@ -3200,23 +3201,23 @@ index 0000000000000000000000000000000000000000..f9a2da353114cfb8a5fd70671c0baefd + return false; + } +} -diff --git a/src/main/java/top/leavesmc/leaves/bot/agent/actions/UseItemToOffhandAction.java b/src/main/java/top/leavesmc/leaves/bot/agent/actions/UseItemToOffhandAction.java +diff --git a/src/main/java/org/leavesmc/leaves/bot/agent/actions/UseItemToOffhandAction.java b/src/main/java/org/leavesmc/leaves/bot/agent/actions/UseItemToOffhandAction.java new file mode 100644 -index 0000000000000000000000000000000000000000..1398b7d07e5c510fffce81dc2d103f9686ccd7df +index 0000000000000000000000000000000000000000..46c8dad4a6205e3e460b82f8ce5617f832381806 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/bot/agent/actions/UseItemToOffhandAction.java ++++ b/src/main/java/org/leavesmc/leaves/bot/agent/actions/UseItemToOffhandAction.java @@ -0,0 +1,38 @@ -+package top.leavesmc.leaves.bot.agent.actions; ++package org.leavesmc.leaves.bot.agent.actions; + +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.phys.EntityHitResult; +import org.jetbrains.annotations.NotNull; -+import top.leavesmc.leaves.bot.ServerBot; -+import top.leavesmc.leaves.bot.agent.BotAction; -+import top.leavesmc.leaves.command.CommandArgument; -+import top.leavesmc.leaves.command.CommandArgumentResult; -+import top.leavesmc.leaves.command.CommandArgumentType; ++import org.leavesmc.leaves.bot.ServerBot; ++import org.leavesmc.leaves.bot.agent.BotAction; ++import org.leavesmc.leaves.command.CommandArgument; ++import org.leavesmc.leaves.command.CommandArgumentResult; ++import org.leavesmc.leaves.command.CommandArgumentType; + +import java.util.List; + @@ -3244,10 +3245,10 @@ index 0000000000000000000000000000000000000000..1398b7d07e5c510fffce81dc2d103f96 + return false; + } +} -diff --git a/src/main/java/top/leavesmc/leaves/command/CommandArgument.java b/src/main/java/top/leavesmc/leaves/command/CommandArgument.java -index eadc6d168fb13299348b0c275ae352ee2f1e1ea2..134c6d26acc612bf6142ae6b6885a0ee53d2a196 100644 ---- a/src/main/java/top/leavesmc/leaves/command/CommandArgument.java -+++ b/src/main/java/top/leavesmc/leaves/command/CommandArgument.java +diff --git a/src/main/java/org/leavesmc/leaves/command/CommandArgument.java b/src/main/java/org/leavesmc/leaves/command/CommandArgument.java +index 381cd8b33137a5b7dc688306b56805f35c57012a..2f0e6671dd8bfe4f320eab92c5f5bbc10abc3b05 100644 +--- a/src/main/java/org/leavesmc/leaves/command/CommandArgument.java ++++ b/src/main/java/org/leavesmc/leaves/command/CommandArgument.java @@ -32,6 +32,12 @@ public class CommandArgument { return this; } @@ -3261,33 +3262,33 @@ index eadc6d168fb13299348b0c275ae352ee2f1e1ea2..134c6d26acc612bf6142ae6b6885a0ee public CommandArgumentResult parse(int index, String @NotNull [] args) { Object[] result = new Object[argumentTypes.size()]; Arrays.fill(result, null); -diff --git a/src/main/java/top/leavesmc/leaves/command/CommandArgumentResult.java b/src/main/java/top/leavesmc/leaves/command/CommandArgumentResult.java -index 340eaca64c96180b895a075ce9e44402cd104eed..39e90dcff0de259373d7955021c29397c2cc15d5 100644 ---- a/src/main/java/top/leavesmc/leaves/command/CommandArgumentResult.java -+++ b/src/main/java/top/leavesmc/leaves/command/CommandArgumentResult.java +diff --git a/src/main/java/org/leavesmc/leaves/command/CommandArgumentResult.java b/src/main/java/org/leavesmc/leaves/command/CommandArgumentResult.java +index e50ca0473ab4d40e2623ab15f8566276cc14f4e7..6549037cf0bb8460fef8bef41d2335be079b9e9b 100644 +--- a/src/main/java/org/leavesmc/leaves/command/CommandArgumentResult.java ++++ b/src/main/java/org/leavesmc/leaves/command/CommandArgumentResult.java @@ -58,5 +58,4 @@ public class CommandArgumentResult { return null; } } - } -diff --git a/src/main/java/top/leavesmc/leaves/entity/CraftBot.java b/src/main/java/top/leavesmc/leaves/entity/CraftBot.java +diff --git a/src/main/java/org/leavesmc/leaves/entity/CraftBot.java b/src/main/java/org/leavesmc/leaves/entity/CraftBot.java new file mode 100644 -index 0000000000000000000000000000000000000000..713240da3ba37915b455d952a45ae7f68b8294ee +index 0000000000000000000000000000000000000000..fe1df01906f15e130cf947bbecb5df4bddf98c7c --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/entity/CraftBot.java ++++ b/src/main/java/org/leavesmc/leaves/entity/CraftBot.java @@ -0,0 +1,67 @@ -+package top.leavesmc.leaves.entity; ++package org.leavesmc.leaves.entity; + +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.entity.CraftPlayer; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; -+import top.leavesmc.leaves.bot.ServerBot; -+import top.leavesmc.leaves.bot.agent.Actions; -+import top.leavesmc.leaves.bot.agent.BotAction; -+import top.leavesmc.leaves.entity.botaction.LeavesBotAction; ++import org.leavesmc.leaves.bot.ServerBot; ++import org.leavesmc.leaves.bot.agent.Actions; ++import org.leavesmc.leaves.bot.agent.BotAction; ++import org.leavesmc.leaves.entity.botaction.LeavesBotAction; + +import java.util.UUID; + @@ -3344,13 +3345,13 @@ index 0000000000000000000000000000000000000000..713240da3ba37915b455d952a45ae7f6 + return "CraftBot{" + "name=" + getName() + '}'; + } +} -diff --git a/src/main/java/top/leavesmc/leaves/entity/CraftBotManager.java b/src/main/java/top/leavesmc/leaves/entity/CraftBotManager.java +diff --git a/src/main/java/org/leavesmc/leaves/entity/CraftBotManager.java b/src/main/java/org/leavesmc/leaves/entity/CraftBotManager.java new file mode 100644 -index 0000000000000000000000000000000000000000..df5796bfa333a287ccd486be9a9cdae4ca5dc757 +index 0000000000000000000000000000000000000000..3995912855a612f09567027138f855ec40e26acf --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/entity/CraftBotManager.java ++++ b/src/main/java/org/leavesmc/leaves/entity/CraftBotManager.java @@ -0,0 +1,93 @@ -+package top.leavesmc.leaves.entity; ++package org.leavesmc.leaves.entity; + +import com.google.common.base.Function; +import com.google.common.collect.Lists; @@ -3358,10 +3359,10 @@ index 0000000000000000000000000000000000000000..df5796bfa333a287ccd486be9a9cdae4 +import org.bukkit.util.Consumer; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; -+import top.leavesmc.leaves.bot.ServerBot; -+import top.leavesmc.leaves.bot.agent.Actions; -+import top.leavesmc.leaves.bot.agent.actions.CraftCustomBotAction; -+import top.leavesmc.leaves.entity.botaction.CustomBotAction; ++import org.leavesmc.leaves.bot.ServerBot; ++import org.leavesmc.leaves.bot.agent.Actions; ++import org.leavesmc.leaves.bot.agent.actions.CraftCustomBotAction; ++import org.leavesmc.leaves.entity.botaction.CustomBotAction; + +import java.util.Collection; +import java.util.Collections; @@ -3443,13 +3444,13 @@ index 0000000000000000000000000000000000000000..df5796bfa333a287ccd486be9a9cdae4 + return Actions.unregister(name); + } +} -diff --git a/src/main/java/top/leavesmc/leaves/util/MathUtils.java b/src/main/java/top/leavesmc/leaves/util/MathUtils.java +diff --git a/src/main/java/org/leavesmc/leaves/util/MathUtils.java b/src/main/java/org/leavesmc/leaves/util/MathUtils.java new file mode 100644 -index 0000000000000000000000000000000000000000..349cd0c0d2d9dc2c9c745ef3469e548a798931ba +index 0000000000000000000000000000000000000000..6c42b029d98ed293645f06dde6838761f87f20bb --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/util/MathUtils.java ++++ b/src/main/java/org/leavesmc/leaves/util/MathUtils.java @@ -0,0 +1,78 @@ -+package top.leavesmc.leaves.util; ++package org.leavesmc.leaves.util; + +import org.bukkit.util.NumberConversions; +import org.bukkit.util.Vector; diff --git a/patches/server/0011-Make-shears-in-dispenser-can-unlimited-use.patch b/patches/server/0012-Make-shears-in-dispenser-can-unlimited-use.patch similarity index 63% rename from patches/server/0011-Make-shears-in-dispenser-can-unlimited-use.patch rename to patches/server/0012-Make-shears-in-dispenser-can-unlimited-use.patch index e51f010a..db79877c 100644 --- a/patches/server/0011-Make-shears-in-dispenser-can-unlimited-use.patch +++ b/patches/server/0012-Make-shears-in-dispenser-can-unlimited-use.patch @@ -5,15 +5,15 @@ Subject: [PATCH] Make shears in dispenser can unlimited use diff --git a/src/main/java/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java b/src/main/java/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java -index ec43e8294d7e7112478a2fc1475f0852690a4882..840524c55d52b5ecaf0b1decfdc871c1fd8e0f42 100644 +index a024c697a65bbab27408da1d6a75e531d9719b47..d572549fa76e08e233b810e1b82f79b8174009b9 100644 --- a/src/main/java/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java +++ b/src/main/java/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java -@@ -63,7 +63,7 @@ public class ShearsDispenseItemBehavior extends OptionalDispenseItemBehavior { +@@ -64,7 +64,7 @@ public class ShearsDispenseItemBehavior extends OptionalDispenseItemBehavior { BlockPos blockposition = pointer.pos().relative((Direction) pointer.state().getValue(DispenserBlock.FACING)); this.setSuccess(ShearsDispenseItemBehavior.tryShearBeehive(worldserver, blockposition) || ShearsDispenseItemBehavior.tryShearLivingEntity(worldserver, blockposition, bukkitBlock, craftItem)); // CraftBukkit -- if (this.isSuccess() && stack.hurt(1, worldserver.getRandom(), (ServerPlayer) null)) { -+ if (this.isSuccess() && stack.hurt(1, worldserver.getRandom(), (ServerPlayer) null) && !top.leavesmc.leaves.LeavesConfig.shearsInDispenserCanZeroAmount) { // Leaves - Make shears in dispenser can unlimited use - stack.setCount(0); - } - } +- if (this.isSuccess()) { ++ if (this.isSuccess() && !org.leavesmc.leaves.LeavesConfig.shearsInDispenserCanZeroAmount) { // Leaves - Make shears in dispenser can unlimited use + stack.hurtAndBreak(1, worldserver.getRandom(), (ServerPlayer) null, () -> { + stack.setCount(0); + }); diff --git a/patches/server/0012-Redstone-Shears-Wrench.patch b/patches/server/0013-Redstone-Shears-Wrench.patch similarity index 92% rename from patches/server/0012-Redstone-Shears-Wrench.patch rename to patches/server/0013-Redstone-Shears-Wrench.patch index a8b7f1c1..8b597761 100644 --- a/patches/server/0012-Redstone-Shears-Wrench.patch +++ b/patches/server/0013-Redstone-Shears-Wrench.patch @@ -5,25 +5,23 @@ Subject: [PATCH] Redstone Shears Wrench diff --git a/src/main/java/net/minecraft/world/item/ShearsItem.java b/src/main/java/net/minecraft/world/item/ShearsItem.java -index 7ce81a910ceaa979499b7be269ac8a49e75d3a1c..c55459bb9a03432afd3ea15c8e38a5faeaedeaa1 100644 +index cb809796372a4658aa617404f9fddffff9b45cb7..4e931906c152f269793b92d682e890b2a50172d3 100644 --- a/src/main/java/net/minecraft/world/item/ShearsItem.java +++ b/src/main/java/net/minecraft/world/item/ShearsItem.java -@@ -1,7 +1,9 @@ - package net.minecraft.world.item; - -+import net.minecraft.Util; +@@ -3,6 +3,7 @@ package net.minecraft.world.item; + import java.util.List; import net.minecraft.advancements.CriteriaTriggers; import net.minecraft.core.BlockPos; +import net.minecraft.network.chat.Component; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; -@@ -12,10 +14,21 @@ import net.minecraft.world.entity.LivingEntity; - import net.minecraft.world.entity.player.Player; +@@ -15,9 +16,21 @@ import net.minecraft.world.item.component.Tool; import net.minecraft.world.item.context.UseOnContext; import net.minecraft.world.level.Level; -+import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; ++import net.minecraft.world.level.block.Block; ++import net.minecraft.Util; +import net.minecraft.world.level.block.ComparatorBlock; +import net.minecraft.world.level.block.DispenserBlock; import net.minecraft.world.level.block.GrowingPlantHeadBlock; @@ -40,13 +38,13 @@ index 7ce81a910ceaa979499b7be269ac8a49e75d3a1c..c55459bb9a03432afd3ea15c8e38a5fa public class ShearsItem extends Item { public ShearsItem(Item.Properties settings) { -@@ -79,6 +92,60 @@ public class ShearsItem extends Item { +@@ -77,6 +90,60 @@ public class ShearsItem extends Item { return InteractionResult.sidedSuccess(level.isClientSide); } + // Leaves start - shears wrench + Block block = blockState.getBlock(); -+ if (top.leavesmc.leaves.LeavesConfig.redstoneShearsWrench && block instanceof ObserverBlock || block instanceof DispenserBlock || ++ if (org.leavesmc.leaves.LeavesConfig.redstoneShearsWrench && block instanceof ObserverBlock || block instanceof DispenserBlock || + block instanceof PistonBaseBlock || block instanceof HopperBlock || block instanceof RepeaterBlock || block instanceof ComparatorBlock) { + StateDefinition blockstatelist = block.getStateDefinition(); + Property iblockstate = blockstatelist.getProperty("facing"); diff --git a/patches/server/0013-Add-isShrink-to-EntityResurrectEvent.patch b/patches/server/0014-Add-isShrink-to-EntityResurrectEvent.patch similarity index 87% rename from patches/server/0013-Add-isShrink-to-EntityResurrectEvent.patch rename to patches/server/0014-Add-isShrink-to-EntityResurrectEvent.patch index f6df295a..707b93f6 100644 --- a/patches/server/0013-Add-isShrink-to-EntityResurrectEvent.patch +++ b/patches/server/0014-Add-isShrink-to-EntityResurrectEvent.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Add isShrink to EntityResurrectEvent diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index ac3d31b0ed54fd07f07a0768017cc34f7ae9709f..5a453688f9f9f48e5952b00382bbca0632995022 100644 +index e8a472f7e90dfb39b16521f75521d60b532af5cc..d106491e5ca187cf62758cbd33bab575ccbc3bec 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -1622,12 +1622,12 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -1648,12 +1648,12 @@ public abstract class LivingEntity extends Entity implements Attackable { } org.bukkit.inventory.EquipmentSlot handSlot = (hand != null) ? org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(hand) : null; @@ -23,7 +23,7 @@ index ac3d31b0ed54fd07f07a0768017cc34f7ae9709f..5a453688f9f9f48e5952b00382bbca06 itemstack1.shrink(1); } if (itemstack != null && this instanceof ServerPlayer) { -@@ -4565,3 +4565,4 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -4562,3 +4562,4 @@ public abstract class LivingEntity extends Entity implements Attackable { } } diff --git a/patches/server/0014-Budding-Amethyst-can-push-by-piston.patch b/patches/server/0015-Budding-Amethyst-can-push-by-piston.patch similarity index 84% rename from patches/server/0014-Budding-Amethyst-can-push-by-piston.patch rename to patches/server/0015-Budding-Amethyst-can-push-by-piston.patch index ce456138..7f8d0d55 100644 --- a/patches/server/0014-Budding-Amethyst-can-push-by-piston.patch +++ b/patches/server/0015-Budding-Amethyst-can-push-by-piston.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Budding Amethyst can push by piston 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 3212771ac19044ca37bf60e231eac5615a9c240e..ee6cb4042421a74095473360126f6d083513934b 100644 +index 555d255a79c6136d0df3504218a0bc4681a5489f..e27f2317e4e2f13b6ef12be727046497a750fd3a 100644 --- a/src/main/java/net/minecraft/world/level/block/Block.java +++ b/src/main/java/net/minecraft/world/level/block/Block.java -@@ -603,6 +603,12 @@ public class Block extends BlockBehaviour implements ItemLike { +@@ -591,6 +591,12 @@ public class Block extends BlockBehaviour implements ItemLike { } // Spigot end @@ -22,7 +22,7 @@ index 3212771ac19044ca37bf60e231eac5615a9c240e..ee6cb4042421a74095473360126f6d08 private final BlockState first; diff --git a/src/main/java/net/minecraft/world/level/block/BuddingAmethystBlock.java b/src/main/java/net/minecraft/world/level/block/BuddingAmethystBlock.java -index 7f58c9f5935cd14ea1096de14633f653eb486d7e..b83efe46ecb3ebf2b3d0c4499eec29055663fd3f 100644 +index 8920855b07a31715327b8102c7faafc9f916825d..32d926a1b952b8069c5bf48c88e3c108b08b4ab1 100644 --- a/src/main/java/net/minecraft/world/level/block/BuddingAmethystBlock.java +++ b/src/main/java/net/minecraft/world/level/block/BuddingAmethystBlock.java @@ -60,4 +60,11 @@ public class BuddingAmethystBlock extends AmethystBlock { @@ -33,15 +33,15 @@ index 7f58c9f5935cd14ea1096de14633f653eb486d7e..b83efe46ecb3ebf2b3d0c4499eec2905 + // Leaves start - budding amethyst can push by piston + @Override + public net.minecraft.world.level.material.PushReaction getResetPushReaction() { -+ return top.leavesmc.leaves.LeavesConfig.buddingAmethystCanPushByPiston ? net.minecraft.world.level.material.PushReaction.PUSH_ONLY : null; ++ return org.leavesmc.leaves.LeavesConfig.buddingAmethystCanPushByPiston ? net.minecraft.world.level.material.PushReaction.PUSH_ONLY : null; + } + // Leaves end - budding amethyst can push by piston } diff --git a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java -index 2892e586146cbc560f0bcf4b9af6d0575cb0a82e..ebba87e53105ee68a6f030476a2def609e668fb3 100644 +index 2034ca2edd3aff61d94416266e75402babd3e741..d7ae3a3a63a3eb3a95534c303ba87303cb96744d 100644 --- a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java +++ b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java -@@ -1157,7 +1157,7 @@ public abstract class BlockBehaviour implements FeatureElement { +@@ -1088,7 +1088,7 @@ public abstract class BlockBehaviour implements FeatureElement { } public PushReaction getPistonPushReaction() { diff --git a/patches/server/0015-Spectator-dont-get-Advancement.patch b/patches/server/0015-Spectator-dont-get-Advancement.patch deleted file mode 100644 index 7428bc5e..00000000 --- a/patches/server/0015-Spectator-dont-get-Advancement.patch +++ /dev/null @@ -1,30 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: violetc <58360096+s-yh-china@users.noreply.github.com> -Date: Sat, 25 Jun 2022 18:04:35 +0800 -Subject: [PATCH] Spectator dont get Advancement - - -diff --git a/src/main/java/net/minecraft/server/PlayerAdvancements.java b/src/main/java/net/minecraft/server/PlayerAdvancements.java -index 2694f899241ad8ce06d3bcba78550af5626561ce..f941e7add46e690e21d39111bed520df9156f154 100644 ---- a/src/main/java/net/minecraft/server/PlayerAdvancements.java -+++ b/src/main/java/net/minecraft/server/PlayerAdvancements.java -@@ -45,6 +45,7 @@ import net.minecraft.server.level.ServerPlayer; - import net.minecraft.server.players.PlayerList; - import net.minecraft.util.datafix.DataFixTypes; - import net.minecraft.world.level.GameRules; -+import net.minecraft.world.level.GameType; - import org.slf4j.Logger; - - public class PlayerAdvancements { -@@ -226,6 +227,11 @@ public class PlayerAdvancements { - return false; - } - // Leaves end - bot can't get advancement -+ // Leaves start - spectator don't get advancement -+ if (top.leavesmc.leaves.LeavesConfig.spectatorDontGetAdvancement && player.gameMode.getGameModeForPlayer() == GameType.SPECTATOR) { -+ return false; -+ } -+ // Leaves end - spectator don't get advancement - boolean flag = false; - AdvancementProgress advancementprogress = this.getOrStartProgress(advancement); - boolean flag1 = advancementprogress.isDone(); diff --git a/patches/server/0016-Spectator-dont-get-Advancement.patch b/patches/server/0016-Spectator-dont-get-Advancement.patch new file mode 100644 index 00000000..3d93d94a --- /dev/null +++ b/patches/server/0016-Spectator-dont-get-Advancement.patch @@ -0,0 +1,22 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: violetc <58360096+s-yh-china@users.noreply.github.com> +Date: Sat, 25 Jun 2022 18:04:35 +0800 +Subject: [PATCH] Spectator dont get Advancement + + +diff --git a/src/main/java/net/minecraft/server/PlayerAdvancements.java b/src/main/java/net/minecraft/server/PlayerAdvancements.java +index 8d2b26b2ec48727b12ddb1bede53aecb71f46feb..60ad7e71a3d4b9dc7bab2f961865eac76c0f68c1 100644 +--- a/src/main/java/net/minecraft/server/PlayerAdvancements.java ++++ b/src/main/java/net/minecraft/server/PlayerAdvancements.java +@@ -221,6 +221,11 @@ public class PlayerAdvancements { + } + + public boolean award(AdvancementHolder advancement, String criterionName) { ++ // Leaves start - spectator don't get advancement ++ if (org.leavesmc.leaves.LeavesConfig.spectatorDontGetAdvancement && player.gameMode.getGameModeForPlayer() == net.minecraft.world.level.GameType.SPECTATOR) { ++ return false; ++ } ++ // Leaves end - spectator don't get advancement + // Leaves start - bot can't get advancement + if (player instanceof org.leavesmc.leaves.bot.ServerBot) { + return false; diff --git a/patches/server/0016-Stick-can-change-ArmorStand-arm-status.patch b/patches/server/0017-Stick-can-change-ArmorStand-arm-status.patch similarity index 82% rename from patches/server/0016-Stick-can-change-ArmorStand-arm-status.patch rename to patches/server/0017-Stick-can-change-ArmorStand-arm-status.patch index d6c23d08..5c461905 100644 --- a/patches/server/0016-Stick-can-change-ArmorStand-arm-status.patch +++ b/patches/server/0017-Stick-can-change-ArmorStand-arm-status.patch @@ -5,15 +5,15 @@ Subject: [PATCH] Stick can change ArmorStand arm status diff --git a/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java b/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java -index eadcebd7845ee716e33c0ac0544502da1a6c5941..575ef3806fc89b7492f5d6b6500e37c775dfaad8 100644 +index a02ca704e98ef42f32c3c50b111ee3537f60bf7b..32fd9c3d79bb9e9e75b03750696425089e503dcb 100644 --- a/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java +++ b/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java -@@ -387,6 +387,12 @@ public class ArmorStand extends LivingEntity { +@@ -393,6 +393,12 @@ public class ArmorStand extends LivingEntity { return InteractionResult.SUCCESS; } } else { + // Leaves start - stick can change ArmorStand arm status -+ if (top.leavesmc.leaves.LeavesConfig.stickChangeArmorStandArmStatus && itemstack.is(Items.STICK) && player.isShiftKeyDown()) { ++ if (org.leavesmc.leaves.LeavesConfig.stickChangeArmorStandArmStatus && itemstack.is(Items.STICK) && player.isShiftKeyDown()) { + setShowArms(!isShowArms()); + } + // Leaves end - stick can change ArmorStand arm status diff --git a/patches/server/0017-Fix-tripwire-update.patch b/patches/server/0018-Fix-tripwire-update.patch similarity index 88% rename from patches/server/0017-Fix-tripwire-update.patch rename to patches/server/0018-Fix-tripwire-update.patch index bbcc7f45..4e27e63b 100644 --- a/patches/server/0017-Fix-tripwire-update.patch +++ b/patches/server/0018-Fix-tripwire-update.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Fix tripwire update diff --git a/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java b/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java -index efd8d77a441fd334ea4c09c5e31c6d946c1ae0b7..d9b3877257b31ca1b5acc4a47fbf5b993de69ae0 100644 +index 76aca266d3f3222502ff4c196228f08fcd88c5f8..8614fad5b3df7a6030384b108b1689bf6b9f1209 100644 --- a/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java +++ b/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java -@@ -201,8 +201,9 @@ public class TripWireHookBlock extends Block { +@@ -202,8 +202,9 @@ public class TripWireHookBlock extends Block { BlockState iblockdata4 = aiblockdata[l]; if (iblockdata4 != null) { diff --git a/patches/server/0018-No-chat-sign.patch b/patches/server/0019-No-chat-sign.patch similarity index 71% rename from patches/server/0018-No-chat-sign.patch rename to patches/server/0019-No-chat-sign.patch index a6c62c96..c334257a 100644 --- a/patches/server/0018-No-chat-sign.patch +++ b/patches/server/0019-No-chat-sign.patch @@ -5,7 +5,7 @@ Subject: [PATCH] No chat sign diff --git a/src/main/java/io/papermc/paper/adventure/ChatProcessor.java b/src/main/java/io/papermc/paper/adventure/ChatProcessor.java -index 1d78e8beacbc93ef2cd6beb418edca843f8a5429..6177f91146d2bc9dc1a066a24f84581cec0f53cd 100644 +index e83f9517b31c5171b8dc75ab63a5bfe654221c84..19d973a0582c487617fafadd3df4857f8a1819a4 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 { @@ -13,12 +13,12 @@ index 1d78e8beacbc93ef2cd6beb418edca843f8a5429..6177f91146d2bc9dc1a066a24f84581c 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, ChatProcessor.this.server.getPlayerList().verifyChatTrusted(toConsoleMessage) || top.leavesmc.leaves.LeavesConfig.noChatSign ? null : "Not Secure"); // Leaves - No Not Secure ++ ChatProcessor.this.server.logChatMessage(toConsoleMessage.decoratedContent(), chatType, ChatProcessor.this.server.getPlayerList().verifyChatTrusted(toConsoleMessage) || org.leavesmc.leaves.LeavesConfig.noChatSign ? null : "Not Secure"); // Leaves - No Not Secure } } diff --git a/src/main/java/net/minecraft/commands/arguments/ArgumentSignatures.java b/src/main/java/net/minecraft/commands/arguments/ArgumentSignatures.java -index 4abd7babc3aa7268975386e7c2319f7961b0c3aa..07076b5212cf580390c212d00c76b50397195a02 100644 +index 479e6e2aa88a22ef7f8fccb06add6806f5b71d9d..e6a6d09a64414ae6932e9bac338ce36043bd4b26 100644 --- a/src/main/java/net/minecraft/commands/arguments/ArgumentSignatures.java +++ b/src/main/java/net/minecraft/commands/arguments/ArgumentSignatures.java @@ -13,10 +13,17 @@ public record ArgumentSignatures(List entries) { @@ -33,68 +33,73 @@ index 4abd7babc3aa7268975386e7c2319f7961b0c3aa..07076b5212cf580390c212d00c76b503 + private static List readSign(FriendlyByteBuf buf) { + var entries = buf.readCollection(FriendlyByteBuf.limitValue(ArrayList::new, 8), Entry::new); -+ return top.leavesmc.leaves.LeavesConfig.noChatSign ? List.of() : entries; ++ return org.leavesmc.leaves.LeavesConfig.noChatSign ? List.of() : entries; + } + // Leaves end - no chat sign + - @Nullable - public MessageSignature get(String argumentName) { - for (ArgumentSignatures.Entry entry : this.entries) { + public void write(FriendlyByteBuf buf) { + buf.writeCollection(this.entries, (buf2, entry) -> entry.write(buf2)); + } diff --git a/src/main/java/net/minecraft/network/FriendlyByteBuf.java b/src/main/java/net/minecraft/network/FriendlyByteBuf.java -index b863249ff7e13cf4939c8961601f0564c62fd661..92df5611cdf4b3a8a82ed7194eba1d398a8cc9bd 100644 +index aafeb9c61ddba6a8671f0238eda47b227619f1af..84a57cf6454db6b84aabc78017b64cc57c3a2070 100644 --- a/src/main/java/net/minecraft/network/FriendlyByteBuf.java +++ b/src/main/java/net/minecraft/network/FriendlyByteBuf.java -@@ -143,6 +143,16 @@ public class FriendlyByteBuf extends ByteBuf { +@@ -129,6 +129,16 @@ public class FriendlyByteBuf extends ByteBuf { // Paper end - Adventure; add max length parameter DataResult dataresult = codec.encodeStart(JsonOps.INSTANCE, value); + // Leaves start - no chat sign + if (codec == net.minecraft.network.protocol.status.ServerStatus.CODEC) { -+ JsonElement element = Util.getOrThrow(dataresult, string -> new EncoderException("Failed to encode: " + string + " " + value)); -+ element.getAsJsonObject().addProperty("preventsChatReports", top.leavesmc.leaves.LeavesConfig.noChatSign); ++ JsonElement element = dataresult.getOrThrow(string -> new EncoderException("Failed to encode: " + string + " " + value)); ++ element.getAsJsonObject().addProperty("preventsChatReports", org.leavesmc.leaves.LeavesConfig.noChatSign); + + this.writeUtf(GSON.toJson(element)); -+ return; ++ return; + } + // Leaves end - no chat sign + - this.writeUtf(FriendlyByteBuf.GSON.toJson((JsonElement) Util.getOrThrow(dataresult, (s) -> { - return new EncoderException("Failed to encode: " + s + " " + value); + this.writeUtf(FriendlyByteBuf.GSON.toJson((JsonElement) dataresult.getOrThrow((s) -> { + return new EncoderException("Failed to encode: " + s + " " + String.valueOf(value)); })), maxLength); // Paper - Adventure; add max length parameter diff --git a/src/main/java/net/minecraft/network/protocol/game/ServerboundChatPacket.java b/src/main/java/net/minecraft/network/protocol/game/ServerboundChatPacket.java -index 831178218ddfaa1828c00d0662b251d11bb29ff5..865eda0ea24e86b053ea69714b55130af94e1c50 100644 +index 07df3299f1d1aa5506e1f6f146347d53e0278d9c..fb441424c03d547cdf4dcfcde5e60d8e4d6a4f59 100644 --- a/src/main/java/net/minecraft/network/protocol/game/ServerboundChatPacket.java +++ b/src/main/java/net/minecraft/network/protocol/game/ServerboundChatPacket.java -@@ -9,10 +9,18 @@ import net.minecraft.network.protocol.Packet; +@@ -15,8 +15,9 @@ public record ServerboundChatPacket(String message, Instant timeStamp, long salt + ServerboundChatPacket::write, ServerboundChatPacket::new + ); - public record ServerboundChatPacket(String message, Instant timeStamp, long salt, @Nullable MessageSignature signature, LastSeenMessages.Update lastSeenMessages) - implements Packet { + // Leaves start - no chat sign - public ServerboundChatPacket(FriendlyByteBuf buf) { + private ServerboundChatPacket(FriendlyByteBuf buf) { - this(buf.readUtf(256), buf.readInstant(), buf.readLong(), buf.readNullable(MessageSignature::read), new LastSeenMessages.Update(buf)); + this(buf.readUtf(256), buf.readInstant(), buf.readLong(), buf.readNullable(ServerboundChatPacket::readSign), new LastSeenMessages.Update(buf)); } + private void write(FriendlyByteBuf buf) { +@@ -27,6 +28,13 @@ public record ServerboundChatPacket(String message, Instant timeStamp, long salt + this.lastSeenMessages.write(buf); + } + + private static MessageSignature readSign(FriendlyByteBuf buf) { + byte[] bs = new byte[256]; + buf.readBytes(bs); -+ return top.leavesmc.leaves.LeavesConfig.noChatSign ? null : new MessageSignature(bs); ++ return org.leavesmc.leaves.LeavesConfig.noChatSign ? null : new MessageSignature(bs); + } + // Leaves end - no chat sign + @Override - public void write(FriendlyByteBuf buf) { - buf.writeUtf(this.message, 256); + public PacketType type() { + return GamePacketTypes.SERVERBOUND_CHAT; diff --git a/src/main/java/net/minecraft/network/protocol/game/ServerboundChatSessionUpdatePacket.java b/src/main/java/net/minecraft/network/protocol/game/ServerboundChatSessionUpdatePacket.java -index 9d6db4a378036559efab91c8b7dcf2a6b0c2cce6..2c349dc502ce275a8215766933f4855f1c7bd726 100644 +index 5705cb920084b775cce4b361683b32c6b6e003ed..cbff868303d751d09b68f431c78bb13b4734f48f 100644 --- a/src/main/java/net/minecraft/network/protocol/game/ServerboundChatSessionUpdatePacket.java +++ b/src/main/java/net/minecraft/network/protocol/game/ServerboundChatSessionUpdatePacket.java -@@ -16,6 +16,11 @@ public record ServerboundChatSessionUpdatePacket(RemoteChatSession.Data chatSess +@@ -26,6 +26,11 @@ public record ServerboundChatSessionUpdatePacket(RemoteChatSession.Data chatSess @Override public void handle(ServerGamePacketListener listener) { + // Leaves start - no chat report -+ if (top.leavesmc.leaves.LeavesConfig.noChatSign) { ++ if (org.leavesmc.leaves.LeavesConfig.noChatSign) { + return; + } + // Leaves end - no chat report @@ -102,44 +107,41 @@ index 9d6db4a378036559efab91c8b7dcf2a6b0c2cce6..2c349dc502ce275a8215766933f4855f } } diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -index 60e5129b42c430ba6b9776bf63d0db608552b50f..6725bbf2d966ae900e9b5efa619875c386bb9526 100644 +index 437f714fc1b38f0040b57cef94a76faa88f1c495..f240a9d90ec469a99d3d8b82cfa3fcb5d0e78057 100644 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -@@ -643,7 +643,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -663,7 +663,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface // Paper start - Add setting for proxy online mode status return dedicatedserverproperties.enforceSecureProfile && io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode() - && this.services.canValidateProfileKeys(); -+ && this.services.canValidateProfileKeys() && !top.leavesmc.leaves.LeavesConfig.noChatSign; // Leaves - no chat sign ++ && this.services.canValidateProfileKeys() && !org.leavesmc.leaves.LeavesConfig.noChatSign; // Leaves - no chat sign // Paper end - Add setting for proxy online mode status } diff --git a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java -index 8aa1337b420e1c9fbf51f951f14a63d89f61d3f4..19db81d87d1e0eb9716ceaf88dc407db10e48f5f 100644 +index 82bf29bb3096797801f768c2b631d8b6cae8f761..c02f073e6fa16a05927154462af694731c24347b 100644 --- a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java -@@ -239,10 +239,27 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack +@@ -295,10 +295,24 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack } public void send(Packet packet) { -+ // Leaves start - no ClientboundPlayerChatHeaderPacket and rebuild ClientboundPlayerChatPacket -+ if (top.leavesmc.leaves.LeavesConfig.noChatSign) { -+ if (packet instanceof net.minecraft.network.protocol.game.ClientboundPlayerChatPacket chat) { -+ packet = new net.minecraft.network.protocol.game.ClientboundSystemChatPacket(chat.chatType().resolve(this.player.level().registryAccess()) -+ .get().decorate(chat.unsignedContent() != null ? chat.unsignedContent() -+ : Component.literal(chat.body().content())), false); ++ // Leaves start - rebuild ClientboundPlayerChatPacket ++ if (org.leavesmc.leaves.LeavesConfig.noChatSign) { ++ if (this instanceof ServerGamePacketListenerImpl && packet instanceof net.minecraft.network.protocol.game.ClientboundPlayerChatPacket chat) { ++ packet = new net.minecraft.network.protocol.game.ClientboundSystemChatPacket(chat.chatType().decorate(chat.unsignedContent() != null ? chat.unsignedContent() : Component.literal(chat.body().content())), false); + } + } -+ // Leaves end - no ClientboundPlayerChatHeaderPacket and rebuild ClientboundPlayerChatPacket ++ // Leaves end - rebuild ClientboundPlayerChatPacket this.send(packet, (PacketSendListener) null); } public void send(Packet packet, @Nullable PacketSendListener callbacks) { + // Leaves start - no ClientboundPlayerChatHeaderPacket and rebuild ClientboundPlayerChatPacket -+ if (top.leavesmc.leaves.LeavesConfig.noChatSign) { ++ if (org.leavesmc.leaves.LeavesConfig.noChatSign) { + if (packet instanceof net.minecraft.network.protocol.game.ClientboundPlayerChatPacket chat && callbacks != null) { -+ this.send(chat); -+ return; ++ callbacks = null; + } + } + // Leaves end - no ClientboundPlayerChatHeaderPacket and rebuild ClientboundPlayerChatPacket @@ -147,15 +149,15 @@ index 8aa1337b420e1c9fbf51f951f14a63d89f61d3f4..19db81d87d1e0eb9716ceaf88dc407db if (packet == null || this.processedDisconnect) { // Spigot return; diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index 44b354431a9c21166211e6d1de1ce573b9f7253c..c1a50cedca731c08f793ba3eba4210bc26824e16 100644 +index ef719bf410912b24d57de422d1fa3fb2bcef5105..00809b615f65b2f4985856673430d8ba68525765 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java -@@ -1489,7 +1489,7 @@ public abstract class PlayerList { +@@ -1488,7 +1488,7 @@ public abstract class PlayerList { } public boolean verifyChatTrusted(PlayerChatMessage message) { // Paper - private -> public - return message.hasSignature() && !message.hasExpiredServer(Instant.now()); -+ return top.leavesmc.leaves.LeavesConfig.noChatSign || (message.hasSignature() && !message.hasExpiredServer(Instant.now())); // Leaves - No Not Secure ++ return org.leavesmc.leaves.LeavesConfig.noChatSign || (message.hasSignature() && !message.hasExpiredServer(Instant.now())); // Leaves - No Not Secure } // CraftBukkit start diff --git a/patches/server/0019-Dont-send-useless-entity-packets.patch b/patches/server/0020-Dont-send-useless-entity-packets.patch similarity index 89% rename from patches/server/0019-Dont-send-useless-entity-packets.patch rename to patches/server/0020-Dont-send-useless-entity-packets.patch index 1ce97b9d..f2e044d4 100644 --- a/patches/server/0019-Dont-send-useless-entity-packets.patch +++ b/patches/server/0020-Dont-send-useless-entity-packets.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Dont send useless entity packets This patch is Powered by Purpur(https://github.com/PurpurMC/Purpur) diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java -index 529ab44baaf573b97cf7e89560c548642733188f..b2183c298b0c68daee41238735621ff002338a68 100644 +index f16a69775332a08ed0e87d27acd0fc959359694c..770c51528e5a31e2738fbce5d63d2ea3f11186f8 100644 --- a/src/main/java/net/minecraft/server/level/ServerEntity.java +++ b/src/main/java/net/minecraft/server/level/ServerEntity.java -@@ -197,6 +197,7 @@ public class ServerEntity { +@@ -204,6 +204,7 @@ public class ServerEntity { flag4 = true; flag5 = true; } @@ -17,19 +17,19 @@ index 529ab44baaf573b97cf7e89560c548642733188f..b2183c298b0c68daee41238735621ff0 } else { this.wasOnGround = this.entity.onGround(); this.teleportDelay = 0; -@@ -204,6 +205,11 @@ public class ServerEntity { +@@ -211,6 +212,11 @@ public class ServerEntity { flag4 = true; flag5 = true; } + // Leaves start - dont send useless entity packets -+ if (top.leavesmc.leaves.LeavesConfig.dontSendUselessEntityPackets && isUselessPacket(packet1)) { ++ if (org.leavesmc.leaves.LeavesConfig.dontSendUselessEntityPackets && isUselessPacket(packet1)) { + packet1 = null; + } + // Leaves end - dont send useless entity packets } if ((this.trackDelta || this.entity.hasImpulse || this.entity instanceof LivingEntity && ((LivingEntity) this.entity).isFallFlying()) && this.tickCount > 0) { -@@ -276,6 +282,21 @@ public class ServerEntity { +@@ -291,6 +297,21 @@ public class ServerEntity { }); } diff --git a/patches/server/0020-Optimize-entity-coordinate-key.patch b/patches/server/0021-Optimize-entity-coordinate-key.patch similarity index 83% rename from patches/server/0020-Optimize-entity-coordinate-key.patch rename to patches/server/0021-Optimize-entity-coordinate-key.patch index 3344ab3c..2ee302d5 100644 --- a/patches/server/0020-Optimize-entity-coordinate-key.patch +++ b/patches/server/0021-Optimize-entity-coordinate-key.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Optimize entity coordinate key This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish) diff --git a/src/main/java/io/papermc/paper/util/MCUtil.java b/src/main/java/io/papermc/paper/util/MCUtil.java -index e028353e0261310afc42ca0454b723d9f1ffc131..f97258893cb774294e7b43c2d31c9e59ff8d157b 100644 +index 1d6b3fe2ce240af4ede61588795456b046eee6c9..21847dfde06ded5944699ca30a4ec9c2d3511555 100644 --- a/src/main/java/io/papermc/paper/util/MCUtil.java +++ b/src/main/java/io/papermc/paper/util/MCUtil.java @@ -215,7 +215,13 @@ public final class MCUtil { @@ -15,7 +15,7 @@ index e028353e0261310afc42ca0454b723d9f1ffc131..f97258893cb774294e7b43c2d31c9e59 public static long getCoordinateKey(final Entity entity) { - return ((long)(MCUtil.fastFloor(entity.getZ()) >> 4) << 32) | ((MCUtil.fastFloor(entity.getX()) >> 4) & 0xFFFFFFFFL); + // Leaves start - eliminate double -> long cast in hotpath -+ if (top.leavesmc.leaves.LeavesConfig.optimizeEntityCoordinateKey) { ++ if (org.leavesmc.leaves.LeavesConfig.optimizeEntityCoordinateKey) { + return ((long)(entity.blockPosition.getZ() >> 4) << 32) | ((entity.blockPosition.getX() >> 4) & 0xFFFFFFFFL); + } else { + return ((long)(MCUtil.fastFloor(entity.getZ()) >> 4) << 32) | ((MCUtil.fastFloor(entity.getX()) >> 4) & 0xFFFFFFFFL); @@ -25,10 +25,10 @@ index e028353e0261310afc42ca0454b723d9f1ffc131..f97258893cb774294e7b43c2d31c9e59 public static long getCoordinateKey(final ChunkPos pair) { diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 0a8ad5a68e161e6991edafe31ceeeecc10ea8dab..68a8aca051df609747b25ef89e5217932edbec51 100644 +index 082b484df1bd3d6a87413e3ab9a07a8f5401c65d..e87a60ca43fe080209620e11833099e7ea9164b5 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -309,7 +309,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -312,7 +312,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess public double yo; public double zo; private Vec3 position; diff --git a/patches/server/0021-Optimize-suffocation.patch b/patches/server/0022-Optimize-suffocation.patch similarity index 86% rename from patches/server/0021-Optimize-suffocation.patch rename to patches/server/0022-Optimize-suffocation.patch index df097a38..d598c658 100644 --- a/patches/server/0021-Optimize-suffocation.patch +++ b/patches/server/0022-Optimize-suffocation.patch @@ -6,19 +6,19 @@ Subject: [PATCH] Optimize suffocation This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish) diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index 5a453688f9f9f48e5952b00382bbca0632995022..e598a29f7285d961262ff2a86142e004f34520ef 100644 +index d106491e5ca187cf62758cbd33bab575ccbc3bec..9755d85c090d336364f041d32f11ea7c5041945e 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -413,7 +413,7 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -426,7 +426,7 @@ public abstract class LivingEntity extends Entity implements Attackable { boolean flag = this instanceof net.minecraft.world.entity.player.Player; if (!this.level().isClientSide) { - if (this.isInWall()) { -+ if ((!top.leavesmc.leaves.LeavesConfig.enableSuffocationOptimization || this instanceof WitherBoss || (tickCount % 10 == 0 && couldPossiblyBeHurt(1.0F))) && this.isInWall()) { // Leaves - optimize suffocation ++ if ((!org.leavesmc.leaves.LeavesConfig.enableSuffocationOptimization || this instanceof WitherBoss || (tickCount % 10 == 0 && couldPossiblyBeHurt(1.0F))) && this.isInWall()) { // Leaves - optimize suffocation this.hurt(this.damageSources().inWall(), 1.0F); } else if (flag && !this.level().getWorldBorder().isWithinBounds(this.getBoundingBox())) { double d0 = this.level().getWorldBorder().getDistanceToBorder(this) + this.level().getWorldBorder().getDamageSafeZone(); -@@ -1417,6 +1417,15 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -1430,6 +1430,15 @@ public abstract class LivingEntity extends Entity implements Attackable { return this.getHealth() <= 0.0F; } diff --git a/patches/server/0022-Only-check-for-spooky-season-once-an-hour.patch b/patches/server/0023-Only-check-for-spooky-season-once-an-hour.patch similarity index 79% rename from patches/server/0022-Only-check-for-spooky-season-once-an-hour.patch rename to patches/server/0023-Only-check-for-spooky-season-once-an-hour.patch index e3d04946..1252e93c 100644 --- a/patches/server/0022-Only-check-for-spooky-season-once-an-hour.patch +++ b/patches/server/0023-Only-check-for-spooky-season-once-an-hour.patch @@ -6,10 +6,18 @@ Subject: [PATCH] Only check for spooky season once an hour This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish) 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 44fa2d4f90389f5526746bd94a2450c03340bd0b..3f51df1325f8cec5bd979cc4896a091c4157667d 100644 +index dc27ddf5131e7398a5390a5187261d4c7fb6ccaa..8237f252cf60cb0ed85f6eb61e2bdb5f8e3cefef 100644 --- a/src/main/java/net/minecraft/world/entity/ambient/Bat.java +++ b/src/main/java/net/minecraft/world/entity/ambient/Bat.java -@@ -241,13 +241,30 @@ public class Bat extends AmbientCreature { +@@ -215,6 +215,7 @@ public class Bat extends AmbientCreature { + super.readAdditionalSaveData(nbt); + this.entityData.set(Bat.DATA_ID_FLAGS, nbt.getByte("BatFlags")); + } ++ // Leaves end - only check for spooky season once an hour + + @Override + public void addAdditionalSaveData(CompoundTag nbt) { +@@ -239,12 +240,28 @@ public class Bat extends AmbientCreature { } } @@ -21,7 +29,7 @@ index 44fa2d4f90389f5526746bd94a2450c03340bd0b..3f51df1325f8cec5bd979cc4896a091c - LocalDate localdate = LocalDate.now(); - int i = localdate.get(ChronoField.DAY_OF_MONTH); - int j = localdate.get(ChronoField.MONTH_OF_YEAR); -+ if (top.leavesmc.leaves.LeavesConfig.checkSpookySeasonOnceAnHour) { ++ if (org.leavesmc.leaves.LeavesConfig.checkSpookySeasonOnceAnHour) { + if (net.minecraft.server.MinecraftServer.currentTick - lastSpookyCheck > ONE_HOUR) { + LocalDate localdate = LocalDate.now(); + int i = localdate.get(ChronoField.DAY_OF_MONTH); @@ -40,7 +48,5 @@ index 44fa2d4f90389f5526746bd94a2450c03340bd0b..3f51df1325f8cec5bd979cc4896a091c + return j == 10 && i >= 20 || j == 11 && i <= 3; + } } -+ // Leaves end - only check for spooky season once an hour - @Override - protected float getStandingEyeHeight(Pose pose, EntityDimensions dimensions) { + private void setupAnimationStates() { diff --git a/patches/server/0023-Move-ThreadUnsafeRandom-Initialization.patch b/patches/server/0024-Move-ThreadUnsafeRandom-Initialization.patch similarity index 90% rename from patches/server/0023-Move-ThreadUnsafeRandom-Initialization.patch rename to patches/server/0024-Move-ThreadUnsafeRandom-Initialization.patch index 2455b197..78639f7d 100644 --- a/patches/server/0023-Move-ThreadUnsafeRandom-Initialization.patch +++ b/patches/server/0024-Move-ThreadUnsafeRandom-Initialization.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Move ThreadUnsafeRandom Initialization This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish) diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index cda7db7a3544ae36fbd692884a5fd92ac670bdcd..bfbb509e09dd5099b9930f3d07383d59620d0364 100644 +index c93d0fbb921309a63c21ba7775fdf44aaa7985c4..84472442e0e68c22c4ebeaaf980aee1e8a234d81 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java -@@ -965,7 +965,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -971,7 +971,7 @@ public class ServerLevel extends Level implements WorldGenLevel { } // Paper start - optimise random block ticking private final BlockPos.MutableBlockPos chunkTickMutablePosition = new BlockPos.MutableBlockPos(); @@ -19,10 +19,10 @@ index cda7db7a3544ae36fbd692884a5fd92ac670bdcd..bfbb509e09dd5099b9930f3d07383d59 public void tickChunk(LevelChunk chunk, int randomTickSpeed) { diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index 998f37b01ae67807757a96eb512a695ed5e94700..377c517d63ba367b51c6eba86eac0544a9a6b2bd 100644 +index 34654d0f7d5c159ceaf76b327a3f86bd4f82c175..d4854e404b111b0cb936539b4ce95890b22a6f9d 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -208,6 +208,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -212,6 +212,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable { public abstract ResourceKey getTypeKey(); diff --git a/patches/server/0024-Optimize-random-calls-in-chunk-ticking.patch b/patches/server/0025-Optimize-random-calls-in-chunk-ticking.patch similarity index 85% rename from patches/server/0024-Optimize-random-calls-in-chunk-ticking.patch rename to patches/server/0025-Optimize-random-calls-in-chunk-ticking.patch index fbf07626..ef21f4fe 100644 --- a/patches/server/0024-Optimize-random-calls-in-chunk-ticking.patch +++ b/patches/server/0025-Optimize-random-calls-in-chunk-ticking.patch @@ -6,15 +6,15 @@ Subject: [PATCH] Optimize random calls in chunk ticking This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish) diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index 2a19a45e9c7ac4646ce89c566b5fec21281c45b9..a3db45d411772d71ba46632633e935f2251bcfda 100644 +index 256ad83f10e6df5d32959d38eeabc126b9b7b190..db41ee04b5dd3e162830342e4b1f2b457ffb7fed 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -@@ -495,6 +495,11 @@ public class ServerChunkCache extends ChunkSource { +@@ -494,6 +494,11 @@ public class ServerChunkCache extends ChunkSource { ProfilerFiller gameprofilerfiller = this.level.getProfiler(); gameprofilerfiller.push("pollingChunks"); + // Leaves start - reset ice & snow tick random -+ if (top.leavesmc.leaves.LeavesConfig.optimizeChunkTicking) { ++ if (org.leavesmc.leaves.LeavesConfig.optimizeChunkTicking) { + this.level.resetIceAndSnowTick(); + } + // Leaves end - reset ice & snow tick random @@ -22,10 +22,10 @@ index 2a19a45e9c7ac4646ce89c566b5fec21281c45b9..a3db45d411772d71ba46632633e935f2 // Paper - optimise chunk tick iteration diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index c9e578cd3d941fa343cc957805df882b51e0761f..bb5833265661bfdef0808745c65ec04cc9240519 100644 +index 84472442e0e68c22c4ebeaaf980aee1e8a234d81..38fcba055839fc1b5522e8a88bdaa63d6f24780d 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java -@@ -968,6 +968,13 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -974,6 +974,13 @@ public class ServerLevel extends Level implements WorldGenLevel { // private final io.papermc.paper.util.math.ThreadUnsafeRandom randomTickRandom = new io.papermc.paper.util.math.ThreadUnsafeRandom(this.random.nextLong()); // Leaves - moved to super // Paper end @@ -39,20 +39,20 @@ index c9e578cd3d941fa343cc957805df882b51e0761f..bb5833265661bfdef0808745c65ec04c public void tickChunk(LevelChunk chunk, int randomTickSpeed) { ChunkPos chunkcoordintpair = chunk.getPos(); boolean flag = this.isRaining(); -@@ -978,7 +985,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -984,7 +991,7 @@ public class ServerLevel extends Level implements WorldGenLevel { gameprofilerfiller.push("thunder"); final BlockPos.MutableBlockPos blockposition = this.chunkTickMutablePosition; // Paper - use mutable to reduce allocation rate, final to force compile fail on change - if (!this.paperConfig().environment.disableThunder && flag && this.isThundering() && this.spigotConfig.thunderChance > 0 && this.random.nextInt(this.spigotConfig.thunderChance) == 0) { // Spigot // Paper - Option to disable thunder -+ if (!this.paperConfig().environment.disableThunder && flag && this.isThundering() && this.spigotConfig.thunderChance > 0 && (top.leavesmc.leaves.LeavesConfig.optimizeChunkTicking ? chunk.shouldDoLightning(this.random) : this.random.nextInt(this.spigotConfig.thunderChance) == 0)) { // Spigot // Paper - Option to disable thunder // Leaves - replace random with shouldDoLightning ++ if (!this.paperConfig().environment.disableThunder && flag && this.isThundering() && this.spigotConfig.thunderChance > 0 && (org.leavesmc.leaves.LeavesConfig.optimizeChunkTicking ? chunk.shouldDoLightning(this.random) : this.random.nextInt(this.spigotConfig.thunderChance) == 0)) { // Spigot // Paper - Option to disable thunder // Leaves - replace random with shouldDoLightning blockposition.set(this.findLightningTargetAround(this.getBlockRandomPos(j, 0, k, 15))); // Paper if (this.isRainingAt(blockposition)) { 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 44b9aaa534a4683b2924a2aa61a92218f9c846b3..ae746ebde8ba2aded37bc1c9b3c4acdfd5f9def0 100644 +index 96490c90697ad42565c465a5ed1d956fc1c73f73..8b4f58dae2dba4c661dbd3de0ef65cdbf3bb861e 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 { +@@ -88,6 +88,18 @@ public class LevelChunk extends ChunkAccess { private final LevelChunkTicks fluidTicks; public volatile FullChunkStatus chunkStatus = FullChunkStatus.INACCESSIBLE; // Paper - rewrite chunk system @@ -71,13 +71,13 @@ index 44b9aaa534a4683b2924a2aa61a92218f9c846b3..ae746ebde8ba2aded37bc1c9b3c4acdf public LevelChunk(Level world, ChunkPos pos) { this(world, pos, UpgradeData.EMPTY, new LevelChunkTicks<>(), new LevelChunkTicks<>(), 0L, (LevelChunkSection[]) null, (LevelChunk.PostLoadProcessor) null, (BlendingData) null); } -@@ -109,6 +121,12 @@ public class LevelChunk extends ChunkAccess { +@@ -111,6 +123,12 @@ public class LevelChunk extends ChunkAccess { this.postLoad = entityLoader; this.blockTicks = blockTickScheduler; this.fluidTicks = fluidTickScheduler; + + // Leaves start - initialize lightning tick -+ if (top.leavesmc.leaves.LeavesConfig.optimizeChunkTicking) { ++ if (org.leavesmc.leaves.LeavesConfig.optimizeChunkTicking) { + this.lightningTick = this.level.getThreadUnsafeRandom().nextInt(100000) << 1; + } + // Leaves end - initialize lightning tick diff --git a/patches/server/0025-Early-return-optimization-for-target-finding.patch b/patches/server/0026-Early-return-optimization-for-target-finding.patch similarity index 92% rename from patches/server/0025-Early-return-optimization-for-target-finding.patch rename to patches/server/0026-Early-return-optimization-for-target-finding.patch index e149286f..5a269647 100644 --- a/patches/server/0025-Early-return-optimization-for-target-finding.patch +++ b/patches/server/0026-Early-return-optimization-for-target-finding.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Early return optimization for target finding This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish) 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 d2f0c3b26d4beedb49d86e0242d843590d469d02..a7f78a2c611fc79fd3a1d221be1ec54992d463c1 100644 +index d2f0c3b26d4beedb49d86e0242d843590d469d02..0f06374f81f8cc727955c661626dac33d7f7b210 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 @@ -76,9 +76,17 @@ public class TargetingConditions { @@ -15,7 +15,7 @@ index d2f0c3b26d4beedb49d86e0242d843590d469d02..a7f78a2c611fc79fd3a1d221be1ec549 if (this.range > 0.0) { + // Leaves start - check range before getting visibility + double f = baseEntity.distanceToSqr(targetEntity.getX(), targetEntity.getY(), targetEntity.getZ()); -+ if (top.leavesmc.leaves.LeavesConfig.entityTargetFindingOptimization) { ++ if (org.leavesmc.leaves.LeavesConfig.entityTargetFindingOptimization) { + double followRangeRaw = this.useFollowRange ? this.getFollowRange(baseEntity) : 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 + return false; diff --git a/patches/server/0026-Use-thread-unsafe-random-for-mob-spawning.patch b/patches/server/0027-Use-thread-unsafe-random-for-mob-spawning.patch similarity index 90% rename from patches/server/0026-Use-thread-unsafe-random-for-mob-spawning.patch rename to patches/server/0027-Use-thread-unsafe-random-for-mob-spawning.patch index 42db9fb8..e8d2f211 100644 --- a/patches/server/0026-Use-thread-unsafe-random-for-mob-spawning.patch +++ b/patches/server/0027-Use-thread-unsafe-random-for-mob-spawning.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Use thread unsafe random for mob spawning This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish) diff --git a/src/main/java/net/minecraft/world/level/NaturalSpawner.java b/src/main/java/net/minecraft/world/level/NaturalSpawner.java -index 140c9e6c7bd5e2e52c586ab6954edbc790e6e02b..93fbf20c6e5ded31570415c30b837f5dc0dd5d42 100644 +index 189a6bd4967aba72e12170e091dbb5b779e752a0..9c72271382fa0b6be5f38b45577fb1ae81ce80a3 100644 --- a/src/main/java/net/minecraft/world/level/NaturalSpawner.java +++ b/src/main/java/net/minecraft/world/level/NaturalSpawner.java -@@ -425,12 +425,21 @@ public final class NaturalSpawner { +@@ -408,12 +408,21 @@ public final class NaturalSpawner { private static BlockPos getRandomPosWithin(Level world, LevelChunk chunk) { ChunkPos chunkcoordintpair = chunk.getPos(); @@ -20,7 +20,7 @@ index 140c9e6c7bd5e2e52c586ab6954edbc790e6e02b..93fbf20c6e5ded31570415c30b837f5d - - return new BlockPos(i, l, j); + // Leaves start - use thread unsafe random -+ if (top.leavesmc.leaves.LeavesConfig.useMoreThreadUnsafeRandom) { ++ if (org.leavesmc.leaves.LeavesConfig.useMoreThreadUnsafeRandom) { + int i = chunkcoordintpair.getMinBlockX() + world.getThreadUnsafeRandom().nextInt(16); + int j = chunkcoordintpair.getMinBlockZ() + world.getThreadUnsafeRandom().nextInt(16); + int k = chunk.getHeight(Heightmap.Types.WORLD_SURFACE, i, j) + 1; diff --git a/patches/server/0027-Config-to-disable-method-profiler.patch b/patches/server/0028-Config-to-disable-method-profiler.patch similarity index 76% rename from patches/server/0027-Config-to-disable-method-profiler.patch rename to patches/server/0028-Config-to-disable-method-profiler.patch index 5a4c19ad..bd95715c 100644 --- a/patches/server/0027-Config-to-disable-method-profiler.patch +++ b/patches/server/0028-Config-to-disable-method-profiler.patch @@ -6,15 +6,15 @@ Subject: [PATCH] Config to disable method profiler This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish) diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 76a9548becd0a1aeb8889f1e4060a2ac0f546682..e7ce8db1391f96ee648f72b0c8680a24569de334 100644 +index d8ac4b133c52c46494518a93884f715108dc8f17..35a67136f5e22c5f9b65841fb7c10309e0b0e1c2 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -2427,6 +2427,11 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop attributes = Maps.newHashMap(); - private final Set dirtyAttributes = Sets.newHashSet(); +@@ -22,9 +22,11 @@ public class AttributeMap { + private final Map, AttributeInstance> attributes = new Object2ObjectOpenHashMap<>(); + private final Set dirtyAttributes = new ObjectOpenHashSet<>(); private final AttributeSupplier supplier; -+ private final java.util.function.Function createInstance; // Leaves - reduce entity allocations ++ private final java.util.function.Function, AttributeInstance> createInstance; // Leaves - reduce entity allocations public AttributeMap(AttributeSupplier defaultAttributes) { this.supplier = defaultAttributes; @@ -21,13 +21,13 @@ index b99a080ab27e24d8131fda931ca70d6d271bb01c..a2a1de65dfd420185ed0e52e28c7000f } private void onAttributeModified(AttributeInstance instance) { -@@ -44,7 +46,13 @@ public class AttributeMap { +@@ -43,7 +45,13 @@ public class AttributeMap { @Nullable - public AttributeInstance getInstance(Attribute attribute) { + public AttributeInstance getInstance(Holder attribute) { - return this.attributes.computeIfAbsent(attribute, attributex -> this.supplier.createInstance(this::onAttributeModified, attributex)); + // Leaves start - cache lambda, as for some reason java allocates it anyways -+ if (top.leavesmc.leaves.LeavesConfig.reduceEntityAllocations) { ++ if (org.leavesmc.leaves.LeavesConfig.reduceEntityAllocations) { + return this.attributes.computeIfAbsent(attribute, this.createInstance); + } else { + return this.attributes.computeIfAbsent(attribute, attributex -> this.supplier.createInstance(this::onAttributeModified, attributex)); @@ -35,4 +35,4 @@ index b99a080ab27e24d8131fda931ca70d6d271bb01c..a2a1de65dfd420185ed0e52e28c7000f + // Leaves end - cache lambda, as for some reason java allocates it anyways } - @Nullable + public boolean hasAttribute(Holder attribute) { diff --git a/patches/server/0030-Remove-lambda-from-ticking-guard.patch b/patches/server/0031-Remove-lambda-from-ticking-guard.patch similarity index 91% rename from patches/server/0030-Remove-lambda-from-ticking-guard.patch rename to patches/server/0031-Remove-lambda-from-ticking-guard.patch index 7ac1bc2d..7d593f41 100644 --- a/patches/server/0030-Remove-lambda-from-ticking-guard.patch +++ b/patches/server/0031-Remove-lambda-from-ticking-guard.patch @@ -6,16 +6,16 @@ Subject: [PATCH] Remove lambda from ticking guard This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish) diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index bb5833265661bfdef0808745c65ec04cc9240519..be185196d2d4ce1f1dd90da8a46b014127e591a0 100644 +index 38fcba055839fc1b5522e8a88bdaa63d6f24780d..63652c3011c48c461c1b5be1889847b2f065e34c 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java -@@ -902,7 +902,24 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -908,7 +908,24 @@ public class ServerLevel extends Level implements WorldGenLevel { } gameprofilerfiller.push("tick"); - this.guardEntityTick(this::tickNonPassenger, entity); + // Leaves start - copied from this.guardEntityTick -+ if (top.leavesmc.leaves.LeavesConfig.removeTickGuardLambda) { ++ if (org.leavesmc.leaves.LeavesConfig.removeTickGuardLambda) { + try { + this.tickNonPassenger(entity); // Leaves - changed + MinecraftServer.getServer().executeMidTickTasks(); // Tuinity - execute chunk tasks mid tick diff --git a/patches/server/0031-Remove-iterators-from-inventory-contains.patch b/patches/server/0032-Remove-iterators-from-inventory-contains.patch similarity index 66% rename from patches/server/0031-Remove-iterators-from-inventory-contains.patch rename to patches/server/0032-Remove-iterators-from-inventory-contains.patch index 89417a65..020f6cc4 100644 --- a/patches/server/0031-Remove-iterators-from-inventory-contains.patch +++ b/patches/server/0032-Remove-iterators-from-inventory-contains.patch @@ -6,22 +6,42 @@ Subject: [PATCH] Remove iterators from inventory contains This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish) diff --git a/src/main/java/net/minecraft/world/entity/player/Inventory.java b/src/main/java/net/minecraft/world/entity/player/Inventory.java -index 309acf7bd07e38043aa81e0e686edba1136bd04c..d2f6027056af9d2816542f4e3d9e278d9ec2c9b4 100644 +index ca7fbe4f8c1e1d2fb90095aa35be4dda3029c23e..3c8f35f92ed7e9518d676087f82d1e4da963b779 100644 --- a/src/main/java/net/minecraft/world/entity/player/Inventory.java +++ b/src/main/java/net/minecraft/world/entity/player/Inventory.java -@@ -687,21 +687,35 @@ public class Inventory implements Container, Nameable { +@@ -1,9 +1,11 @@ + package net.minecraft.world.entity.player; + + import com.google.common.collect.ImmutableList; ++ + import java.util.Iterator; + import java.util.List; + import java.util.function.Predicate; ++ + import net.minecraft.CrashReport; + import net.minecraft.CrashReportCategory; + import net.minecraft.ReportedException; +@@ -24,6 +26,7 @@ import net.minecraft.world.item.ItemStack; + import net.minecraft.world.level.block.state.BlockState; + // CraftBukkit start + import java.util.ArrayList; ++ + import org.bukkit.Location; + import org.bukkit.craftbukkit.entity.CraftHumanEntity; + import org.bukkit.entity.HumanEntity; +@@ -643,17 +646,31 @@ public class Inventory implements Container, Nameable { } public boolean contains(ItemStack stack) { - Iterator iterator = this.compartments.iterator(); + // Leaves start - don't allocate iterators -+ if (top.leavesmc.leaves.LeavesConfig.removeInventoryContainsIterators) { ++ if (org.leavesmc.leaves.LeavesConfig.removeInventoryContainsIterators) { + for (int i = 0; i < this.compartments.size(); i++) { + List list = this.compartments.get(i); + for (int j = 0; j < list.size(); j++) { + ItemStack itemstack1 = list.get(j); + -+ if (!itemstack1.isEmpty() && ItemStack.isSameItemSameTags(itemstack1, stack)) { ++ if (!itemstack1.isEmpty() && ItemStack.isSameItemSameComponents(itemstack1, stack)) { + return true; + } + } @@ -41,14 +61,18 @@ index 309acf7bd07e38043aa81e0e686edba1136bd04c..d2f6027056af9d2816542f4e3d9e278d + while (iterator1.hasNext()) { + ItemStack itemstack1 = (ItemStack) iterator1.next(); -- if (!itemstack1.isEmpty() && ItemStack.isSameItemSameTags(itemstack1, stack)) { +- if (!itemstack1.isEmpty() && ItemStack.isSameItemSameComponents(itemstack1, stack)) { - return true; -+ if (!itemstack1.isEmpty() && ItemStack.isSameItemSameTags(itemstack1, stack)) { ++ if (!itemstack1.isEmpty() && ItemStack.isSameItemSameComponents(itemstack1, stack)) { + return true; + } } } } +@@ -695,7 +712,7 @@ public class Inventory implements Container, Nameable { + } + } + } - + // Leaves end - don't allocate iterators return false; diff --git a/patches/server/0032-Remove-streams-and-iterators-from-range-check.patch b/patches/server/0033-Remove-streams-and-iterators-from-range-check.patch similarity index 92% rename from patches/server/0032-Remove-streams-and-iterators-from-range-check.patch rename to patches/server/0033-Remove-streams-and-iterators-from-range-check.patch index c7fca1cc..a260babe 100644 --- a/patches/server/0032-Remove-streams-and-iterators-from-range-check.patch +++ b/patches/server/0033-Remove-streams-and-iterators-from-range-check.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Remove streams and iterators from range check This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish) diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java -index 85be9376fe30f18fe4fea437955f1a60c5c3f05a..c32002aca09ec20aadfe71c2626672e75255a31a 100644 +index d1a42800e069fa89d3f3fb4dcb9948d1ac3ea577..da65f980f2145ea03341911ce75f7e61b358c9d7 100644 --- a/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java -@@ -1423,19 +1423,45 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1451,19 +1451,45 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider return ChunkMap.this.level.getServer().getScaledTrackingDistance(initialDistance); } @@ -37,7 +37,7 @@ index 85be9376fe30f18fe4fea437955f1a60c5c3f05a..c32002aca09ec20aadfe71c2626672e7 int i = this.range; - Iterator iterator = this.entity.getIndirectPassengers().iterator(); + // Leaves start - remove iterators and streams -+ if (top.leavesmc.leaves.LeavesConfig.removeRangeCheckStreams) { ++ if (org.leavesmc.leaves.LeavesConfig.removeRangeCheckStreams) { + i = getHighestRange(this.entity, i); + } else { + Iterator iterator = this.entity.getIndirectPassengers().iterator(); diff --git a/patches/server/0033-Cache-climbing-check-for-activation.patch b/patches/server/0034-Cache-climbing-check-for-activation.patch similarity index 90% rename from patches/server/0033-Cache-climbing-check-for-activation.patch rename to patches/server/0034-Cache-climbing-check-for-activation.patch index 104ce9e0..5a523e83 100644 --- a/patches/server/0033-Cache-climbing-check-for-activation.patch +++ b/patches/server/0034-Cache-climbing-check-for-activation.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Cache climbing check for activation This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish) diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index d5c676c629be25c4400c60a22125715827e9cf81..15c8e9214b7df1cf1e9252a17b7acfc080e547a3 100644 +index 9755d85c090d336364f041d32f11ea7c5041945e..8e5bfb7579b528d68b270665c02588bfa39643a3 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -2032,6 +2032,22 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -2058,6 +2058,22 @@ public abstract class LivingEntity extends Entity implements Attackable { return this.lastClimbablePos; } @@ -18,7 +18,7 @@ index d5c676c629be25c4400c60a22125715827e9cf81..15c8e9214b7df1cf1e9252a17b7acfc0 + private BlockPos lastClimbingPosition = null; + + public boolean onClimableCached() { -+ if (!top.leavesmc.leaves.LeavesConfig.cacheClimbCheck) { ++ if (!org.leavesmc.leaves.LeavesConfig.cacheClimbCheck) { + return this.onClimbable(); + } + if (!this.blockPosition().equals(this.lastClimbingPosition)) { diff --git a/patches/server/0034-Use-aging-cache-for-biome-temperatures.patch b/patches/server/0035-Use-aging-cache-for-biome-temperatures.patch similarity index 92% rename from patches/server/0034-Use-aging-cache-for-biome-temperatures.patch rename to patches/server/0035-Use-aging-cache-for-biome-temperatures.patch index 8d556fa2..53f5f75f 100644 --- a/patches/server/0034-Use-aging-cache-for-biome-temperatures.patch +++ b/patches/server/0035-Use-aging-cache-for-biome-temperatures.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Use aging cache for biome temperatures This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish) diff --git a/src/main/java/net/minecraft/world/level/biome/Biome.java b/src/main/java/net/minecraft/world/level/biome/Biome.java -index 64076a452a315090d299a7a58a43fd3b5c1b4e0a..0071e220624d636aec5f1477b8338c4d6b4f8918 100644 +index 15f82c9a1ce1fef2e951d1b3c7a65e64b82061ea..0e318fd031ddb2ec95fe9479f7ad6b28171d1797 100644 --- a/src/main/java/net/minecraft/world/level/biome/Biome.java +++ b/src/main/java/net/minecraft/world/level/biome/Biome.java @@ -63,7 +63,17 @@ public final class Biome { @@ -16,7 +16,7 @@ index 64076a452a315090d299a7a58a43fd3b5c1b4e0a..0071e220624d636aec5f1477b8338c4d - private final ThreadLocal temperatureCache = ThreadLocal.withInitial(() -> Util.make(() -> { + // Leaves start - use our cache + private final ThreadLocal temperatureCache; -+ private final ThreadLocal temperatureAgingCache; ++ private final ThreadLocal temperatureAgingCache; + + Biome(Biome.ClimateSettings weather, BiomeSpecialEffects effects, BiomeGenerationSettings generationSettings, MobSpawnSettings spawnSettings) { + this.climateSettings = weather; @@ -40,7 +40,7 @@ index 64076a452a315090d299a7a58a43fd3b5c1b4e0a..0071e220624d636aec5f1477b8338c4d - this.specialEffects = effects; + temperatureAgingCache = ThreadLocal.withInitial(() -> { + return Util.make(() -> { -+ return new top.leavesmc.leaves.structs.Long2FloatAgingCache(TEMPERATURE_CACHE_SIZE); ++ return new org.leavesmc.leaves.structs.Long2FloatAgingCache(TEMPERATURE_CACHE_SIZE); + }); + }); } @@ -57,8 +57,8 @@ index 64076a452a315090d299a7a58a43fd3b5c1b4e0a..0071e220624d636aec5f1477b8338c4d - if (!Float.isNaN(f)) { - return f; + // Leaves start - use our cache -+ if (top.leavesmc.leaves.LeavesConfig.biomeTemperaturesUseAgingCache) { -+ top.leavesmc.leaves.structs.Long2FloatAgingCache cache = this.temperatureAgingCache.get(); ++ if (org.leavesmc.leaves.LeavesConfig.biomeTemperaturesUseAgingCache) { ++ org.leavesmc.leaves.structs.Long2FloatAgingCache cache = this.temperatureAgingCache.get(); + float f = cache.getValue(l); + if (!Float.isNaN(f)) { + return f; @@ -91,13 +91,13 @@ index 64076a452a315090d299a7a58a43fd3b5c1b4e0a..0071e220624d636aec5f1477b8338c4d } public boolean shouldFreeze(LevelReader world, BlockPos blockPos) { -diff --git a/src/main/java/top/leavesmc/leaves/structs/Long2FloatAgingCache.java b/src/main/java/top/leavesmc/leaves/structs/Long2FloatAgingCache.java +diff --git a/src/main/java/org/leavesmc/leaves/structs/Long2FloatAgingCache.java b/src/main/java/org/leavesmc/leaves/structs/Long2FloatAgingCache.java new file mode 100644 -index 0000000000000000000000000000000000000000..26f9d4d9099739d6ddc159184a20e2ae9abde5cd +index 0000000000000000000000000000000000000000..cd8b1bbfe553c28b75ea92d344364650756e9fdd --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/structs/Long2FloatAgingCache.java ++++ b/src/main/java/org/leavesmc/leaves/structs/Long2FloatAgingCache.java @@ -0,0 +1,121 @@ -+package top.leavesmc.leaves.structs; ++package org.leavesmc.leaves.structs; + +import it.unimi.dsi.fastutil.HashCommon; + diff --git a/patches/server/0035-Reduce-entity-fluid-lookups-if-no-fluids.patch b/patches/server/0036-Reduce-entity-fluid-lookups-if-no-fluids.patch similarity index 95% rename from patches/server/0035-Reduce-entity-fluid-lookups-if-no-fluids.patch rename to patches/server/0036-Reduce-entity-fluid-lookups-if-no-fluids.patch index 452e636d..5d4ea302 100644 --- a/patches/server/0035-Reduce-entity-fluid-lookups-if-no-fluids.patch +++ b/patches/server/0036-Reduce-entity-fluid-lookups-if-no-fluids.patch @@ -6,15 +6,15 @@ Subject: [PATCH] Reduce entity fluid lookups if no fluids This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish) diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 68a8aca051df609747b25ef89e5217932edbec51..f491c1d402499e68191d4cdc9c8ef2e7caae9c7b 100644 +index e87a60ca43fe080209620e11833099e7ea9164b5..bf8e3d510631e418eb6d2e641b51a1220bee2d7d 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -4430,16 +4430,18 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -4487,16 +4487,18 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess } public boolean updateFluidHeightAndDoFluidPushing(TagKey tag, double speed) { - if (this.touchingUnloadedChunk()) { -+ if (!top.leavesmc.leaves.LeavesConfig.reduceEntityFluidLookup && this.touchingUnloadedChunk()) { // Leaves - cost of a lookup here is the same cost as below, so skip ++ if (!org.leavesmc.leaves.LeavesConfig.reduceEntityFluidLookup && this.touchingUnloadedChunk()) { // Leaves - cost of a lookup here is the same cost as below, so skip return false; } else { AABB axisalignedbb = this.getBoundingBox().deflate(0.001D); @@ -35,7 +35,7 @@ index 68a8aca051df609747b25ef89e5217932edbec51..f491c1d402499e68191d4cdc9c8ef2e7 double d1 = 0.0D; boolean flag = this.isPushedByFluid(); boolean flag1 = false; -@@ -4447,38 +4449,123 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -4504,38 +4506,123 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess int k1 = 0; BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos(); @@ -45,7 +45,7 @@ index 68a8aca051df609747b25ef89e5217932edbec51..f491c1d402499e68191d4cdc9c8ef2e7 - blockposition_mutableblockposition.set(l1, i2, j2); - FluidState fluid = this.level().getFluidState(blockposition_mutableblockposition); + // Leaves start - based off CollisionUtil.getCollisionsForBlocksOrWorldBorder -+ if (top.leavesmc.leaves.LeavesConfig.reduceEntityFluidLookup) { ++ if (org.leavesmc.leaves.LeavesConfig.reduceEntityFluidLookup) { + final int minSection = io.papermc.paper.util.WorldUtil.getMinSection(this.level); + final int maxSection = io.papermc.paper.util.WorldUtil.getMaxSection(this.level); + final int minBlock = minSection << 4; @@ -181,7 +181,7 @@ index 68a8aca051df609747b25ef89e5217932edbec51..f491c1d402499e68191d4cdc9c8ef2e7 if (vec3d.length() > 0.0D) { if (k1 > 0) { diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java -index 796bbef3544e06b8e7aac7e8ac5f740a2613f4bd..e4701dd6e023331c9138549cdeece5c0a270877d 100644 +index a2a5aef769ee8bb638a5a9f3da9812fa4a85dda5..73b0bd67b5d3506383df3be065375c9370cff570 100644 --- a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java +++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java @@ -25,6 +25,7 @@ public class LevelChunkSection { diff --git a/patches/server/0036-Reduce-chunk-loading-lookups.patch b/patches/server/0037-Reduce-chunk-loading-lookups.patch similarity index 91% rename from patches/server/0036-Reduce-chunk-loading-lookups.patch rename to patches/server/0037-Reduce-chunk-loading-lookups.patch index af141d1e..bd56adf5 100644 --- a/patches/server/0036-Reduce-chunk-loading-lookups.patch +++ b/patches/server/0037-Reduce-chunk-loading-lookups.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Reduce chunk loading & lookups This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish) 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 f33c03e81b7ff643741f56eea055e6af260de618..9ea374d9baf1612898b67f329e6b5c798ad43b3e 100644 +index 260202fab3ac300552c557b44dcf251f083c6a78..215176eb7152c11c4934c8576ac8c9fa9b2d0833 100644 --- a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java +++ b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java -@@ -333,11 +333,28 @@ public class EnderMan extends Monster implements NeutralMob { +@@ -318,11 +318,28 @@ 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); @@ -17,7 +17,7 @@ index f33c03e81b7ff643741f56eea055e6af260de618..9ea374d9baf1612898b67f329e6b5c79 - blockposition_mutableblockposition.move(Direction.DOWN); + // Leaves start - single chunk lookup + BlockState iblockdata; -+ if (top.leavesmc.leaves.LeavesConfig.reduceChuckLoadAndLookup) { ++ if (org.leavesmc.leaves.LeavesConfig.reduceChuckLoadAndLookup) { + net.minecraft.world.level.chunk.LevelChunk chunk = this.level().getChunkIfLoaded(blockposition_mutableblockposition); + if (chunk == null) { + return false; diff --git a/patches/server/0038-Placeholder-of-PCA-sync-protocol.patch b/patches/server/0038-Placeholder-of-PCA-sync-protocol.patch new file mode 100644 index 00000000..222ec8fe --- /dev/null +++ b/patches/server/0038-Placeholder-of-PCA-sync-protocol.patch @@ -0,0 +1,15 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: MC_XiaoHei +Date: Tue, 7 May 2024 23:46:15 +0800 +Subject: [PATCH] Placeholder of PCA-sync-protocol + + +diff --git a/.gitignore b/.gitignore +index 3811c0d849a3eb028ed1a6b7a2d4747f7f570448..1ad93453221244f880855b510e888e759275b640 100644 +--- a/.gitignore ++++ b/.gitignore +@@ -46,3 +46,4 @@ dependency-reduced-pom.xml + # vs code + /.vscode + /.factorypath ++ diff --git a/patches/server/0039-Placeholder-of-BBOR-Protocol.patch b/patches/server/0039-Placeholder-of-BBOR-Protocol.patch new file mode 100644 index 00000000..f756ecfe --- /dev/null +++ b/patches/server/0039-Placeholder-of-BBOR-Protocol.patch @@ -0,0 +1,15 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: MC_XiaoHei +Date: Tue, 7 May 2024 23:49:41 +0800 +Subject: [PATCH] Placeholder of BBOR-Protocol + + +diff --git a/.gitignore b/.gitignore +index 1ad93453221244f880855b510e888e759275b640..3811c0d849a3eb028ed1a6b7a2d4747f7f570448 100644 +--- a/.gitignore ++++ b/.gitignore +@@ -46,4 +46,3 @@ dependency-reduced-pom.xml + # vs code + /.vscode + /.factorypath +- diff --git a/patches/server/0039-InstantBlockUpdater-Reintroduced.patch b/patches/server/0040-InstantBlockUpdater-Reintroduced.patch similarity index 82% rename from patches/server/0039-InstantBlockUpdater-Reintroduced.patch rename to patches/server/0040-InstantBlockUpdater-Reintroduced.patch index 5f61d099..91308a05 100644 --- a/patches/server/0039-InstantBlockUpdater-Reintroduced.patch +++ b/patches/server/0040-InstantBlockUpdater-Reintroduced.patch @@ -6,24 +6,24 @@ Subject: [PATCH] InstantBlockUpdater Reintroduced This patch is Powered by Carpet-TIS-Addition(https://github.com/plusls/Carpet-TIS-Addition) diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index 34b6e04c2bfb3a44980906e786c260e066ad4020..6071b5463073cb250579ee66d2312b61cef34605 100644 +index 68d065ff98141176e0c4ed43ea4d7a3531fa62da..c04e07fa16d701d814a2df82758d4339e3b4e5f1 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -68,6 +68,7 @@ import net.minecraft.world.level.lighting.LevelLightEngine; +@@ -73,6 +73,7 @@ import net.minecraft.world.level.lighting.LevelLightEngine; import net.minecraft.world.level.material.FluidState; import net.minecraft.world.level.material.Fluids; import net.minecraft.world.level.redstone.CollectingNeighborUpdater; +import net.minecraft.world.level.redstone.InstantNeighborUpdater; import net.minecraft.world.level.redstone.NeighborUpdater; + import net.minecraft.world.level.saveddata.maps.MapId; import net.minecraft.world.level.saveddata.maps.MapItemSavedData; - import net.minecraft.world.level.storage.LevelData; -@@ -253,7 +254,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -254,7 +255,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable { this.thread = Thread.currentThread(); this.biomeManager = new BiomeManager(this, i); this.isDebug = flag1; - this.neighborUpdater = new CollectingNeighborUpdater(this, j); + // Leaves start - instantBlockUpdaterReintroduced -+ if (top.leavesmc.leaves.LeavesConfig.instantBlockUpdaterReintroduced) { ++ if (org.leavesmc.leaves.LeavesConfig.instantBlockUpdaterReintroduced) { + this.neighborUpdater = new InstantNeighborUpdater(this); + } else { + this.neighborUpdater = new CollectingNeighborUpdater(this, j); diff --git a/patches/server/0040-Random-flatten-triangular-distribution.patch b/patches/server/0041-Random-flatten-triangular-distribution.patch similarity index 87% rename from patches/server/0040-Random-flatten-triangular-distribution.patch rename to patches/server/0041-Random-flatten-triangular-distribution.patch index 85c47d1a..e6d51c9b 100644 --- a/patches/server/0040-Random-flatten-triangular-distribution.patch +++ b/patches/server/0041-Random-flatten-triangular-distribution.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Random flatten triangular distribution This patch is Powered by Carpet-TIS-Addition(https://github.com/plusls/Carpet-TIS-Addition) diff --git a/src/main/java/net/minecraft/util/RandomSource.java b/src/main/java/net/minecraft/util/RandomSource.java -index 9c6f5b55b1f1376fa75e216cd366ee47c79fafc4..35d90a4f3ec07844a444dbbc99b81f417ded2dd5 100644 +index 9c6f5b55b1f1376fa75e216cd366ee47c79fafc4..50dc6530e6191f2a00025d4610e335041bc858a4 100644 --- a/src/main/java/net/minecraft/util/RandomSource.java +++ b/src/main/java/net/minecraft/util/RandomSource.java @@ -53,7 +53,14 @@ public interface RandomSource { @@ -15,7 +15,7 @@ index 9c6f5b55b1f1376fa75e216cd366ee47c79fafc4..35d90a4f3ec07844a444dbbc99b81f41 default double triangle(double mode, double deviation) { - return mode + deviation * (this.nextDouble() - this.nextDouble()); + // Leaves start - flattenTriangularDistribution -+ if (top.leavesmc.leaves.LeavesConfig.flattenTriangularDistribution) { ++ if (org.leavesmc.leaves.LeavesConfig.flattenTriangularDistribution) { + this.nextDouble(); + return mode + deviation * (-1 + this.nextDouble() * 2); + } else { diff --git a/patches/server/0042-Placeholder-of-Jade-Protocol.patch b/patches/server/0042-Placeholder-of-Jade-Protocol.patch new file mode 100644 index 00000000..31ec5cc2 --- /dev/null +++ b/patches/server/0042-Placeholder-of-Jade-Protocol.patch @@ -0,0 +1,15 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: MC_XiaoHei +Date: Tue, 7 May 2024 23:52:04 +0800 +Subject: [PATCH] Placeholder of Jade-Protocol + + +diff --git a/.gitignore b/.gitignore +index 3811c0d849a3eb028ed1a6b7a2d4747f7f570448..1ad93453221244f880855b510e888e759275b640 100644 +--- a/.gitignore ++++ b/.gitignore +@@ -46,3 +46,4 @@ dependency-reduced-pom.xml + # vs code + /.vscode + /.factorypath ++ diff --git a/patches/server/0042-Alternative-block-placement-Protocol.patch b/patches/server/0043-Alternative-block-placement-Protocol.patch similarity index 91% rename from patches/server/0042-Alternative-block-placement-Protocol.patch rename to patches/server/0043-Alternative-block-placement-Protocol.patch index b0f920fa..2325d262 100644 --- a/patches/server/0042-Alternative-block-placement-Protocol.patch +++ b/patches/server/0043-Alternative-block-placement-Protocol.patch @@ -8,11 +8,20 @@ carpet-extra(https://github.com/gnembon/carpet-extra) MasaGadget(https://github.com/plusls/MasaGadget) litematica(https://github.com/maruohon/litematica) +diff --git a/.gitignore b/.gitignore +index 1ad93453221244f880855b510e888e759275b640..3811c0d849a3eb028ed1a6b7a2d4747f7f570448 100644 +--- a/.gitignore ++++ b/.gitignore +@@ -46,4 +46,3 @@ dependency-reduced-pom.xml + # vs code + /.vscode + /.factorypath +- diff --git a/src/main/java/net/minecraft/world/item/BlockItem.java b/src/main/java/net/minecraft/world/item/BlockItem.java -index 8d2c0accadaf0c5d28e7db6e62a05f6c619cf02f..d5e7cc59314b2f16d7665bc0ad8cea576f1f1235 100644 +index 96fb69ec6db2e7c8c728435f0c537b076259b2fb..7632d5ac83c84e943654477b3f36e6605e28c9a7 100644 --- a/src/main/java/net/minecraft/world/item/BlockItem.java +++ b/src/main/java/net/minecraft/world/item/BlockItem.java -@@ -157,7 +157,7 @@ public class BlockItem extends Item { +@@ -162,7 +162,7 @@ public class BlockItem extends Item { @Nullable protected BlockState getPlacementState(BlockPlaceContext context) { @@ -44,10 +53,10 @@ index f8f909ebdad5e96379e8bd8c610164ef0697368e..0b761f3ae15ad4a3b8152f497a604032 if (iblockdata2 != null && this.canPlace(world, iblockdata2, blockposition)) { iblockdata1 = iblockdata2; 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 ee6cb4042421a74095473360126f6d083513934b..feab3cc5724a1fc44374a30c75dca9e3a3721adc 100644 +index e27f2317e4e2f13b6ef12be727046497a750fd3a..41f1a7bf2fb87b6d28d2ca392dfee5d5032d2151 100644 --- a/src/main/java/net/minecraft/world/level/block/Block.java +++ b/src/main/java/net/minecraft/world/level/block/Block.java -@@ -420,6 +420,33 @@ public class Block extends BlockBehaviour implements ItemLike { +@@ -412,6 +412,33 @@ public class Block extends BlockBehaviour implements ItemLike { public void stepOn(Level world, BlockPos pos, BlockState state, Entity entity) {} @@ -55,22 +64,22 @@ index ee6cb4042421a74095473360126f6d083513934b..feab3cc5724a1fc44374a30c75dca9e3 + @Nullable + public BlockState getRealStateForPlacement(BlockPlaceContext ctx) { + BlockState vanillaState = getStateForPlacement(ctx); -+ switch (top.leavesmc.leaves.LeavesConfig.alternativeBlockPlacement) { ++ switch (org.leavesmc.leaves.LeavesConfig.alternativeBlockPlacement) { + case "CARPET" -> { -+ BlockState tryState = top.leavesmc.leaves.protocol.CarpetAlternativeBlockPlacement.alternativeBlockPlacement(this, ctx); ++ BlockState tryState = org.leavesmc.leaves.protocol.CarpetAlternativeBlockPlacement.alternativeBlockPlacement(this, ctx); + if (tryState != null) { + return tryState; + } + } + case "CARPET_FIX" -> { -+ BlockState tryState = top.leavesmc.leaves.protocol.CarpetAlternativeBlockPlacement.alternativeBlockPlacementFix(this, ctx); ++ BlockState tryState = org.leavesmc.leaves.protocol.CarpetAlternativeBlockPlacement.alternativeBlockPlacementFix(this, ctx); + if (tryState != null) { + return tryState; + } + } + case "LITEMATICA" -> { + if (vanillaState != null) { -+ return top.leavesmc.leaves.protocol.LitematicaEasyPlaceProtocol.applyPlacementProtocol(vanillaState, ctx); ++ return org.leavesmc.leaves.protocol.LitematicaEasyPlaceProtocol.applyPlacementProtocol(vanillaState, ctx); + } + } + } @@ -81,13 +90,13 @@ index ee6cb4042421a74095473360126f6d083513934b..feab3cc5724a1fc44374a30c75dca9e3 @Nullable public BlockState getStateForPlacement(BlockPlaceContext ctx) { return this.defaultBlockState(); -diff --git a/src/main/java/top/leavesmc/leaves/protocol/CarpetAlternativeBlockPlacement.java b/src/main/java/top/leavesmc/leaves/protocol/CarpetAlternativeBlockPlacement.java +diff --git a/src/main/java/org/leavesmc/leaves/protocol/CarpetAlternativeBlockPlacement.java b/src/main/java/org/leavesmc/leaves/protocol/CarpetAlternativeBlockPlacement.java new file mode 100644 -index 0000000000000000000000000000000000000000..dff01bc7495620fecb23d658c4dbd17f96a5819a +index 0000000000000000000000000000000000000000..100356d5b0f62b62e1bcb02ca515225179fc0cc6 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/protocol/CarpetAlternativeBlockPlacement.java ++++ b/src/main/java/org/leavesmc/leaves/protocol/CarpetAlternativeBlockPlacement.java @@ -0,0 +1,161 @@ -+package top.leavesmc.leaves.protocol; ++package org.leavesmc.leaves.protocol; + +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; @@ -248,13 +257,13 @@ index 0000000000000000000000000000000000000000..dff01bc7495620fecb23d658c4dbd17f + return null; + } +} -diff --git a/src/main/java/top/leavesmc/leaves/protocol/LitematicaEasyPlaceProtocol.java b/src/main/java/top/leavesmc/leaves/protocol/LitematicaEasyPlaceProtocol.java +diff --git a/src/main/java/org/leavesmc/leaves/protocol/LitematicaEasyPlaceProtocol.java b/src/main/java/org/leavesmc/leaves/protocol/LitematicaEasyPlaceProtocol.java new file mode 100644 -index 0000000000000000000000000000000000000000..8463318fcad637c409679707b2adf0648ba5a173 +index 0000000000000000000000000000000000000000..7a49e2591e1eabf9d9444d530f631f038a7a47aa --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/protocol/LitematicaEasyPlaceProtocol.java ++++ b/src/main/java/org/leavesmc/leaves/protocol/LitematicaEasyPlaceProtocol.java @@ -0,0 +1,214 @@ -+package top.leavesmc.leaves.protocol; ++package org.leavesmc.leaves.protocol; + +import com.google.common.collect.ImmutableSet; +import net.minecraft.core.BlockPos; @@ -270,8 +279,8 @@ index 0000000000000000000000000000000000000000..8463318fcad637c409679707b2adf064 +import net.minecraft.world.level.block.state.properties.Property; +import net.minecraft.world.level.block.state.properties.SlabType; +import net.minecraft.world.phys.Vec3; -+import top.leavesmc.leaves.LeavesLogger; -+import top.leavesmc.leaves.util.MathUtils; ++import org.leavesmc.leaves.LeavesLogger; ++import org.leavesmc.leaves.util.MathUtils; + +import javax.annotation.Nullable; +import java.util.ArrayList; @@ -468,10 +477,10 @@ index 0000000000000000000000000000000000000000..8463318fcad637c409679707b2adf064 + } + } +} -diff --git a/src/main/java/top/leavesmc/leaves/util/MathUtils.java b/src/main/java/top/leavesmc/leaves/util/MathUtils.java -index 349cd0c0d2d9dc2c9c745ef3469e548a798931ba..0f57d18ee124da23d42abe8cee55a50f4d244615 100644 ---- a/src/main/java/top/leavesmc/leaves/util/MathUtils.java -+++ b/src/main/java/top/leavesmc/leaves/util/MathUtils.java +diff --git a/src/main/java/org/leavesmc/leaves/util/MathUtils.java b/src/main/java/org/leavesmc/leaves/util/MathUtils.java +index 6c42b029d98ed293645f06dde6838761f87f20bb..cd66a5f1b544640de1277cef870a60b53e1a128b 100644 +--- a/src/main/java/org/leavesmc/leaves/util/MathUtils.java ++++ b/src/main/java/org/leavesmc/leaves/util/MathUtils.java @@ -75,4 +75,29 @@ public class MathUtils { return vector; diff --git a/patches/server/0043-Player-operation-limiter.patch b/patches/server/0044-Player-operation-limiter.patch similarity index 85% rename from patches/server/0043-Player-operation-limiter.patch rename to patches/server/0044-Player-operation-limiter.patch index b1410f9d..842dee35 100644 --- a/patches/server/0043-Player-operation-limiter.patch +++ b/patches/server/0044-Player-operation-limiter.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Player operation limiter This patch is Powered by plusls-carpet-addition(https://github.com/plusls/plusls-carpet-addition) diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java -index 6767665e55ca1ec9cf2707918c349fd3ea5ada8a..6c15eb1a368aa41c44521054b95a8a46776d76a4 100644 +index b1a32440f92f54ea86356391ecaa14c676f79eed..1c9c28436645737e8691d5e4dd9a757ab668e458 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java -@@ -282,6 +282,10 @@ public class ServerPlayer extends Player { +@@ -299,6 +299,10 @@ public class ServerPlayer extends Player { public com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper - PlayerNaturallySpawnCreaturesEvent public @Nullable String clientBrandName = null; // Paper - Brand support public org.bukkit.event.player.PlayerQuitEvent.QuitReason quitReason = null; // Paper - Add API for quit reason; there are a lot of changes to do if we change all methods leading to the event @@ -20,7 +20,7 @@ index 6767665e55ca1ec9cf2707918c349fd3ea5ada8a..6c15eb1a368aa41c44521054b95a8a46 // Paper start - replace player chunk loader private final java.util.concurrent.atomic.AtomicReference viewDistances = new java.util.concurrent.atomic.AtomicReference<>(new io.papermc.paper.chunk.system.RegionizedPlayerChunkLoader.ViewDistances(-1, -1, -1)); -@@ -723,6 +727,7 @@ public class ServerPlayer extends Player { +@@ -773,6 +777,7 @@ public class ServerPlayer extends Player { this.joining = false; } // CraftBukkit end @@ -28,7 +28,7 @@ index 6767665e55ca1ec9cf2707918c349fd3ea5ada8a..6c15eb1a368aa41c44521054b95a8a46 this.gameMode.tick(); this.wardenSpawnTracker.tick(); --this.spawnInvulnerableTime; -@@ -2768,5 +2773,32 @@ public class ServerPlayer extends Player { +@@ -2876,5 +2881,32 @@ public class ServerPlayer extends Player { public CraftPlayer getBukkitEntity() { return (CraftPlayer) super.getBukkitEntity(); } @@ -62,23 +62,23 @@ index 6767665e55ca1ec9cf2707918c349fd3ea5ada8a..6c15eb1a368aa41c44521054b95a8a46 // CraftBukkit end } diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java -index a7b217ddbcbf92513bd38101fdfca2075505e267..e4436d3f479246eff4b0ad06d6d24fc12b4e0c90 100644 +index 5cedce1f432f6b809b25269242a16477682c824f..3c729ffe8366e6550cfa03da2d986030fbbff02e 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java -@@ -44,6 +44,7 @@ import org.bukkit.event.Event; +@@ -43,6 +43,7 @@ import org.bukkit.event.Event; import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerGameModeChangeEvent; import org.bukkit.event.player.PlayerInteractEvent; -+import top.leavesmc.leaves.event.player.PlayerOperationLimitEvent; ++import org.leavesmc.leaves.event.player.PlayerOperationLimitEvent; // CraftBukkit end public class ServerPlayerGameMode { -@@ -331,6 +332,19 @@ public class ServerPlayerGameMode { +@@ -334,6 +335,19 @@ public class ServerPlayerGameMode { } public void destroyAndAck(BlockPos pos, int sequence, String reason) { + // Leaves start - player operation limiter -+ if (top.leavesmc.leaves.LeavesConfig.playerOperationLimiter) { ++ if (org.leavesmc.leaves.LeavesConfig.playerOperationLimiter) { + if (reason.equals("insta mine")) { + player.addInstaBreakCountPerTick(); + if (!player.allowOperation()) { @@ -94,28 +94,27 @@ index a7b217ddbcbf92513bd38101fdfca2075505e267..e4436d3f479246eff4b0ad06d6d24fc1 this.debugLogging(pos, true, sequence, reason); } else { diff --git a/src/main/java/net/minecraft/world/item/BlockItem.java b/src/main/java/net/minecraft/world/item/BlockItem.java -index d5e7cc59314b2f16d7665bc0ad8cea576f1f1235..e1ffc1b52641e9cf91f524a83b8c8ee047932d1a 100644 +index 7632d5ac83c84e943654477b3f36e6605e28c9a7..c21a65d9637739f1040dd27b096101a7a7adc0df 100644 --- a/src/main/java/net/minecraft/world/item/BlockItem.java +++ b/src/main/java/net/minecraft/world/item/BlockItem.java -@@ -32,9 +32,12 @@ import net.minecraft.world.level.block.state.StateDefinition; - import net.minecraft.world.level.block.state.properties.Property; +@@ -32,8 +32,11 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.phys.shapes.CollisionContext; -+import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.block.CraftBlock; +import org.bukkit.craftbukkit.block.CraftBlockState; ++import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.block.data.CraftBlockData; import org.bukkit.event.block.BlockCanBuildEvent; -+import top.leavesmc.leaves.event.player.PlayerOperationLimitEvent; ++import org.leavesmc.leaves.event.player.PlayerOperationLimitEvent; // CraftBukkit end public class BlockItem extends Item { -@@ -83,6 +86,20 @@ public class BlockItem extends Item { +@@ -80,6 +83,20 @@ public class BlockItem extends Item { final org.bukkit.block.BlockState oldBlockstate = blockstate != null ? blockstate : org.bukkit.craftbukkit.block.CraftBlockStates.getBlockState(blockactioncontext1.getLevel(), blockactioncontext1.getClickedPos()); // Paper - Reset placed block on exception // CraftBukkit end + // Leaves start - player operation limiter -+ if (top.leavesmc.leaves.LeavesConfig.playerOperationLimiter && !context.getLevel().isClientSide()) { ++ if (org.leavesmc.leaves.LeavesConfig.playerOperationLimiter && !context.getLevel().isClientSide()) { + ServerPlayer player = (ServerPlayer) context.getPlayer(); + if (player != null && iblockdata != null) { + player.addPlaceBlockCountPerTick(); diff --git a/patches/server/0044-Renewable-Elytra.patch b/patches/server/0045-Renewable-Elytra.patch similarity index 78% rename from patches/server/0044-Renewable-Elytra.patch rename to patches/server/0045-Renewable-Elytra.patch index 16be64bf..7d5c511f 100644 --- a/patches/server/0044-Renewable-Elytra.patch +++ b/patches/server/0045-Renewable-Elytra.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Renewable Elytra This patch is Powered by Carpet-TIS-Addition(https://github.com/plusls/Carpet-TIS-Addition) diff --git a/src/main/java/net/minecraft/world/entity/monster/Phantom.java b/src/main/java/net/minecraft/world/entity/monster/Phantom.java -index 187037c43ebb5b245ffa4b50163d443490668744..29d735390dbe0c7169b576c469f3a3957a6bfb45 100644 +index 68f8945292753535a3b73acb9f48c1594f0789a4..da5df2271a8192bf4c86772bd84107e55f3040aa 100644 --- a/src/main/java/net/minecraft/world/entity/monster/Phantom.java +++ b/src/main/java/net/minecraft/world/entity/monster/Phantom.java -@@ -36,6 +36,8 @@ import net.minecraft.world.entity.ai.goal.Goal; +@@ -35,6 +35,8 @@ import net.minecraft.world.entity.ai.goal.Goal; import net.minecraft.world.entity.ai.targeting.TargetingConditions; import net.minecraft.world.entity.animal.Cat; import net.minecraft.world.entity.player.Player; @@ -18,16 +18,16 @@ index 187037c43ebb5b245ffa4b50163d443490668744..29d735390dbe0c7169b576c469f3a395 import net.minecraft.world.level.Level; import net.minecraft.world.level.ServerLevelAccessor; import net.minecraft.world.level.levelgen.Heightmap; -@@ -255,6 +257,20 @@ public class Phantom extends FlyingMob implements Enemy { - return -0.125F; +@@ -233,6 +235,20 @@ public class Phantom extends FlyingMob implements Enemy { + return entitysize.scale(1.0F + 0.15F * (float) i); } + // Leaves start - renewable elytra + @Override + protected void dropFromLootTable(DamageSource source, boolean causedByPlayer) { + super.dropFromLootTable(source, causedByPlayer); -+ if (top.leavesmc.leaves.LeavesConfig.renewableElytra > 0.0D) { -+ if (source.getEntity() instanceof Shulker && this.random.nextDouble() < top.leavesmc.leaves.LeavesConfig.renewableElytra) { ++ if (org.leavesmc.leaves.LeavesConfig.renewableElytra > 0.0D) { ++ if (source.getEntity() instanceof Shulker && this.random.nextDouble() < org.leavesmc.leaves.LeavesConfig.renewableElytra) { + ItemStack item = new ItemStack(Items.ELYTRA); + item.setDamageValue(432); + this.spawnAtLocation(item); @@ -37,5 +37,5 @@ index 187037c43ebb5b245ffa4b50163d443490668744..29d735390dbe0c7169b576c469f3a395 + // Leaves end - renewable elytra + // Paper start + @Nullable java.util.UUID spawningEntity; - diff --git a/patches/server/0045-Stackable-ShulkerBoxes.patch b/patches/server/0046-Stackable-ShulkerBoxes.patch similarity index 68% rename from patches/server/0045-Stackable-ShulkerBoxes.patch rename to patches/server/0046-Stackable-ShulkerBoxes.patch index 0b552256..4fdd5e11 100644 --- a/patches/server/0045-Stackable-ShulkerBoxes.patch +++ b/patches/server/0046-Stackable-ShulkerBoxes.patch @@ -6,12 +6,12 @@ Subject: [PATCH] Stackable ShulkerBoxes This patch is Powered by fabric-carpet(https://github.com/gnembon/fabric-carpet) and plusls-carpet-addition(https://github.com/plusls/plusls-carpet-addition) 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 29ce703a79f7893ac990ad80e0f1c1cf63546e6c..569b7f66b505f9cbfb45322ecab057534f4a6330 100644 +index 8fd3845c4965843be9c37498760d93f1ebdff541..d3fa592892fc72c8fc8f23e8e477eb88902bba16 100644 --- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java -@@ -14,10 +14,12 @@ import net.minecraft.world.entity.Entity; - import net.minecraft.world.entity.EntityType; +@@ -22,10 +22,12 @@ import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.MoverType; + import net.minecraft.world.entity.SlotAccess; import net.minecraft.world.entity.TraceableEntity; +import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.Item; @@ -21,8 +21,8 @@ index 29ce703a79f7893ac990ad80e0f1c1cf63546e6c..569b7f66b505f9cbfb45322ecab05753 +import net.minecraft.world.level.block.ShulkerBoxBlock; import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.phys.Vec3; - import net.minecraft.core.BlockPos; -@@ -33,6 +35,7 @@ import net.minecraft.sounds.SoundSource; + // CraftBukkit start +@@ -35,6 +37,7 @@ import net.minecraft.sounds.SoundSource; import net.minecraft.stats.Stats; import org.bukkit.craftbukkit.event.CraftEventFactory; import org.bukkit.entity.Player; @@ -30,42 +30,42 @@ index 29ce703a79f7893ac990ad80e0f1c1cf63546e6c..569b7f66b505f9cbfb45322ecab05753 import org.bukkit.event.entity.EntityPickupItemEvent; import org.bukkit.event.entity.EntityRemoveEvent; import org.bukkit.event.player.PlayerPickupItemEvent; -@@ -74,6 +77,13 @@ public class ItemEntity extends Entity implements TraceableEntity { +@@ -78,6 +81,13 @@ public class ItemEntity extends Entity implements TraceableEntity { this.setDeltaMovement(this.random.nextDouble() * 0.2D - 0.1D, 0.2D, this.random.nextDouble() * 0.2D - 0.1D); this.setItem(stack); // Paper end - Don't use level random in entity constructors + // Leaves start - stackable shulker boxes -+ if (top.leavesmc.leaves.LeavesConfig.shulkerBoxStackSize > 1) { ++ if (org.leavesmc.leaves.LeavesConfig.shulkerBoxStackSize > 1) { + if (stack.getItem() instanceof BlockItem bi && bi.getBlock() instanceof ShulkerBoxBlock) { -+ top.leavesmc.leaves.util.ShulkerBoxUtils.cleanUpShulkerBoxTag(stack); ++ org.leavesmc.leaves.util.ShulkerBoxUtils.cleanUpShulkerBoxTag(stack); + } + } + // Leaves end - stackable shulker boxes } public ItemEntity(Level world, double x, double y, double z, ItemStack stack, double velocityX, double velocityY, double velocityZ) { -@@ -308,10 +318,49 @@ public class ItemEntity extends Entity implements TraceableEntity { +@@ -314,10 +324,49 @@ public class ItemEntity extends Entity implements TraceableEntity { private boolean isMergable() { ItemStack itemstack = this.getItem(); - return this.isAlive() && this.pickupDelay != 32767 && this.age != -32768 && this.age < this.despawnRate && itemstack.getCount() < itemstack.getMaxStackSize(); // Paper - Alternative item-despawn-rate -+ return this.isAlive() && this.pickupDelay != 32767 && this.age != -32768 && this.age < this.despawnRate && itemstack.getCount() < top.leavesmc.leaves.util.ShulkerBoxUtils.getItemStackMaxCount(itemstack); // Paper - Alternative item-despawn-rate // Leaves - stackable shulker boxes ++ return this.isAlive() && this.pickupDelay != 32767 && this.age != -32768 && this.age < this.despawnRate && itemstack.getCount() < org.leavesmc.leaves.util.ShulkerBoxUtils.getItemStackMaxCount(itemstack); // Paper - Alternative item-despawn-rate // Leaves - stackable shulker boxes } + // Leaves end - stackable shulker boxes + private boolean tryStackShulkerBoxes(ItemEntity other) { + ItemStack selfStack = this.getItem(); -+ if (top.leavesmc.leaves.LeavesConfig.shulkerBoxStackSize == 1 || !(selfStack.getItem() instanceof BlockItem bi) || !(bi.getBlock() instanceof ShulkerBoxBlock)) { ++ if (org.leavesmc.leaves.LeavesConfig.shulkerBoxStackSize == 1 || !(selfStack.getItem() instanceof BlockItem bi) || !(bi.getBlock() instanceof ShulkerBoxBlock)) { + return false; + } + + ItemStack otherStack = other.getItem(); + if (selfStack.getItem() == otherStack.getItem() -+ && !top.leavesmc.leaves.util.ShulkerBoxUtils.shulkerBoxHasItems(selfStack) -+ && !top.leavesmc.leaves.util.ShulkerBoxUtils.shulkerBoxHasItems(otherStack) -+ && Objects.equals(selfStack.getTag(), otherStack.getTag()) // empty block entity tags are cleaned up when spawning -+ && selfStack.getCount() != top.leavesmc.leaves.LeavesConfig.shulkerBoxStackSize) { -+ int amount = Math.min(otherStack.getCount(), top.leavesmc.leaves.LeavesConfig.shulkerBoxStackSize - selfStack.getCount()); ++ && !org.leavesmc.leaves.util.ShulkerBoxUtils.shulkerBoxHasItems(selfStack) ++ && !org.leavesmc.leaves.util.ShulkerBoxUtils.shulkerBoxHasItems(otherStack) ++ && Objects.equals(selfStack.getComponents(), otherStack.getComponents()) // empty block entity tags are cleaned up when spawning ++ && selfStack.getCount() != org.leavesmc.leaves.LeavesConfig.shulkerBoxStackSize) { ++ int amount = Math.min(otherStack.getCount(), org.leavesmc.leaves.LeavesConfig.shulkerBoxStackSize - selfStack.getCount()); + + selfStack.grow(amount); + this.setItem(selfStack); @@ -96,43 +96,40 @@ index 29ce703a79f7893ac990ad80e0f1c1cf63546e6c..569b7f66b505f9cbfb45322ecab05753 ItemStack itemstack1 = other.getItem(); diff --git a/src/main/java/net/minecraft/world/entity/player/Inventory.java b/src/main/java/net/minecraft/world/entity/player/Inventory.java -index cc93e118605484c71ce069f208e7bb4d3a3211b0..c2a6a472ebb9ef1053f69bf5b9bd7b910fbc579f 100644 +index 3c8f35f92ed7e9518d676087f82d1e4da963b779..9037c6c8f0947e72e02552557f3c47625927681e 100644 --- a/src/main/java/net/minecraft/world/entity/player/Inventory.java +++ b/src/main/java/net/minecraft/world/entity/player/Inventory.java @@ -114,7 +114,7 @@ public class Inventory implements Container, Nameable { } private boolean hasRemainingSpaceForItem(ItemStack existingStack, ItemStack stack) { -- return !existingStack.isEmpty() && existingStack.isStackable() && existingStack.getCount() < existingStack.getMaxStackSize() && existingStack.getCount() < this.getMaxStackSize() && ItemStack.isSameItemSameTags(existingStack, stack); // Paper - check if itemstack is stackable first -+ return !existingStack.isEmpty() && top.leavesmc.leaves.util.ShulkerBoxUtils.isStackable(existingStack) && existingStack.getCount() < top.leavesmc.leaves.util.ShulkerBoxUtils.getItemStackMaxCount(existingStack) && existingStack.getCount() < this.getMaxStackSize() && ItemStack.isSameItemSameTags(existingStack, stack); // Paper - check if itemstack is stackable first // Leaves - stackable shulker boxes +- return !existingStack.isEmpty() && existingStack.isStackable() && existingStack.getCount() < this.getMaxStackSize(existingStack) && ItemStack.isSameItemSameComponents(existingStack, stack); // Paper - check if itemstack is stackable first ++ return !existingStack.isEmpty() && org.leavesmc.leaves.util.ShulkerBoxUtils.isStackable(existingStack) && existingStack.getCount() < org.leavesmc.leaves.util.ShulkerBoxUtils.getItemStackMaxCount(existingStack) && ItemStack.isSameItemSameComponents(existingStack, stack); // Paper - check if itemstack is stackable first } // CraftBukkit start - Watch method above! :D -@@ -289,9 +289,11 @@ public class Inventory implements Container, Nameable { - - int k = j; - -- if (j > itemstack1.getMaxStackSize() - itemstack1.getCount()) { -- k = itemstack1.getMaxStackSize() - itemstack1.getCount(); -+ // Leaves start - stackable shulker boxes -+ if (j > top.leavesmc.leaves.util.ShulkerBoxUtils.getItemStackMaxCount(itemstack1) - itemstack1.getCount()) { -+ k = top.leavesmc.leaves.util.ShulkerBoxUtils.getItemStackMaxCount(itemstack1) - itemstack1.getCount(); +@@ -282,7 +282,9 @@ public class Inventory implements Container, Nameable { + this.setItem(slot, itemstack1); } -+ // Leaves start - stackable shulker boxes - if (k > this.getMaxStackSize() - itemstack1.getCount()) { - k = this.getMaxStackSize() - itemstack1.getCount(); -@@ -409,7 +411,7 @@ public class Inventory implements Container, Nameable { +- int k = this.getMaxStackSize(itemstack1) - itemstack1.getCount(); ++ // Leaves start - stackable shulker boxes ++ int k = org.leavesmc.leaves.util.ShulkerBoxUtils.getItemStackMaxCount(itemstack1) - itemstack1.getCount(); ++ // Leaves end - stackable shulker boxes + int l = Math.min(j, k); + + if (l == 0) { +@@ -397,7 +399,7 @@ public class Inventory implements Container, Nameable { } if (i != -1) { - int j = stack.getMaxStackSize() - this.getItem(i).getCount(); -+ int j = top.leavesmc.leaves.util.ShulkerBoxUtils.getItemStackMaxCount(stack) - this.getItem(i).getCount(); // Leaves - stackable shulker boxes ++ int j = org.leavesmc.leaves.util.ShulkerBoxUtils.getItemStackMaxCount(stack) - this.getItem(i).getCount(); // Leaves - stackable shulker boxes if (this.add(i, stack.split(j)) && notifiesClient && this.player instanceof ServerPlayer) { ((ServerPlayer) this.player).connection.send(new ClientboundContainerSetSlotPacket(-2, 0, i, this.getItem(i))); diff --git a/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java b/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java -index 7cef5c518207752f7e1bfdd5bbec55fe9fafca6b..925cc4d99d1388bc32cebb5238a322102b6f68e5 100644 +index 961a7193fda00fa62acea9c39fda1c93f7fbe412..c66eb0f17299e8be4403ecf2483b83471d533525 100644 --- a/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java +++ b/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java @@ -456,7 +456,7 @@ public abstract class AbstractContainerMenu { @@ -140,16 +137,16 @@ index 7cef5c518207752f7e1bfdd5bbec55fe9fafca6b..925cc4d99d1388bc32cebb5238a32210 if (slot1 != null && AbstractContainerMenu.canItemQuickReplace(slot1, itemstack2, true) && slot1.mayPlace(itemstack2) && (this.quickcraftType == 2 || itemstack2.getCount() >= this.quickcraftSlots.size()) && this.canDragTo(slot1)) { int j1 = slot1.hasItem() ? slot1.getItem().getCount() : 0; - int k1 = Math.min(itemstack1.getMaxStackSize(), slot1.getMaxStackSize(itemstack1)); -+ int k1 = Math.min(top.leavesmc.leaves.util.ShulkerBoxUtils.getItemStackMaxCount(itemstack1), slot1.getMaxStackSize(itemstack1)); // Leaves - stackable shulker boxes int l1 = Math.min(AbstractContainerMenu.getQuickCraftPlaceCount(this.quickcraftSlots, this.quickcraftType, itemstack1) + j1, k1); ++ int k1 = Math.min(org.leavesmc.leaves.util.ShulkerBoxUtils.getItemStackMaxCount(itemstack1), slot1.getMaxStackSize(itemstack1)); // Leaves - stackable shulker boxes int l1 = Math.min(AbstractContainerMenu.getQuickCraftPlaceCount(this.quickcraftSlots, this.quickcraftType, itemstack1) + j1, k1); int l1 = Math.min(AbstractContainerMenu.getQuickCraftPlaceCount(this.quickcraftSlots, this.quickcraftType, itemstack1) + j1, k1); l -= l1 - j1; @@ -575,7 +575,7 @@ public abstract class AbstractContainerMenu { slot.setByPlayer(itemstack3); } - } else if (ItemStack.isSameItemSameTags(itemstack, itemstack3)) { + } else if (ItemStack.isSameItemSameComponents(itemstack, itemstack3)) { - Optional optional1 = slot.tryRemove(itemstack.getCount(), itemstack3.getMaxStackSize() - itemstack3.getCount(), player); -+ Optional optional1 = slot.tryRemove(itemstack.getCount(), top.leavesmc.leaves.util.ShulkerBoxUtils.getItemStackMaxCount(itemstack3) - itemstack3.getCount(), player); ++ Optional optional1 = slot.tryRemove(itemstack.getCount(), org.leavesmc.leaves.util.ShulkerBoxUtils.getItemStackMaxCount(itemstack3) - itemstack3.getCount(), player); optional1.ifPresent((itemstack4) -> { itemstack3.grow(itemstack4.getCount()); @@ -158,7 +155,7 @@ index 7cef5c518207752f7e1bfdd5bbec55fe9fafca6b..925cc4d99d1388bc32cebb5238a32210 if (slot2.hasItem()) { itemstack1 = slot2.getItem(); - this.setCarried(itemstack1.copyWithCount(itemstack1.getMaxStackSize())); -+ this.setCarried(itemstack1.copyWithCount(top.leavesmc.leaves.util.ShulkerBoxUtils.getItemStackMaxCount(itemstack1))); // Leaves - stackable shulker boxes ++ this.setCarried(itemstack1.copyWithCount(org.leavesmc.leaves.util.ShulkerBoxUtils.getItemStackMaxCount(itemstack1))); // Leaves - stackable shulker boxes } } else if (actionType == ClickType.THROW && this.getCarried().isEmpty() && slotIndex >= 0) { slot2 = (Slot) this.slots.get(slotIndex); @@ -167,51 +164,37 @@ index 7cef5c518207752f7e1bfdd5bbec55fe9fafca6b..925cc4d99d1388bc32cebb5238a32210 for (i2 = 0; i2 < 2; ++i2) { - for (int k2 = l; k2 >= 0 && k2 < this.slots.size() && itemstack1.getCount() < itemstack1.getMaxStackSize(); k2 += j2) { -+ for (int k2 = l; k2 >= 0 && k2 < this.slots.size() && itemstack1.getCount() < top.leavesmc.leaves.util.ShulkerBoxUtils.getItemStackMaxCount(itemstack1); k2 += j2) { // Leaves - stackable shulker boxes ++ for (int k2 = l; k2 >= 0 && k2 < this.slots.size() && itemstack1.getCount() < org.leavesmc.leaves.util.ShulkerBoxUtils.getItemStackMaxCount(itemstack1); k2 += j2) { // Leaves - stackable shulker boxes Slot slot3 = (Slot) this.slots.get(k2); if (slot3.hasItem() && AbstractContainerMenu.canItemQuickReplace(slot3, itemstack1, true) && slot3.mayPickup(player) && this.canTakeItemForPickAll(itemstack1, slot3)) { ItemStack itemstack5 = slot3.getItem(); - if (i2 != 0 || itemstack5.getCount() != itemstack5.getMaxStackSize()) { -+ if (i2 != 0 || itemstack5.getCount() != top.leavesmc.leaves.util.ShulkerBoxUtils.getItemStackMaxCount(itemstack5)) { ++ if (i2 != 0 || itemstack5.getCount() != org.leavesmc.leaves.util.ShulkerBoxUtils.getItemStackMaxCount(itemstack5)) { ItemStack itemstack6 = slot3.safeTake(itemstack5.getCount(), itemstack1.getMaxStackSize() - itemstack1.getCount(), player); itemstack1.grow(itemstack6.getCount()); @@ -805,7 +805,7 @@ public abstract class AbstractContainerMenu { - Slot slot; ItemStack itemstack1; + int l; - if (stack.isStackable()) { -+ if (top.leavesmc.leaves.util.ShulkerBoxUtils.isStackable(stack)) { // Leaves - stackable shulker boxes ++ if (org.leavesmc.leaves.util.ShulkerBoxUtils.isStackable(stack)) { // Leaves - stackable shulker boxes while (!stack.isEmpty()) { if (fromLast) { if (k < startIndex) { -@@ -825,16 +825,18 @@ public abstract class AbstractContainerMenu { - if (!itemstack1.isEmpty() && ItemStack.isSameItemSameTags(stack, itemstack1)) { - int l = itemstack1.getCount() + stack.getCount(); +@@ -824,7 +824,7 @@ public abstract class AbstractContainerMenu { + // Paper end - Add PlayerTradeEvent and PlayerPurchaseEvent + if (!itemstack1.isEmpty() && ItemStack.isSameItemSameComponents(stack, itemstack1)) { + l = itemstack1.getCount() + stack.getCount(); +- int i1 = slot.getMaxStackSize(itemstack1); ++ int i1 = org.leavesmc.leaves.util.ShulkerBoxUtils.getItemStackMaxCount(itemstack1); // Leaves - stackable shulker boxes -- if (l <= stack.getMaxStackSize()) { -+ if (l <= top.leavesmc.leaves.util.ShulkerBoxUtils.getItemStackMaxCount(stack)) { // Leaves - stackable shulker boxes + if (l <= i1) { stack.setCount(0); - itemstack1.setCount(l); - if (!isCheck) { // Paper - Add PlayerTradeEvent and PlayerPurchaseEvent - slot.setChanged(); - } // Paper - Add PlayerTradeEvent and PlayerPurchaseEvent - flag1 = true; -- } else if (itemstack1.getCount() < stack.getMaxStackSize()) { -- stack.shrink(stack.getMaxStackSize() - itemstack1.getCount()); -- itemstack1.setCount(stack.getMaxStackSize()); -+ // Leaves start - stackable shulker boxes -+ } else if (itemstack1.getCount() < top.leavesmc.leaves.util.ShulkerBoxUtils.getItemStackMaxCount(stack)) { -+ stack.shrink(top.leavesmc.leaves.util.ShulkerBoxUtils.getItemStackMaxCount(stack) - itemstack1.getCount()); -+ itemstack1.setCount(top.leavesmc.leaves.util.ShulkerBoxUtils.getItemStackMaxCount(stack)); -+ // Leaves end - stackable shulker boxes - if (!isCheck) { // Paper - Add PlayerTradeEvent and PlayerPurchaseEvent - slot.setChanged(); - } // Paper - Add PlayerTradeEvent and PlayerPurchaseEvent diff --git a/src/main/java/net/minecraft/world/inventory/Slot.java b/src/main/java/net/minecraft/world/inventory/Slot.java -index 1b1d4c46827aa397183ca3dfec46c785e5531b71..3c34532b9a7118fef6b37e545a19cbf193201352 100644 +index c39c773112fb8b534b926f2f2b47fe6fbb69fcb2..ae9338b8a5598e7a257b469adae72858fed95c39 100644 --- a/src/main/java/net/minecraft/world/inventory/Slot.java +++ b/src/main/java/net/minecraft/world/inventory/Slot.java @@ -76,7 +76,7 @@ public class Slot { @@ -219,30 +202,43 @@ index 1b1d4c46827aa397183ca3dfec46c785e5531b71..3c34532b9a7118fef6b37e545a19cbf1 public int getMaxStackSize(ItemStack stack) { - return Math.min(this.getMaxStackSize(), stack.getMaxStackSize()); -+ return Math.min(this.getMaxStackSize(), top.leavesmc.leaves.util.ShulkerBoxUtils.getItemStackMaxCount(stack)); // Leaves - stackable shulker boxes ++ return Math.min(this.getMaxStackSize(), org.leavesmc.leaves.util.ShulkerBoxUtils.getItemStackMaxCount(stack)); // Leaves - stackable shulker boxes } @Nullable +diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java +index 893efb2c4a07c33d41e934279dd914a9dbd4ef79..364e8ed48512dd499bf393947fd7a954c22acc0e 100644 +--- a/src/main/java/net/minecraft/world/item/ItemStack.java ++++ b/src/main/java/net/minecraft/world/item/ItemStack.java +@@ -228,7 +228,7 @@ public final class ItemStack implements DataComponentHolder { + @Deprecated + @Nullable + private Item item; +- private PatchedDataComponentMap components; ++ public PatchedDataComponentMap components; // Leaves - stackable shulker boxes + @Nullable + private Entity entityRepresentation; + diff --git a/src/main/java/net/minecraft/world/level/block/AbstractCauldronBlock.java b/src/main/java/net/minecraft/world/level/block/AbstractCauldronBlock.java -index 04ae1fe0f4bc902d2f97ed809c8e1038342d7bb7..a51781ad09da5f13180aea2413b883c095f5299d 100644 +index 20f2b575c8131621edea0e75fbf38a9fe20a36c4..812856b02cab1c437550ba9c706da318cf420338 100644 --- a/src/main/java/net/minecraft/world/level/block/AbstractCauldronBlock.java +++ b/src/main/java/net/minecraft/world/level/block/AbstractCauldronBlock.java -@@ -57,9 +57,27 @@ public abstract class AbstractCauldronBlock extends Block { - public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { - ItemStack itemStack = player.getItemInHand(hand); - CauldronInteraction cauldronInteraction = this.interactions.map().get(itemStack.getItem()); -- return cauldronInteraction.interact(state, world, pos, player, hand, itemStack); -+ return wrapInteractor(cauldronInteraction, state, world, pos, player, hand, itemStack); // Leaves - stackable shulker boxes +@@ -58,9 +58,27 @@ public abstract class AbstractCauldronBlock extends Block { + ItemStack stack, BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit + ) { + CauldronInteraction cauldronInteraction = this.interactions.map().get(stack.getItem()); +- return cauldronInteraction.interact(state, world, pos, player, hand, stack); ++ return wrapInteractor(cauldronInteraction, state, world, pos, player, hand, stack); } + // Leaves start - stackable shulker boxes -+ private InteractionResult wrapInteractor(CauldronInteraction cauldronBehavior, BlockState blockState, Level world, BlockPos blockPos, Player playerEntity, InteractionHand hand, ItemStack itemStack) { ++ private ItemInteractionResult wrapInteractor(CauldronInteraction cauldronBehavior, BlockState blockState, Level world, BlockPos blockPos, Player playerEntity, InteractionHand hand, ItemStack itemStack) { + int count = -1; -+ if (top.leavesmc.leaves.LeavesConfig.shulkerBoxStackSize > 1 && itemStack.getItem() instanceof net.minecraft.world.item.BlockItem bi && ++ if (org.leavesmc.leaves.LeavesConfig.shulkerBoxStackSize > 1 && itemStack.getItem() instanceof net.minecraft.world.item.BlockItem bi && + bi.getBlock() instanceof ShulkerBoxBlock) { + count = itemStack.getCount(); + } -+ InteractionResult result = cauldronBehavior.interact(blockState, world, blockPos, playerEntity, hand, itemStack); ++ ItemInteractionResult result = cauldronBehavior.interact(blockState, world, blockPos, playerEntity, hand, itemStack); + if (count > 0 && result.consumesAction()) { + ItemStack current = playerEntity.getItemInHand(hand); + if (current.getItem() instanceof net.minecraft.world.item.BlockItem bi && bi.getBlock() instanceof ShulkerBoxBlock) { @@ -254,13 +250,13 @@ index 04ae1fe0f4bc902d2f97ed809c8e1038342d7bb7..a51781ad09da5f13180aea2413b883c0 + // Leaves end - stackable shulker boxes + @Override - public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) { + protected VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) { return SHAPE; 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 cffc280655851e18439c9dfcb01ff69aab61e025..21a64f3a704fb362ed3aade559d55c0804ae5023 100644 +index 8310d132006043e93c612890514c4c7f3eb1c74d..592b330f187fb5eca51d60911bbebbaeaf46ef87 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 -@@ -734,9 +734,9 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -728,9 +728,9 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen if (itemstack1.isEmpty()) { // Spigot start - SPIGOT-6693, InventorySubcontainer#setItem ItemStack leftover = ItemStack.EMPTY; // Paper - Make hoppers respect inventory max stack size @@ -272,21 +268,27 @@ index cffc280655851e18439c9dfcb01ff69aab61e025..21a64f3a704fb362ed3aade559d55c08 } // Spigot end ignoreTileUpdates = true; // Paper - Perf: Optimize Hoppers -diff --git a/src/main/java/top/leavesmc/leaves/util/ShulkerBoxUtils.java b/src/main/java/top/leavesmc/leaves/util/ShulkerBoxUtils.java +diff --git a/src/main/java/org/leavesmc/leaves/util/ShulkerBoxUtils.java b/src/main/java/org/leavesmc/leaves/util/ShulkerBoxUtils.java new file mode 100644 -index 0000000000000000000000000000000000000000..82b4337965663ec8eccbc8c77892e3c49bff87cf +index 0000000000000000000000000000000000000000..401e4384007ffd8ef21b9a3dc6c07d34d257843a --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/util/ShulkerBoxUtils.java -@@ -0,0 +1,71 @@ -+package top.leavesmc.leaves.util; ++++ b/src/main/java/org/leavesmc/leaves/util/ShulkerBoxUtils.java +@@ -0,0 +1,78 @@ ++package org.leavesmc.leaves.util; + ++import net.minecraft.core.component.DataComponentMap; ++import net.minecraft.core.component.DataComponentPatch; ++import net.minecraft.core.component.PatchedDataComponentMap; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.inventory.Slot; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.ItemStack; ++import net.minecraft.world.item.component.CustomData; +import net.minecraft.world.level.block.ShulkerBoxBlock; +import org.jetbrains.annotations.NotNull; -+import top.leavesmc.leaves.LeavesConfig; ++import org.leavesmc.leaves.LeavesConfig; ++ ++import static net.minecraft.core.component.DataComponents.BLOCK_ENTITY_DATA; + +// Powered by fabric-carpet/src/main/java/carpet/helpers/InventoryHelper.java +public class ShulkerBoxUtils { @@ -307,40 +309,41 @@ index 0000000000000000000000000000000000000000..82b4337965663ec8eccbc8c77892e3c4 + + public static boolean cleanUpShulkerBoxTag(@NotNull ItemStack stack) { + boolean changed = false; -+ CompoundTag tag = stack.getTag(); ++ DataComponentMap components = stack.getComponents(); + -+ if (tag == null || !tag.contains("BlockEntityTag", TAG_COMPOUND)) return false; ++ if (!components.has(BLOCK_ENTITY_DATA)) return false; + -+ CompoundTag bet = tag.getCompound("BlockEntityTag"); ++ CompoundTag bet = components.get(BLOCK_ENTITY_DATA).copyTag(); + if (bet.contains("Items", TAG_LIST) && bet.getList("Items", TAG_COMPOUND).isEmpty()) { + bet.remove("Items"); ++ stack.applyComponents(DataComponentPatch.builder().set(BLOCK_ENTITY_DATA, CustomData.of(bet)).build()); + changed = true; + } + + if (bet.isEmpty() || (bet.size() == 1 && bet.getString("id").equals("minecraft:shulker_box"))) { -+ tag.remove("BlockEntityTag"); ++ stack.applyComponents(DataComponentPatch.builder().remove(BLOCK_ENTITY_DATA).build()); + changed = true; + } -+ if (tag.isEmpty()) { -+ stack.setTag(null); ++ if (components.isEmpty()) { ++ stack.components = (PatchedDataComponentMap.fromPatch(DataComponentMap.EMPTY, DataComponentPatch.EMPTY)); + changed = true; + } + return changed; + } + + public static boolean shulkerBoxHasItems(@NotNull ItemStack stack) { -+ CompoundTag tag = stack.getTag(); ++ DataComponentMap components = stack.getComponents(); + -+ if (tag == null || !tag.contains("BlockEntityTag", TAG_COMPOUND)) return false; ++ if (!components.has(BLOCK_ENTITY_DATA)) return false; + -+ CompoundTag bet = tag.getCompound("BlockEntityTag"); ++ CompoundTag bet = components.get(BLOCK_ENTITY_DATA).copyTag(); + return bet.contains("Items", TAG_LIST) && !bet.getList("Items", TAG_COMPOUND).isEmpty(); + } + + public static int getItemStackMaxCount(ItemStack stack) { + if (LeavesConfig.shulkerBoxStackSize > 1 && stack.getItem() instanceof BlockItem bi && -+ bi.getBlock() instanceof ShulkerBoxBlock && !top.leavesmc.leaves.util.ShulkerBoxUtils.shulkerBoxHasItems(stack)) { -+ return top.leavesmc.leaves.LeavesConfig.shulkerBoxStackSize; ++ bi.getBlock() instanceof ShulkerBoxBlock && !org.leavesmc.leaves.util.ShulkerBoxUtils.shulkerBoxHasItems(stack)) { ++ return org.leavesmc.leaves.LeavesConfig.shulkerBoxStackSize; + } + return stack.getMaxStackSize(); + } diff --git a/patches/server/0046-Improve-fluid-direction-caching.patch b/patches/server/0047-Improve-fluid-direction-caching.patch similarity index 93% rename from patches/server/0046-Improve-fluid-direction-caching.patch rename to patches/server/0047-Improve-fluid-direction-caching.patch index 15100225..7b221e56 100644 --- a/patches/server/0046-Improve-fluid-direction-caching.patch +++ b/patches/server/0047-Improve-fluid-direction-caching.patch @@ -7,7 +7,7 @@ This patch is Powered by Pufferfish (https://github.com/pufferfish-gg/Pufferfish) 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 6d8ff6c06af5545634f255ed17dc1e489ece2548..82cad323e4fba9aea082047d3eb6c4351681d9af 100644 +index c2943d892b067b3f1fb3b93301a092e912d71f08..d5352883ee51dfc646352ae7e2b76af7efd0441e 100644 --- a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java +++ b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java @@ -53,6 +53,11 @@ public abstract class FlowingFluid extends Fluid { @@ -15,8 +15,8 @@ index 6d8ff6c06af5545634f255ed17dc1e489ece2548..82cad323e4fba9aea082047d3eb6c435 return object2bytelinkedopenhashmap; }); + // Leaves start - use our own cache -+ private static final ThreadLocal> localFluidDirectionCache = ThreadLocal.withInitial(() -> { -+ return new top.leavesmc.leaves.structs.FluidDirectionCache<>(2048); ++ private static final ThreadLocal> localFluidDirectionCache = ThreadLocal.withInitial(() -> { ++ return new org.leavesmc.leaves.structs.FluidDirectionCache<>(2048); + }); + // Leaves end - use our own cache private final Map shapes = Maps.newIdentityHashMap(); @@ -34,7 +34,7 @@ index 6d8ff6c06af5545634f255ed17dc1e489ece2548..82cad323e4fba9aea082047d3eb6c435 - object2bytelinkedopenhashmap = null; - } + // Leaves start - cache -+ if (!top.leavesmc.leaves.LeavesConfig.improveFluidDirectionCaching) { ++ if (!org.leavesmc.leaves.LeavesConfig.improveFluidDirectionCaching) { + Object2ByteLinkedOpenHashMap object2bytelinkedopenhashmap; + + if (!state.getBlock().hasDynamicShape() && !fromState.getBlock().hasDynamicShape()) { @@ -78,7 +78,7 @@ index 6d8ff6c06af5545634f255ed17dc1e489ece2548..82cad323e4fba9aea082047d3eb6c435 } else { - block_a = null; - } -+ top.leavesmc.leaves.structs.FluidDirectionCache cache = null; ++ org.leavesmc.leaves.structs.FluidDirectionCache cache = null; + if (!state.getBlock().hasDynamicShape() && !fromState.getBlock().hasDynamicShape()) { + cache = localFluidDirectionCache.get(); + } @@ -117,13 +117,13 @@ index 6d8ff6c06af5545634f255ed17dc1e489ece2548..82cad323e4fba9aea082047d3eb6c435 } public abstract Fluid getFlowing(); -diff --git a/src/main/java/top/leavesmc/leaves/structs/FluidDirectionCache.java b/src/main/java/top/leavesmc/leaves/structs/FluidDirectionCache.java +diff --git a/src/main/java/org/leavesmc/leaves/structs/FluidDirectionCache.java b/src/main/java/org/leavesmc/leaves/structs/FluidDirectionCache.java new file mode 100644 -index 0000000000000000000000000000000000000000..30dc532e75bc4dd7ddb086ffb24118cf4b7b5d2f +index 0000000000000000000000000000000000000000..e07a7c68d6d552767a77ffc507e6023b77daeac5 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/structs/FluidDirectionCache.java ++++ b/src/main/java/org/leavesmc/leaves/structs/FluidDirectionCache.java @@ -0,0 +1,138 @@ -+package top.leavesmc.leaves.structs; ++package org.leavesmc.leaves.structs; + +import it.unimi.dsi.fastutil.HashCommon; + diff --git a/patches/server/0047-MC-Technical-Survival-Mode.patch b/patches/server/0048-MC-Technical-Survival-Mode.patch similarity index 79% rename from patches/server/0047-MC-Technical-Survival-Mode.patch rename to patches/server/0048-MC-Technical-Survival-Mode.patch index 638c675f..e45558c4 100644 --- a/patches/server/0047-MC-Technical-Survival-Mode.patch +++ b/patches/server/0048-MC-Technical-Survival-Mode.patch @@ -6,7 +6,7 @@ Subject: [PATCH] MC Technical Survival Mode Will automatically overwrite some configuration after startup diff --git a/src/main/java/io/papermc/paper/adventure/ChatProcessor.java b/src/main/java/io/papermc/paper/adventure/ChatProcessor.java -index 6177f91146d2bc9dc1a066a24f84581cec0f53cd..04eab3a1f3cb5332293a95f1b3023ed55ab42237 100644 +index 19d973a0582c487617fafadd3df4857f8a1819a4..9cf1ab96f4f249f542b6698301237a989d4b6ff8 100644 --- a/src/main/java/io/papermc/paper/adventure/ChatProcessor.java +++ b/src/main/java/io/papermc/paper/adventure/ChatProcessor.java @@ -331,14 +331,14 @@ public final class ChatProcessor { @@ -14,7 +14,7 @@ index 6177f91146d2bc9dc1a066a24f84581cec0f53cd..04eab3a1f3cb5332293a95f1b3023ed5 static String legacyDisplayName(final CraftPlayer player) { - if (((org.bukkit.craftbukkit.CraftWorld) player.getWorld()).getHandle().paperConfig().scoreboards.useVanillaWorldScoreboardNameColoring) { -+ if (((org.bukkit.craftbukkit.CraftWorld) player.getWorld()).getHandle().paperConfig().scoreboards.useVanillaWorldScoreboardNameColoring || top.leavesmc.leaves.LeavesConfig.mcTechnicalMode) { // Leaves - mc technical mode ++ if (((org.bukkit.craftbukkit.CraftWorld) player.getWorld()).getHandle().paperConfig().scoreboards.useVanillaWorldScoreboardNameColoring || org.leavesmc.leaves.LeavesConfig.mcTechnicalMode) { // Leaves - mc technical mode return legacySection().serialize(player.teamDisplayName()) + ChatFormatting.RESET; } return player.getDisplayName(); @@ -22,12 +22,12 @@ index 6177f91146d2bc9dc1a066a24f84581cec0f53cd..04eab3a1f3cb5332293a95f1b3023ed5 static Component displayName(final CraftPlayer player) { - if (((CraftWorld) player.getWorld()).getHandle().paperConfig().scoreboards.useVanillaWorldScoreboardNameColoring) { -+ if (((CraftWorld) player.getWorld()).getHandle().paperConfig().scoreboards.useVanillaWorldScoreboardNameColoring || top.leavesmc.leaves.LeavesConfig.mcTechnicalMode) { // Leaves - mc technical mode ++ if (((CraftWorld) player.getWorld()).getHandle().paperConfig().scoreboards.useVanillaWorldScoreboardNameColoring || org.leavesmc.leaves.LeavesConfig.mcTechnicalMode) { // Leaves - mc technical mode return player.teamDisplayName(); } return player.displayName(); diff --git a/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkHolderManager.java b/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkHolderManager.java -index 5b446e6ac151f99f64f0c442d0b40b5e251bc4c4..c2eb3e8b019dbc0543a2308d7e88e324aa265cfe 100644 +index 5b446e6ac151f99f64f0c442d0b40b5e251bc4c4..b133b977bc7d452b5032809f84f8ac2ff96ae5bb 100644 --- a/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkHolderManager.java +++ b/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkHolderManager.java @@ -608,7 +608,7 @@ public final class ChunkHolderManager { @@ -35,50 +35,50 @@ index 5b446e6ac151f99f64f0c442d0b40b5e251bc4c4..c2eb3e8b019dbc0543a2308d7e88e324 // these days, the patch is mostly useful to keep chunks ticking when players teleport // so that their pets can teleport with them as well. - final long delayTimeout = this.world.paperConfig().chunks.delayChunkUnloadsBy.ticks(); -+ final long delayTimeout = top.leavesmc.leaves.LeavesConfig.mcTechnicalMode ? 0 : this.world.paperConfig().chunks.delayChunkUnloadsBy.ticks(); // Leaves - mc technical survival mode ++ final long delayTimeout = org.leavesmc.leaves.LeavesConfig.mcTechnicalMode ? 0 : this.world.paperConfig().chunks.delayChunkUnloadsBy.ticks(); // Leaves - mc technical survival mode final TicketType toAdd; final long timeout; if (type == RegionizedPlayerChunkLoader.REGION_PLAYER_TICKET && delayTimeout > 0) { diff --git a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java -index fa1c0aee8c3a4d0868482cf5c703bbfd08e09874..c24148d8486420434922864df6f1ffa0b9929612 100644 +index 83a726bcf8b7dce73a361b0d79dbd63a0afc7a12..12cf1f7ba7d6c14b8b31d939b6f281bd2135656a 100644 --- a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java +++ b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java -@@ -317,6 +317,7 @@ public class PaperConfigurations extends Configurations 0 && ++this.level().spigotConfig.currentPrimedTnt > this.level().spigotConfig.maxTntTicksPerTick) { return; } // Spigot -+ if (this.level().spigotConfig.maxTntTicksPerTick > 0 && ++this.level().spigotConfig.currentPrimedTnt > (top.leavesmc.leaves.LeavesConfig.mcTechnicalMode ? 2000 : this.level().spigotConfig.maxTntTicksPerTick)) { return; } // Spigot // Leaves - mc technical survival mode - if (!this.isNoGravity()) { - this.setDeltaMovement(this.getDeltaMovement().add(0.0D, -0.04D, 0.0D)); - } ++ if (this.level().spigotConfig.maxTntTicksPerTick > 0 && ++this.level().spigotConfig.currentPrimedTnt > (org.leavesmc.leaves.LeavesConfig.mcTechnicalMode ? 2000 : this.level().spigotConfig.maxTntTicksPerTick)) { return; } // Spigot // Leaves - mc technical survival mode + this.applyGravity(); + this.move(MoverType.SELF, this.getDeltaMovement()); + // Paper start - Configurable TNT height nerf 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 156809090f1f83ad68e7e2477a3cfddac5757a8e..7f191b04f7c84f3188b96c108616424bf54170cb 100644 +index 74c596264d4da551437bd2a23e1c70022cfc73fc..71d2f2a98ede3ba2992ae3745d78b33c9d999650 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java +++ b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java -@@ -119,7 +119,7 @@ public abstract class Projectile extends Entity implements TraceableEntity { +@@ -120,7 +120,7 @@ public abstract class Projectile extends Entity implements TraceableEntity { if (nbt.hasUUID("Owner")) { this.ownerUUID = nbt.getUUID("Owner"); this.cachedOwner = null; - if (this instanceof ThrownEnderpearl && this.level() != null && this.level().paperConfig().fixes.disableUnloadedChunkEnderpearlExploit) { this.ownerUUID = null; } // Paper - Reset pearls when they stop being ticked; Don't store shooter name for pearls to block enderpearl travel exploit -+ if (this instanceof ThrownEnderpearl && this.level() != null && this.level().paperConfig().fixes.disableUnloadedChunkEnderpearlExploit && !top.leavesmc.leaves.LeavesConfig.mcTechnicalMode) { this.ownerUUID = null; } // Paper - Reset pearls when they stop being ticked; Don't store shooter name for pearls to block enderpearl travel exploit // Leaves - mc technical mode ++ if (this instanceof ThrownEnderpearl && this.level() != null && this.level().paperConfig().fixes.disableUnloadedChunkEnderpearlExploit && !org.leavesmc.leaves.LeavesConfig.mcTechnicalMode) { this.ownerUUID = null; } // Paper - Reset pearls when they stop being ticked; Don't store shooter name for pearls to block enderpearl travel exploit // Leaves - mc technical mode } this.leftOwner = nbt.getBoolean("LeftOwner"); diff --git a/src/main/java/net/minecraft/world/level/NaturalSpawner.java b/src/main/java/net/minecraft/world/level/NaturalSpawner.java -index 93fbf20c6e5ded31570415c30b837f5dc0dd5d42..667a480b7c546bb130bbd32a8ae7ce85d37a6b0a 100644 +index 9c72271382fa0b6be5f38b45577fb1ae81ce80a3..a9fda9cb7e8266c21aba70d5b1890b30900a5b00 100644 --- a/src/main/java/net/minecraft/world/level/NaturalSpawner.java +++ b/src/main/java/net/minecraft/world/level/NaturalSpawner.java -@@ -95,7 +95,7 @@ public final class NaturalSpawner { +@@ -90,7 +90,7 @@ public final class NaturalSpawner { if (enumcreaturetype != MobCategory.MISC) { // Paper start - Only count natural spawns - if (!entity.level().paperConfig().entities.spawning.countAllMobsForSpawning && -+ if (!top.leavesmc.leaves.LeavesConfig.mcTechnicalMode && !entity.level().paperConfig().entities.spawning.countAllMobsForSpawning && // Leaves - mc technical survival mode ++ if (!org.leavesmc.leaves.LeavesConfig.mcTechnicalMode && !entity.level().paperConfig().entities.spawning.countAllMobsForSpawning && // Leaves - mc technical survival mode !(entity.spawnReason == org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL || entity.spawnReason == org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN)) { continue; 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 21a64f3a704fb362ed3aade559d55c0804ae5023..006e990d57c7ad1081f63402ef85a3ba856fe329 100644 +index 592b330f187fb5eca51d60911bbebbaeaf46ef87..b08b7ffbcfbc6a12d74cadf878fd069f7a1345cb 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 -@@ -292,7 +292,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -280,7 +280,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen origItemStack.setCount(originalItemCount); } } - if (foundItem && level.paperConfig().hopper.cooldownWhenFull) { // Inventory was full - cooldown -+ if (foundItem && level.paperConfig().hopper.cooldownWhenFull && !top.leavesmc.leaves.LeavesConfig.mcTechnicalMode) { // Inventory was full - cooldown // Leaves ++ if (foundItem && level.paperConfig().hopper.cooldownWhenFull && !org.leavesmc.leaves.LeavesConfig.mcTechnicalMode) { // Inventory was full - cooldown // Leaves hopper.setCooldown(level.spigotConfig.hopperTransfer); } return false; -@@ -333,7 +333,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -321,7 +321,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen } origItemStack.setCount(originalItemCount); - if (level.paperConfig().hopper.cooldownWhenFull) { -+ if (level.paperConfig().hopper.cooldownWhenFull && !top.leavesmc.leaves.LeavesConfig.mcTechnicalMode) { // Leaves ++ if (level.paperConfig().hopper.cooldownWhenFull && !org.leavesmc.leaves.LeavesConfig.mcTechnicalMode) { // Leaves cooldownHopper(hopper); } -diff --git a/src/main/java/top/leavesmc/leaves/util/McTechnicalModeHelper.java b/src/main/java/top/leavesmc/leaves/util/McTechnicalModeHelper.java +diff --git a/src/main/java/org/leavesmc/leaves/util/McTechnicalModeHelper.java b/src/main/java/org/leavesmc/leaves/util/McTechnicalModeHelper.java new file mode 100644 -index 0000000000000000000000000000000000000000..4822a3806c55126e219364c3f76d0159a6f6453e +index 0000000000000000000000000000000000000000..76452b5a2c97160da6b4605d9c094dbc5c62861b --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/util/McTechnicalModeHelper.java ++++ b/src/main/java/org/leavesmc/leaves/util/McTechnicalModeHelper.java @@ -0,0 +1,27 @@ -+package top.leavesmc.leaves.util; ++package org.leavesmc.leaves.util; + +import io.papermc.paper.configuration.GlobalConfiguration; -+import top.leavesmc.leaves.LeavesConfig; ++import org.leavesmc.leaves.LeavesConfig; + +import java.util.Map; + @@ -179,7 +179,7 @@ index 0000000000000000000000000000000000000000..4822a3806c55126e219364c3f76d0159 + GlobalConfiguration.get().packetLimiter.allPackets = new GlobalConfiguration.PacketLimiter.PacketLimit(GlobalConfiguration.get().packetLimiter.allPackets.interval(), + 5000.0, GlobalConfiguration.get().packetLimiter.allPackets.action()); + GlobalConfiguration.get().packetLimiter.overrides = Map.of(); -+ GlobalConfiguration.get().unsupportedSettings.allowGrindstoneOverstacking = true; ++ // GlobalConfiguration.get().unsupportedSettings.allowGrindstoneOverstacking = true; + GlobalConfiguration.get().itemValidation.resolveSelectorsInBooks = true; + GlobalConfiguration.get().scoreboards.saveEmptyScoreboardTeams = true; + } diff --git a/patches/server/0048-Return-nether-portal-fix.patch b/patches/server/0049-Return-nether-portal-fix.patch similarity index 86% rename from patches/server/0048-Return-nether-portal-fix.patch rename to patches/server/0049-Return-nether-portal-fix.patch index 1fcb1251..1894d742 100644 --- a/patches/server/0048-Return-nether-portal-fix.patch +++ b/patches/server/0049-Return-nether-portal-fix.patch @@ -6,23 +6,23 @@ Subject: [PATCH] Return nether portal fix This patch is powered by NetherPortalFix(https://github.com/TwelveIterationMods/NetherPortalFix) diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java -index 362ec0d4de4f77511651b28d47b8bdac626f935b..6e084edb04d5bbcd5b25ccd820b3950ea89408d4 100644 +index 2945dc0d1ad1c50fded0d61e9dd582bbe20bbecd..bab6ae23c77cb9dc575625720ac31ae67a28d5d9 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java -@@ -187,6 +187,7 @@ import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; - import org.bukkit.event.player.PlayerToggleSneakEvent; - import org.bukkit.inventory.MainHand; - import top.leavesmc.leaves.bot.ServerBot; -+import top.leavesmc.leaves.util.ReturnPortalManager; - // CraftBukkit end - - public class ServerPlayer extends Player { -@@ -1293,6 +1294,24 @@ public class ServerPlayer extends Player { +@@ -19,6 +19,7 @@ import java.util.UUID; + import java.util.stream.Collectors; + import javax.annotation.Nullable; + import net.minecraft.BlockUtil; ++import org.leavesmc.leaves.util.ReturnPortalManager; + import net.minecraft.ChatFormatting; + import net.minecraft.CrashReport; + import net.minecraft.CrashReportCategory; +@@ -1370,6 +1371,24 @@ public class ServerPlayer extends Player { PlayerChangedWorldEvent changeEvent = new PlayerChangedWorldEvent(this.getBukkitEntity(), worldserver1.getWorld()); this.level().getCraftServer().getPluginManager().callEvent(changeEvent); // CraftBukkit end + // Leaves start - nether portal fix -+ if (top.leavesmc.leaves.LeavesConfig.netherPortalFix) { ++ if (org.leavesmc.leaves.LeavesConfig.netherPortalFix) { + final ResourceKey fromDim = worldserver1.dimension(); + final ResourceKey toDim = level().dimension(); + final ResourceKey OVERWORLD = Level.OVERWORLD; @@ -42,12 +42,12 @@ index 362ec0d4de4f77511651b28d47b8bdac626f935b..6e084edb04d5bbcd5b25ccd820b3950e } // Paper start - Reset shield blocking on dimension change if (this.isBlocking()) { -@@ -1345,6 +1364,30 @@ public class ServerPlayer extends Player { +@@ -1422,6 +1441,30 @@ public class ServerPlayer extends Player { protected Optional getExitPortal(ServerLevel worldserver, BlockPos blockposition, boolean flag, WorldBorder worldborder, int searchRadius, boolean canCreatePortal, int createRadius) { // CraftBukkit Optional optional = super.getExitPortal(worldserver, blockposition, flag, worldborder, searchRadius, canCreatePortal, createRadius); // CraftBukkit + // Leaves start - nether portal fix -+ if (top.leavesmc.leaves.LeavesConfig.netherPortalFix) { ++ if (org.leavesmc.leaves.LeavesConfig.netherPortalFix) { + BlockPos fromPos = blockPosition(); + final ResourceKey fromDim = level().dimension(); + final ResourceKey toDim = level().dimension(); @@ -74,23 +74,23 @@ index 362ec0d4de4f77511651b28d47b8bdac626f935b..6e084edb04d5bbcd5b25ccd820b3950e return optional; } else { diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index 82751434c31fe8825f32921f498fd0156da15454..03c278836208a65b77030b629f2b7678ded29b03 100644 +index 00809b615f65b2f4985856673430d8ba68525765..a65aede101004f23f76ce08781ab0a94d4c9113e 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java -@@ -122,6 +122,7 @@ import org.bukkit.event.player.PlayerSpawnChangeEvent; - // CraftBukkit end - - import top.leavesmc.leaves.bot.ServerBot; -+import top.leavesmc.leaves.util.ReturnPortalManager; // Leaves - return portal fix - - public abstract class PlayerList { - -@@ -1004,6 +1005,24 @@ public abstract class PlayerList { +@@ -26,6 +26,7 @@ import java.util.function.Predicate; + import javax.annotation.Nullable; + import net.minecraft.ChatFormatting; + import net.minecraft.FileUtil; ++import org.leavesmc.leaves.util.ReturnPortalManager; // Leaves - return portal fix + import net.minecraft.commands.CommandSourceStack; + import net.minecraft.core.BlockPos; + import net.minecraft.core.LayeredRegistryAccess; +@@ -1003,6 +1004,24 @@ public abstract class PlayerList { if (fromWorld != location.getWorld()) { PlayerChangedWorldEvent event = new PlayerChangedWorldEvent(entityplayer.getBukkitEntity(), fromWorld); this.server.server.getPluginManager().callEvent(event); + // Leaves start - nether portal fix -+ if (top.leavesmc.leaves.LeavesConfig.netherPortalFix) { ++ if (org.leavesmc.leaves.LeavesConfig.netherPortalFix) { + final ResourceKey fromDim = entityplayer.level().dimension(); + final ResourceKey toDim = entityplayer1.level().dimension(); + final ResourceKey OVERWORLD = Level.OVERWORLD; @@ -111,10 +111,10 @@ index 82751434c31fe8825f32921f498fd0156da15454..03c278836208a65b77030b629f2b7678 // Save player file again if they were disconnected diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index 15c8e9214b7df1cf1e9252a17b7acfc080e547a3..ffa9ada2e803bc77f8cae4be81ac4b5c2eee0b7f 100644 +index 8e5bfb7579b528d68b270665c02588bfa39643a3..3ad2f5234925e7f454d2b2bcb507493cdc3e454a 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -241,7 +241,7 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -251,7 +251,7 @@ public abstract class LivingEntity extends Entity implements Attackable { protected ItemStack useItem; public int useItemRemaining; protected int fallFlyTicks; @@ -123,13 +123,13 @@ index 15c8e9214b7df1cf1e9252a17b7acfc080e547a3..ffa9ada2e803bc77f8cae4be81ac4b5c private Optional lastClimbablePos; @Nullable private DamageSource lastDamageSource; -diff --git a/src/main/java/top/leavesmc/leaves/util/ReturnPortalManager.java b/src/main/java/top/leavesmc/leaves/util/ReturnPortalManager.java +diff --git a/src/main/java/org/leavesmc/leaves/util/ReturnPortalManager.java b/src/main/java/org/leavesmc/leaves/util/ReturnPortalManager.java new file mode 100644 -index 0000000000000000000000000000000000000000..24f887cbe608eea3beb7dc69cabdca7f32a66a9d +index 0000000000000000000000000000000000000000..d7066d268e7a3b4b2c1b1ef28491078997989d4c --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/util/ReturnPortalManager.java ++++ b/src/main/java/org/leavesmc/leaves/util/ReturnPortalManager.java @@ -0,0 +1,105 @@ -+package top.leavesmc.leaves.util; ++package org.leavesmc.leaves.util; + +import net.minecraft.BlockUtil; +import net.minecraft.core.BlockPos; diff --git a/patches/server/0049-Appleskin-Protocol.patch b/patches/server/0050-Appleskin-Protocol.patch similarity index 83% rename from patches/server/0049-Appleskin-Protocol.patch rename to patches/server/0050-Appleskin-Protocol.patch index dab3484c..02595e8a 100644 --- a/patches/server/0049-Appleskin-Protocol.patch +++ b/patches/server/0050-Appleskin-Protocol.patch @@ -4,13 +4,22 @@ Date: Wed, 25 Jan 2023 11:03:53 +0800 Subject: [PATCH] Appleskin Protocol -diff --git a/src/main/java/top/leavesmc/leaves/protocol/AppleSkinProtocol.java b/src/main/java/top/leavesmc/leaves/protocol/AppleSkinProtocol.java +diff --git a/.gitignore b/.gitignore +index 3811c0d849a3eb028ed1a6b7a2d4747f7f570448..1ad93453221244f880855b510e888e759275b640 100644 +--- a/.gitignore ++++ b/.gitignore +@@ -46,3 +46,4 @@ dependency-reduced-pom.xml + # vs code + /.vscode + /.factorypath ++ +diff --git a/src/main/java/org/leavesmc/leaves/protocol/AppleSkinProtocol.java b/src/main/java/org/leavesmc/leaves/protocol/AppleSkinProtocol.java new file mode 100644 -index 0000000000000000000000000000000000000000..6fd6a1c9ef54c95e452e08a69f9ddb1d6600e651 +index 0000000000000000000000000000000000000000..6662ecf8a9342db2e0ded507d7420319388f9974 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/protocol/AppleSkinProtocol.java ++++ b/src/main/java/org/leavesmc/leaves/protocol/AppleSkinProtocol.java @@ -0,0 +1,106 @@ -+package top.leavesmc.leaves.protocol; ++package org.leavesmc.leaves.protocol; + +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.MinecraftServer; @@ -18,10 +27,10 @@ index 0000000000000000000000000000000000000000..6fd6a1c9ef54c95e452e08a69f9ddb1d +import net.minecraft.world.food.FoodData; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; -+import top.leavesmc.leaves.LeavesConfig; -+import top.leavesmc.leaves.protocol.core.LeavesProtocol; -+import top.leavesmc.leaves.protocol.core.ProtocolHandler; -+import top.leavesmc.leaves.protocol.core.ProtocolUtils; ++import org.leavesmc.leaves.LeavesConfig; ++import org.leavesmc.leaves.protocol.core.LeavesProtocol; ++import org.leavesmc.leaves.protocol.core.ProtocolHandler; ++import org.leavesmc.leaves.protocol.core.ProtocolUtils; + +import java.util.HashMap; +import java.util.HashSet; diff --git a/patches/server/0050-Xaero-Map-Protocol.patch b/patches/server/0051-Xaero-Map-Protocol.patch similarity index 73% rename from patches/server/0050-Xaero-Map-Protocol.patch rename to patches/server/0051-Xaero-Map-Protocol.patch index 38ba4ab7..ecc872fd 100644 --- a/patches/server/0050-Xaero-Map-Protocol.patch +++ b/patches/server/0051-Xaero-Map-Protocol.patch @@ -4,33 +4,42 @@ Date: Fri, 27 Jan 2023 09:42:57 +0800 Subject: [PATCH] Xaero Map Protocol +diff --git a/.gitignore b/.gitignore +index 1ad93453221244f880855b510e888e759275b640..3811c0d849a3eb028ed1a6b7a2d4747f7f570448 100644 +--- a/.gitignore ++++ b/.gitignore +@@ -46,4 +46,3 @@ dependency-reduced-pom.xml + # vs code + /.vscode + /.factorypath +- diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index 03c278836208a65b77030b629f2b7678ded29b03..6e5a7edfbc8781def735d0b2250888288560fbc4 100644 +index a65aede101004f23f76ce08781ab0a94d4c9113e..c9e904ab960739c5b64f44ef92e3a02159149e66 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java -@@ -1323,6 +1323,7 @@ public abstract class PlayerList { +@@ -1322,6 +1322,7 @@ public abstract class PlayerList { player.connection.send(new ClientboundInitializeBorderPacket(worldborder)); player.connection.send(new ClientboundSetTimePacket(world.getGameTime(), world.getDayTime(), world.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT))); player.connection.send(new ClientboundSetDefaultSpawnPositionPacket(world.getSharedSpawnPos(), world.getSharedSpawnAngle())); -+ top.leavesmc.leaves.protocol.XaeroMapProtocol.onSendWorldInfo(player); // Leaves - xaero map protocol ++ org.leavesmc.leaves.protocol.XaeroMapProtocol.onSendWorldInfo(player); // Leaves - xaero map protocol if (world.isRaining()) { // CraftBukkit start - handle player weather // entityplayer.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.START_RAINING, 0.0F)); -diff --git a/src/main/java/top/leavesmc/leaves/protocol/XaeroMapProtocol.java b/src/main/java/top/leavesmc/leaves/protocol/XaeroMapProtocol.java +diff --git a/src/main/java/org/leavesmc/leaves/protocol/XaeroMapProtocol.java b/src/main/java/org/leavesmc/leaves/protocol/XaeroMapProtocol.java new file mode 100644 -index 0000000000000000000000000000000000000000..c0317bcaee60e8680812119bf94e1032d7816023 +index 0000000000000000000000000000000000000000..14e66b8eb6f2d768e03439df7f4dedc9ba8624dd --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/protocol/XaeroMapProtocol.java ++++ b/src/main/java/org/leavesmc/leaves/protocol/XaeroMapProtocol.java @@ -0,0 +1,42 @@ -+package top.leavesmc.leaves.protocol; ++package org.leavesmc.leaves.protocol; + +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.level.ServerPlayer; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; -+import top.leavesmc.leaves.LeavesConfig; -+import top.leavesmc.leaves.protocol.core.LeavesProtocol; -+import top.leavesmc.leaves.protocol.core.ProtocolUtils; ++import org.leavesmc.leaves.LeavesConfig; ++import org.leavesmc.leaves.protocol.core.LeavesProtocol; ++import org.leavesmc.leaves.protocol.core.ProtocolUtils; + +@LeavesProtocol(namespace = {"xaerominimap", "xaeroworldmap"}) +public class XaeroMapProtocol { diff --git a/patches/server/0051-Leaves-Extra-Yggdrasil-Service.patch b/patches/server/0052-Leaves-Extra-Yggdrasil-Service.patch similarity index 87% rename from patches/server/0051-Leaves-Extra-Yggdrasil-Service.patch rename to patches/server/0052-Leaves-Extra-Yggdrasil-Service.patch index 9299846c..093ab58c 100644 --- a/patches/server/0051-Leaves-Extra-Yggdrasil-Service.patch +++ b/patches/server/0052-Leaves-Extra-Yggdrasil-Service.patch @@ -4,6 +4,15 @@ Date: Thu, 2 Feb 2023 16:01:18 +0800 Subject: [PATCH] Leaves Extra Yggdrasil Service +diff --git a/.gitignore b/.gitignore +index 3811c0d849a3eb028ed1a6b7a2d4747f7f570448..1ad93453221244f880855b510e888e759275b640 100644 +--- a/.gitignore ++++ b/.gitignore +@@ -46,3 +46,4 @@ dependency-reduced-pom.xml + # vs code + /.vscode + /.factorypath ++ diff --git a/src/main/java/com/destroystokyo/paper/profile/PaperAuthenticationService.java b/src/main/java/com/destroystokyo/paper/profile/PaperAuthenticationService.java index 48e774677edf17d4a99ae9ed23d1b371dab41abb..21409ff86db65c00d92bff9eae8bdeb3a872a361 100644 --- a/src/main/java/com/destroystokyo/paper/profile/PaperAuthenticationService.java @@ -31,20 +40,20 @@ index bfc1e27c37689c1fbb927404a7176780a439a057..bc8ab50ef1390a2c51110a89dc43db58 private final String baseUrl; private final URL joinUrl; diff --git a/src/main/java/net/minecraft/server/Main.java b/src/main/java/net/minecraft/server/Main.java -index bc391d27399d8c22e78735ca39aa8ab45efb6413..89e1e1ee0fce2cc6b3a305dfca937ab777edbb5e 100644 +index 5443013060b62e3bfcc51cddca96d1c0bc59fe72..66c2b5caa08ab1659a9412c4b21404e90d8360f1 100644 --- a/src/main/java/net/minecraft/server/Main.java +++ b/src/main/java/net/minecraft/server/Main.java -@@ -187,7 +187,7 @@ public class Main { +@@ -190,7 +190,7 @@ public class Main { file = new File(bukkitConfiguration.getString("settings.world-container", ".")); } // Paper end - fix SPIGOT-5824 - Services services = Services.create(new com.destroystokyo.paper.profile.PaperAuthenticationService(Proxy.NO_PROXY), file, userCacheFile, optionset); // Paper - pass OptionSet to load paper config files; override authentication service; fix world-container -+ Services services = Services.create(new top.leavesmc.leaves.profile.LeavesAuthenticationService(Proxy.NO_PROXY), file, userCacheFile, optionset); // Paper - pass OptionSet to load paper config files; override authentication service; fix world-container // Leaves - extra-yggdrasil-service ++ Services services = Services.create(new org.leavesmc.leaves.profile.LeavesAuthenticationService(Proxy.NO_PROXY), file, userCacheFile, optionset); // Paper - pass OptionSet to load paper config files; override authentication service; fix world-container // Leaves - extra-yggdrasil-service // CraftBukkit start String s = (String) Optional.ofNullable((String) optionset.valueOf("world")).orElse(dedicatedserversettings.getProperties().levelName); LevelStorageSource convertable = LevelStorageSource.createDefault(file.toPath()); diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 690ae3e77d753af8351eb17bb5c35fbd2657f258..d615062782fa13e5df1d029b15967fd7f258c998 100644 +index 35a67136f5e22c5f9b65841fb7c10309e0b0e1c2..81e557588bf91bdd4654833ec967f2a727823d27 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -259,7 +259,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop public private long lastServerStatus; public final Thread serverThread; - private long nextTickTimeNanos; -diff --git a/src/main/java/top/leavesmc/leaves/profile/LeavesAuthenticationService.java b/src/main/java/top/leavesmc/leaves/profile/LeavesAuthenticationService.java + private long lastTickNanos; +diff --git a/src/main/java/org/leavesmc/leaves/profile/LeavesAuthenticationService.java b/src/main/java/org/leavesmc/leaves/profile/LeavesAuthenticationService.java new file mode 100644 -index 0000000000000000000000000000000000000000..3da207a13fce243bf880c8a4f7054cf20997991d +index 0000000000000000000000000000000000000000..6f14a66d78709fae9fecbefc80e3489b68e8d0c7 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/profile/LeavesAuthenticationService.java ++++ b/src/main/java/org/leavesmc/leaves/profile/LeavesAuthenticationService.java @@ -0,0 +1,18 @@ -+package top.leavesmc.leaves.profile; ++package org.leavesmc.leaves.profile; + +import com.destroystokyo.paper.profile.PaperAuthenticationService; +import com.mojang.authlib.minecraft.MinecraftSessionService; @@ -80,13 +89,13 @@ index 0000000000000000000000000000000000000000..3da207a13fce243bf880c8a4f7054cf2 + return new LeavesMinecraftSessionService(this.getServicesKeySet(), this.getProxy(), this.environment); + } +} -diff --git a/src/main/java/top/leavesmc/leaves/profile/LeavesMinecraftSessionService.java b/src/main/java/top/leavesmc/leaves/profile/LeavesMinecraftSessionService.java +diff --git a/src/main/java/org/leavesmc/leaves/profile/LeavesMinecraftSessionService.java b/src/main/java/org/leavesmc/leaves/profile/LeavesMinecraftSessionService.java new file mode 100644 -index 0000000000000000000000000000000000000000..9bfa0d0c12ac2a44968cd39b6d9f406defb23c07 +index 0000000000000000000000000000000000000000..c99092acd7aecb7f4c4c5cd1327991d9d468c5c5 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/profile/LeavesMinecraftSessionService.java ++++ b/src/main/java/org/leavesmc/leaves/profile/LeavesMinecraftSessionService.java @@ -0,0 +1,102 @@ -+package top.leavesmc.leaves.profile; ++package org.leavesmc.leaves.profile; + +import com.destroystokyo.paper.profile.PaperMinecraftSessionService; +import com.mojang.authlib.Environment; @@ -102,8 +111,8 @@ index 0000000000000000000000000000000000000000..9bfa0d0c12ac2a44968cd39b6d9f406d +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.level.ServerPlayer; +import org.jetbrains.annotations.Nullable; -+import top.leavesmc.leaves.LeavesConfig; -+import top.leavesmc.leaves.bot.ServerBot; ++import org.leavesmc.leaves.LeavesConfig; ++import org.leavesmc.leaves.bot.ServerBot; + +import java.net.InetAddress; +import java.net.Proxy; diff --git a/patches/server/0052-Use-vanilla-random-config.patch b/patches/server/0053-Use-vanilla-random-config.patch similarity index 79% rename from patches/server/0052-Use-vanilla-random-config.patch rename to patches/server/0053-Use-vanilla-random-config.patch index 0916a2d4..f8208687 100644 --- a/patches/server/0052-Use-vanilla-random-config.patch +++ b/patches/server/0053-Use-vanilla-random-config.patch @@ -5,55 +5,55 @@ Subject: [PATCH] Use vanilla random config diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index f491c1d402499e68191d4cdc9c8ef2e7caae9c7b..017efdee91fe6326c8e0270c294276b24b42604a 100644 +index bf8e3d510631e418eb6d2e641b51a1220bee2d7d..d6b5514dfe94b48a81ddd62b57a5d72b0510a61f 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -578,7 +578,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -580,7 +580,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess this.bb = Entity.INITIAL_AABB; this.stuckSpeedMultiplier = Vec3.ZERO; this.nextStep = 1.0F; - this.random = SHARED_RANDOM; // Paper - Share random for entities to make them more random -+ this.random = top.leavesmc.leaves.LeavesConfig.useVanillaRandom ? RandomSource.create() : SHARED_RANDOM; // Paper - Share random for entities to make them more random // Leaves - vanilla plz ++ this.random = org.leavesmc.leaves.LeavesConfig.useVanillaRandom ? RandomSource.create() : SHARED_RANDOM; // Paper - Share random for entities to make them more random // Leaves - vanilla plz this.remainingFireTicks = -this.getFireImmuneTicks(); this.fluidHeight = new Object2DoubleArrayMap(2); this.fluidOnEyes = new HashSet(); diff --git a/src/main/java/net/minecraft/world/entity/animal/Bee.java b/src/main/java/net/minecraft/world/entity/animal/Bee.java -index f9521a6e115f0c975a7885b024c99eae300b63bf..358b4efefbf9de576194040ca5da9b877afa3e1b 100644 +index 0dfb8109fd8c022b079da00f6a0e3fc85b57bf7a..3c9560b63e77059ea32ccf7844817d2d22881162 100644 --- a/src/main/java/net/minecraft/world/entity/animal/Bee.java +++ b/src/main/java/net/minecraft/world/entity/animal/Bee.java -@@ -1036,7 +1036,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal { +@@ -1018,7 +1018,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal { BeeGoToHiveGoal() { super(); - this.travellingTicks = Bee.this.random.nextInt(10); // CraftBukkit - SPIGOT-7495: Give Bees another chance and let them use their own random, avoid concurrency issues -+ this.travellingTicks = top.leavesmc.leaves.LeavesConfig.useVanillaRandom ? Bee.this.level().random.nextInt(10) : Bee.this.random.nextInt(10); // CraftBukkit - SPIGOT-7495: Give Bees another chance and let them use their own random, avoid concurrency issues // Leaves - why no vanilla ++ this.travellingTicks = org.leavesmc.leaves.LeavesConfig.useVanillaRandom ? Bee.this.level().random.nextInt(10) : Bee.this.random.nextInt(10); // CraftBukkit - SPIGOT-7495: Give Bees another chance and let them use their own random, avoid concurrency issues // Leaves - why no vanilla this.blacklistedTargets = Lists.newArrayList(); this.setFlags(EnumSet.of(Goal.Flag.MOVE)); } diff --git a/src/main/java/net/minecraft/world/entity/animal/Squid.java b/src/main/java/net/minecraft/world/entity/animal/Squid.java -index 4f32597c7af34d599f6658fe4962d41624e60419..23efed794def54b0563ed5ab1a43773f3bb7378b 100644 +index 43b4ea96c5c4a6234e5b83d41db9b85c1fe27b8f..7e5294d856a757e55fe873d92d1de00a6a7b570e 100644 --- a/src/main/java/net/minecraft/world/entity/animal/Squid.java +++ b/src/main/java/net/minecraft/world/entity/animal/Squid.java -@@ -44,7 +44,7 @@ public class Squid extends WaterAnimal { +@@ -42,7 +42,7 @@ public class Squid extends WaterAnimal { public Squid(EntityType type, Level world) { super(type, world); - //this.random.setSeed((long)this.getId()); // Paper - Share random for entities to make them more random -+ if (top.leavesmc.leaves.LeavesConfig.useVanillaRandom) this.random.setSeed(this.getId()); // Paper - Share random for entities to make them more random // Leaves - vanilla plz ++ if (org.leavesmc.leaves.LeavesConfig.useVanillaRandom) this.random.setSeed(this.getId()); // Paper - Share random for entities to make them more random // Leaves - vanilla plz this.tentacleSpeed = 1.0F / (this.random.nextFloat() + 1.0F) * 0.2F; } 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 b5b522c1307a58453aa293aaa808dd9ec86901fc..45dc79f877bbb4a5384c21a32dc009270b8dc021 100644 +index d3fa592892fc72c8fc8f23e8e477eb88902bba16..1bb762349c868e6a68b46366710dbbee60466eaf 100644 --- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java -@@ -74,7 +74,13 @@ public class ItemEntity extends Entity implements TraceableEntity { +@@ -78,7 +78,13 @@ public class ItemEntity extends Entity implements TraceableEntity { // Paper start - Don't use level random in entity constructors (to make them thread-safe) this(EntityType.ITEM, world); this.setPos(x, y, z); - this.setDeltaMovement(this.random.nextDouble() * 0.2D - 0.1D, 0.2D, this.random.nextDouble() * 0.2D - 0.1D); + // Leaves start - vanilla yes, paper no -+ if (top.leavesmc.leaves.LeavesConfig.useVanillaRandom) { ++ if (org.leavesmc.leaves.LeavesConfig.useVanillaRandom) { + this.setDeltaMovement(world.random.nextDouble() * 0.2D - 0.1D, 0.2D, world.random.nextDouble() * 0.2D - 0.1D); + } else { + this.setDeltaMovement(this.random.nextDouble() * 0.2D - 0.1D, 0.2D, this.random.nextDouble() * 0.2D - 0.1D); @@ -63,15 +63,15 @@ index b5b522c1307a58453aa293aaa808dd9ec86901fc..45dc79f877bbb4a5384c21a32dc00927 // Paper end - Don't use level random in entity constructors // Leaves start - stackable shulker boxes diff --git a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java -index 89681445d9d66a7fdbab50c39fd598fb45cd7441..6c6c953b2ea5b461ec8ed9a8adf0d28c78ea21d9 100644 +index eb9529b4bf20f828fd7e8abf6895baf0c7900dcc..248a94f366d9fb30112c65d151b19879c684b803 100644 --- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java +++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java -@@ -44,7 +44,7 @@ public class PrimedTnt extends Entity implements TraceableEntity { +@@ -42,7 +42,7 @@ public class PrimedTnt extends Entity implements TraceableEntity { public PrimedTnt(Level world, double x, double y, double z, @Nullable LivingEntity igniter) { this(EntityType.TNT, world); this.setPos(x, y, z); - double d3 = this.random.nextDouble() * 6.2831854820251465D; // Paper - Don't use level random in entity constructors -+ double d3 = (top.leavesmc.leaves.LeavesConfig.useVanillaRandom ? world.random.nextDouble() : this.random.nextDouble()) * 6.2831854820251465D; // Paper - Don't use level random in entity constructors // Leaves - why? ++ double d3 = (org.leavesmc.leaves.LeavesConfig.useVanillaRandom ? world.random.nextDouble() : this.random.nextDouble()) * 6.2831854820251465D; // Paper - Don't use level random in entity constructors // Leaves - why? this.setDeltaMovement(-Math.sin(d3) * 0.02D, 0.20000000298023224D, -Math.cos(d3) * 0.02D); this.setFuse(80); diff --git a/patches/server/0053-Fix-update-suppression-crash.patch b/patches/server/0054-Fix-update-suppression-crash.patch similarity index 71% rename from patches/server/0053-Fix-update-suppression-crash.patch rename to patches/server/0054-Fix-update-suppression-crash.patch index d55494f3..fb6999d7 100644 --- a/patches/server/0053-Fix-update-suppression-crash.patch +++ b/patches/server/0054-Fix-update-suppression-crash.patch @@ -5,25 +5,25 @@ Subject: [PATCH] Fix update suppression crash diff --git a/src/main/java/net/minecraft/network/protocol/PacketUtils.java b/src/main/java/net/minecraft/network/protocol/PacketUtils.java -index 070231080052ef3d0da179a8ed8b754ed6f8dd11..84530927aa4517709ba3f38d27755bb5d2eaac34 100644 +index d6daa27a8d7aca00b181e90d789f4249e8437d29..61b0e26a34bf94b10ce0ac78a662d5e97ad4cc9a 100644 --- a/src/main/java/net/minecraft/network/protocol/PacketUtils.java +++ b/src/main/java/net/minecraft/network/protocol/PacketUtils.java -@@ -51,6 +51,10 @@ public class PacketUtils { +@@ -52,6 +52,10 @@ public class PacketUtils { if (listener.shouldHandleMessage(packet)) { try { packet.handle(listener); + // Leaves start - update suppression crash fix -+ } catch (top.leavesmc.leaves.util.UpdateSuppressionException exception) { -+ top.leavesmc.leaves.LeavesLogger.LOGGER.info(exception.getMessage()); ++ } catch (org.leavesmc.leaves.util.UpdateSuppressionException exception) { ++ org.leavesmc.leaves.LeavesLogger.LOGGER.info(exception.getMessage()); + // Leaves start - update suppression crash fix } catch (Exception exception) { - label25: - { + if (exception instanceof ReportedException) { + ReportedException reportedexception = (ReportedException) exception; diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 4091c7b992d885fa14e03df7fa8c5edc0c25f76d..c5c9a9a6f42da7b71103fd754661534dbc9fc13e 100644 +index 81e557588bf91bdd4654833ec967f2a727823d27..c2b2af0a2a4480aa09c0f1a43967ab41cb0e80b1 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -1701,7 +1701,13 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop -Date: Wed, 22 Mar 2023 17:18:23 +0800 +From: MC_XiaoHei +Date: Wed, 8 May 2024 22:19:25 +0800 Subject: [PATCH] Bedrock break list +diff --git a/.gitignore b/.gitignore +index 1ad93453221244f880855b510e888e759275b640..3811c0d849a3eb028ed1a6b7a2d4747f7f570448 100644 +--- a/.gitignore ++++ b/.gitignore +@@ -46,4 +46,3 @@ dependency-reduced-pom.xml + # vs code + /.vscode + /.factorypath +- diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 35433d438e7bcec89363f94ef3903b02b5d02987..1684ea38e395af6236e88ebaeb008526de9f1b4e 100644 +index c2b2af0a2a4480aa09c0f1a43967ab41cb0e80b1..21b659382656f01d7576cd0481c831166f7f3229 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -1737,6 +1737,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop +Date: Wed, 8 May 2024 22:26:38 +0800 +Subject: [PATCH] Placeholder for Syncmatica-Protocol + + +diff --git a/.gitignore b/.gitignore +index 3811c0d849a3eb028ed1a6b7a2d4747f7f570448..1ad93453221244f880855b510e888e759275b640 100644 +--- a/.gitignore ++++ b/.gitignore +@@ -46,3 +46,4 @@ dependency-reduced-pom.xml + # vs code + /.vscode + /.factorypath ++ diff --git a/patches/server/0057-Disable-distance-check-for-UseItemOnPacket.patch b/patches/server/0058-Disable-distance-check-for-UseItemOnPacket.patch similarity index 58% rename from patches/server/0057-Disable-distance-check-for-UseItemOnPacket.patch rename to patches/server/0058-Disable-distance-check-for-UseItemOnPacket.patch index 231808b5..56914792 100644 --- a/patches/server/0057-Disable-distance-check-for-UseItemOnPacket.patch +++ b/patches/server/0058-Disable-distance-check-for-UseItemOnPacket.patch @@ -5,15 +5,15 @@ Subject: [PATCH] Disable distance check for UseItemOnPacket diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 1ff216875a540452b0ce3e5c462a5738c35a3f98..8f2bb7df5c0925b2ef700aebfcbdc539a4dddfe1 100644 +index b9b3277c8ed94e0cd30b20b9c00a33eaad48e5ac..21a3e948ee82605bb970e8503be57b0e66373f77 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -1932,7 +1932,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl - Vec3 vec3d2 = vec3d.subtract(vec3d1); +@@ -1920,7 +1920,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl + Vec3 vec3d1 = vec3d.subtract(Vec3.atCenterOf(blockposition)); double d0 = 1.0000001D; -- if (Math.abs(vec3d2.x()) < 1.0000001D && Math.abs(vec3d2.y()) < 1.0000001D && Math.abs(vec3d2.z()) < 1.0000001D) { -+ if (top.leavesmc.leaves.LeavesConfig.disableDistanceCheckForUseItem || (Math.abs(vec3d2.x()) < 1.0000001D && Math.abs(vec3d2.y()) < 1.0000001D && Math.abs(vec3d2.z()) < 1.0000001D)) { // Leaves - disable check +- if (Math.abs(vec3d1.x()) < 1.0000001D && Math.abs(vec3d1.y()) < 1.0000001D && Math.abs(vec3d1.z()) < 1.0000001D) { ++ if (org.leavesmc.leaves.LeavesConfig.disableDistanceCheckForUseItem || (Math.abs(vec3d1.x()) < 1.0000001D && Math.abs(vec3d1.y()) < 1.0000001D && Math.abs(vec3d1.z()) < 1.0000001D)) { Direction enumdirection = movingobjectpositionblock.getDirection(); this.player.resetLastActionTime(); diff --git a/patches/server/0058-No-feather-falling-trample.patch b/patches/server/0059-No-feather-falling-trample.patch similarity index 66% rename from patches/server/0058-No-feather-falling-trample.patch rename to patches/server/0059-No-feather-falling-trample.patch index 3ff65eed..9b6ef741 100644 --- a/patches/server/0058-No-feather-falling-trample.patch +++ b/patches/server/0059-No-feather-falling-trample.patch @@ -5,16 +5,24 @@ Subject: [PATCH] No feather falling trample diff --git a/src/main/java/net/minecraft/world/level/block/FarmBlock.java b/src/main/java/net/minecraft/world/level/block/FarmBlock.java -index 6e4c852c93f2418ea69e485ed3a10cbe3a6e3bd2..4630cb593cd493c5105c53e70d099f3aa1dd212f 100644 +index d59e33e7326489c6d55d316d0130f22235f4c63c..79ef9b8bd2905d4ca3562971823a9bf48e60a038 100644 --- a/src/main/java/net/minecraft/world/level/block/FarmBlock.java +++ b/src/main/java/net/minecraft/world/level/block/FarmBlock.java -@@ -111,6 +111,13 @@ public class FarmBlock extends Block { +@@ -14,6 +14,7 @@ import net.minecraft.world.entity.Entity; + import net.minecraft.world.entity.LivingEntity; + import net.minecraft.world.entity.player.Player; + import net.minecraft.world.item.context.BlockPlaceContext; ++import net.minecraft.world.item.enchantment.Enchantments; + import net.minecraft.world.level.BlockGetter; + import net.minecraft.world.level.GameRules; + import net.minecraft.world.level.Level; +@@ -112,6 +113,13 @@ public class FarmBlock extends Block { public void fallOn(Level world, BlockState state, BlockPos pos, Entity entity, float fallDistance) { super.fallOn(world, state, pos, entity, fallDistance); // CraftBukkit - moved here as game rules / events shouldn't affect fall damage. if (!world.isClientSide && world.random.nextFloat() < fallDistance - 0.5F && entity instanceof LivingEntity && (entity instanceof Player || world.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) && entity.getBbWidth() * entity.getBbWidth() * entity.getBbHeight() > 0.512F) { + // Leaves start - noFeatherFallingTrample -+ if (top.leavesmc.leaves.LeavesConfig.noFeatherFallingTrample) { -+ if (net.minecraft.world.item.enchantment.EnchantmentHelper.getEnchantmentLevel(net.minecraft.world.item.enchantment.Enchantments.FALL_PROTECTION, (LivingEntity) entity) > 0) { ++ if (org.leavesmc.leaves.LeavesConfig.noFeatherFallingTrample) { ++ if (net.minecraft.world.item.enchantment.EnchantmentHelper.getEnchantmentLevel(Enchantments.FEATHER_FALLING, (LivingEntity) entity) > 0) { + return; + } + } diff --git a/patches/server/0059-Shared-villager-discounts.patch b/patches/server/0060-Shared-villager-discounts.patch similarity index 90% rename from patches/server/0059-Shared-villager-discounts.patch rename to patches/server/0060-Shared-villager-discounts.patch index 88557997..49a4445a 100644 --- a/patches/server/0059-Shared-villager-discounts.patch +++ b/patches/server/0060-Shared-villager-discounts.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Shared villager discounts diff --git a/src/main/java/net/minecraft/world/entity/ai/gossip/GossipContainer.java b/src/main/java/net/minecraft/world/entity/ai/gossip/GossipContainer.java -index c7f012674361a323c1efeca4660cd3f46d308ee1..8c35461b80cba062b8711375a2ff82225ce933a6 100644 +index c7f012674361a323c1efeca4660cd3f46d308ee1..cea09319941f39dbb958ea7ee78c52c7f34fad9e 100644 --- a/src/main/java/net/minecraft/world/entity/ai/gossip/GossipContainer.java +++ b/src/main/java/net/minecraft/world/entity/ai/gossip/GossipContainer.java @@ -115,6 +115,16 @@ public class GossipContainer { @@ -13,7 +13,7 @@ index c7f012674361a323c1efeca4660cd3f46d308ee1..8c35461b80cba062b8711375a2ff8222 public int getReputation(UUID target, Predicate gossipTypeFilter) { GossipContainer.EntityGossips entityGossips = this.gossips.get(target); + // Leaves start - sharedVillagerDiscounts -+ if (top.leavesmc.leaves.LeavesConfig.sharedVillagerDiscounts && gossipTypeFilter.test(GossipType.MAJOR_POSITIVE)) { ++ if (org.leavesmc.leaves.LeavesConfig.sharedVillagerDiscounts && gossipTypeFilter.test(GossipType.MAJOR_POSITIVE)) { + int otherRep = 0; + if (entityGossips != null) { + otherRep = entityGossips.weightedValue(v -> gossipTypeFilter.test(v) && !v.equals(GossipType.MAJOR_POSITIVE)); diff --git a/patches/server/0061-Disable-check-out-of-order-command.patch b/patches/server/0061-Disable-check-out-of-order-command.patch deleted file mode 100644 index 444a6d6d..00000000 --- a/patches/server/0061-Disable-check-out-of-order-command.patch +++ /dev/null @@ -1,19 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: violetc <58360096+s-yh-china@users.noreply.github.com> -Date: Sun, 10 Dec 2023 13:13:14 +0800 -Subject: [PATCH] Disable check out-of-order command - - -diff --git a/src/main/java/net/minecraft/network/chat/SignedMessageChain.java b/src/main/java/net/minecraft/network/chat/SignedMessageChain.java -index 0af9ed92824ccf30814eceb6a2c2e5c12661c991..b007bacf311edd71ef7773e43e8aa2ddd4871bd4 100644 ---- a/src/main/java/net/minecraft/network/chat/SignedMessageChain.java -+++ b/src/main/java/net/minecraft/network/chat/SignedMessageChain.java -@@ -37,7 +37,7 @@ public class SignedMessageChain { - throw new SignedMessageChain.DecodeException(Component.translatable("chat.disabled.chain_broken"), false); // Paper - diff on change (if disconnects, need a new kick event cause) - } else if (playerPublicKey.data().hasExpired()) { - throw new SignedMessageChain.DecodeException(Component.translatable("chat.disabled.expiredProfileKey"), false, org.bukkit.event.player.PlayerKickEvent.Cause.EXPIRED_PROFILE_PUBLIC_KEY); // Paper - kick event causes -- } else if (body.timeStamp().isBefore(this.lastTimeStamp)) { -+ } else if (body.timeStamp().isBefore(this.lastTimeStamp) && !top.leavesmc.leaves.LeavesConfig.disableCheckOutOfOrderCommand) { // Leaves - disable check to support Velocity - throw new SignedMessageChain.DecodeException(Component.translatable("multiplayer.disconnect.out_of_order_chat"), true, org.bukkit.event.player.PlayerKickEvent.Cause.OUT_OF_ORDER_CHAT); // Paper - kick event causes - } else { - this.lastTimeStamp = body.timeStamp(); diff --git a/patches/server/0060-Redstone-wire-dont-connect-if-on-trapdoor.patch b/patches/server/0061-Redstone-wire-dont-connect-if-on-trapdoor.patch similarity index 75% rename from patches/server/0060-Redstone-wire-dont-connect-if-on-trapdoor.patch rename to patches/server/0061-Redstone-wire-dont-connect-if-on-trapdoor.patch index 531a0eb8..9a3a0d9b 100644 --- a/patches/server/0060-Redstone-wire-dont-connect-if-on-trapdoor.patch +++ b/patches/server/0061-Redstone-wire-dont-connect-if-on-trapdoor.patch @@ -5,24 +5,24 @@ Subject: [PATCH] Redstone wire dont connect if on trapdoor diff --git a/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java b/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java -index b5a71fd4e2f55bf036c2c697da5d50cc90fc657c..6afe31169948d644f9af68b8eb31a89c53304826 100644 +index c131734cad123a35456d18f8a161f77a4ac9ac99..067aaa8cea1534f8b87159ad161917e81a258dac 100644 --- a/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java +++ b/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java -@@ -174,7 +174,7 @@ public class RedStoneWireBlock extends Block { +@@ -173,7 +173,7 @@ public class RedStoneWireBlock extends Block { @Override - public BlockState updateShape(BlockState state, Direction direction, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) { + protected BlockState updateShape(BlockState state, Direction direction, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) { if (direction == Direction.DOWN) { - return !this.canSurviveOn(world, neighborPos, neighborState) ? Blocks.AIR.defaultBlockState() : state; -+ return top.leavesmc.leaves.LeavesConfig.redstoneDontCantOnTrapDoor ? state : !this.canSurviveOn(world, neighborPos, neighborState) ? Blocks.AIR.defaultBlockState() : state; // Leaves - behavior to 1.19 ++ return org.leavesmc.leaves.LeavesConfig.redstoneDontCantOnTrapDoor ? state : !this.canSurviveOn(world, neighborPos, neighborState) ? Blocks.AIR.defaultBlockState() : state; // Leaves - behavior to 1.19 } else if (direction == Direction.UP) { return this.getConnectionState(world, state, pos); } else { -@@ -233,7 +233,7 @@ public class RedStoneWireBlock extends Block { +@@ -232,7 +232,7 @@ public class RedStoneWireBlock extends Block { BlockState iblockdata = world.getBlockState(blockposition1); if (flag) { - boolean flag1 = iblockdata.getBlock() instanceof TrapDoorBlock || this.canSurviveOn(world, blockposition1, iblockdata); -+ boolean flag1 = (!top.leavesmc.leaves.LeavesConfig.redstoneDontCantOnTrapDoor && iblockdata.getBlock() instanceof TrapDoorBlock) || this.canSurviveOn(world, blockposition1, iblockdata); // Leaves - behavior to 1.19 ++ boolean flag1 = (!org.leavesmc.leaves.LeavesConfig.redstoneDontCantOnTrapDoor && iblockdata.getBlock() instanceof TrapDoorBlock) || this.canSurviveOn(world, blockposition1, iblockdata); // Leaves - behavior to 1.19 if (flag1 && RedStoneWireBlock.shouldConnectTo(world.getBlockState(blockposition1.above()))) { if (iblockdata.isFaceSturdy(world, blockposition1, direction.getOpposite())) { diff --git a/patches/server/0062-Disable-check-out-of-order-command.patch b/patches/server/0062-Disable-check-out-of-order-command.patch new file mode 100644 index 00000000..8c25354a --- /dev/null +++ b/patches/server/0062-Disable-check-out-of-order-command.patch @@ -0,0 +1,19 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: violetc <58360096+s-yh-china@users.noreply.github.com> +Date: Sun, 10 Dec 2023 13:13:14 +0800 +Subject: [PATCH] Disable check out-of-order command + + +diff --git a/src/main/java/net/minecraft/network/chat/SignedMessageChain.java b/src/main/java/net/minecraft/network/chat/SignedMessageChain.java +index 300929a406905f5ff1ede664d5b99fb0938d4d2e..82d7c376a0a71075f7a013518e284bfe3789f329 100644 +--- a/src/main/java/net/minecraft/network/chat/SignedMessageChain.java ++++ b/src/main/java/net/minecraft/network/chat/SignedMessageChain.java +@@ -45,7 +45,7 @@ public class SignedMessageChain { + SignedMessageLink signedMessageLink = SignedMessageChain.this.nextLink; + if (signedMessageLink == null) { + throw new SignedMessageChain.DecodeException(SignedMessageChain.DecodeException.CHAIN_BROKEN); +- } else if (body.timeStamp().isBefore(SignedMessageChain.this.lastTimeStamp)) { ++ } else if (!org.leavesmc.leaves.LeavesConfig.disableCheckOutOfOrderCommand && body.timeStamp().isBefore(SignedMessageChain.this.lastTimeStamp)) { // Leaves - disable check to support Velocity + 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/patches/server/0062-Despawn-enderman-with-block.patch b/patches/server/0063-Despawn-enderman-with-block.patch similarity index 79% rename from patches/server/0062-Despawn-enderman-with-block.patch rename to patches/server/0063-Despawn-enderman-with-block.patch index 74826caf..3757b00f 100644 --- a/patches/server/0062-Despawn-enderman-with-block.patch +++ b/patches/server/0063-Despawn-enderman-with-block.patch @@ -5,15 +5,15 @@ Subject: [PATCH] Despawn enderman with block 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 9ea374d9baf1612898b67f329e6b5c798ad43b3e..5afa37d2026833c1ded968f957c522436dfe43fd 100644 +index 215176eb7152c11c4934c8576ac8c9fa9b2d0833..675a504ac428aaa130dc607bb8e759e156523f33 100644 --- a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java +++ b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java -@@ -486,7 +486,7 @@ public class EnderMan extends Monster implements NeutralMob { +@@ -469,7 +469,7 @@ public class EnderMan extends Monster implements NeutralMob { @Override public boolean requiresCustomPersistence() { - return super.requiresCustomPersistence() || this.getCarriedBlock() != null; -+ return super.requiresCustomPersistence() || (!top.leavesmc.leaves.LeavesConfig.despawnEndermanWithBlock && this.getCarriedBlock() != null); // Leaves - despawn enderman with block ++ return super.requiresCustomPersistence() || (!org.leavesmc.leaves.LeavesConfig.despawnEndermanWithBlock && this.getCarriedBlock() != null); // Leaves - despawn enderman with block } private static class EndermanFreezeWhenLookedAt extends Goal { diff --git a/patches/server/0064-Placeholder-for-Leaves-carpet-support.patch b/patches/server/0064-Placeholder-for-Leaves-carpet-support.patch new file mode 100644 index 00000000..d692acba --- /dev/null +++ b/patches/server/0064-Placeholder-for-Leaves-carpet-support.patch @@ -0,0 +1,15 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: MC_XiaoHei +Date: Wed, 8 May 2024 22:27:22 +0800 +Subject: [PATCH] Placeholder for Leaves-carpet-support + + +diff --git a/.gitignore b/.gitignore +index 1ad93453221244f880855b510e888e759275b640..3811c0d849a3eb028ed1a6b7a2d4747f7f570448 100644 +--- a/.gitignore ++++ b/.gitignore +@@ -46,4 +46,3 @@ dependency-reduced-pom.xml + # vs code + /.vscode + /.factorypath +- diff --git a/patches/server/0064-Creative-fly-no-clip.patch b/patches/server/0065-Creative-fly-no-clip.patch similarity index 88% rename from patches/server/0064-Creative-fly-no-clip.patch rename to patches/server/0065-Creative-fly-no-clip.patch index f354c577..1ee8efac 100644 --- a/patches/server/0064-Creative-fly-no-clip.patch +++ b/patches/server/0065-Creative-fly-no-clip.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Creative fly no clip 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 567704f61034363e48ef2a5b5566ebdc91682297..8f37983e57321da2a59e047be4a0119118a85a6e 100644 +index 093d1388ff90ad59110a37536b6639f939549068..ba6886d0185eda0c7c6d37640c20636cc163ccf4 100644 --- a/src/main/java/net/minecraft/world/entity/player/Player.java +++ b/src/main/java/net/minecraft/world/entity/player/Player.java -@@ -238,8 +238,8 @@ public abstract class Player extends LivingEntity { +@@ -250,8 +250,8 @@ public abstract class Player extends LivingEntity { @Override public void tick() { @@ -19,7 +19,7 @@ index 567704f61034363e48ef2a5b5566ebdc91682297..8f37983e57321da2a59e047be4a01191 this.setOnGround(false); } -@@ -418,7 +418,7 @@ public abstract class Player extends LivingEntity { +@@ -430,7 +430,7 @@ public abstract class Player extends LivingEntity { Pose entitypose1; @@ -28,7 +28,7 @@ index 567704f61034363e48ef2a5b5566ebdc91682297..8f37983e57321da2a59e047be4a01191 if (this.canPlayerFitWithinBlocksAndEntitiesWhen(Pose.CROUCHING)) { entitypose1 = Pose.CROUCHING; } else { -@@ -578,7 +578,7 @@ public abstract class Player extends LivingEntity { +@@ -577,7 +577,7 @@ public abstract class Player extends LivingEntity { } this.bob += (f - this.bob) * 0.4F; @@ -37,13 +37,13 @@ index 567704f61034363e48ef2a5b5566ebdc91682297..8f37983e57321da2a59e047be4a01191 AABB axisalignedbb; if (this.isPassenger() && !this.getVehicle().isRemoved()) { -@@ -2076,6 +2076,21 @@ public abstract class Player extends LivingEntity { +@@ -2099,6 +2099,21 @@ public abstract class Player extends LivingEntity { @Override public abstract boolean isSpectator(); + // Leaves start - creative no clip + public boolean isCreativeFlyOrSpectator() { -+ return isSpectator() || (top.leavesmc.leaves.LeavesConfig.creativeNoClip && isCreative() && getAbilities().flying); ++ return isSpectator() || (org.leavesmc.leaves.LeavesConfig.creativeNoClip && isCreative() && getAbilities().flying); + } + + public boolean canSpectatingPlace(Level world, BlockState state, BlockPos pos, net.minecraft.world.phys.shapes.CollisionContext context) { @@ -60,15 +60,15 @@ index 567704f61034363e48ef2a5b5566ebdc91682297..8f37983e57321da2a59e047be4a01191 public boolean canBeHitByProjectile() { return !this.isSpectator() && super.canBeHitByProjectile(); diff --git a/src/main/java/net/minecraft/world/item/BlockItem.java b/src/main/java/net/minecraft/world/item/BlockItem.java -index e1ffc1b52641e9cf91f524a83b8c8ee047932d1a..2c799cd93fbba079f53dd37535126a6c0e0261b7 100644 +index c21a65d9637739f1040dd27b096101a7a7adc0df..6dec706a2cadedfad0dff5e7784fe9bec65aad6c 100644 --- a/src/main/java/net/minecraft/world/item/BlockItem.java +++ b/src/main/java/net/minecraft/world/item/BlockItem.java -@@ -228,7 +228,7 @@ public class BlockItem extends Item { +@@ -205,7 +205,7 @@ public class BlockItem extends Item { CollisionContext voxelshapecollision = entityhuman == null ? CollisionContext.empty() : CollisionContext.of(entityhuman); // CraftBukkit start - store default return Level world = context.getLevel(); // Paper - Cancel hit for vanished players - boolean defaultReturn = (!this.mustSurvive() || state.canSurvive(context.getLevel(), context.getClickedPos())) && world.checkEntityCollision(state, entityhuman, voxelshapecollision, context.getClickedPos(), true); // Paper - Cancel hit for vanished players -+ boolean defaultReturn = (!this.mustSurvive() || state.canSurvive(context.getLevel(), context.getClickedPos())) && (top.leavesmc.leaves.LeavesConfig.creativeNoClip && context.getPlayer() != null ? context.getPlayer().canSpectatingPlace(world, state, context.getClickedPos(), voxelshapecollision) : world.checkEntityCollision(state, entityhuman, voxelshapecollision, context.getClickedPos(), true)); // Paper - Cancel hit for vanished players // Leaves - creative no clip ++ boolean defaultReturn = (!this.mustSurvive() || state.canSurvive(context.getLevel(), context.getClickedPos())) && (org.leavesmc.leaves.LeavesConfig.creativeNoClip && context.getPlayer() != null ? context.getPlayer().canSpectatingPlace(world, state, context.getClickedPos(), voxelshapecollision) : world.checkEntityCollision(state, entityhuman, voxelshapecollision, context.getClickedPos(), true)); // Paper - Cancel hit for vanished players // Leaves - creative no clip org.bukkit.entity.Player player = (context.getPlayer() instanceof ServerPlayer) ? (org.bukkit.entity.Player) context.getPlayer().getBukkitEntity() : null; BlockCanBuildEvent event = new BlockCanBuildEvent(CraftBlock.at(context.getLevel(), context.getClickedPos()), player, CraftBlockData.fromData(state), defaultReturn, org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(context.getHand())); // Paper - Expose hand in BlockCanBuildEvent @@ -86,10 +86,10 @@ index 0b761f3ae15ad4a3b8152f497a60403212109534..fdb2bb8a5e6c5d69692804adb086a2d4 BlockCanBuildEvent event = new BlockCanBuildEvent(CraftBlock.at(world, blockposition), player, CraftBlockData.fromData(iblockdata1), defaultReturn, org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(context.getHand())); // Paper - Expose hand in BlockCanBuildEvent diff --git a/src/main/java/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java -index 5c311270a39f6b4996c8b58822d24556c67adc41..cb40179236952edcc1678a58a5886b1916349314 100644 +index 0d68db20f5fbe5e834f12c1e8fd429099a44e4b6..193673d2b70035dac69422aaae185315a901effc 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java -@@ -162,7 +162,7 @@ public class ShulkerBoxBlockEntity extends RandomizableContainerBlockEntity impl +@@ -163,7 +163,7 @@ public class ShulkerBoxBlockEntity extends RandomizableContainerBlockEntity impl while (iterator.hasNext()) { Entity entity = (Entity) iterator.next(); @@ -99,10 +99,10 @@ index 5c311270a39f6b4996c8b58822d24556c67adc41..cb40179236952edcc1678a58a5886b19 } } 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 098fde8200a11f91f934ddab6b1486dac4014dfe..88c9097368f7a842e1d31c460330aa3d267676ef 100644 +index 93bd70c1dc2ba8b893a6087730071c81fb1132f4..4af071ff2d0a29ad9315e1076436f70f848c89b8 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 -@@ -18,6 +18,7 @@ import net.minecraft.util.Mth; +@@ -19,6 +19,7 @@ import net.minecraft.util.Mth; import net.minecraft.util.RandomSource; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntitySelector; @@ -110,7 +110,7 @@ index 098fde8200a11f91f934ddab6b1486dac4014dfe..88c9097368f7a842e1d31c460330aa3d import net.minecraft.world.entity.projectile.ThrownEnderpearl; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.ChunkPos; -@@ -121,7 +122,7 @@ public class TheEndGatewayBlockEntity extends TheEndPortalBlockEntity { +@@ -117,7 +118,7 @@ public class TheEndGatewayBlockEntity extends TheEndPortalBlockEntity { } public static boolean canEntityTeleport(Entity entity) { @@ -120,10 +120,10 @@ index 098fde8200a11f91f934ddab6b1486dac4014dfe..88c9097368f7a842e1d31c460330aa3d public boolean isSpawning() { diff --git a/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java b/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java -index 9f45dda6ff45ac1ffb7ac99575b7d09bdc61c56a..1fde81b6f68f43cd8d9c6123fff1262ccbaa6038 100644 +index b35f476e26a020cf75e53a5eb488717d996a6935..73651a8ae9341807ec96300914d49329fb8a4e90 100644 --- a/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java -@@ -146,7 +146,7 @@ public class PistonMovingBlockEntity extends BlockEntity { +@@ -147,7 +147,7 @@ public class PistonMovingBlockEntity extends BlockEntity { h = (double)direction.getStepZ(); } @@ -132,7 +132,7 @@ index 9f45dda6ff45ac1ffb7ac99575b7d09bdc61c56a..1fde81b6f68f43cd8d9c6123fff1262c // Paper - EAR items stuck in in slime pushed by a piston entity.activatedTick = Math.max(entity.activatedTick, net.minecraft.server.MinecraftServer.currentTick + 10); entity.activatedImmunityTick = Math.max(entity.activatedImmunityTick, net.minecraft.server.MinecraftServer.currentTick + 10); -@@ -182,6 +182,7 @@ public class PistonMovingBlockEntity extends BlockEntity { +@@ -183,6 +183,7 @@ public class PistonMovingBlockEntity extends BlockEntity { } private static void moveEntityByPiston(Direction direction, Entity entity, double distance, Direction movementDirection) { diff --git a/patches/server/0065-Optimized-dragon-respawn.patch b/patches/server/0066-Optimized-dragon-respawn.patch similarity index 93% rename from patches/server/0065-Optimized-dragon-respawn.patch rename to patches/server/0066-Optimized-dragon-respawn.patch index e956aefd..d3a434e2 100644 --- a/patches/server/0065-Optimized-dragon-respawn.patch +++ b/patches/server/0066-Optimized-dragon-respawn.patch @@ -18,7 +18,7 @@ index ee99519ebd46b1db3e76e7eb86e5cc121c867dc4..63f6f1328c4e39cc1f35480166ae5e22 for (int j = 0; j < this.height; j++) { for (int k = 0; k < this.depth; k++) { 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 d4f903c402765c6e8e1db99e148613748f530726..939f1d6958c93819e188946c2173c2668f6d90a1 100644 +index 18a1b4325cac81b040596071dab99ef9bf6f3142..cc08fbadde12ad9f2193811f75628d4bd8d59a0f 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 @@ -45,6 +45,7 @@ import net.minecraft.world.entity.boss.enderdragon.phases.EnderDragonPhase; @@ -40,7 +40,7 @@ index d4f903c402765c6e8e1db99e148613748f530726..939f1d6958c93819e188946c2173c266 + @Nullable public BlockPattern.BlockPatternMatch findExitPortal() { -+ if (top.leavesmc.leaves.LeavesConfig.optimizedDragonRespawn) { ++ if (org.leavesmc.leaves.LeavesConfig.optimizedDragonRespawn) { + int i, j; + for (i = cachePortalChunkIteratorX; i <= 8; ++i) { + for (j = cachePortalChunkIteratorZ; j <= 8; ++j) { @@ -76,7 +76,7 @@ index d4f903c402765c6e8e1db99e148613748f530726..939f1d6958c93819e188946c2173c266 + for (j = i; j >= 0; --j) { + BlockPattern.BlockPatternMatch result2 = null; + if (notFirstSearch) { -+ result2 = top.leavesmc.leaves.util.BlockPatternHelper.partialSearchAround(this.exitPortalPattern, this.level, new BlockPos(EndPodiumFeature.getLocation(BlockPos.ZERO).getY(), j, EndPodiumFeature.getLocation(BlockPos.ZERO).getZ())); ++ result2 = org.leavesmc.leaves.util.BlockPatternHelper.partialSearchAround(this.exitPortalPattern, this.level, new BlockPos(EndPodiumFeature.getLocation(BlockPos.ZERO).getY(), j, EndPodiumFeature.getLocation(BlockPos.ZERO).getZ())); + } else { + result2 = this.exitPortalPattern.find(this.level, new BlockPos(EndPodiumFeature.getLocation(BlockPos.ZERO).getX(), j, EndPodiumFeature.getLocation(BlockPos.ZERO).getZ())); + } @@ -109,13 +109,13 @@ index d4f903c402765c6e8e1db99e148613748f530726..939f1d6958c93819e188946c2173c266 if (this.dragonKilled && this.respawnStage == null) { for (BlockPattern.BlockPatternMatch shapedetector_shapedetectorcollection = this.findExitPortal(); shapedetector_shapedetectorcollection != null; shapedetector_shapedetectorcollection = this.findExitPortal()) { for (int i = 0; i < this.exitPortalPattern.getWidth(); ++i) { -diff --git a/src/main/java/top/leavesmc/leaves/util/BlockPatternHelper.java b/src/main/java/top/leavesmc/leaves/util/BlockPatternHelper.java +diff --git a/src/main/java/org/leavesmc/leaves/util/BlockPatternHelper.java b/src/main/java/org/leavesmc/leaves/util/BlockPatternHelper.java new file mode 100644 -index 0000000000000000000000000000000000000000..cbe424356db5237c261320f0ad5ef5bcf2c70ed4 +index 0000000000000000000000000000000000000000..567cd33afbd17d61ac1847692f5cb762270a3c40 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/util/BlockPatternHelper.java ++++ b/src/main/java/org/leavesmc/leaves/util/BlockPatternHelper.java @@ -0,0 +1,28 @@ -+package top.leavesmc.leaves.util; ++package org.leavesmc.leaves.util; + +import com.google.common.cache.LoadingCache; +import net.minecraft.core.BlockPos; diff --git a/patches/server/0066-Enchantment-mending-compatibility-infinity.patch b/patches/server/0067-Enchantment-mending-compatibility-infinity.patch similarity index 79% rename from patches/server/0066-Enchantment-mending-compatibility-infinity.patch rename to patches/server/0067-Enchantment-mending-compatibility-infinity.patch index 23b03f1a..1eb5059f 100644 --- a/patches/server/0066-Enchantment-mending-compatibility-infinity.patch +++ b/patches/server/0067-Enchantment-mending-compatibility-infinity.patch @@ -5,14 +5,14 @@ Subject: [PATCH] Enchantment mending compatibility infinity diff --git a/src/main/java/net/minecraft/world/item/enchantment/ArrowInfiniteEnchantment.java b/src/main/java/net/minecraft/world/item/enchantment/ArrowInfiniteEnchantment.java -index 04c39359585d909dedbdfd78f6cbdc06b926607a..aef23527fe185df4929dffb96d8e705910bcabe0 100644 +index 81cc05c929d612898609965d82454b89cd18f9f5..96bfa0098a903aca604308877c53336e6269b059 100644 --- a/src/main/java/net/minecraft/world/item/enchantment/ArrowInfiniteEnchantment.java +++ b/src/main/java/net/minecraft/world/item/enchantment/ArrowInfiniteEnchantment.java -@@ -19,6 +19,6 @@ public class ArrowInfiniteEnchantment extends Enchantment { +@@ -7,6 +7,6 @@ public class ArrowInfiniteEnchantment extends Enchantment { @Override public boolean checkCompatibility(Enchantment other) { - return !(other instanceof MendingEnchantment) && super.checkCompatibility(other); -+ return (top.leavesmc.leaves.LeavesConfig.mendingCompatibilityInfinity || !(other instanceof MendingEnchantment)) && super.checkCompatibility(other); // Leaves - mendingCompatibilityInfinity ++ return (org.leavesmc.leaves.LeavesConfig.mendingCompatibilityInfinity || !(other instanceof MendingEnchantment)) && super.checkCompatibility(other); // Leaves - mendingCompatibilityInfinity } } diff --git a/patches/server/0067-Shave-snow-layers.patch b/patches/server/0068-Shave-snow-layers.patch similarity index 52% rename from patches/server/0067-Shave-snow-layers.patch rename to patches/server/0068-Shave-snow-layers.patch index 638b5e16..1c4bcf6d 100644 --- a/patches/server/0067-Shave-snow-layers.patch +++ b/patches/server/0068-Shave-snow-layers.patch @@ -5,11 +5,24 @@ Subject: [PATCH] Shave snow layers diff --git a/src/main/java/net/minecraft/world/item/ShovelItem.java b/src/main/java/net/minecraft/world/item/ShovelItem.java -index 9aba0211f37501bbd19b583d22fa83eae32390d9..8e496f0256091a2ad82537c76b1ce7125dc5a0da 100644 +index 24f6a158e4759aac3be8da4cf5e0d40bd295355b..8c15f74cc5f3c4dfc499e6bdab75f10f66ea36b1 100644 --- a/src/main/java/net/minecraft/world/item/ShovelItem.java +++ b/src/main/java/net/minecraft/world/item/ShovelItem.java -@@ -11,10 +11,12 @@ import net.minecraft.tags.BlockTags; +@@ -2,20 +2,25 @@ package net.minecraft.world.item; + + import com.google.common.collect.Maps; + import com.google.common.collect.ImmutableMap.Builder; ++ + import java.util.Map; ++ + import net.minecraft.core.BlockPos; + import net.minecraft.core.Direction; + import net.minecraft.sounds.SoundEvents; + import net.minecraft.sounds.SoundSource; + import net.minecraft.tags.BlockTags; import net.minecraft.world.InteractionResult; ++import net.minecraft.world.entity.EquipmentSlot; + import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.item.enchantment.EnchantmentHelper; @@ -21,21 +34,23 @@ index 9aba0211f37501bbd19b583d22fa83eae32390d9..8e496f0256091a2ad82537c76b1ce712 import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.gameevent.GameEvent; -@@ -43,6 +45,22 @@ public class ShovelItem extends DiggerItem { +@@ -44,6 +49,24 @@ public class ShovelItem extends DiggerItem { return InteractionResult.PASS; } else { Player player = context.getPlayer(); + // Leaves start - shaveSnowLayers -+ if (top.leavesmc.leaves.LeavesConfig.shaveSnowLayers && blockState.is(Blocks.SNOW)) { ++ if (org.leavesmc.leaves.LeavesConfig.shaveSnowLayers && blockState.is(Blocks.SNOW)) { + int layers = blockState.getValue(SnowLayerBlock.LAYERS); + level.setBlock(blockPos, layers > 1 ? blockState.setValue(SnowLayerBlock.LAYERS, layers - 1) : Blocks.AIR.defaultBlockState(), 11); + Block.popResource(level, blockPos, new ItemStack(EnchantmentHelper.hasSilkTouch(context.getItemInHand()) ? Items.SNOW : Items.SNOWBALL)); + level.playSound(player, blockPos, SoundEvents.SNOW_BREAK, SoundSource.BLOCKS, 1.0F, 1.0F); + -+ if(player != null) { -+ context.getItemInHand().hurtAndBreak(1, player, (p) -> { -+ p.broadcastBreakEvent(context.getHand()); -+ }); ++ if (player != null) { ++ context.getItemInHand().hurtAndBreak(1, player.getRandom(), player, () -> ++ player.broadcastBreakEvent(switch (context.getHand()) { ++ case MAIN_HAND -> EquipmentSlot.MAINHAND; ++ case OFF_HAND -> EquipmentSlot.OFFHAND; ++ })); + } + + return InteractionResult.SUCCESS; @@ -44,3 +59,19 @@ index 9aba0211f37501bbd19b583d22fa83eae32390d9..8e496f0256091a2ad82537c76b1ce712 BlockState blockState2 = FLATTENABLES.get(blockState.getBlock()); BlockState blockState3 = null; Runnable afterAction = null; // Paper +@@ -52,11 +75,11 @@ public class ShovelItem extends DiggerItem { + blockState3 = blockState2; + } else if (blockState.getBlock() instanceof CampfireBlock && blockState.getValue(CampfireBlock.LIT)) { + afterAction = () -> { // Paper +- if (!level.isClientSide()) { +- level.levelEvent(null, 1009, blockPos, 0); +- } ++ if (!level.isClientSide()) { ++ level.levelEvent(null, 1009, blockPos, 0); ++ } + +- CampfireBlock.dowse(context.getPlayer(), level, blockPos, blockState); ++ CampfireBlock.dowse(context.getPlayer(), level, blockPos, blockState); + }; // Paper + blockState3 = blockState.setValue(CampfireBlock.LIT, Boolean.valueOf(false)); + } diff --git a/patches/server/0068-Spawn-ignore-lc.patch b/patches/server/0069-Spawn-ignore-lc.patch similarity index 89% rename from patches/server/0068-Spawn-ignore-lc.patch rename to patches/server/0069-Spawn-ignore-lc.patch index fb82b883..b28d4d52 100644 --- a/patches/server/0068-Spawn-ignore-lc.patch +++ b/patches/server/0069-Spawn-ignore-lc.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Spawn ignore lc diff --git a/src/main/java/net/minecraft/world/level/NaturalSpawner.java b/src/main/java/net/minecraft/world/level/NaturalSpawner.java -index 667a480b7c546bb130bbd32a8ae7ce85d37a6b0a..3e10668ca548472238bb4bb0a80a89f169a71496 100644 +index a9fda9cb7e8266c21aba70d5b1890b30900a5b00..083a8a7dd99e447904dbac161dd3a1de663d6011 100644 --- a/src/main/java/net/minecraft/world/level/NaturalSpawner.java +++ b/src/main/java/net/minecraft/world/level/NaturalSpawner.java -@@ -40,6 +40,7 @@ import net.minecraft.world.level.block.state.BlockState; +@@ -38,6 +38,7 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraft.world.level.chunk.ChunkGenerator; import net.minecraft.world.level.chunk.LevelChunk; @@ -16,12 +16,12 @@ index 667a480b7c546bb130bbd32a8ae7ce85d37a6b0a..3e10668ca548472238bb4bb0a80a89f1 import net.minecraft.world.level.levelgen.Heightmap; import net.minecraft.world.level.levelgen.structure.BuiltinStructures; import net.minecraft.world.level.levelgen.structure.Structure; -@@ -204,6 +205,19 @@ public final class NaturalSpawner { +@@ -199,6 +200,19 @@ public final class NaturalSpawner { } public static int spawnCategoryForChunk(MobCategory group, ServerLevel world, LevelChunk chunk, NaturalSpawner.SpawnPredicate checker, NaturalSpawner.AfterSpawnCallback runner, int maxSpawns, Consumer trackEntity) { // Paper end - Optional per player mob spawns + // Leaves start - ignore lc -+ if (top.leavesmc.leaves.LeavesConfig.ignoreLC) { ++ if (org.leavesmc.leaves.LeavesConfig.ignoreLC) { + int spawnN = 0; + for (int i = chunk.getMinBuildHeight(); i < chunk.getMaxBuildHeight(); i += 16) { + LevelChunkSection section = chunk.getSections()[chunk.getSectionIndex(i)]; @@ -36,7 +36,7 @@ index 667a480b7c546bb130bbd32a8ae7ce85d37a6b0a..3e10668ca548472238bb4bb0a80a89f1 BlockPos blockposition = NaturalSpawner.getRandomPosWithin(world, chunk); if (blockposition.getY() >= world.getMinBuildHeight() + 1) { -@@ -212,6 +226,16 @@ public final class NaturalSpawner { +@@ -207,6 +221,16 @@ public final class NaturalSpawner { return 0; // Paper - Optional per player mob spawns } diff --git a/patches/server/0069-Elytra-aeronautics-no-chunk-load.patch b/patches/server/0070-Elytra-aeronautics-no-chunk-load.patch similarity index 81% rename from patches/server/0069-Elytra-aeronautics-no-chunk-load.patch rename to patches/server/0070-Elytra-aeronautics-no-chunk-load.patch index eae73dc6..33ccd3ff 100644 --- a/patches/server/0069-Elytra-aeronautics-no-chunk-load.patch +++ b/patches/server/0070-Elytra-aeronautics-no-chunk-load.patch @@ -4,11 +4,20 @@ Date: Sun, 2 Jul 2023 09:25:00 +0800 Subject: [PATCH] Elytra aeronautics no chunk load +diff --git a/.gitignore b/.gitignore +index 3811c0d849a3eb028ed1a6b7a2d4747f7f570448..1ad93453221244f880855b510e888e759275b640 100644 +--- a/.gitignore ++++ b/.gitignore +@@ -46,3 +46,4 @@ dependency-reduced-pom.xml + # vs code + /.vscode + /.factorypath ++ diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java -index 8d3df7a26a5fa217648754cf6c52651d423d4511..234897e942df0023307418566211a549a32124e9 100644 +index da65f980f2145ea03341911ce75f7e61b358c9d7..7dcdc9b40c594234d87bef3e75a68ddaa58506a3 100644 --- a/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java -@@ -150,7 +150,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -166,7 +166,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider } // Paper end - use distance map to optimise tracker @@ -17,7 +26,7 @@ index 8d3df7a26a5fa217648754cf6c52651d423d4511..234897e942df0023307418566211a549 int chunkX = io.papermc.paper.util.MCUtil.getChunkCoordinate(player.getX()); int chunkZ = io.papermc.paper.util.MCUtil.getChunkCoordinate(player.getZ()); // Note: players need to be explicitly added to distance maps before they can be updated -@@ -166,7 +166,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -182,7 +182,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider // Paper end - use distance map to optimise entity tracker } @@ -26,17 +35,17 @@ index 8d3df7a26a5fa217648754cf6c52651d423d4511..234897e942df0023307418566211a549 int chunkX = io.papermc.paper.util.MCUtil.getChunkCoordinate(player.getX()); int chunkZ = io.papermc.paper.util.MCUtil.getChunkCoordinate(player.getZ()); // Note: players need to be explicitly added to distance maps before they can be updated -@@ -963,7 +963,8 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -994,7 +994,8 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider } private boolean skipPlayer(ServerPlayer player) { - return player.isSpectator() && !this.level.getGameRules().getBoolean(GameRules.RULE_SPECTATORSGENERATECHUNKS); + return (player.isSpectator() && !this.level.getGameRules().getBoolean(GameRules.RULE_SPECTATORSGENERATECHUNKS)) -+ || (top.leavesmc.leaves.LeavesConfig.elytraAeronauticsNoChunk && player.elytraAeronauticsNoChunk); // Leaves - Elytra aeronautics ++ || (org.leavesmc.leaves.LeavesConfig.elytraAeronauticsNoChunk && player.elytraAeronauticsNoChunk); // Leaves - Elytra aeronautics } void updatePlayerStatus(ServerPlayer player, boolean added) { -@@ -1000,6 +1001,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1031,6 +1032,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider } public void move(ServerPlayer player) { @@ -45,10 +54,10 @@ index 8d3df7a26a5fa217648754cf6c52651d423d4511..234897e942df0023307418566211a549 SectionPos sectionposition = player.getLastSectionPos(); diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index d72326ff333adf3300a6159b1cc644d3381cede6..703d2bf9f486a4effba2c265c117b8a24a8bb65f 100644 +index 21a3e948ee82605bb970e8503be57b0e66373f77..1005e1c4c86f707c3e55ef3c5325dd76bf885ef0 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -545,7 +545,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -556,7 +556,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl speed *= 2f; // TODO: Get the speed of the vehicle instead of the player // Paper start - Prevent moving into unloaded chunks @@ -58,25 +67,25 @@ index d72326ff333adf3300a6159b1cc644d3381cede6..703d2bf9f486a4effba2c265c117b8a2 !worldserver.areChunksLoadedForMove(entity.getBoundingBox().expandTowards(new Vec3(toX, toY, toZ).subtract(entity.position()))) )) { diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 017efdee91fe6326c8e0270c294276b24b42604a..2d3fe02aab536876db949dce184395f731c5d31c 100644 +index d6b5514dfe94b48a81ddd62b57a5d72b0510a61f..1a17258f338f8a4c575e30e4783a8f13ed9380ef 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -1115,7 +1115,13 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -1157,7 +1157,13 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess return; } } - + // Leaves start - elytra aeronautics -+ if (top.leavesmc.leaves.LeavesConfig.elytraAeronauticsNoChunk && this instanceof Player player) { ++ if (org.leavesmc.leaves.LeavesConfig.elytraAeronauticsNoChunk && this instanceof Player player) { + if (movementType == MoverType.PLAYER && player.isFallFlying()) { -+ top.leavesmc.leaves.util.ElytraAeronauticsHelper.flightBehaviour(player, movement); ++ org.leavesmc.leaves.util.ElytraAeronauticsHelper.flightBehaviour(player, movement); + } + } + // Leaves end - elytra aeronautics this.level().getProfiler().push("move"); if (this.stuckSpeedMultiplier.lengthSqr() > 1.0E-7D) { movement = movement.multiply(this.stuckSpeedMultiplier); -@@ -2050,6 +2056,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -2105,6 +2111,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess this.yo = y; this.zo = d4; this.setPos(d3, y, d4); @@ -85,11 +94,11 @@ index 017efdee91fe6326c8e0270c294276b24b42604a..2d3fe02aab536876db949dce184395f7 } 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 8f37983e57321da2a59e047be4a0119118a85a6e..73bef9f6b24dd8a87f82a8a0817be03420267d17 100644 +index ba6886d0185eda0c7c6d37640c20636cc163ccf4..17eef5f974a2d61a99224877cc0f79c4fea7c565 100644 --- a/src/main/java/net/minecraft/world/entity/player/Player.java +++ b/src/main/java/net/minecraft/world/entity/player/Player.java -@@ -183,6 +183,8 @@ public abstract class Player extends LivingEntity { - public float hurtDir; // Paper - protected -> public +@@ -195,6 +195,8 @@ public abstract class Player extends LivingEntity { + public boolean ignoreFallDamageFromCurrentImpulse; public boolean affectsSpawning = true; // Paper - Affects Spawning API public net.kyori.adventure.util.TriState flyingFallDamage = net.kyori.adventure.util.TriState.NOT_SET; // Paper - flying fall damage + // Paper end @@ -97,13 +106,13 @@ index 8f37983e57321da2a59e047be4a0119118a85a6e..73bef9f6b24dd8a87f82a8a0817be034 // CraftBukkit start public boolean fauxSleeping; -diff --git a/src/main/java/top/leavesmc/leaves/util/ElytraAeronauticsHelper.java b/src/main/java/top/leavesmc/leaves/util/ElytraAeronauticsHelper.java +diff --git a/src/main/java/org/leavesmc/leaves/util/ElytraAeronauticsHelper.java b/src/main/java/org/leavesmc/leaves/util/ElytraAeronauticsHelper.java new file mode 100644 -index 0000000000000000000000000000000000000000..fc25e2f960a2936e656541c0fe13745e62451179 +index 0000000000000000000000000000000000000000..3b0e805b3ac9dc40280f9daa1302b1b358bd8083 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/util/ElytraAeronauticsHelper.java ++++ b/src/main/java/org/leavesmc/leaves/util/ElytraAeronauticsHelper.java @@ -0,0 +1,39 @@ -+package top.leavesmc.leaves.util; ++package org.leavesmc.leaves.util; + +import net.minecraft.core.SectionPos; +import net.minecraft.network.chat.Component; @@ -111,7 +120,7 @@ index 0000000000000000000000000000000000000000..fc25e2f960a2936e656541c0fe13745e +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.phys.Vec3; -+import top.leavesmc.leaves.LeavesConfig; ++import org.leavesmc.leaves.LeavesConfig; + +public class ElytraAeronauticsHelper { + diff --git a/patches/server/0070-Cache-ignite-odds.patch b/patches/server/0071-Cache-ignite-odds.patch similarity index 95% rename from patches/server/0070-Cache-ignite-odds.patch rename to patches/server/0071-Cache-ignite-odds.patch index bd3013c4..cf2f04ba 100644 --- a/patches/server/0070-Cache-ignite-odds.patch +++ b/patches/server/0071-Cache-ignite-odds.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Cache ignite odds diff --git a/src/main/java/net/minecraft/world/level/block/FireBlock.java b/src/main/java/net/minecraft/world/level/block/FireBlock.java -index 7f05e58358024d303eab9ab4fbc1bb299760ad1e..8670ffb3aec9980622ae7f59b407689790c075ae 100644 +index 4d467ecf0dd8006b9fa4fb8fb5aadc0622a1e512..2a60644479cdc31cd08beff154864b6c39538649 100644 --- a/src/main/java/net/minecraft/world/level/block/FireBlock.java +++ b/src/main/java/net/minecraft/world/level/block/FireBlock.java @@ -220,6 +220,7 @@ public class FireBlock extends BaseFireBlock { @@ -21,7 +21,7 @@ index 7f05e58358024d303eab9ab4fbc1bb299760ad1e..8670ffb3aec9980622ae7f59b4076897 blockposition_mutableblockposition.setWithOffset(pos, l, j1, i1); - int l1 = this.getIgniteOdds(world, blockposition_mutableblockposition); -+ int l1 = this.getIgniteOdds(world, blockposition_mutableblockposition, top.leavesmc.leaves.LeavesConfig.cacheIgniteOdds ? blockPositionIgniteCache : null); // Leaves - cache ignite odds ++ int l1 = this.getIgniteOdds(world, blockposition_mutableblockposition, org.leavesmc.leaves.LeavesConfig.cacheIgniteOdds ? blockPositionIgniteCache : null); // Leaves - cache ignite odds if (l1 > 0) { int i2 = (l1 + 40 + world.getDifficulty().getId() * 7) / (i + 30); diff --git a/patches/server/0071-Lava-riptide.patch b/patches/server/0072-Lava-riptide.patch similarity index 67% rename from patches/server/0071-Lava-riptide.patch rename to patches/server/0072-Lava-riptide.patch index 1f0d9485..b91aec9e 100644 --- a/patches/server/0071-Lava-riptide.patch +++ b/patches/server/0072-Lava-riptide.patch @@ -5,24 +5,24 @@ Subject: [PATCH] Lava riptide diff --git a/src/main/java/net/minecraft/world/item/TridentItem.java b/src/main/java/net/minecraft/world/item/TridentItem.java -index a792c7b7a6179aa88fc473b27ef0ca13bd91a395..95318fe882bc65d1483c7547b41e6f660c0c0012 100644 +index 47de500fddb0716d142f8f5876a82a95afaa06fa..b01e85c9665fef476acdde74f08beaba168561db 100644 --- a/src/main/java/net/minecraft/world/item/TridentItem.java +++ b/src/main/java/net/minecraft/world/item/TridentItem.java -@@ -66,7 +66,7 @@ public class TridentItem extends Item implements Vanishable { +@@ -70,7 +70,7 @@ public class TridentItem extends Item implements ProjectileItem { if (j >= 10) { int k = EnchantmentHelper.getRiptide(stack); - if (k <= 0 || entityhuman.isInWaterOrRain()) { -+ if (k <= 0 || entityhuman.isInWaterOrRain() || (top.leavesmc.leaves.LeavesConfig.lavaRiptide && entityhuman.isInLava())) { // Leaves - lava riptide ++ if (k <= 0 || entityhuman.isInWaterOrRain() || (org.leavesmc.leaves.LeavesConfig.lavaRiptide && entityhuman.isInLava())) { // Leaves - lava riptide if (!world.isClientSide) { - // CraftBukkit - moved down - /* -@@ -160,7 +160,7 @@ public class TridentItem extends Item implements Vanishable { + // itemstack.hurtAndBreak(1, entityhuman, EntityLiving.getSlotForHand(entityliving.getUsedItemHand())); // CraftBukkit - moved down + if (k == 0) { +@@ -155,7 +155,7 @@ public class TridentItem extends Item implements ProjectileItem { if (itemstack.getDamageValue() >= itemstack.getMaxDamage() - 1) { return InteractionResultHolder.fail(itemstack); - } else if (EnchantmentHelper.getRiptide(itemstack) > 0 && !user.isInWaterOrRain()) { -+ } else if (EnchantmentHelper.getRiptide(itemstack) > 0 && !user.isInWaterOrRain() && !(top.leavesmc.leaves.LeavesConfig.lavaRiptide && user.isInLava())) { // Leaves - lava riptide ++ } else if (EnchantmentHelper.getRiptide(itemstack) > 0 && !user.isInWaterOrRain() && !(org.leavesmc.leaves.LeavesConfig.lavaRiptide && user.isInLava())) { // Leaves - lava riptide return InteractionResultHolder.fail(itemstack); } else { user.startUsingItem(hand); diff --git a/patches/server/0072-No-block-update-command.patch b/patches/server/0073-No-block-update-command.patch similarity index 79% rename from patches/server/0072-No-block-update-command.patch rename to patches/server/0073-No-block-update-command.patch index 571e6cbf..5845b892 100644 --- a/patches/server/0072-No-block-update-command.patch +++ b/patches/server/0073-No-block-update-command.patch @@ -5,32 +5,32 @@ Subject: [PATCH] No block update command diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index 9488fbbf0442d38c18632f0ed50c23fd27078f71..9e95045f10904744f7cbf6e4203f8cbe762a9afc 100644 +index 0f3a92155fa0b4ed9d7fbc87202fd04dc01a0890..3bb53128f6919712f0a88ec11c1bce25bf5b8b84 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java -@@ -2517,6 +2517,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2464,6 +2464,7 @@ public class ServerLevel extends Level implements WorldGenLevel { @Override public void blockUpdated(BlockPos pos, Block block) { -+ if (top.leavesmc.leaves.command.NoBlockUpdateCommand.isNoBlockUpdate()) return; // Leaves - no block update ++ if (org.leavesmc.leaves.command.NoBlockUpdateCommand.isNoBlockUpdate()) return; // Leaves - no block update if (!this.isDebug()) { // CraftBukkit start if (this.populating) { diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java -index 1ad126d992d95062a3db08374db7a927f23a0cac..418a7c9217e6e06bff6866deffff3e7822d35a14 100644 +index 364e8ed48512dd499bf393947fd7a954c22acc0e..cb5effe8be9f43ef6b3fa48c25600cdcd69ddc9e 100644 --- a/src/main/java/net/minecraft/world/item/ItemStack.java +++ b/src/main/java/net/minecraft/world/item/ItemStack.java -@@ -483,7 +483,7 @@ public final class ItemStack { +@@ -504,7 +504,7 @@ public final class ItemStack implements DataComponentHolder { net.minecraft.world.level.block.state.BlockState block = world.getBlockState(newblockposition); if (!(block.getBlock() instanceof BaseEntityBlock)) { // Containers get placed automatically -- block.getBlock().onPlace(block, world, newblockposition, oldBlock, true, context); // Paper - pass context -+ if (!top.leavesmc.leaves.command.NoBlockUpdateCommand.isNoBlockUpdate()) block.getBlock().onPlace(block, world, newblockposition, oldBlock, true, context); // Paper - pass context // Leaves - no block update +- block.onPlace(world, newblockposition, oldBlock, true, context); // Paper - pass context ++ if (!org.leavesmc.leaves.command.NoBlockUpdateCommand.isNoBlockUpdate()) block.onPlace(world, newblockposition, oldBlock, true, context); // Paper - pass context // Leaves - no block update } world.notifyAndUpdatePhysics(newblockposition, null, oldBlock, block, world.getBlockState(newblockposition), updateFlag, 512); // send null chunk as chunk.k() returns false by this point 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 6c611afce3ca26e5b08f3341563a986d2a21142f..46230b09fc176665ba1d29ab3233c3b956a07710 100644 +index 8b4f58dae2dba4c661dbd3de0ef65cdbf3bb861e..2b8bbb6bdb636457796029120960a7e6f98d46e7 100644 --- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java +++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java @@ -481,7 +481,7 @@ public class LevelChunk extends ChunkAccess { @@ -38,66 +38,66 @@ index 6c611afce3ca26e5b08f3341563a986d2a21142f..46230b09fc176665ba1d29ab3233c3b9 // CraftBukkit - Don't place while processing the BlockPlaceEvent, unless it's a BlockContainer. Prevents blocks such as TNT from activating when cancelled. if (!this.level.isClientSide && doPlace && (!this.level.captureBlockStates || block instanceof net.minecraft.world.level.block.BaseEntityBlock)) { - iblockdata.onPlace(this.level, blockposition, iblockdata1, flag); -+ if (!top.leavesmc.leaves.command.NoBlockUpdateCommand.isNoBlockUpdate()) iblockdata.onPlace(this.level, blockposition, iblockdata1, flag); // Leaves - no block update ++ if (!org.leavesmc.leaves.command.NoBlockUpdateCommand.isNoBlockUpdate()) iblockdata.onPlace(this.level, blockposition, iblockdata1, flag); // Leaves - no block update } if (iblockdata.hasBlockEntity()) { 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 82cad323e4fba9aea082047d3eb6c4351681d9af..8a9b471b3cfff45a6c78d8fffa0efb3304152acb 100644 +index d5352883ee51dfc646352ae7e2b76af7efd0441e..57f952323639c1ce409032b8023a7911b4fee9b2 100644 --- a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java +++ b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java -@@ -520,6 +520,7 @@ public abstract class FlowingFluid extends Fluid { +@@ -518,6 +518,7 @@ public abstract class FlowingFluid extends Fluid { @Override public void tick(Level world, BlockPos pos, FluidState state) { -+ if (top.leavesmc.leaves.command.NoBlockUpdateCommand.isNoBlockUpdate()) return; // Leaves - no block update ++ if (org.leavesmc.leaves.command.NoBlockUpdateCommand.isNoBlockUpdate()) return; // Leaves - no block update if (!state.isSource()) { FluidState fluid1 = this.getNewLiquid(world, pos, world.getBlockState(pos)); int i = this.getSpreadDelay(world, pos, state, fluid1); diff --git a/src/main/java/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java b/src/main/java/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java -index 106af2b2c7ff72c7549975aef75cdcff8d9a7d97..5807f624d72f5f83ec28491236153710d29c4e9a 100644 +index 106af2b2c7ff72c7549975aef75cdcff8d9a7d97..ef9f2552367dfa8b708f18d66a4526fea8c24807 100644 --- a/src/main/java/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java +++ b/src/main/java/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java @@ -48,6 +48,7 @@ public class CollectingNeighborUpdater implements NeighborUpdater { } private void addAndRun(BlockPos pos, CollectingNeighborUpdater.NeighborUpdates entry) { -+ if (top.leavesmc.leaves.command.NoBlockUpdateCommand.isNoBlockUpdate()) return; // Leaves - no block update ++ if (org.leavesmc.leaves.command.NoBlockUpdateCommand.isNoBlockUpdate()) return; // Leaves - no block update boolean bl = this.count > 0; boolean bl2 = this.maxChainedNeighborUpdates >= 0 && this.count >= this.maxChainedNeighborUpdates; this.count++; diff --git a/src/main/java/net/minecraft/world/level/redstone/InstantNeighborUpdater.java b/src/main/java/net/minecraft/world/level/redstone/InstantNeighborUpdater.java -index 2708251ebc1995e71fb0e5dca9e158a3005f8a8a..e28351b379677fec356b6efec2d882ee20e7bd48 100644 +index 2708251ebc1995e71fb0e5dca9e158a3005f8a8a..2c39d07e5612b3d435fb782d7861448c470950b4 100644 --- a/src/main/java/net/minecraft/world/level/redstone/InstantNeighborUpdater.java +++ b/src/main/java/net/minecraft/world/level/redstone/InstantNeighborUpdater.java @@ -15,17 +15,20 @@ public class InstantNeighborUpdater implements NeighborUpdater { @Override public void shapeUpdate(Direction direction, BlockState neighborState, BlockPos pos, BlockPos neighborPos, int flags, int maxUpdateDepth) { -+ if (top.leavesmc.leaves.command.NoBlockUpdateCommand.isNoBlockUpdate()) return; // Leaves - no block update ++ if (org.leavesmc.leaves.command.NoBlockUpdateCommand.isNoBlockUpdate()) return; // Leaves - no block update NeighborUpdater.executeShapeUpdate(this.level, direction, neighborState, pos, neighborPos, flags, maxUpdateDepth - 1); } @Override public void neighborChanged(BlockPos pos, Block sourceBlock, BlockPos sourcePos) { -+ if (top.leavesmc.leaves.command.NoBlockUpdateCommand.isNoBlockUpdate()) return; // Leaves - no block update ++ if (org.leavesmc.leaves.command.NoBlockUpdateCommand.isNoBlockUpdate()) return; // Leaves - no block update BlockState blockState = this.level.getBlockState(pos); this.neighborChanged(blockState, pos, sourceBlock, sourcePos, false); } @Override public void neighborChanged(BlockState state, BlockPos pos, Block sourceBlock, BlockPos sourcePos, boolean notify) { -+ if (top.leavesmc.leaves.command.NoBlockUpdateCommand.isNoBlockUpdate()) return; // Leaves - no block update ++ if (org.leavesmc.leaves.command.NoBlockUpdateCommand.isNoBlockUpdate()) return; // Leaves - no block update NeighborUpdater.executeUpdate(this.level, state, pos, sourceBlock, sourcePos, notify); } } -diff --git a/src/main/java/top/leavesmc/leaves/command/NoBlockUpdateCommand.java b/src/main/java/top/leavesmc/leaves/command/NoBlockUpdateCommand.java +diff --git a/src/main/java/org/leavesmc/leaves/command/NoBlockUpdateCommand.java b/src/main/java/org/leavesmc/leaves/command/NoBlockUpdateCommand.java new file mode 100644 -index 0000000000000000000000000000000000000000..819d5a5383dc6978f53645b727722fa924b7a505 +index 0000000000000000000000000000000000000000..f60f3409aeb72f8f0195e667ccb139a7f81729b6 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/command/NoBlockUpdateCommand.java ++++ b/src/main/java/org/leavesmc/leaves/command/NoBlockUpdateCommand.java @@ -0,0 +1,52 @@ -+package top.leavesmc.leaves.command; ++package org.leavesmc.leaves.command; + +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.JoinConfiguration; @@ -109,7 +109,7 @@ index 0000000000000000000000000000000000000000..819d5a5383dc6978f53645b727722fa9 +import org.bukkit.permissions.PermissionDefault; +import org.bukkit.plugin.PluginManager; +import org.jetbrains.annotations.NotNull; -+import top.leavesmc.leaves.LeavesConfig; ++import org.leavesmc.leaves.LeavesConfig; + +import java.util.List; + diff --git a/patches/server/0073-Raider-die-skip-self-raid-check.patch b/patches/server/0073-Raider-die-skip-self-raid-check.patch deleted file mode 100644 index 4e51d488..00000000 --- a/patches/server/0073-Raider-die-skip-self-raid-check.patch +++ /dev/null @@ -1,19 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: violetc <58360096+s-yh-china@users.noreply.github.com> -Date: Sun, 9 Jul 2023 16:51:47 +0800 -Subject: [PATCH] Raider die skip self raid check - - -diff --git a/src/main/java/net/minecraft/world/entity/raid/Raider.java b/src/main/java/net/minecraft/world/entity/raid/Raider.java -index 93bbf7556f9599e9dd90761085a57d78bd521867..e6af29b4934a3d2344ad97c4bbc23523e458ea6a 100644 ---- a/src/main/java/net/minecraft/world/entity/raid/Raider.java -+++ b/src/main/java/net/minecraft/world/entity/raid/Raider.java -@@ -137,7 +137,7 @@ public abstract class Raider extends PatrollingMonster { - raid.removeFromRaid(this, false); - } - -- if (this.isPatrolLeader() && raid == null && ((ServerLevel) this.level()).getRaidAt(this.blockPosition()) == null) { -+ if (this.isPatrolLeader() && (top.leavesmc.leaves.LeavesConfig.skipSelfRaidCheck || raid == null) && ((ServerLevel) this.level()).getRaidAt(this.blockPosition()) == null) { // Leaves - skip self raid check - ItemStack itemstack = this.getItemBySlot(EquipmentSlot.HEAD); - Player entityhuman = null; - diff --git a/patches/server/0074-Container-open-passthrough.patch b/patches/server/0074-Container-open-passthrough.patch deleted file mode 100644 index 6b31077a..00000000 --- a/patches/server/0074-Container-open-passthrough.patch +++ /dev/null @@ -1,36 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: violetc <58360096+s-yh-china@users.noreply.github.com> -Date: Mon, 17 Jul 2023 11:41:50 +0800 -Subject: [PATCH] Container open passthrough - - -diff --git a/src/main/java/net/minecraft/world/level/block/SignBlock.java b/src/main/java/net/minecraft/world/level/block/SignBlock.java -index 27a1e8ffc43efe4e086e7fd88ee4d80c23f98674..aafe4fd8b406f6b880ab37d39958e57550d5b6a1 100644 ---- a/src/main/java/net/minecraft/world/level/block/SignBlock.java -+++ b/src/main/java/net/minecraft/world/level/block/SignBlock.java -@@ -117,6 +117,25 @@ public abstract class SignBlock extends BaseEntityBlock implements SimpleWaterlo - return InteractionResult.SUCCESS; - } else if (flag2) { - return InteractionResult.SUCCESS; -+ // Leaves start - signContainerPassthrough -+ } else if (top.leavesmc.leaves.LeavesConfig.containerPassthrough) { -+ if (item == net.minecraft.world.item.Items.AIR && player.isShiftKeyDown()) { -+ if (!this.otherPlayerIsEditingSign(player, tileentitysign) && player.mayBuild() && this.hasEditableText(player, tileentitysign, flag1)) { -+ this.openTextEdit(player, tileentitysign, flag1); -+ return InteractionResult.SUCCESS; -+ } -+ } -+ -+ BlockPos pos1 = pos.relative(hit.getDirection().getOpposite()); -+ if (this instanceof WallSignBlock || this instanceof WallHangingSignBlock) { -+ pos1 = pos.relative(state.getValue(HorizontalDirectionalBlock.FACING).getOpposite()); -+ } -+ if (world.getBlockEntity(pos1) instanceof net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity) { -+ BlockState state1 = world.getBlockState(pos1); -+ return state1.use(world, player, hand, hit.withPosition(pos1)); -+ } -+ return InteractionResult.PASS; -+ // Leaves end - signContainerPassthrough - } else if (!this.otherPlayerIsEditingSign(player, tileentitysign) && player.mayBuild() && this.hasEditableText(player, tileentitysign, flag1)) { - this.openTextEdit(player, tileentitysign, flag1, io.papermc.paper.event.player.PlayerOpenSignEvent.Cause.INTERACT); // Paper - Add PlayerOpenSignEvent - return this.getInteractionResult(flag); diff --git a/patches/server/0074-Raider-die-skip-self-raid-check.patch b/patches/server/0074-Raider-die-skip-self-raid-check.patch new file mode 100644 index 00000000..11b9c1b1 --- /dev/null +++ b/patches/server/0074-Raider-die-skip-self-raid-check.patch @@ -0,0 +1,19 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: violetc <58360096+s-yh-china@users.noreply.github.com> +Date: Sun, 9 Jul 2023 16:51:47 +0800 +Subject: [PATCH] Raider die skip self raid check + + +diff --git a/src/main/java/net/minecraft/world/entity/raid/Raider.java b/src/main/java/net/minecraft/world/entity/raid/Raider.java +index 98e558338b5d9fb03869d2cc21b3e90eb45b95f6..d9e3c0ff607cc55dbe0df4519279889bcb30e1b2 100644 +--- a/src/main/java/net/minecraft/world/entity/raid/Raider.java ++++ b/src/main/java/net/minecraft/world/entity/raid/Raider.java +@@ -128,7 +128,7 @@ public abstract class Raider extends PatrollingMonster { + Raid raid = this.getCurrentRaid(); + + if (raid != null) { +- if (this.isPatrolLeader()) { ++ if (!org.leavesmc.leaves.LeavesConfig.skipSelfRaidCheck && this.isPatrolLeader()) { // Leaves - skip self raid check + raid.removeLeader(this.getWave()); + } + diff --git a/patches/server/0075-Container-open-passthrough.patch b/patches/server/0075-Container-open-passthrough.patch new file mode 100644 index 00000000..3a0043e3 --- /dev/null +++ b/patches/server/0075-Container-open-passthrough.patch @@ -0,0 +1,55 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: violetc <58360096+s-yh-china@users.noreply.github.com> +Date: Mon, 17 Jul 2023 11:41:50 +0800 +Subject: [PATCH] Container open passthrough + + +diff --git a/src/main/java/net/minecraft/world/level/block/SignBlock.java b/src/main/java/net/minecraft/world/level/block/SignBlock.java +index f7bae8060d993176799ff3ff4653d760a137faba..01dcc910e9151fb28828f99afa0adc21f5a700d7 100644 +--- a/src/main/java/net/minecraft/world/level/block/SignBlock.java ++++ b/src/main/java/net/minecraft/world/level/block/SignBlock.java +@@ -113,6 +113,18 @@ public abstract class SignBlock extends BaseEntityBlock implements SimpleWaterlo + } else { + return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION; + } ++ // Leaves start - signContainerPassthrough ++ } else if (org.leavesmc.leaves.LeavesConfig.containerPassthrough) { ++ BlockPos pos1 = pos.relative(hit.getDirection().getOpposite()); ++ if (this instanceof WallSignBlock || this instanceof WallHangingSignBlock) { ++ pos1 = pos.relative(state.getValue(HorizontalDirectionalBlock.FACING).getOpposite()); ++ } ++ if (world.getBlockEntity(pos1) instanceof net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity) { ++ BlockState state1 = world.getBlockState(pos1); ++ return state1.useItemOn(stack, world, player, hand, hit.withPosition(pos1)); ++ } ++ return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION; ++ // Leaves end - signContainerPassthrough + } else { + return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION; + } +@@ -141,6 +153,25 @@ public abstract class SignBlock extends BaseEntityBlock implements SimpleWaterlo + return InteractionResult.SUCCESS; + } else if (flag1) { + return InteractionResult.SUCCESS; ++ // Leaves start - signContainerPassthrough ++ } else if (org.leavesmc.leaves.LeavesConfig.containerPassthrough) { ++ if (player.isShiftKeyDown()) { ++ if (!this.otherPlayerIsEditingSign(player, tileentitysign) && player.mayBuild() && this.hasEditableText(player, tileentitysign, flag1)) { ++ this.openTextEdit(player, tileentitysign, flag1); ++ return InteractionResult.SUCCESS; ++ } ++ } ++ ++ BlockPos pos1 = pos.relative(hit.getDirection().getOpposite()); ++ if (this instanceof WallSignBlock || this instanceof WallHangingSignBlock) { ++ pos1 = pos.relative(state.getValue(HorizontalDirectionalBlock.FACING).getOpposite()); ++ } ++ if (world.getBlockEntity(pos1) instanceof net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity) { ++ BlockState state1 = world.getBlockState(pos1); ++ return state1.useWithoutItem(world, player, hit.withPosition(pos1)); ++ } ++ return InteractionResult.PASS; ++ // Leaves end - signContainerPassthrough + } else if (!this.otherPlayerIsEditingSign(player, tileentitysign) && player.mayBuild() && this.hasEditableText(player, tileentitysign, flag)) { + this.openTextEdit(player, tileentitysign, flag, io.papermc.paper.event.player.PlayerOpenSignEvent.Cause.INTERACT); // Paper - Add PlayerOpenSignEvent + return InteractionResult.SUCCESS; diff --git a/patches/server/0076-Placeholder-for-Bladeren-Protocol.patch b/patches/server/0076-Placeholder-for-Bladeren-Protocol.patch new file mode 100644 index 00000000..1526b462 --- /dev/null +++ b/patches/server/0076-Placeholder-for-Bladeren-Protocol.patch @@ -0,0 +1,15 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: MC_XiaoHei +Date: Wed, 8 May 2024 22:28:35 +0800 +Subject: [PATCH] Placeholder for Bladeren-Protocol + + +diff --git a/.gitignore b/.gitignore +index 1ad93453221244f880855b510e888e759275b640..3811c0d849a3eb028ed1a6b7a2d4747f7f570448 100644 +--- a/.gitignore ++++ b/.gitignore +@@ -46,4 +46,3 @@ dependency-reduced-pom.xml + # vs code + /.vscode + /.factorypath +- diff --git a/patches/server/0077-Placeholder-for-Bladeren-mspt-sync-protocol.patch b/patches/server/0077-Placeholder-for-Bladeren-mspt-sync-protocol.patch new file mode 100644 index 00000000..0a0343e3 --- /dev/null +++ b/patches/server/0077-Placeholder-for-Bladeren-mspt-sync-protocol.patch @@ -0,0 +1,15 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: MC_XiaoHei +Date: Wed, 8 May 2024 22:28:54 +0800 +Subject: [PATCH] Placeholder for Bladeren-mspt-sync-protocol + + +diff --git a/.gitignore b/.gitignore +index 3811c0d849a3eb028ed1a6b7a2d4747f7f570448..1ad93453221244f880855b510e888e759275b640 100644 +--- a/.gitignore ++++ b/.gitignore +@@ -46,3 +46,4 @@ dependency-reduced-pom.xml + # vs code + /.vscode + /.factorypath ++ diff --git a/patches/server/0077-SIMD-support.patch b/patches/server/0078-SIMD-support.patch similarity index 79% rename from patches/server/0077-SIMD-support.patch rename to patches/server/0078-SIMD-support.patch index 631bb6cf..cddbc9e3 100644 --- a/patches/server/0077-SIMD-support.patch +++ b/patches/server/0078-SIMD-support.patch @@ -5,10 +5,10 @@ Subject: [PATCH] SIMD support diff --git a/build.gradle.kts b/build.gradle.kts -index a2441f300345c3936bce69d6d3f21fdd6626136d..77d6f5eeeb9918a70e0003e97671778303c33ce9 100644 +index fe1f6f1a97ab35c44f596596d16765b8b81753a9..28baa9a192a6fd83563b57a411e9bc905ba6b7e1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts -@@ -70,6 +70,7 @@ tasks.withType { +@@ -73,6 +73,7 @@ tasks.withType { compilerArgs.add("-Xlint:-module") compilerArgs.add("-Xlint:-removal") compilerArgs.add("-Xlint:-dep-ann") @@ -16,7 +16,7 @@ index a2441f300345c3936bce69d6d3f21fdd6626136d..77d6f5eeeb9918a70e0003e976717783 } // Leaves end - hide irrelevant compilation warnings -@@ -189,6 +190,8 @@ fun TaskContainer.registerRunTask( +@@ -182,6 +183,8 @@ fun TaskContainer.registerRunTask( minHeapSize = "${memoryGb}G" maxHeapSize = "${memoryGb}G" diff --git a/patches/server/0078-Dont-respond-ping-before-start-fully.patch b/patches/server/0079-Dont-respond-ping-before-start-fully.patch similarity index 89% rename from patches/server/0078-Dont-respond-ping-before-start-fully.patch rename to patches/server/0079-Dont-respond-ping-before-start-fully.patch index 56b907ba..18103663 100644 --- a/patches/server/0078-Dont-respond-ping-before-start-fully.patch +++ b/patches/server/0079-Dont-respond-ping-before-start-fully.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Dont respond ping before start fully This patch is Powered by Gale(https://github.com/GaleMC/Gale) diff --git a/src/main/java/net/minecraft/server/network/ServerStatusPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerStatusPacketListenerImpl.java -index e5006e7672ba79ed4bcf2c4173c5a9ed4c68395b..06093105d58db26ae4b7dac80bce659995eeaf0f 100644 +index 6f1c9fa89e718cbc01a8d72de34154f49c5f46db..093d0cea2fa37c96086afdb026bf988a7ea3c9ed 100644 --- a/src/main/java/net/minecraft/server/network/ServerStatusPacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerStatusPacketListenerImpl.java @@ -153,6 +153,12 @@ public class ServerStatusPacketListenerImpl implements ServerStatusPacketListene @@ -15,7 +15,7 @@ index e5006e7672ba79ed4bcf2c4173c5a9ed4c68395b..06093105d58db26ae4b7dac80bce6599 */ + // Leaves start - dont respond it before start full + var status = MinecraftServer.getServer().getStatus(); -+ if (top.leavesmc.leaves.LeavesConfig.dontRespondPingBeforeStart && (status == null || status.version() == null || status.version().isEmpty())) { ++ if (org.leavesmc.leaves.LeavesConfig.dontRespondPingBeforeStart && (status == null || status.version() == null || status.version().isEmpty())) { + return; + } + // Leaves end - dont respond it before start full diff --git a/patches/server/0079-Faster-chunk-serialization.patch b/patches/server/0080-Faster-chunk-serialization.patch similarity index 96% rename from patches/server/0079-Faster-chunk-serialization.patch rename to patches/server/0080-Faster-chunk-serialization.patch index 90179dd7..865cf981 100644 --- a/patches/server/0079-Faster-chunk-serialization.patch +++ b/patches/server/0080-Faster-chunk-serialization.patch @@ -112,14 +112,14 @@ index acae3eb30e0689048937f479dc3070f0688abdad..029b62acf1d9f8479ab64a55c12f00ba 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 adfbdca12fbdee2602feb0158674166d5256e49e..7f823b131c3a50a99077665ed688b53862b9fb52 100644 +index 81368bf186365878db2e1ed305bb7bf36c26f61f..c753dbe90aa4126a4c3ad79bb8d6768cb06c096b 100644 --- a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java +++ b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java @@ -23,8 +23,25 @@ import net.minecraft.util.Mth; import net.minecraft.util.SimpleBitStorage; import net.minecraft.util.ThreadingDetector; import net.minecraft.util.ZeroBitStorage; -+import top.leavesmc.leaves.lithium.common.world.chunk.LithiumHashPalette; ++import org.leavesmc.leaves.lithium.common.world.chunk.LithiumHashPalette; public class PalettedContainer implements PaletteResize, PalettedContainerRO { + @@ -160,7 +160,7 @@ index adfbdca12fbdee2602feb0158674166d5256e49e..7f823b131c3a50a99077665ed688b538 - } else { - optional = Optional.empty(); + // Leaves start - faster chunk serialization -+ if (!top.leavesmc.leaves.LeavesConfig.fasterChunkSerialization) { ++ if (!org.leavesmc.leaves.LeavesConfig.fasterChunkSerialization) { + PalettedContainerRO.PackedData var12; + try { + HashMapPalette hashMapPalette = new HashMapPalette<>(idList, this.data.storage.getBits(), this.dummyPaletteResize); @@ -246,7 +246,7 @@ index adfbdca12fbdee2602feb0158674166d5256e49e..7f823b131c3a50a99077665ed688b538 - if (this.data.palette.getSize() == 1) { - counter.accept(this.data.palette.valueFor(0), this.data.storage.getSize()); + // Leaves start - faster chunk serialization -+ if (!top.leavesmc.leaves.LeavesConfig.fasterChunkSerialization) { ++ if (!org.leavesmc.leaves.LeavesConfig.fasterChunkSerialization) { + if (this.data.palette.getSize() == 1) { + counter.accept(this.data.palette.valueFor(0), this.data.storage.getSize()); + } else { @@ -292,13 +292,13 @@ index adfbdca12fbdee2602feb0158674166d5256e49e..7f823b131c3a50a99077665ed688b538 } static record Configuration(Palette.Factory factory, int bits) { -diff --git a/src/main/java/top/leavesmc/leaves/lithium/common/world/chunk/LithiumHashPalette.java b/src/main/java/top/leavesmc/leaves/lithium/common/world/chunk/LithiumHashPalette.java +diff --git a/src/main/java/org/leavesmc/leaves/lithium/common/world/chunk/LithiumHashPalette.java b/src/main/java/org/leavesmc/leaves/lithium/common/world/chunk/LithiumHashPalette.java new file mode 100644 -index 0000000000000000000000000000000000000000..e9573d57ef70ea43be59fd1474399ad48eb4e43a +index 0000000000000000000000000000000000000000..3a110e892dafa965274597018265fc5b9d9a9640 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/lithium/common/world/chunk/LithiumHashPalette.java ++++ b/src/main/java/org/leavesmc/leaves/lithium/common/world/chunk/LithiumHashPalette.java @@ -0,0 +1,197 @@ -+package top.leavesmc.leaves.lithium.common.world.chunk; ++package org.leavesmc.leaves.lithium.common.world.chunk; + +import com.google.common.collect.ImmutableList; +import it.unimi.dsi.fastutil.HashCommon; diff --git a/patches/server/0080-Optimize-world-generation-chunk-and-block-access.patch b/patches/server/0080-Optimize-world-generation-chunk-and-block-access.patch deleted file mode 100644 index d6006c3e..00000000 --- a/patches/server/0080-Optimize-world-generation-chunk-and-block-access.patch +++ /dev/null @@ -1,198 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: violetc <58360096+s-yh-china@users.noreply.github.com> -Date: Tue, 18 Jul 2023 13:36:25 +0800 -Subject: [PATCH] Optimize world generation chunk and block access - -This patch is Powered by Gale(https://github.com/GaleMC/Gale) - -diff --git a/src/main/java/net/minecraft/server/level/WorldGenRegion.java b/src/main/java/net/minecraft/server/level/WorldGenRegion.java -index 5ece375eaf6bcc61864997a389bb5e24625e4505..68d806b4e397f9f90bd66138cbdd23f3108b87e7 100644 ---- a/src/main/java/net/minecraft/server/level/WorldGenRegion.java -+++ b/src/main/java/net/minecraft/server/level/WorldGenRegion.java -@@ -83,6 +83,10 @@ public class WorldGenRegion implements WorldGenLevel { - private Supplier currentlyGenerating; - private final AtomicLong subTickCount = new AtomicLong(); - private static final ResourceLocation WORLDGEN_REGION_RANDOM = new ResourceLocation("worldgen_region_random"); -+ // Leaves start - optimize world generation chunk and block access -+ private ChunkAccess[] chunksArr; -+ private int minChunkX, minChunkZ; -+ // Leaves end - optimize world generation chunk and block access - - public WorldGenRegion(ServerLevel world, List chunks, ChunkStatus status, int placementRadius) { - this.generatingStatus = status; -@@ -105,6 +109,11 @@ public class WorldGenRegion implements WorldGenLevel { - this.lastPos = ((ChunkAccess) chunks.get(chunks.size() - 1)).getPos(); - this.structureManager = world.structureManager().forWorldGenRegion(this); - } -+ // Leaves start - optimize world generation chunk and block access -+ this.minChunkX = this.firstPos.x; -+ this.minChunkZ = this.firstPos.z; -+ this.chunksArr = chunks.toArray(new ChunkAccess[0]); -+ // Leaves end - optimize world generation chunk and block access - } - - // Paper start - starlight -@@ -143,8 +152,29 @@ public class WorldGenRegion implements WorldGenLevel { - - @Override - public ChunkAccess getChunk(int chunkX, int chunkZ) { -- return this.getChunk(chunkX, chunkZ, ChunkStatus.EMPTY); -+ // Leaves start - optimize world generation chunk and block access -+ if (!top.leavesmc.leaves.LeavesConfig.optimizeWorldGenerationAccess) { -+ return this.getChunk(chunkX, chunkZ, ChunkStatus.EMPTY); -+ } else { -+ int x = chunkX - this.minChunkX; -+ int z = chunkZ - this.minChunkZ; -+ int w = this.size; -+ -+ if (x >= 0 && z >= 0 && x < w && z < w) { -+ return this.chunksArr[x + z * w]; -+ } else { -+ throw new NullPointerException("No chunk exists at " + new ChunkPos(chunkX, chunkZ)); -+ } -+ } -+ // Leaves end - optimize world generation chunk and block access -+ } -+ -+ // Leaves start - optimize world generation chunk and block access -+ public ChunkAccess getChunk(BlockPos pos) { -+ // Skip checking chunk.getStatus().isAtLeast(ChunkStatus.EMPTY) here, because it is always true -+ return this.getChunk(SectionPos.blockToSectionCoord(pos.getX()), SectionPos.blockToSectionCoord(pos.getZ())); - } -+ // Leaves end - optimize world generation chunk and block access - - @Nullable - @Override -@@ -203,7 +233,21 @@ public class WorldGenRegion implements WorldGenLevel { - - @Override - public BlockState getBlockState(BlockPos pos) { -- return this.getChunk(SectionPos.blockToSectionCoord(pos.getX()), SectionPos.blockToSectionCoord(pos.getZ())).getBlockState(pos); -+ // Leaves start - optimize world generation chunk and block access -+ if (!top.leavesmc.leaves.LeavesConfig.optimizeWorldGenerationAccess) { -+ return this.getChunk(SectionPos.blockToSectionCoord(pos.getX()), SectionPos.blockToSectionCoord(pos.getZ())).getBlockState(pos); -+ } else { -+ int x = SectionPos.blockToSectionCoord(pos.getX()) - this.minChunkX; -+ int z = SectionPos.blockToSectionCoord(pos.getZ()) - this.minChunkZ; -+ int w = this.size; -+ -+ if (x >= 0 && z >= 0 && x < w && z < w) { -+ return this.chunksArr[x + z * w].getBlockState(pos); -+ } else { -+ throw new NullPointerException("No chunk exists at " + new ChunkPos(pos)); -+ } -+ } -+ // Leaves end - optimize world generation chunk and block access - } - - @Override -diff --git a/src/main/java/top/leavesmc/leaves/lithium/common/util/Pos.java b/src/main/java/top/leavesmc/leaves/lithium/common/util/Pos.java -new file mode 100644 -index 0000000000000000000000000000000000000000..f1650846d080ab743aa324a3fe94447e2b3d7ece ---- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/lithium/common/util/Pos.java -@@ -0,0 +1,104 @@ -+ -+package top.leavesmc.leaves.lithium.common.util; -+ -+import net.minecraft.core.SectionPos; -+import net.minecraft.world.level.LevelHeightAccessor; -+ -+public class Pos { -+ -+ public static class BlockCoord { -+ public static int getYSize(LevelHeightAccessor view) { -+ return view.getHeight(); -+ } -+ -+ public static int getMinY(LevelHeightAccessor view) { -+ return view.getMinBuildHeight(); -+ } -+ -+ public static int getMaxYInclusive(LevelHeightAccessor view) { -+ return view.getMaxBuildHeight() - 1; -+ } -+ -+ public static int getMaxYExclusive(LevelHeightAccessor view) { -+ return view.getMaxBuildHeight(); -+ } -+ -+ public static int getMaxInSectionCoord(int sectionCoord) { -+ return 15 + getMinInSectionCoord(sectionCoord); -+ } -+ -+ public static int getMaxYInSectionIndex(LevelHeightAccessor view, int sectionIndex) { -+ return getMaxInSectionCoord(SectionYCoord.fromSectionIndex(view, sectionIndex)); -+ } -+ -+ public static int getMinInSectionCoord(int sectionCoord) { -+ return SectionPos.sectionToBlockCoord(sectionCoord); -+ } -+ -+ public static int getMinYInSectionIndex(LevelHeightAccessor view, int sectionIndex) { -+ return getMinInSectionCoord(SectionYCoord.fromSectionIndex(view, sectionIndex)); -+ } -+ } -+ -+ public static class ChunkCoord { -+ public static int fromBlockCoord(int blockCoord) { -+ return SectionPos.blockToSectionCoord(blockCoord); -+ } -+ -+ public static int fromBlockSize(int i) { -+ return i >> 4; //same method as fromBlockCoord, just be clear about coord/size semantic difference -+ } -+ } -+ -+ public static class SectionYCoord { -+ public static int getNumYSections(LevelHeightAccessor view) { -+ return view.getSectionsCount(); -+ } -+ -+ public static int getMinYSection(LevelHeightAccessor view) { -+ return view.getMinSection(); -+ } -+ -+ public static int getMaxYSectionInclusive(LevelHeightAccessor view) { -+ return view.getMaxSection() - 1; -+ } -+ -+ public static int getMaxYSectionExclusive(LevelHeightAccessor view) { -+ return view.getMaxSection(); -+ } -+ -+ public static int fromSectionIndex(LevelHeightAccessor view, int sectionCoord) { -+ return sectionCoord + SectionYCoord.getMinYSection(view); -+ } -+ -+ public static int fromBlockCoord(int blockCoord) { -+ return SectionPos.blockToSectionCoord(blockCoord); -+ } -+ } -+ -+ public static class SectionYIndex { -+ public static int getNumYSections(LevelHeightAccessor view) { -+ return view.getSectionsCount(); -+ } -+ -+ public static int getMinYSectionIndex(LevelHeightAccessor view) { -+ return 0; -+ } -+ -+ public static int getMaxYSectionIndexInclusive(LevelHeightAccessor view) { -+ return view.getSectionsCount() - 1; -+ } -+ -+ public static int getMaxYSectionIndexExclusive(LevelHeightAccessor view) { -+ return view.getSectionsCount(); -+ } -+ -+ public static int fromSectionCoord(LevelHeightAccessor view, int sectionCoord) { -+ return sectionCoord - SectionYCoord.getMinYSection(view); -+ } -+ -+ public static int fromBlockCoord(LevelHeightAccessor view, int blockCoord) { -+ return fromSectionCoord(view, SectionPos.blockToSectionCoord(blockCoord)); -+ } -+ } -+} diff --git a/patches/server/0081-Optimize-world-generation-chunk-and-block-access.patch b/patches/server/0081-Optimize-world-generation-chunk-and-block-access.patch new file mode 100644 index 00000000..42a02a8a --- /dev/null +++ b/patches/server/0081-Optimize-world-generation-chunk-and-block-access.patch @@ -0,0 +1,88 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: violetc <58360096+s-yh-china@users.noreply.github.com> +Date: Tue, 18 Jul 2023 13:36:25 +0800 +Subject: [PATCH] Optimize world generation chunk and block access + +This patch is Powered by Gale(https://github.com/GaleMC/Gale) + +diff --git a/src/main/java/net/minecraft/server/level/WorldGenRegion.java b/src/main/java/net/minecraft/server/level/WorldGenRegion.java +index 1351423a12c19a01f602a202832372a399e6a867..fdd4d4a22b75d74cb882f9065d1d30bb1bac044c 100644 +--- a/src/main/java/net/minecraft/server/level/WorldGenRegion.java ++++ b/src/main/java/net/minecraft/server/level/WorldGenRegion.java +@@ -86,6 +86,10 @@ public class WorldGenRegion implements WorldGenLevel { + private Supplier currentlyGenerating; + private final AtomicLong subTickCount = new AtomicLong(); + private static final ResourceLocation WORLDGEN_REGION_RANDOM = new ResourceLocation("worldgen_region_random"); ++ // Leaves start - optimize world generation chunk and block access ++ private ChunkAccess[] chunksArr; ++ private int minChunkX, minChunkZ; ++ // Leaves end - optimize world generation chunk and block access + + public WorldGenRegion(ServerLevel world, List chunks, ChunkStatus status, int placementRadius) { + this.generatingStatus = status; +@@ -107,6 +111,11 @@ public class WorldGenRegion implements WorldGenLevel { + this.firstPos = ((ChunkAccess) chunks.get(0)).getPos(); + this.lastPos = ((ChunkAccess) chunks.get(chunks.size() - 1)).getPos(); + } ++ // Leaves start - optimize world generation chunk and block access ++ this.minChunkX = this.firstPos.x; ++ this.minChunkZ = this.firstPos.z; ++ this.chunksArr = chunks.toArray(new ChunkAccess[0]); ++ // Leaves end - optimize world generation chunk and block access + } + + // Paper start - starlight +@@ -145,8 +154,29 @@ public class WorldGenRegion implements WorldGenLevel { + + @Override + public ChunkAccess getChunk(int chunkX, int chunkZ) { +- return this.getChunk(chunkX, chunkZ, ChunkStatus.EMPTY); ++ // Leaves start - optimize world generation chunk and block access ++ if (!org.leavesmc.leaves.LeavesConfig.optimizeWorldGenerationAccess) { ++ return this.getChunk(chunkX, chunkZ, ChunkStatus.EMPTY); ++ } else { ++ int x = chunkX - this.minChunkX; ++ int z = chunkZ - this.minChunkZ; ++ int w = this.size; ++ ++ if (x >= 0 && z >= 0 && x < w && z < w) { ++ return this.chunksArr[x + z * w]; ++ } else { ++ throw new NullPointerException("No chunk exists at " + new ChunkPos(chunkX, chunkZ)); ++ } ++ } ++ // Leaves end - optimize world generation chunk and block access ++ } ++ ++ // Leaves start - optimize world generation chunk and block access ++ public ChunkAccess getChunk(BlockPos pos) { ++ // Skip checking chunk.getStatus().isAtLeast(ChunkStatus.EMPTY) here, because it is always true ++ return this.getChunk(SectionPos.blockToSectionCoord(pos.getX()), SectionPos.blockToSectionCoord(pos.getZ())); + } ++ // Leaves end - optimize world generation chunk and block access + + @Nullable + @Override +@@ -211,7 +241,21 @@ public class WorldGenRegion implements WorldGenLevel { + + @Override + public BlockState getBlockState(BlockPos pos) { +- return this.getChunk(SectionPos.blockToSectionCoord(pos.getX()), SectionPos.blockToSectionCoord(pos.getZ())).getBlockState(pos); ++ // Leaves start - optimize world generation chunk and block access ++ if (!org.leavesmc.leaves.LeavesConfig.optimizeWorldGenerationAccess) { ++ return this.getChunk(SectionPos.blockToSectionCoord(pos.getX()), SectionPos.blockToSectionCoord(pos.getZ())).getBlockState(pos); ++ } else { ++ int x = SectionPos.blockToSectionCoord(pos.getX()) - this.minChunkX; ++ int z = SectionPos.blockToSectionCoord(pos.getZ()) - this.minChunkZ; ++ int w = this.size; ++ ++ if (x >= 0 && z >= 0 && x < w && z < w) { ++ return this.chunksArr[x + z * w].getBlockState(pos); ++ } else { ++ throw new NullPointerException("No chunk exists at " + new ChunkPos(pos)); ++ } ++ } ++ // Leaves end - optimize world generation chunk and block access + } + + @Override diff --git a/patches/server/0081-Cache-world-generator-sea-level.patch b/patches/server/0082-Cache-world-generator-sea-level.patch similarity index 93% rename from patches/server/0081-Cache-world-generator-sea-level.patch rename to patches/server/0082-Cache-world-generator-sea-level.patch index e97e5953..3fae06ad 100644 --- a/patches/server/0081-Cache-world-generator-sea-level.patch +++ b/patches/server/0082-Cache-world-generator-sea-level.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Cache world generator sea level This patch is Powered by Gale(https://github.com/GaleMC/Gale) 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 98c7f695093acbcf9382a5f07a7a89e373709763..5cb228f3362b87418561ed3a77f4a241ddb8e9b5 100644 +index 8ce870a5341a61fbbaf42021ef7f7f615a6a3e09..d217bccc5af50360e3b3b265953fba91aaf204db 100644 --- a/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java +++ b/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java @@ -62,12 +62,17 @@ public final class NoiseBasedChunkGenerator extends ChunkGenerator { @@ -34,7 +34,7 @@ index 98c7f695093acbcf9382a5f07a7a89e373709763..5cb228f3362b87418561ed3a77f4a241 public int getSeaLevel() { - return ((NoiseGeneratorSettings) this.settings.value()).seaLevel(); + // Leaves start - cache world generator sea level -+ if (!top.leavesmc.leaves.LeavesConfig.cacheWorldGeneratorSeaLevel) { ++ if (!org.leavesmc.leaves.LeavesConfig.cacheWorldGeneratorSeaLevel) { + return ((NoiseGeneratorSettings) this.settings.value()).seaLevel(); + } else { + return cachedSeaLevel; diff --git a/patches/server/0082-Skip-secondary-POI-sensor-if-absent.patch b/patches/server/0083-Skip-secondary-POI-sensor-if-absent.patch similarity index 89% rename from patches/server/0082-Skip-secondary-POI-sensor-if-absent.patch rename to patches/server/0083-Skip-secondary-POI-sensor-if-absent.patch index bda3c447..672f74e9 100644 --- a/patches/server/0082-Skip-secondary-POI-sensor-if-absent.patch +++ b/patches/server/0083-Skip-secondary-POI-sensor-if-absent.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Skip secondary POI sensor if absent This patch is Powered by Gale(https://github.com/GaleMC/Gale) 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 cb1d91f9fe98f21c2afbe3894dfd9bca3bdd3ba6..ea89cf4a0746ecf1fdb1eae27560299b813d4374 100644 +index a0e0692d17760f440fe81d52887284c787e562db..4b9470eb94ca1d90161cfbd3de06ec5f56adbb7b 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 @@ -22,6 +22,15 @@ public class SecondaryPoiSensor extends Sensor { @@ -14,7 +14,7 @@ index cb1d91f9fe98f21c2afbe3894dfd9bca3bdd3ba6..ea89cf4a0746ecf1fdb1eae27560299b @Override protected void doTick(ServerLevel world, Villager entity) { + // Leaves start - skip secondary POI sensor if absent -+ if (top.leavesmc.leaves.LeavesConfig.skipSecondaryPOISensorIfAbsent) { ++ if (org.leavesmc.leaves.LeavesConfig.skipSecondaryPOISensorIfAbsent) { + var secondaryPoi = entity.getVillagerData().getProfession().secondaryPoi(); + if (secondaryPoi.isEmpty()) { + entity.getBrain().eraseMemory(MemoryModuleType.SECONDARY_JOB_SITE); diff --git a/patches/server/0083-Cache-CubeVoxelShape-shape-array.patch b/patches/server/0084-Cache-CubeVoxelShape-shape-array.patch similarity index 91% rename from patches/server/0083-Cache-CubeVoxelShape-shape-array.patch rename to patches/server/0084-Cache-CubeVoxelShape-shape-array.patch index 0d13abfd..d456cc0b 100644 --- a/patches/server/0083-Cache-CubeVoxelShape-shape-array.patch +++ b/patches/server/0084-Cache-CubeVoxelShape-shape-array.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Cache CubeVoxelShape shape array This patch is Powered by Gale(https://github.com/GaleMC/Gale) diff --git a/src/main/java/net/minecraft/world/phys/shapes/CubeVoxelShape.java b/src/main/java/net/minecraft/world/phys/shapes/CubeVoxelShape.java -index 110405e6e70d980d3e09f04d79562b32a7413071..8e44c1ae9f898f943d8c74fe34447546677be7d4 100644 +index b9af1d14c7815c99273bce8165cf384d669c1a75..832f9d8ee74823fb50b243033ce3de0e27ab4837 100644 --- a/src/main/java/net/minecraft/world/phys/shapes/CubeVoxelShape.java +++ b/src/main/java/net/minecraft/world/phys/shapes/CubeVoxelShape.java @@ -5,6 +5,9 @@ import net.minecraft.core.Direction; @@ -25,7 +25,7 @@ index 110405e6e70d980d3e09f04d79562b32a7413071..8e44c1ae9f898f943d8c74fe34447546 protected DoubleList getCoords(Direction.Axis axis) { - return new CubePointRange(this.shape.getSize(axis)); + // Leaves start - cache CubeVoxelShape shape array -+ if (!top.leavesmc.leaves.LeavesConfig.cacheCubeVoxelShapeShapeArray) { ++ if (!org.leavesmc.leaves.LeavesConfig.cacheCubeVoxelShapeShapeArray) { + return new CubePointRange(this.shape.getSize(axis)); + } else { + if (this.list == null) { diff --git a/patches/server/0084-Store-mob-counts-in-an-array.patch b/patches/server/0085-Store-mob-counts-in-an-array.patch similarity index 89% rename from patches/server/0084-Store-mob-counts-in-an-array.patch rename to patches/server/0085-Store-mob-counts-in-an-array.patch index 3f8c487c..78303a6e 100644 --- a/patches/server/0084-Store-mob-counts-in-an-array.patch +++ b/patches/server/0085-Store-mob-counts-in-an-array.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Store mob counts in an array This patch is Powered by Gale(https://github.com/GaleMC/Gale) diff --git a/src/main/java/net/minecraft/world/level/LocalMobCapCalculator.java b/src/main/java/net/minecraft/world/level/LocalMobCapCalculator.java -index 09199c574169057ae6e52ee7df277c03fa6ba5c2..11427a5bafc8833f03dd9f5136923f11c09d06af 100644 +index 09199c574169057ae6e52ee7df277c03fa6ba5c2..388c2e43a46bdf4ac98279955560c6639e70f4de 100644 --- a/src/main/java/net/minecraft/world/level/LocalMobCapCalculator.java +++ b/src/main/java/net/minecraft/world/level/LocalMobCapCalculator.java @@ -43,13 +43,26 @@ public class LocalMobCapCalculator { @@ -18,7 +18,7 @@ index 09199c574169057ae6e52ee7df277c03fa6ba5c2..11427a5bafc8833f03dd9f5136923f11 public void add(MobCategory spawnGroup) { - this.counts.computeInt(spawnGroup, (group, density) -> density == null ? 1 : density + 1); + // Leaves start - store mob counts in an array -+ if (!top.leavesmc.leaves.LeavesConfig.storeMobCountsInArray) { ++ if (!org.leavesmc.leaves.LeavesConfig.storeMobCountsInArray) { + this.counts.computeInt(spawnGroup, (group, density) -> density == null ? 1 : density + 1); + } else { + this.arrCounts[spawnGroup.ordinal()]++; @@ -29,7 +29,7 @@ index 09199c574169057ae6e52ee7df277c03fa6ba5c2..11427a5bafc8833f03dd9f5136923f11 public boolean canSpawn(MobCategory spawnGroup) { - return this.counts.getOrDefault(spawnGroup, 0) < spawnGroup.getMaxInstancesPerChunk(); + // Leaves start - store mob counts in an array -+ if (!top.leavesmc.leaves.LeavesConfig.storeMobCountsInArray) { ++ if (!org.leavesmc.leaves.LeavesConfig.storeMobCountsInArray) { + return this.counts.getOrDefault(spawnGroup, 0) < spawnGroup.getMaxInstancesPerChunk(); + } else { + return this.arrCounts[spawnGroup.ordinal()] < spawnGroup.getMaxInstancesPerChunk(); diff --git a/patches/server/0085-Cache-BlockStatePairKey-hash.patch b/patches/server/0086-Cache-BlockStatePairKey-hash.patch similarity index 87% rename from patches/server/0085-Cache-BlockStatePairKey-hash.patch rename to patches/server/0086-Cache-BlockStatePairKey-hash.patch index e882717f..7f977e6e 100644 --- a/patches/server/0085-Cache-BlockStatePairKey-hash.patch +++ b/patches/server/0086-Cache-BlockStatePairKey-hash.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Cache BlockStatePairKey hash This patch is Powered by Gale(https://github.com/GaleMC/Gale) 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 feab3cc5724a1fc44374a30c75dca9e3a3721adc..10c0fdfec1fcec3f9f7897685b2c7e00dc291b2d 100644 +index 41f1a7bf2fb87b6d28d2ca392dfee5d5032d2151..c6bb82c8b755b012735d74bd27deab8e380858c1 100644 --- a/src/main/java/net/minecraft/world/level/block/Block.java +++ b/src/main/java/net/minecraft/world/level/block/Block.java -@@ -641,11 +641,18 @@ public class Block extends BlockBehaviour implements ItemLike { +@@ -629,11 +629,18 @@ public class Block extends BlockBehaviour implements ItemLike { private final BlockState first; private final BlockState second; private final Direction direction; @@ -28,13 +28,13 @@ index feab3cc5724a1fc44374a30c75dca9e3a3721adc..10c0fdfec1fcec3f9f7897685b2c7e00 } public boolean equals(Object object) { -@@ -661,11 +668,17 @@ public class Block extends BlockBehaviour implements ItemLike { +@@ -649,11 +656,17 @@ public class Block extends BlockBehaviour implements ItemLike { } public int hashCode() { - int i = this.first.hashCode(); + // Leaves start - cache BlockStatePairKey hash -+ if (!top.leavesmc.leaves.LeavesConfig.cacheBlockStatePairKeyHash) { ++ if (!org.leavesmc.leaves.LeavesConfig.cacheBlockStatePairKeyHash) { + int i = this.first.hashCode(); - i = 31 * i + this.second.hashCode(); diff --git a/patches/server/0086-Optimize-noise-generation.patch b/patches/server/0087-Optimize-noise-generation.patch similarity index 95% rename from patches/server/0086-Optimize-noise-generation.patch rename to patches/server/0087-Optimize-noise-generation.patch index 9815ecd5..645abca5 100644 --- a/patches/server/0086-Optimize-noise-generation.patch +++ b/patches/server/0087-Optimize-noise-generation.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Optimize noise generation This patch is Powered by Gale(https://github.com/GaleMC/Gale) 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..a2892eb6aa1604a49ba0494a2c98e47f605f0327 100644 +index 9a97e5cd23d839183ac4d243d28df92af3119fe7..6eeb8ff51a3fa519f43f17a3ced2b2080f264d7a 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 { @@ -48,7 +48,7 @@ index 9a97e5cd23d839183ac4d243d28df92af3119fe7..a2892eb6aa1604a49ba0494a2c98e47f + double g; + double h; + double l; -+ if (!top.leavesmc.leaves.LeavesConfig.optimizeNoiseGeneration) { ++ if (!org.leavesmc.leaves.LeavesConfig.optimizeNoiseGeneration) { + g = d - (double)i; + h = e - (double)j; + l = f - (double)k; @@ -67,7 +67,7 @@ index 9a97e5cd23d839183ac4d243d28df92af3119fe7..a2892eb6aa1604a49ba0494a2c98e47f - o = (double)Mth.floor(m / yScale + 1.0E-7F) * yScale; + // Leaves start - optimize noise generation -+ if (!top.leavesmc.leaves.LeavesConfig.optimizeNoiseGeneration) { ++ if (!org.leavesmc.leaves.LeavesConfig.optimizeNoiseGeneration) { + o = (double)Mth.floor(m / yScale + 1.0E-7F) * yScale; + } else { + o = Math.floor(m / yScale + (double)1.0E-7F) * yScale; @@ -79,7 +79,7 @@ index 9a97e5cd23d839183ac4d243d28df92af3119fe7..a2892eb6aa1604a49ba0494a2c98e47f - return this.sampleAndLerp(i, j, k, g, h - o, l, h); + // Leaves start - optimize noise generation -+ if (!top.leavesmc.leaves.LeavesConfig.optimizeNoiseGeneration) { ++ if (!org.leavesmc.leaves.LeavesConfig.optimizeNoiseGeneration) { + return this.sampleAndLerp(i, j, k, g, h - o, l, h); + } else { + return this.sampleAndLerp((int) i, (int) j, (int) k, g, h - o, l, h); @@ -97,7 +97,7 @@ index 9a97e5cd23d839183ac4d243d28df92af3119fe7..a2892eb6aa1604a49ba0494a2c98e47f - double l = f - (double)k; - return this.sampleWithDerivative(i, j, k, g, h, l, ds); + // Leaves start - optimize noise generation -+ if (!top.leavesmc.leaves.LeavesConfig.optimizeNoiseGeneration) { ++ if (!org.leavesmc.leaves.LeavesConfig.optimizeNoiseGeneration) { + double g = d - (double)i; + double h = e - (double)j; + double l = f - (double)k; @@ -135,7 +135,7 @@ index 9a97e5cd23d839183ac4d243d28df92af3119fe7..a2892eb6aa1604a49ba0494a2c98e47f - double t = Mth.smoothstep(localZ); - return Mth.lerp3(r, s, t, d, e, f, g, h, o, p, q); + // Leaves start - optimize noise generation -+ if (!top.leavesmc.leaves.LeavesConfig.optimizeNoiseGeneration) { ++ if (!org.leavesmc.leaves.LeavesConfig.optimizeNoiseGeneration) { + int i = this.p(sectionX); + int j = this.p(sectionX + 1); + int k = this.p(i + sectionY); @@ -222,7 +222,7 @@ index 9a97e5cd23d839183ac4d243d28df92af3119fe7..a2892eb6aa1604a49ba0494a2c98e47f 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..7fd2ddcc8db7ef4e49ccf3bf13b17ef960b93159 100644 +index 35820670837376bcad8891241724d5b946fbd31f..cd52ee8c8ad0a3f0befc8d9d98e5afc75a802d15 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 { @@ -253,7 +253,7 @@ index 35820670837376bcad8891241724d5b946fbd31f..7fd2ddcc8db7ef4e49ccf3bf13b17ef9 public double getValue(double x, double y, double z) { - return this.getValue(x, y, z, 0.0, 0.0, false); + // Leaves start - optimize noise generation -+ if (!top.leavesmc.leaves.LeavesConfig.optimizeNoiseGeneration) { ++ if (!org.leavesmc.leaves.LeavesConfig.optimizeNoiseGeneration) { + return this.getValue(x, y, z, 0.0, 0.0, false); + } else { + double d = 0.0; diff --git a/patches/server/0087-Disable-packet-limit.patch b/patches/server/0088-Disable-packet-limit.patch similarity index 78% rename from patches/server/0087-Disable-packet-limit.patch rename to patches/server/0088-Disable-packet-limit.patch index c89849ea..766d005e 100644 --- a/patches/server/0087-Disable-packet-limit.patch +++ b/patches/server/0088-Disable-packet-limit.patch @@ -5,15 +5,15 @@ Subject: [PATCH] Disable packet limit diff --git a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java -index dd402f077922ea3946a18cdf04285c67fd093538..41372edb33ac41f92bd1b0351cd2cf2e89d888df 100644 +index 0cb47b5fee85230989293d430c02e53391e0ef67..124ea4b5894022df757578ce89374c33d5768a52 100644 --- a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java +++ b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java -@@ -267,7 +267,7 @@ public class GlobalConfiguration extends ConfigurationPart { +@@ -265,7 +265,7 @@ public class GlobalConfiguration extends ConfigurationPart { } public boolean isEnabled() { - return this.interval > 0.0 && this.maxPacketRate > 0.0; -+ return !top.leavesmc.leaves.LeavesConfig.disablePacketLimit && (this.interval > 0.0 && this.maxPacketRate > 0.0); // Leaves - disable packet limit ++ return !org.leavesmc.leaves.LeavesConfig.disablePacketLimit && (this.interval > 0.0 && this.maxPacketRate > 0.0); // Leaves - disable packet limit } public enum ViolateAction { diff --git a/patches/server/0088-Reduce-array-allocations.patch b/patches/server/0089-Reduce-array-allocations.patch similarity index 75% rename from patches/server/0088-Reduce-array-allocations.patch rename to patches/server/0089-Reduce-array-allocations.patch index 033b70e6..572bcde5 100644 --- a/patches/server/0088-Reduce-array-allocations.patch +++ b/patches/server/0089-Reduce-array-allocations.patch @@ -6,14 +6,14 @@ Subject: [PATCH] Reduce array allocations This patch is Powered by Gale(https://github.com/GaleMC/Gale) diff --git a/src/main/java/com/destroystokyo/paper/util/maplist/EntityList.java b/src/main/java/com/destroystokyo/paper/util/maplist/EntityList.java -index 0133ea6feb1ab88f021f66855669f58367e7420b..d5e5463e3054cc06bd6589a864ff2003b1dfb9e3 100644 +index 0133ea6feb1ab88f021f66855669f58367e7420b..f56c2491fb2e84e459073ad128abf0dc699d45e9 100644 --- a/src/main/java/com/destroystokyo/paper/util/maplist/EntityList.java +++ b/src/main/java/com/destroystokyo/paper/util/maplist/EntityList.java @@ -5,6 +5,7 @@ import net.minecraft.world.entity.Entity; import java.util.Arrays; import java.util.Iterator; import java.util.NoSuchElementException; -+import top.leavesmc.leaves.util.ArrayConstants; ++import org.leavesmc.leaves.util.ArrayConstants; // list with O(1) remove & contains /** @@ -29,14 +29,14 @@ index 0133ea6feb1ab88f021f66855669f58367e7420b..d5e5463e3054cc06bd6589a864ff2003 public int size() { diff --git a/src/main/java/com/destroystokyo/paper/util/maplist/IBlockDataList.java b/src/main/java/com/destroystokyo/paper/util/maplist/IBlockDataList.java -index 277cfd9d1e8fff5d9b5e534b75c3c5162d58b0b7..19d5f3e167d7c94d33fcedc6c787d86ad5fee770 100644 +index 277cfd9d1e8fff5d9b5e534b75c3c5162d58b0b7..7b870ea004d338b2bb9423f9d8c5759801315950 100644 --- a/src/main/java/com/destroystokyo/paper/util/maplist/IBlockDataList.java +++ b/src/main/java/com/destroystokyo/paper/util/maplist/IBlockDataList.java @@ -6,6 +6,7 @@ import java.util.Arrays; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.chunk.GlobalPalette; -+import top.leavesmc.leaves.util.ArrayConstants; ++import org.leavesmc.leaves.util.ArrayConstants; /** * @author Spottedleaf @@ -52,14 +52,14 @@ index 277cfd9d1e8fff5d9b5e534b75c3c5162d58b0b7..19d5f3e167d7c94d33fcedc6c787d86a public static int getLocationKey(final int x, final int y, final int z) { 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..ad33c51ea9f74d2afd39c9139a9114b0f4436400 100644 +index ae60bd96b5284d54676d8e7e4dd5d170b526ec1e..0c474b1eb4dbef547890b7db5fcf9c13c86092a2 100644 --- a/src/main/java/io/papermc/paper/command/subcommands/VersionCommand.java +++ b/src/main/java/io/papermc/paper/command/subcommands/VersionCommand.java @@ -7,6 +7,7 @@ import org.bukkit.command.CommandSender; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.framework.qual.DefaultQualifier; -+import top.leavesmc.leaves.util.ArrayConstants; ++import org.leavesmc.leaves.util.ArrayConstants; @DefaultQualifier(NonNull.class) public final class VersionCommand implements PaperSubcommand { @@ -73,14 +73,14 @@ index ae60bd96b5284d54676d8e7e4dd5d170b526ec1e..ad33c51ea9f74d2afd39c9139a9114b0 return true; } diff --git a/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java b/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java -index c78cbec447032de9fe69748591bef6be300160ed..127525545aea0ed32d5385e0f35de1cb5671c429 100644 +index c78cbec447032de9fe69748591bef6be300160ed..d00ddb838eb3ab5871449e591a80cb012b03d20f 100644 --- a/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java +++ b/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java @@ -25,6 +25,7 @@ import java.util.Iterator; import java.util.List; import java.util.function.Predicate; import org.bukkit.event.entity.EntityRemoveEvent; -+import top.leavesmc.leaves.util.ArrayConstants; ++import org.leavesmc.leaves.util.ArrayConstants; public final class ChunkEntitySlices { @@ -121,14 +121,14 @@ index c78cbec447032de9fe69748591bef6be300160ed..127525545aea0ed32d5385e0f35de1cb } else { this.storage = Arrays.copyOf(this.storage, this.storage.length * 2); diff --git a/src/main/java/net/minecraft/nbt/ByteArrayTag.java b/src/main/java/net/minecraft/nbt/ByteArrayTag.java -index 06648f9751fd8a322d0809ffebf6a544596ee1a4..40e957a4364c8017072dcd81fcb7cf2c9415df38 100644 +index 06648f9751fd8a322d0809ffebf6a544596ee1a4..d6761bdb37619b91f147ff7a9197b730b90bd6cb 100644 --- a/src/main/java/net/minecraft/nbt/ByteArrayTag.java +++ b/src/main/java/net/minecraft/nbt/ByteArrayTag.java @@ -7,6 +7,7 @@ import java.io.IOException; import java.util.Arrays; import java.util.List; import org.apache.commons.lang3.ArrayUtils; -+import top.leavesmc.leaves.util.ArrayConstants; ++import org.leavesmc.leaves.util.ArrayConstants; public class ByteArrayTag extends CollectionTag { @@ -142,14 +142,14 @@ index 06648f9751fd8a322d0809ffebf6a544596ee1a4..40e957a4364c8017072dcd81fcb7cf2c @Override diff --git a/src/main/java/net/minecraft/nbt/CompoundTag.java b/src/main/java/net/minecraft/nbt/CompoundTag.java -index 23916b011ed0645ab284fb080c9555921290d875..83ace0d17691ec743a4b92de34d4de5a9ac6ff5b 100644 +index 4e005b7b062e3231f564d284887ea1c2783a4e7d..bc9ee52755c73606e6f5788a947f2bc695986858 100644 --- a/src/main/java/net/minecraft/nbt/CompoundTag.java +++ b/src/main/java/net/minecraft/nbt/CompoundTag.java @@ -18,6 +18,7 @@ import javax.annotation.Nullable; import net.minecraft.CrashReport; import net.minecraft.CrashReportCategory; import net.minecraft.ReportedException; -+import top.leavesmc.leaves.util.ArrayConstants; ++import org.leavesmc.leaves.util.ArrayConstants; public class CompoundTag implements Tag { public static final Codec CODEC = Codec.PASSTHROUGH @@ -181,14 +181,14 @@ index 23916b011ed0645ab284fb080c9555921290d875..83ace0d17691ec743a4b92de34d4de5a 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..c25d23c9c2ed887ce9ae7f07cd8aa0d18dfc719c 100644 +index ff13d67151c50ea11a45117e524c7524e2b1a202..8c3ee4c9aa22bcc46f2dc3a5bc35bdde5fae3e64 100644 --- a/src/main/java/net/minecraft/nbt/IntArrayTag.java +++ b/src/main/java/net/minecraft/nbt/IntArrayTag.java @@ -7,6 +7,7 @@ import java.io.IOException; import java.util.Arrays; import java.util.List; import org.apache.commons.lang3.ArrayUtils; -+import top.leavesmc.leaves.util.ArrayConstants; ++import org.leavesmc.leaves.util.ArrayConstants; public class IntArrayTag extends CollectionTag { @@ -202,22 +202,22 @@ index ff13d67151c50ea11a45117e524c7524e2b1a202..c25d23c9c2ed887ce9ae7f07cd8aa0d1 @Override diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java -index 35d03c7128e0cc9b3e0a9ecf109c17dab927c4a4..e6036459ee5dcd70ca9b945eca12114afb895e3f 100644 +index 53c23d5bbbc5c74a35dafec99bcf13f9fa7552ac..f1632e343eeb9cc6680ec9bddacddf788a5655c6 100644 --- a/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java -@@ -57,6 +57,7 @@ import org.apache.commons.lang3.Validate; +@@ -66,6 +66,7 @@ import org.apache.commons.lang3.Validate; import org.slf4j.Logger; import org.slf4j.Marker; import org.slf4j.MarkerFactory; -+import top.leavesmc.leaves.util.ArrayConstants; ++import org.leavesmc.leaves.util.ArrayConstants; public class Connection extends SimpleChannelInboundHandler> { diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java -index b2183c298b0c68daee41238735621ff002338a68..3957ab1ebd7e84cfe0bef81a8cce566dca9972dc 100644 +index 770c51528e5a31e2738fbce5d63d2ea3f11186f8..c6cd4bed3829b715a42cc51ab9da1385f9eec932 100644 --- a/src/main/java/net/minecraft/server/level/ServerEntity.java +++ b/src/main/java/net/minecraft/server/level/ServerEntity.java -@@ -354,7 +354,7 @@ public class ServerEntity { +@@ -369,7 +369,7 @@ public class ServerEntity { if (this.entity instanceof LivingEntity) { List> list = Lists.newArrayList(); @@ -227,18 +227,18 @@ index b2183c298b0c68daee41238735621ff002338a68..3957ab1ebd7e84cfe0bef81a8cce566d for (int j = 0; j < i; ++j) { diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index 9e95045f10904744f7cbf6e4203f8cbe762a9afc..d27633948861fe72480126cd16b4daa40c5cced0 100644 +index 3bb53128f6919712f0a88ec11c1bce25bf5b8b84..8593af5223c1e8de3684cb89957835dd0d23f111 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java -@@ -177,6 +177,7 @@ import org.bukkit.event.weather.LightningStrikeEvent; - import org.bukkit.event.world.GenericGameEvent; +@@ -180,6 +180,7 @@ import org.bukkit.event.server.MapInitializeEvent; + import org.bukkit.event.weather.LightningStrikeEvent; import org.bukkit.event.world.TimeSkipEvent; // CraftBukkit end -+import top.leavesmc.leaves.util.ArrayConstants; ++import org.leavesmc.leaves.util.ArrayConstants; public class ServerLevel extends Level implements WorldGenLevel { -@@ -1069,7 +1070,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1075,7 +1076,7 @@ public class ServerLevel extends Level implements WorldGenLevel { BlockPos blockposition2 = blockposition.set(j + randomX, randomY, k + randomZ); BlockState iblockdata = com.destroystokyo.paper.util.maplist.IBlockDataList.getBlockDataFromRaw(raw); @@ -247,7 +247,7 @@ index 9e95045f10904744f7cbf6e4203f8cbe762a9afc..d27633948861fe72480126cd16b4daa4 } // We drop the fluid tick since LAVA is ALREADY TICKED by the above method (See LiquidBlock). // TODO CHECK ON UPDATE (ping the Canadian) -@@ -1375,7 +1376,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1381,7 +1382,7 @@ public class ServerLevel extends Level implements WorldGenLevel { public static List getCurrentlyTickingEntities() { Entity ticking = currentlyTickingEntity.get(); @@ -257,18 +257,18 @@ index 9e95045f10904744f7cbf6e4203f8cbe762a9afc..d27633948861fe72480126cd16b4daa4 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 3867eded99e72de706655d875d2e47ae5b135b48..2730718b162c20110145798dbb0eaad0b139e99b 100644 +index 1005e1c4c86f707c3e55ef3c5325dd76bf885ef0..ca22905fa9948f85dcace5098ffd9807d338c93c 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -242,6 +242,7 @@ import org.bukkit.inventory.EquipmentSlot; +@@ -249,6 +249,7 @@ import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.InventoryView; import org.bukkit.inventory.SmithingInventory; // CraftBukkit end -+import top.leavesmc.leaves.util.ArrayConstants; ++import org.leavesmc.leaves.util.ArrayConstants; public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl implements ServerGamePacketListener, ServerPlayerConnection, TickablePacketListener { -@@ -789,7 +790,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -800,7 +801,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl // Paper start final int index; if (packet.getCommand().length() > 64 && ((index = packet.getCommand().indexOf(' ')) == -1 || index >= 64)) { @@ -278,29 +278,33 @@ index 3867eded99e72de706655d875d2e47ae5b135b48..2730718b162c20110145798dbb0eaad0 } // Paper end diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -index c5fa9f4d28f9a7f64a50a902ee5e631bfc00119c..4f93d69b51f91e25f1ee00300b553311ce9c2f7d 100644 +index b656741eb68adeb04bf995f1045902cb6bd5f2e7..73a2857af7c6b6d4578ce879ebe3713ebe55acdf 100644 --- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -@@ -44,6 +44,7 @@ import org.bukkit.craftbukkit.util.Waitable; +@@ -49,6 +49,7 @@ import org.bukkit.craftbukkit.entity.CraftPlayer; + import org.bukkit.craftbukkit.util.Waitable; import org.bukkit.event.player.AsyncPlayerPreLoginEvent; import org.bukkit.event.player.PlayerPreLoginEvent; - // CraftBukkit end -+import top.leavesmc.leaves.util.ArrayConstants; ++import org.leavesmc.leaves.util.ArrayConstants; - public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, TickablePacketListener { + public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, TickablePacketListener, CraftPlayer.TransferCookieConnection { -@@ -138,8 +139,8 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, +@@ -165,12 +166,12 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, @Override public void handleHello(ServerboundHelloPacket packet) { - Validate.validState(this.state == ServerLoginPacketListenerImpl.State.HELLO, "Unexpected hello packet", new Object[0]); -- if (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode() && io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.performUsernameValidation && !this.iKnowThisMayNotBeTheBestIdeaButPleaseDisableUsernameValidation) Validate.validState(Player.isValidUsername(packet.name()), "Invalid characters in username", new Object[0]); // Paper - config username validation + Validate.validState(this.state == ServerLoginPacketListenerImpl.State.HELLO, "Unexpected hello packet", ArrayConstants.emptyObjectArray); // Leaves - reduce array allocations -+ if (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode() && io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.performUsernameValidation && !this.iKnowThisMayNotBeTheBestIdeaButPleaseDisableUsernameValidation) Validate.validState(Player.isValidUsername(packet.name()), "Invalid characters in username", ArrayConstants.emptyObjectArray); // Paper - config username validation // Leaves - reduce array allocations + // 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", ArrayConstants.emptyObjectArray); // Leaves - reduce array allocations + } + // Paper end - Validate usernames this.requestedUsername = packet.name(); - GameProfile gameprofile = this.server.getSingleplayerProfile(); - -@@ -223,7 +224,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, +@@ -268,7 +269,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, @Override public void handleKey(ServerboundKeyPacket packet) { @@ -310,26 +314,26 @@ index c5fa9f4d28f9a7f64a50a902ee5e631bfc00119c..4f93d69b51f91e25f1ee00300b553311 final String s; diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index 6e5a7edfbc8781def735d0b2250888288560fbc4..139129f0110dc656bc729ce795f012ec087641cf 100644 +index c9e904ab960739c5b64f44ef92e3a02159149e66..c4aac957906ff3bf28b29e58e30decc608562e6a 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java -@@ -123,6 +123,7 @@ import org.bukkit.event.player.PlayerSpawnChangeEvent; - - import top.leavesmc.leaves.bot.ServerBot; - import top.leavesmc.leaves.util.ReturnPortalManager; // Leaves - return portal fix -+import top.leavesmc.leaves.util.ArrayConstants; - - public abstract class PlayerList { - +@@ -27,6 +27,7 @@ import javax.annotation.Nullable; + import net.minecraft.ChatFormatting; + import net.minecraft.FileUtil; + import org.leavesmc.leaves.util.ReturnPortalManager; // Leaves - return portal fix ++import org.leavesmc.leaves.util.ArrayConstants; + import net.minecraft.commands.CommandSourceStack; + import net.minecraft.core.BlockPos; + import net.minecraft.core.LayeredRegistryAccess; diff --git a/src/main/java/net/minecraft/server/players/StoredUserList.java b/src/main/java/net/minecraft/server/players/StoredUserList.java -index 7e133752ccb1ea7c0b4fa781feb1a88e2cfdcf6d..b2a8a6f3a6a2934f30d9212bd935651056551be8 100644 +index c038da20b76c0b7b1c18471b20be01e849d29f3a..603007a376dc76c46d34f265283dda693cbf6c88 100644 --- a/src/main/java/net/minecraft/server/players/StoredUserList.java +++ b/src/main/java/net/minecraft/server/players/StoredUserList.java @@ -24,6 +24,7 @@ import javax.annotation.Nullable; import net.minecraft.Util; import net.minecraft.util.GsonHelper; import org.slf4j.Logger; -+import top.leavesmc.leaves.util.ArrayConstants; ++import org.leavesmc.leaves.util.ArrayConstants; public abstract class StoredUserList> { @@ -343,14 +347,14 @@ index 7e133752ccb1ea7c0b4fa781feb1a88e2cfdcf6d..b2a8a6f3a6a2934f30d9212bd9356510 public boolean isEmpty() { diff --git a/src/main/java/net/minecraft/util/ZeroBitStorage.java b/src/main/java/net/minecraft/util/ZeroBitStorage.java -index 54c7d9bed0fead691d06691086f04cc2521dbe07..cebccf16bb0ea0a5085e3ab312ae570b80508e84 100644 +index 54c7d9bed0fead691d06691086f04cc2521dbe07..0c6007c9dbd053cba641038955ef1ca1422c4d6d 100644 --- a/src/main/java/net/minecraft/util/ZeroBitStorage.java +++ b/src/main/java/net/minecraft/util/ZeroBitStorage.java @@ -4,9 +4,10 @@ import java.util.Arrays; import java.util.function.IntConsumer; import org.apache.commons.lang3.Validate; import net.minecraft.world.level.chunk.Palette; -+import top.leavesmc.leaves.util.ArrayConstants; ++import org.leavesmc.leaves.util.ArrayConstants; public class ZeroBitStorage implements BitStorage { - public static final long[] RAW = new long[0]; @@ -359,22 +363,22 @@ index 54c7d9bed0fead691d06691086f04cc2521dbe07..cebccf16bb0ea0a5085e3ab312ae570b 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 8b4dd6ff53d2d61c71f04c37389ac645766305c4..0ff2e701439128abd8ac1bdb3ad9ccf7ff81528d 100644 +index eb3c12e03c0d5c9cec84d97e2c51c50ce59c23a4..0593d76c67f4475d624c5289b65c5d4a3c91e4cd 100644 --- a/src/main/java/net/minecraft/world/entity/EquipmentSlot.java +++ b/src/main/java/net/minecraft/world/entity/EquipmentSlot.java -@@ -15,6 +15,7 @@ public enum EquipmentSlot implements StringRepresentable { +@@ -16,6 +16,7 @@ public enum EquipmentSlot implements StringRepresentable { private final int index; private final int filterFlag; private final String name; + public static final EquipmentSlot[] VALUES = EquipmentSlot.values(); // Leaves - reduce array allocations - private EquipmentSlot(EquipmentSlot.Type type, int entityId, int armorStandId, String name) { + private EquipmentSlot(final EquipmentSlot.Type type, final int entityId, final int armorStandId, final String name) { this.type = type; diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index ffa9ada2e803bc77f8cae4be81ac4b5c2eee0b7f..0a038e46f68011391f5dee5f7609d3192ea0f8da 100644 +index 3ad2f5234925e7f454d2b2bcb507493cdc3e454a..bd85c526a285e0b11c0c8f87fd9ea95ccb9f70a3 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -3166,7 +3166,7 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -3238,7 +3238,7 @@ public abstract class LivingEntity extends Entity implements Attackable { @Nullable private Map collectEquipmentChanges() { Map map = null; @@ -384,10 +388,10 @@ index ffa9ada2e803bc77f8cae4be81ac4b5c2eee0b7f..0a038e46f68011391f5dee5f7609d319 for (int j = 0; j < i; ++j) { diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java -index 06c80f363fec3e9c824b9bbbcb7608fff7659c41..a4a0f99784ba5a0af851ff43eaf4ca10b6e96b1d 100644 +index 22a5e441cd62447e4ac95a8b048bd10942743367..9821e8fc3209eabfa809560bcca36c3a7e5cdc25 100644 --- a/src/main/java/net/minecraft/world/entity/Mob.java +++ b/src/main/java/net/minecraft/world/entity/Mob.java -@@ -1089,7 +1089,7 @@ public abstract class Mob extends LivingEntity implements Targeting { +@@ -1201,7 +1201,7 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Targeti @Override protected void dropCustomDeathLoot(DamageSource source, int lootingMultiplier, boolean allowDrops) { super.dropCustomDeathLoot(source, lootingMultiplier, allowDrops); @@ -396,7 +400,7 @@ index 06c80f363fec3e9c824b9bbbcb7608fff7659c41..a4a0f99784ba5a0af851ff43eaf4ca10 int j = aenumitemslot.length; for (int k = 0; k < j; ++k) { -@@ -1152,7 +1152,7 @@ public abstract class Mob extends LivingEntity implements Targeting { +@@ -1284,7 +1284,7 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Targeti } boolean flag = true; @@ -405,7 +409,7 @@ index 06c80f363fec3e9c824b9bbbcb7608fff7659c41..a4a0f99784ba5a0af851ff43eaf4ca10 int j = aenumitemslot.length; for (int k = 0; k < j; ++k) { -@@ -1239,7 +1239,7 @@ public abstract class Mob extends LivingEntity implements Targeting { +@@ -1371,7 +1371,7 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Targeti float f = localDifficulty.getSpecialMultiplier(); this.enchantSpawnedWeapon(random, f); @@ -414,7 +418,7 @@ index 06c80f363fec3e9c824b9bbbcb7608fff7659c41..a4a0f99784ba5a0af851ff43eaf4ca10 int i = aenumitemslot.length; for (int j = 0; j < i; ++j) { -@@ -1459,7 +1459,7 @@ public abstract class Mob extends LivingEntity implements Targeting { +@@ -1591,7 +1591,7 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Targeti t0.setInvulnerable(this.isInvulnerable()); if (flag) { t0.setCanPickUpLoot(this.canPickUpLoot()); @@ -424,10 +428,10 @@ index 06c80f363fec3e9c824b9bbbcb7608fff7659c41..a4a0f99784ba5a0af851ff43eaf4ca10 for (int j = 0; j < i; ++j) { diff --git a/src/main/java/net/minecraft/world/entity/monster/ZombieVillager.java b/src/main/java/net/minecraft/world/entity/monster/ZombieVillager.java -index 7de9d012e7416eaa0189b513a0972c846e93c4b6..505cae0013a501cbff094a83c491af963087d58f 100644 +index f38acc96f71298e40ce9433e7759fd223ca55e48..03652ec451109d2026fc313f143d78d4b855dd51 100644 --- a/src/main/java/net/minecraft/world/entity/monster/ZombieVillager.java +++ b/src/main/java/net/minecraft/world/entity/monster/ZombieVillager.java -@@ -237,7 +237,7 @@ public class ZombieVillager extends Zombie implements VillagerDataHolder { +@@ -238,7 +238,7 @@ public class ZombieVillager extends Zombie implements VillagerDataHolder { return; } // CraftBukkit end @@ -437,62 +441,73 @@ index 7de9d012e7416eaa0189b513a0972c846e93c4b6..505cae0013a501cbff094a83c491af96 for (int j = 0; j < i; ++j) { diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java -index 418a7c9217e6e06bff6866deffff3e7822d35a14..506ef97bbc82ed901998460207199b1b3c88ca40 100644 +index cb5effe8be9f43ef6b3fa48c25600cdcd69ddc9e..98c6c0b5e795558fc9d1b96643832b3c4b92740a 100644 --- a/src/main/java/net/minecraft/world/item/ItemStack.java +++ b/src/main/java/net/minecraft/world/item/ItemStack.java -@@ -1053,7 +1053,7 @@ public final class ItemStack { - int k; +@@ -1102,7 +1102,7 @@ public final class ItemStack implements DataComponentHolder { + ItemAttributeModifiers itemattributemodifiers = (ItemAttributeModifiers) this.getOrDefault(DataComponents.ATTRIBUTE_MODIFIERS, ItemAttributeModifiers.EMPTY); - if (ItemStack.shouldShowInTooltip(i, ItemStack.TooltipPart.MODIFIERS)) { + if (itemattributemodifiers.showInTooltip()) { - EquipmentSlot[] aenumitemslot = EquipmentSlot.values(); + EquipmentSlot[] aenumitemslot = EquipmentSlot.VALUES; // Leaves - reduce array allocations + int i = aenumitemslot.length; - k = aenumitemslot.length; - + for (int j = 0; j < i; ++j) { diff --git a/src/main/java/net/minecraft/world/item/crafting/ShapedRecipe.java b/src/main/java/net/minecraft/world/item/crafting/ShapedRecipe.java -index d772cf80fa3831e1c79d601ea09a073da089e2c5..4699f5fd794a7ef1f430e801bd35f1c62452aa8e 100644 +index 482d7b12b80328fba97a01bcfeb974b7ac4bcdb7..8068816a64ff9a30476280f53bb60cf0e1fff8ee 100644 --- a/src/main/java/net/minecraft/world/item/crafting/ShapedRecipe.java +++ b/src/main/java/net/minecraft/world/item/crafting/ShapedRecipe.java -@@ -16,6 +16,7 @@ import org.bukkit.craftbukkit.inventory.CraftRecipe; +@@ -17,6 +17,7 @@ import org.bukkit.craftbukkit.inventory.CraftRecipe; import org.bukkit.craftbukkit.inventory.CraftShapedRecipe; import org.bukkit.inventory.RecipeChoice; // CraftBukkit end -+import top.leavesmc.leaves.util.ArrayConstants; ++import org.leavesmc.leaves.util.ArrayConstants; public class ShapedRecipe extends io.papermc.paper.inventory.recipe.RecipeBookExactChoiceRecipe implements CraftingRecipe { // Paper - improve exact recipe choices diff --git a/src/main/java/net/minecraft/world/item/enchantment/Enchantments.java b/src/main/java/net/minecraft/world/item/enchantment/Enchantments.java -index 8343e175a7221f7b0e83c39cd5350683a0649f8d..6cff058e409e7f7d1effbf87d7cd17520f0c24b2 100644 +index e158ff1a9dbd054985873e854fcf6c433102059c..e061322fed6adf49a506ea13db50cdf25eb0fb33 100644 --- a/src/main/java/net/minecraft/world/item/enchantment/Enchantments.java +++ b/src/main/java/net/minecraft/world/item/enchantment/Enchantments.java -@@ -63,10 +63,10 @@ public class Enchantments { - public static final Enchantment MULTISHOT = register("multishot", new MultiShotEnchantment(Enchantment.Rarity.RARE, EquipmentSlot.MAINHAND)); - public static final Enchantment QUICK_CHARGE = register("quick_charge", new QuickChargeEnchantment(Enchantment.Rarity.UNCOMMON, EquipmentSlot.MAINHAND)); - public static final Enchantment PIERCING = register("piercing", new ArrowPiercingEnchantment(Enchantment.Rarity.COMMON, EquipmentSlot.MAINHAND)); -- public static final Enchantment MENDING = register("mending", new MendingEnchantment(Enchantment.Rarity.RARE, EquipmentSlot.values())); -- public static final Enchantment VANISHING_CURSE = register( -- "vanishing_curse", new VanishingCurseEnchantment(Enchantment.Rarity.VERY_RARE, EquipmentSlot.values()) -- ); +@@ -303,20 +303,22 @@ public class Enchantments { + public static final Enchantment DENSITY = register("density", new DensityEnchantment()); + public static final Enchantment BREACH = register("breach", new BreachEnchantment()); + public static final Enchantment WIND_BURST = register("wind_burst", new WindBurstEnchantment()); +- public static final Enchantment MENDING = register( + // Leaves start - reduce array allocations -+ public static final Enchantment MENDING = Enchantments.register("mending", new MendingEnchantment(Enchantment.Rarity.RARE, EquipmentSlot.VALUES)); -+ public static final Enchantment VANISHING_CURSE = Enchantments.register("vanishing_curse", new VanishingCurseEnchantment(Enchantment.Rarity.VERY_RARE, EquipmentSlot.VALUES)); ++ public static final Enchantment MENDING = Enchantments.register( + "mending", + new MendingEnchantment( + Enchantment.definition( +- ItemTags.DURABILITY_ENCHANTABLE, 2, 1, Enchantment.dynamicCost(25, 25), Enchantment.dynamicCost(75, 25), 4, EquipmentSlot.values() ++ ItemTags.DURABILITY_ENCHANTABLE, 2, 1, Enchantment.dynamicCost(25, 25), Enchantment.dynamicCost(75, 25), 4, EquipmentSlot.VALUES + ) + ) + ); + public static final Enchantment VANISHING_CURSE = register( + "vanishing_curse", + new VanishingCurseEnchantment( +- Enchantment.definition(ItemTags.VANISHING_ENCHANTABLE, 1, 1, Enchantment.constantCost(25), Enchantment.constantCost(50), 8, EquipmentSlot.values()) ++ Enchantment.definition(ItemTags.VANISHING_ENCHANTABLE, 1, 1, Enchantment.constantCost(25), Enchantment.constantCost(50), 8, EquipmentSlot.VALUES) + ) + ); + // Leaves end - reduce array allocations private static Enchantment register(String name, Enchantment enchantment) { return Registry.register(BuiltInRegistries.ENCHANTMENT, name, enchantment); diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index e32f8d7f6804a3f0822e0069822d56a3dc873a6a..b219ff03ae82b9d94ba32304671428cf9987329a 100644 +index c04e07fa16d701d814a2df82758d4339e3b4e5f1..fdf56caa8756f065f892847898f2b2b9af18f5c6 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -95,6 +95,7 @@ import org.bukkit.craftbukkit.util.CraftSpawnCategory; +@@ -101,6 +101,7 @@ import org.bukkit.craftbukkit.util.CraftSpawnCategory; import org.bukkit.entity.SpawnCategory; import org.bukkit.event.block.BlockPhysicsEvent; // CraftBukkit end -+import top.leavesmc.leaves.util.ArrayConstants; ++import org.leavesmc.leaves.util.ArrayConstants; public abstract class Level implements LevelAccessor, AutoCloseable { -@@ -1867,7 +1868,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1868,7 +1869,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { public org.bukkit.entity.Entity[] getChunkEntities(int chunkX, int chunkZ) { io.papermc.paper.world.ChunkEntitySlices slices = ((ServerLevel)this).getEntityLookup().getChunk(chunkX, chunkZ); if (slices == null) { @@ -502,18 +517,18 @@ index e32f8d7f6804a3f0822e0069822d56a3dc873a6a..b219ff03ae82b9d94ba32304671428cf return slices.getChunkEntities(); } 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 f9084e2605d7403721fe6b714bfad051f932aaef..07d9620768150444b3cc1e288ab8ad079b213317 100644 +index d3d12f9114173f4971f95d7ef895a4374705bd3f..d9e28a241f7fc9c6828dc3b169f56bad08db5b04 100644 --- a/src/main/java/net/minecraft/world/level/block/ComposterBlock.java +++ b/src/main/java/net/minecraft/world/level/block/ComposterBlock.java -@@ -44,6 +44,7 @@ import net.minecraft.world.phys.shapes.VoxelShape; +@@ -46,6 +46,7 @@ import net.minecraft.world.phys.shapes.VoxelShape; import org.bukkit.craftbukkit.inventory.CraftBlockInventoryHolder; import org.bukkit.craftbukkit.util.DummyGeneratorAccess; // CraftBukkit end -+import top.leavesmc.leaves.util.ArrayConstants; ++import org.leavesmc.leaves.util.ArrayConstants; public class ComposterBlock extends Block implements WorldlyContainerHolder { -@@ -422,7 +423,7 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder { +@@ -430,7 +431,7 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder { @Override public int[] getSlotsForFace(Direction side) { @@ -522,7 +537,7 @@ index f9084e2605d7403721fe6b714bfad051f932aaef..07d9620768150444b3cc1e288ab8ad07 } @Override -@@ -471,7 +472,7 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder { +@@ -479,7 +480,7 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder { @Override public int[] getSlotsForFace(Direction side) { @@ -531,7 +546,7 @@ index f9084e2605d7403721fe6b714bfad051f932aaef..07d9620768150444b3cc1e288ab8ad07 } @Override -@@ -513,7 +514,7 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder { +@@ -521,7 +522,7 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder { @Override public int[] getSlotsForFace(Direction side) { @@ -541,18 +556,18 @@ index f9084e2605d7403721fe6b714bfad051f932aaef..07d9620768150444b3cc1e288ab8ad07 @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 cb0cb894df65e6d4d65b369955a7d7d78fa7bc2b..178c897630e208b4d86615e8f6759ca35e49dae6 100644 +index a99fe191c429bb528209dd0f31b509acf9cccbb5..e544ad7f34005b2aba554a21f3c277bca4f6773d 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 -@@ -59,6 +59,7 @@ import org.bukkit.event.inventory.FurnaceSmeltEvent; +@@ -60,6 +60,7 @@ import org.bukkit.event.inventory.FurnaceSmeltEvent; import org.bukkit.event.inventory.FurnaceStartSmeltEvent; import org.bukkit.inventory.CookingRecipe; // CraftBukkit end -+import top.leavesmc.leaves.util.ArrayConstants; ++import org.leavesmc.leaves.util.ArrayConstants; public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntity implements WorldlyContainer, RecipeCraftingHolder, StackedContentsCompatible { -@@ -66,7 +67,7 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit +@@ -67,7 +68,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; @@ -562,39 +577,26 @@ index cb0cb894df65e6d4d65b369955a7d7d78fa7bc2b..178c897630e208b4d86615e8f6759ca3 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/level/storage/PlayerDataStorage.java b/src/main/java/net/minecraft/world/level/storage/PlayerDataStorage.java -index 63e187c65cb855031f286aad0d25ac4694f7a331..8d73357f0120ada1634f18ded0f72218e533776b 100644 +index 8ab7ca373a885fbe658013c9c6a2e38d32d77bb2..bcf5e0045da9711f48689ffcd266411f71a7bae1 100644 --- a/src/main/java/net/minecraft/world/level/storage/PlayerDataStorage.java +++ b/src/main/java/net/minecraft/world/level/storage/PlayerDataStorage.java -@@ -12,7 +12,6 @@ import net.minecraft.nbt.NbtAccounter; +@@ -16,10 +16,10 @@ import net.minecraft.nbt.NbtAccounter; import net.minecraft.nbt.NbtIo; import net.minecraft.nbt.NbtUtils; import net.minecraft.server.level.ServerPlayer; -import net.minecraft.util.datafix.DataFixTypes; import net.minecraft.world.entity.player.Player; - import org.slf4j.Logger; - -@@ -21,6 +20,7 @@ import java.io.FileInputStream; - import java.io.InputStream; import org.bukkit.craftbukkit.entity.CraftPlayer; - // CraftBukkit end -+import top.leavesmc.leaves.util.ArrayConstants; + import org.slf4j.Logger; ++import org.leavesmc.leaves.util.ArrayConstants; public class PlayerDataStorage { -@@ -124,7 +124,7 @@ public class PlayerDataStorage { - String[] astring = this.playerDir.list(); - - if (astring == null) { -- astring = new String[0]; -+ astring = ArrayConstants.emptyStringArray; // Leaves - reduce array allocations - } - - for (int i = 0; i < astring.length; ++i) { diff --git a/src/main/java/org/bukkit/craftbukkit/CraftEquipmentSlot.java b/src/main/java/org/bukkit/craftbukkit/CraftEquipmentSlot.java -index 402a238cf502003a232bb95473bd13e59e067fab..6095f5c9298558c77a788c1c9f9ef1f32825b37c 100644 +index ae86c45c1d49c7646c721991910592091e7333f8..f3dce7156d518193fe27a69f5792800b72742632 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftEquipmentSlot.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftEquipmentSlot.java -@@ -5,8 +5,10 @@ import org.bukkit.inventory.EquipmentSlot; +@@ -7,8 +7,10 @@ import org.bukkit.inventory.EquipmentSlot; public class CraftEquipmentSlot { @@ -621,14 +623,14 @@ index 6827979a5b270ced53b46ecb9eff548727dadb81..1b84078152d0585ec51288e585754be1 } } diff --git a/src/main/java/org/bukkit/craftbukkit/util/WeakCollection.java b/src/main/java/org/bukkit/craftbukkit/util/WeakCollection.java -index b25dc23b81687dd4d4e70b3615ffb91f8c03c68b..9435ea991a429c1d81d4cba63231e846e3bd2b7e 100644 +index b25dc23b81687dd4d4e70b3615ffb91f8c03c68b..8fdadf58054b2475f2023f76824af7bbe1303383 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/WeakCollection.java +++ b/src/main/java/org/bukkit/craftbukkit/util/WeakCollection.java @@ -6,6 +6,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.NoSuchElementException; -+import top.leavesmc.leaves.util.ArrayConstants; ++import org.leavesmc.leaves.util.ArrayConstants; public final class WeakCollection implements Collection { static final Object NO_VALUE = new Object(); @@ -641,13 +643,13 @@ index b25dc23b81687dd4d4e70b3615ffb91f8c03c68b..9435ea991a429c1d81d4cba63231e846 } @Override -diff --git a/src/main/java/top/leavesmc/leaves/util/ArrayConstants.java b/src/main/java/top/leavesmc/leaves/util/ArrayConstants.java +diff --git a/src/main/java/org/leavesmc/leaves/util/ArrayConstants.java b/src/main/java/org/leavesmc/leaves/util/ArrayConstants.java new file mode 100644 -index 0000000000000000000000000000000000000000..0523062a825bd36f335f1fa6e1440eaaf400fd58 +index 0000000000000000000000000000000000000000..99d6484ca682d3edb6461157dc57322a0ff8584a --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/util/ArrayConstants.java ++++ b/src/main/java/org/leavesmc/leaves/util/ArrayConstants.java @@ -0,0 +1,21 @@ -+package top.leavesmc.leaves.util; ++package org.leavesmc.leaves.util; + +import net.minecraft.server.level.ServerLevel; + diff --git a/patches/server/0089-Optimize-sun-burn-tick.patch b/patches/server/0090-Optimize-sun-burn-tick.patch similarity index 88% rename from patches/server/0089-Optimize-sun-burn-tick.patch rename to patches/server/0090-Optimize-sun-burn-tick.patch index d6c629ff..342dd001 100644 --- a/patches/server/0089-Optimize-sun-burn-tick.patch +++ b/patches/server/0090-Optimize-sun-burn-tick.patch @@ -6,16 +6,16 @@ Subject: [PATCH] Optimize sun burn tick This patch is Powered by Gale(https://github.com/GaleMC/Gale) diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 4b0e6e5366294f74c24a3bbd97699ede15706954..8b5c464eed35364edb441012ce5e7ecf8f03e004 100644 +index 1a17258f338f8a4c575e30e4783a8f13ed9380ef..5b0f931a26bf16633c79eddcae6bc750d8867136 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -2036,8 +2036,22 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -2091,8 +2091,22 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess /** @deprecated */ @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; + // Leaves start - optimize sun burn tick -+ if (!top.leavesmc.leaves.LeavesConfig.optimizeSunBurnTick) { ++ if (!org.leavesmc.leaves.LeavesConfig.optimizeSunBurnTick) { + return this.level().hasChunkAt(this.getBlockX(), this.getBlockZ()) ? this.level().getLightLevelDependentMagicValue(BlockPos.containing(this.getX(), this.getEyeY(), this.getZ())) : 0.0F; + } else { + return this.getLightLevelDependentMagicValue(BlockPos.containing(this.getX(), this.getEyeY(), this.getZ())); @@ -34,11 +34,11 @@ index 4b0e6e5366294f74c24a3bbd97699ede15706954..8b5c464eed35364edb441012ce5e7ecf public void absMoveTo(double x, double y, double z, float yaw, float pitch) { this.absMoveTo(x, y, z); diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java -index a4a0f99784ba5a0af851ff43eaf4ca10b6e96b1d..f41ed311f9368a0ab81a613238cd5a2468aae706 100644 +index 9821e8fc3209eabfa809560bcca36c3a7e5cdc25..9a46da42f122c9d555bfc1b2542cff061440316e 100644 --- a/src/main/java/net/minecraft/world/entity/Mob.java +++ b/src/main/java/net/minecraft/world/entity/Mob.java -@@ -1725,15 +1725,41 @@ public abstract class Mob extends LivingEntity implements Targeting { - +@@ -1845,15 +1845,41 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Targeti + return flag; } + // Leaves start - optimize sun burn tick @@ -52,13 +52,11 @@ index a4a0f99784ba5a0af851ff43eaf4ca10b6e96b1d..f41ed311f9368a0ab81a613238cd5a24 - BlockPos blockposition = BlockPos.containing(this.getX(), this.getEyeY(), this.getZ()); - boolean flag = this.isInWaterRainOrBubble() || this.isInPowderSnow || this.wasInPowderSnow; + // Leaves start - optimize sun burn tick -+ if (!top.leavesmc.leaves.LeavesConfig.optimizeSunBurnTick) { ++ if (!org.leavesmc.leaves.LeavesConfig.optimizeSunBurnTick) { + float f = this.getLightLevelDependentMagicValue(); + BlockPos blockposition = BlockPos.containing(this.getX(), this.getEyeY(), this.getZ()); + 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)) { -- return true; ++ + if (f > 0.5F && this.random.nextFloat() * 30.0F < (f - 0.4F) * 2.0F && !flag && this.level().canSeeSky(blockposition)) { + return true; + } @@ -75,7 +73,9 @@ index a4a0f99784ba5a0af851ff43eaf4ca10b6e96b1d..f41ed311f9368a0ab81a613238cd5a24 + if (f <= 0.5F) return false; + if (this.random.nextFloat() * 30.0F >= (f - 0.4F) * 2.0F) return false; + 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)) { +- return true; + if (!flag && this.level().canSeeSky(this.cached_eye_blockpos)) { + return true; + } diff --git a/patches/server/0090-Reduce-lambda-and-Optional-allocation-in-EntityBased.patch b/patches/server/0091-Reduce-lambda-and-Optional-allocation-in-EntityBased.patch similarity index 92% rename from patches/server/0090-Reduce-lambda-and-Optional-allocation-in-EntityBased.patch rename to patches/server/0091-Reduce-lambda-and-Optional-allocation-in-EntityBased.patch index 7d79e0bc..f0f4b962 100644 --- a/patches/server/0090-Reduce-lambda-and-Optional-allocation-in-EntityBased.patch +++ b/patches/server/0091-Reduce-lambda-and-Optional-allocation-in-EntityBased.patch @@ -7,7 +7,7 @@ Subject: [PATCH] Reduce lambda and Optional allocation in This patch is Powered by Gale(https://github.com/GaleMC/Gale) diff --git a/src/main/java/net/minecraft/world/level/EntityBasedExplosionDamageCalculator.java b/src/main/java/net/minecraft/world/level/EntityBasedExplosionDamageCalculator.java -index 3527f1621ef9b4f3f8d8bbb93379f13ff141c3be..ac349d03b10dac5794b069972394ee87c7bac5b3 100644 +index 3527f1621ef9b4f3f8d8bbb93379f13ff141c3be..523bd9cb8121d419a763b59a64f50cbeae88aeb4 100644 --- a/src/main/java/net/minecraft/world/level/EntityBasedExplosionDamageCalculator.java +++ b/src/main/java/net/minecraft/world/level/EntityBasedExplosionDamageCalculator.java @@ -15,8 +15,20 @@ public class EntityBasedExplosionDamageCalculator extends ExplosionDamageCalcula @@ -16,7 +16,7 @@ index 3527f1621ef9b4f3f8d8bbb93379f13ff141c3be..ac349d03b10dac5794b069972394ee87 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)); -+ if (!top.leavesmc.leaves.LeavesConfig.removeDamageLambda) { ++ if (!org.leavesmc.leaves.LeavesConfig.removeDamageLambda) { + return super.getBlockExplosionResistance(explosion, world, pos, blockState, fluidState) + .map(max -> this.source.getBlockExplosionResistance(explosion, world, pos, blockState, fluidState, max)); + } else { diff --git a/patches/server/0091-Use-optimized-collection.patch b/patches/server/0091-Use-optimized-collection.patch deleted file mode 100644 index f4f7924b..00000000 --- a/patches/server/0091-Use-optimized-collection.patch +++ /dev/null @@ -1,169 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: violetc <58360096+s-yh-china@users.noreply.github.com> -Date: Thu, 20 Jul 2023 16:09:56 +0800 -Subject: [PATCH] Use optimized collection - -This patch is Powered by Gale(https://github.com/GaleMC/Gale) - -diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java -index 234897e942df0023307418566211a549a32124e9..86207dd0f1f666588535d03f5576fbe4e2267eeb 100644 ---- a/src/main/java/net/minecraft/server/level/ChunkMap.java -+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java -@@ -237,7 +237,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider - // Paper - rewrite chunk system - this.tickingGenerated = new AtomicInteger(); - this.playerMap = new PlayerMap(); -- this.entityMap = new Int2ObjectOpenHashMap(); -+ this.entityMap = top.leavesmc.leaves.LeavesConfig.useOptimizedCollection ? new it.unimi.dsi.fastutil.ints.Int2ObjectLinkedOpenHashMap() : new Int2ObjectOpenHashMap(); // Leaves - se linked map for entity trackers - provides faster iteration - this.chunkTypeCache = new Long2ByteOpenHashMap(); - this.chunkSaveCooldowns = new Long2LongOpenHashMap(); - this.unloadQueue = Queues.newConcurrentLinkedQueue(); -diff --git a/src/main/java/net/minecraft/util/ClassInstanceMultiMap.java b/src/main/java/net/minecraft/util/ClassInstanceMultiMap.java -index ebad17e6ec90a7f385cd38c5ec6c2772798d4562..6865a46614adc7dd8077ee37677d087e816a1cec 100644 ---- a/src/main/java/net/minecraft/util/ClassInstanceMultiMap.java -+++ b/src/main/java/net/minecraft/util/ClassInstanceMultiMap.java -@@ -14,7 +14,7 @@ import java.util.Map.Entry; - import java.util.stream.Collectors; - - public class ClassInstanceMultiMap extends AbstractCollection { -- private final Map, List> byClass = Maps.newHashMap(); -+ private final Map, List> byClass = top.leavesmc.leaves.LeavesConfig.useOptimizedCollection ? new it.unimi.dsi.fastutil.objects.Reference2ReferenceOpenHashMap<>(2) : Maps.newHashMap(); // Leaves - replace class map with optimized collection - private final Class baseClass; - private final List allInstances = Lists.newArrayList(); - -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 a2a1de65dfd420185ed0e52e28c7000fde3dd959..ebd95344e81d016464a587dfa00b49e02d4a1c41 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 -@@ -20,8 +20,10 @@ import org.slf4j.Logger; - - public class AttributeMap { - private static final Logger LOGGER = LogUtils.getLogger(); -- private final Map attributes = Maps.newHashMap(); -- private final Set dirtyAttributes = Sets.newHashSet(); -+ // Leaves start - replace AI attributes with optimized collections -+ private final Map attributes = top.leavesmc.leaves.LeavesConfig.useOptimizedCollection ? new it.unimi.dsi.fastutil.objects.Reference2ReferenceOpenHashMap<>(0) : Maps.newHashMap(); -+ private final Set dirtyAttributes = top.leavesmc.leaves.LeavesConfig.useOptimizedCollection ? new it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet<>(0) : Sets.newHashSet(); -+ // Leaves end - replace AI attributes with optimized collections - private final AttributeSupplier supplier; - private final java.util.function.Function createInstance; // Leaves - reduce entity allocations - -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 38af5c7280366fd6ec077f3d914ea5f3ee77451a..4dd4dae9060694f81622f33904806584a799c04c 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 -@@ -29,7 +29,7 @@ public class GoalSelector { - } - }; - private final Map lockedFlags = new EnumMap<>(Goal.Flag.class); -- private final Set availableGoals = Sets.newLinkedHashSet(); -+ private final Set availableGoals = top.leavesmc.leaves.LeavesConfig.useOptimizedCollection ? new it.unimi.dsi.fastutil.objects.ObjectLinkedOpenHashSet<>() : Sets.newLinkedHashSet(); // Leaves - replace AI goal set with optimized collection - private final Supplier profiler; - private final EnumSet disabledFlags = EnumSet.noneOf(Goal.Flag.class); // Paper unused, but dummy to prevent plugins from crashing as hard. Theyll need to support paper in a special case if this is super important, but really doesn't seem like it would be. - private final com.destroystokyo.paper.util.set.OptimizedSmallEnumSet goalTypes = new com.destroystokyo.paper.util.set.OptimizedSmallEnumSet<>(Goal.Flag.class); // Paper - remove streams from pathfindergoalselector -diff --git a/src/main/java/net/minecraft/world/level/GameRules.java b/src/main/java/net/minecraft/world/level/GameRules.java -index 4a340bd1f1859e43bb58e68aee4018fdb4ca7a5a..79be9ba9d94b7fb88a7afab4e193ef9747aaae88 100644 ---- a/src/main/java/net/minecraft/world/level/GameRules.java -+++ b/src/main/java/net/minecraft/world/level/GameRules.java -@@ -142,7 +142,7 @@ public class GameRules { - } - - private GameRules(Map, GameRules.Value> rules) { -- this.rules = rules; -+ this.rules = top.leavesmc.leaves.LeavesConfig.useOptimizedCollection ? new it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap<>(rules) : rules; // Leaves - replace game rules map with optimized collection - - // Paper start - Perf: Use array for gamerule storage - int arraySize = rules.keySet().stream().mapToInt(key -> key.gameRuleIndex).max().orElse(-1) + 1; -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 10c0fdfec1fcec3f9f7897685b2c7e00dc291b2d..0950fbe3da9f166c73da8991df6619107e10542f 100644 ---- a/src/main/java/net/minecraft/world/level/block/Block.java -+++ b/src/main/java/net/minecraft/world/level/block/Block.java -@@ -62,6 +62,7 @@ import net.minecraft.world.phys.shapes.BooleanOp; - import net.minecraft.world.phys.shapes.Shapes; - import net.minecraft.world.phys.shapes.VoxelShape; - import org.slf4j.Logger; -+import top.leavesmc.leaves.lithium.common.util.collections.Object2BooleanCacheTable; - - public class Block extends BlockBehaviour implements ItemLike { - -@@ -74,6 +75,12 @@ public class Block extends BlockBehaviour implements ItemLike { - return !Shapes.joinIsNotEmpty(Shapes.block(), voxelshape, BooleanOp.NOT_SAME); - } - }); -+ // Leaves start - replace shape full block cache with hashtable -+ private static final Object2BooleanCacheTable LITHIUM_SHAPE_FULL_BLOCK_CACHE = new Object2BooleanCacheTable<>( -+ 1536, -+ shape -> !Shapes.joinIsNotEmpty(Shapes.block(), shape, BooleanOp.NOT_SAME) -+ ); -+ // Leaves end - replace shape full block cache with hashtable - public static final int UPDATE_NEIGHBORS = 1; - public static final int UPDATE_CLIENTS = 2; - public static final int UPDATE_INVISIBLE = 4; -diff --git a/src/main/java/top/leavesmc/leaves/lithium/common/util/collections/Object2BooleanCacheTable.java b/src/main/java/top/leavesmc/leaves/lithium/common/util/collections/Object2BooleanCacheTable.java -new file mode 100644 -index 0000000000000000000000000000000000000000..45232059b188b5f072e28c4cdf05929005972220 ---- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/lithium/common/util/collections/Object2BooleanCacheTable.java -@@ -0,0 +1,62 @@ -+package top.leavesmc.leaves.lithium.common.util.collections; -+ -+import it.unimi.dsi.fastutil.HashCommon; -+import net.minecraft.util.Mth; -+ -+import java.util.function.Predicate; -+ -+// Powered by Gale(https://github.com/GaleMC/Gale) -+ -+/** -+ * A lossy hashtable implementation that stores a mapping between an object and a boolean. -+ *

-+ * Any hash collisions will result in an overwrite: this is safe because the correct value can always be recomputed, -+ * given that the given operator is deterministic. -+ *

-+ * This implementation is safe to use from multiple threads -+ */ -+public final class Object2BooleanCacheTable { -+ -+ private final int mask; -+ private final Node[] nodes; -+ private final Predicate operator; -+ -+ @SuppressWarnings("unchecked") -+ public Object2BooleanCacheTable(int capacity, Predicate operator) { -+ int capacity1 = Mth.smallestEncompassingPowerOfTwo(capacity); -+ this.mask = capacity1 - 1; -+ this.nodes = (Node[]) new Node[capacity1]; -+ this.operator = operator; -+ } -+ -+ private static int hash(T key) { -+ return HashCommon.mix(key.hashCode()); -+ } -+ -+ public boolean get(T key) { -+ int idx = hash(key) & this.mask; -+ -+ Node node = this.nodes[idx]; -+ if (node != null && key.equals(node.key)) { -+ return node.value; -+ } -+ -+ boolean test = this.operator.test(key); -+ this.nodes[idx] = new Node<>(key, test); -+ -+ return test; -+ } -+ -+ static class Node { -+ -+ final T key; -+ final boolean value; -+ -+ Node(T key, boolean value) { -+ this.key = key; -+ this.value = value; -+ } -+ -+ } -+ -+} diff --git a/patches/server/0092-Avoid-Class-isAssignableFrom-call-in-ClassInstanceMu.patch b/patches/server/0092-Avoid-Class-isAssignableFrom-call-in-ClassInstanceMu.patch index e5dfa9c6..70a4d4fb 100644 --- a/patches/server/0092-Avoid-Class-isAssignableFrom-call-in-ClassInstanceMu.patch +++ b/patches/server/0092-Avoid-Class-isAssignableFrom-call-in-ClassInstanceMu.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Avoid Class#isAssignableFrom call in ClassInstanceMultiMap This patch is Powered by Gale(https://github.com/GaleMC/Gale) diff --git a/src/main/java/net/minecraft/util/ClassInstanceMultiMap.java b/src/main/java/net/minecraft/util/ClassInstanceMultiMap.java -index 6865a46614adc7dd8077ee37677d087e816a1cec..0a4ad5082de0fc5a54bd92e1d3be1a59dbedc6bd 100644 +index 038710ba934a9a57815dfe9f414b98223b848385..fd2176449a9ed8921032d6265c95dd5e7f5ae325 100644 --- a/src/main/java/net/minecraft/util/ClassInstanceMultiMap.java +++ b/src/main/java/net/minecraft/util/ClassInstanceMultiMap.java @@ -56,13 +56,24 @@ public class ClassInstanceMultiMap extends AbstractCollection { @@ -17,7 +17,7 @@ index 6865a46614adc7dd8077ee37677d087e816a1cec..0a4ad5082de0fc5a54bd92e1d3be1a59 - 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(Collectors.toList())); +- .computeIfAbsent(type, typeClass -> this.allInstances.stream().filter(typeClass::isInstance).collect(Util.toMutableList())); - return (Collection)Collections.unmodifiableCollection(list); + // Leaves start - avoid Class#isAssignableFrom call in ClassInstanceMultiMap + Collection collection = this.byClass.get(type); diff --git a/patches/server/0093-Optimized-CubePointRange.patch b/patches/server/0093-Optimized-CubePointRange.patch index a0555c9c..0c325b54 100644 --- a/patches/server/0093-Optimized-CubePointRange.patch +++ b/patches/server/0093-Optimized-CubePointRange.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Optimized CubePointRange This patch is Powered by Gale(https://github.com/GaleMC/Gale) 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 a544db042c8d2ecec8d323770552c4f10ca758a6..81d18ce2ee4342b466c6623bcad7840c929eb79d 100644 +index a544db042c8d2ecec8d323770552c4f10ca758a6..d913151417ea72dcb2419d691b869fbf75be8aaa 100644 --- a/src/main/java/net/minecraft/world/phys/shapes/CubePointRange.java +++ b/src/main/java/net/minecraft/world/phys/shapes/CubePointRange.java @@ -3,21 +3,31 @@ package net.minecraft.world.phys.shapes; @@ -30,7 +30,7 @@ index a544db042c8d2ecec8d323770552c4f10ca758a6..81d18ce2ee4342b466c6623bcad7840c public double getDouble(int i) { - return (double)i / (double)this.parts; + // Leaves start - replace division by multiplication in CubePointRange -+ if (!top.leavesmc.leaves.LeavesConfig.optimizedCubePointRange) { ++ if (!org.leavesmc.leaves.LeavesConfig.optimizedCubePointRange) { + return (double)i / (double)this.parts; + } else { + return i * this.scale; @@ -40,6 +40,6 @@ index a544db042c8d2ecec8d323770552c4f10ca758a6..81d18ce2ee4342b466c6623bcad7840c public int size() { - return this.parts + 1; -+ return !top.leavesmc.leaves.LeavesConfig.optimizedCubePointRange ? this.parts + 1 : size; // Leaves - replace parts by size in CubePointRange ++ return !org.leavesmc.leaves.LeavesConfig.optimizedCubePointRange ? this.parts + 1 : size; // Leaves - replace parts by size in CubePointRange } } diff --git a/patches/server/0094-Check-frozen-ticks-before-landing-block.patch b/patches/server/0094-Check-frozen-ticks-before-landing-block.patch index dbd4110c..aee65f76 100644 --- a/patches/server/0094-Check-frozen-ticks-before-landing-block.patch +++ b/patches/server/0094-Check-frozen-ticks-before-landing-block.patch @@ -6,20 +6,20 @@ Subject: [PATCH] Check frozen ticks before landing block This patch is Powered by Gale(https://github.com/GaleMC/Gale) diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index 4a743b38d32dc31e3867900e13fffd12505a8710..986f63268649f8bcbd190758cbc9eff766029b32 100644 +index bd85c526a285e0b11c0c8f87fd9ea95ccb9f70a3..e3bac8e9f30685f6014ddc3da8a7359d03337bb1 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -582,11 +582,11 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -593,11 +593,11 @@ public abstract class LivingEntity extends Entity implements Attackable { } protected void tryAddFrost() { - if (!this.getBlockStateOnLegacy().isAir()) { -+ if (top.leavesmc.leaves.LeavesConfig.checkFrozenTicksBeforeLandingBlock || !this.getBlockStateOnLegacy().isAir()) { // Leaves - check frozen ticks before landing block ++ if (org.leavesmc.leaves.LeavesConfig.checkFrozenTicksBeforeLandingBlock || !this.getBlockStateOnLegacy().isAir()) { // Leaves - check frozen ticks before landing block int i = this.getTicksFrozen(); if (i > 0) { - AttributeInstance attributemodifiable = this.getAttribute(Attributes.MOVEMENT_SPEED); -+ AttributeInstance attributemodifiable = !top.leavesmc.leaves.LeavesConfig.checkFrozenTicksBeforeLandingBlock || !this.getBlockStateOnLegacy().isAir() ? this.getAttribute(Attributes.MOVEMENT_SPEED) : null; // Leaves - check frozen ticks before landing block ++ AttributeInstance attributemodifiable = !org.leavesmc.leaves.LeavesConfig.checkFrozenTicksBeforeLandingBlock || !this.getBlockStateOnLegacy().isAir() ? this.getAttribute(Attributes.MOVEMENT_SPEED) : null; // Leaves - check frozen ticks before landing block if (attributemodifiable == null) { return; diff --git a/patches/server/0095-Cache-ominous-banner-item.patch b/patches/server/0095-Cache-ominous-banner-item.patch deleted file mode 100644 index f5a43270..00000000 --- a/patches/server/0095-Cache-ominous-banner-item.patch +++ /dev/null @@ -1,81 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: violetc <58360096+s-yh-china@users.noreply.github.com> -Date: Thu, 20 Jul 2023 21:02:10 +0800 -Subject: [PATCH] Cache ominous banner item - -This patch is Powered by Gale(https://github.com/GaleMC/Gale) - -diff --git a/src/main/java/net/minecraft/advancements/critereon/EntityEquipmentPredicate.java b/src/main/java/net/minecraft/advancements/critereon/EntityEquipmentPredicate.java -index 96f5ccfa0369ca5dd7a327126dbe9b3cfe86ec1b..1dd6c937194cd16cd7219bf55317818decff9959 100644 ---- a/src/main/java/net/minecraft/advancements/critereon/EntityEquipmentPredicate.java -+++ b/src/main/java/net/minecraft/advancements/critereon/EntityEquipmentPredicate.java -@@ -30,9 +30,7 @@ public record EntityEquipmentPredicate( - ) - .apply(instance, EntityEquipmentPredicate::new) - ); -- public static final EntityEquipmentPredicate CAPTAIN = EntityEquipmentPredicate.Builder.equipment() -- .head(ItemPredicate.Builder.item().of(Items.WHITE_BANNER).hasNbt(Raid.getLeaderBannerInstance().getTag())) -- .build(); -+ public static final EntityEquipmentPredicate CAPTAIN = EntityEquipmentPredicate.Builder.equipment().head(ItemPredicate.Builder.item().of(Items.WHITE_BANNER).hasNbt(top.leavesmc.leaves.LeavesConfig.cacheOminousBannerItem ? Raid.LEADER_BANNER.getTag() : Raid.getLeaderBannerInstance().getTag())).build(); // Leaves - cache ominous banner item - - public boolean matches(@Nullable Entity entity) { - return entity instanceof LivingEntity livingEntity -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 bf2c23fad919820512ce031cf28a000b249b2876..261b1a52e219b61973db04aace7429e5d80efb91 100644 ---- a/src/main/java/net/minecraft/world/entity/raid/Raid.java -+++ b/src/main/java/net/minecraft/world/entity/raid/Raid.java -@@ -703,7 +703,14 @@ public class Raid { - this.level.getRaids().setDirty(); - } - -+ // Leaves start - cache ominous banner item -+ public static final ItemStack LEADER_BANNER = createLeaderBanner(); - public static ItemStack getLeaderBannerInstance() { -+ return top.leavesmc.leaves.LeavesConfig.cacheOminousBannerItem ? LEADER_BANNER.copy() : createLeaderBanner(); -+ } -+ // Leaves end - cache ominous banner item -+ -+ public static ItemStack createLeaderBanner() { // Leaves - cache ominous banner item - ItemStack itemstack = new ItemStack(Items.WHITE_BANNER); - CompoundTag nbttagcompound = new CompoundTag(); - ListTag nbttaglist = (new BannerPattern.Builder()).addPattern(BannerPatterns.RHOMBUS_MIDDLE, DyeColor.CYAN).addPattern(BannerPatterns.STRIPE_BOTTOM, DyeColor.LIGHT_GRAY).addPattern(BannerPatterns.STRIPE_CENTER, DyeColor.GRAY).addPattern(BannerPatterns.BORDER, DyeColor.LIGHT_GRAY).addPattern(BannerPatterns.STRIPE_MIDDLE, DyeColor.BLACK).addPattern(BannerPatterns.HALF_HORIZONTAL, DyeColor.LIGHT_GRAY).addPattern(BannerPatterns.CIRCLE_MIDDLE, DyeColor.LIGHT_GRAY).addPattern(BannerPatterns.BORDER, DyeColor.BLACK).toListTag(); -diff --git a/src/main/java/net/minecraft/world/entity/raid/Raider.java b/src/main/java/net/minecraft/world/entity/raid/Raider.java -index e6af29b4934a3d2344ad97c4bbc23523e458ea6a..79c099be8c10d4402fd3410bcaa496a6b2d242d8 100644 ---- a/src/main/java/net/minecraft/world/entity/raid/Raider.java -+++ b/src/main/java/net/minecraft/world/entity/raid/Raider.java -@@ -50,7 +50,7 @@ public abstract class Raider extends PatrollingMonster { - - protected static final EntityDataAccessor IS_CELEBRATING = SynchedEntityData.defineId(Raider.class, EntityDataSerializers.BOOLEAN); - static final Predicate ALLOWED_ITEMS = (entityitem) -> { -- return !entityitem.hasPickUpDelay() && entityitem.isAlive() && ItemStack.matches(entityitem.getItem(), Raid.getLeaderBannerInstance()); -+ return !entityitem.hasPickUpDelay() && entityitem.isAlive() && ItemStack.matches(entityitem.getItem(), top.leavesmc.leaves.LeavesConfig.cacheOminousBannerItem ? Raid.LEADER_BANNER : Raid.getLeaderBannerInstance()); // Leaves - cache ominous banner item - }; - @Nullable - protected Raid raid; -@@ -152,7 +152,7 @@ public abstract class Raider extends PatrollingMonster { - } - } - -- if (!itemstack.isEmpty() && ItemStack.matches(itemstack, Raid.getLeaderBannerInstance()) && entityhuman != null) { -+ if (!itemstack.isEmpty() && ItemStack.matches(itemstack, top.leavesmc.leaves.LeavesConfig.cacheOminousBannerItem ? Raid.LEADER_BANNER : Raid.getLeaderBannerInstance()) && entityhuman != null) { // Leaves - cache ominous banner item - MobEffectInstance mobeffect = entityhuman.getEffect(MobEffects.BAD_OMEN); - byte b0 = 1; - int i; -@@ -247,7 +247,7 @@ public abstract class Raider extends PatrollingMonster { - ItemStack itemstack = item.getItem(); - boolean flag = this.hasActiveRaid() && this.getCurrentRaid().getLeader(this.getWave()) != null; - -- if (this.hasActiveRaid() && !flag && ItemStack.matches(itemstack, Raid.getLeaderBannerInstance())) { -+ if (this.hasActiveRaid() && !flag && ItemStack.matches(itemstack, top.leavesmc.leaves.LeavesConfig.cacheOminousBannerItem ? Raid.LEADER_BANNER : Raid.getLeaderBannerInstance())) { // Leaves - cache ominous banner item - // Paper start - EntityPickupItemEvent fixes - if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(this, item, 0, false).isCancelled()) { - return; -@@ -325,7 +325,7 @@ public abstract class Raider extends PatrollingMonster { - if (!this.mob.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) || !this.mob.canPickUpLoot()) return false; // Paper - respect game and entity rules for picking up items - Raid raid = this.mob.getCurrentRaid(); - -- if (this.mob.hasActiveRaid() && !this.mob.getCurrentRaid().isOver() && this.mob.canBeLeader() && !ItemStack.matches(this.mob.getItemBySlot(EquipmentSlot.HEAD), Raid.getLeaderBannerInstance())) { -+ if (this.mob.hasActiveRaid() && !this.mob.getCurrentRaid().isOver() && this.mob.canBeLeader() && !ItemStack.matches(this.mob.getItemBySlot(EquipmentSlot.HEAD), top.leavesmc.leaves.LeavesConfig.cacheOminousBannerItem ? Raid.LEADER_BANNER : Raid.getLeaderBannerInstance())) { // Leaves - cache ominous banner item - Raider entityraider = raid.getLeader(this.mob.getWave()); - - if (entityraider == null || !entityraider.isAlive()) { diff --git a/patches/server/0096-Skip-entity-move-if-movement-is-zero.patch b/patches/server/0095-Skip-entity-move-if-movement-is-zero.patch similarity index 79% rename from patches/server/0096-Skip-entity-move-if-movement-is-zero.patch rename to patches/server/0095-Skip-entity-move-if-movement-is-zero.patch index a4ffc542..8b4448fe 100644 --- a/patches/server/0096-Skip-entity-move-if-movement-is-zero.patch +++ b/patches/server/0095-Skip-entity-move-if-movement-is-zero.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Skip entity move if movement is zero This patch is Powered by Gale(https://github.com/GaleMC/Gale) diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 63e5a05d2dab763ee7ed9517f5a2807ddff7645b..6f215fdd907526472c6deec855597be967e6242a 100644 +index 5b0f931a26bf16633c79eddcae6bc750d8867136..912d444c478ce57814462e5b84e34b2e56293274 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -317,6 +317,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -320,6 +320,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess public float yRotO; public float xRotO; private AABB bb; @@ -17,12 +17,12 @@ index 63e5a05d2dab763ee7ed9517f5a2807ddff7645b..6f215fdd907526472c6deec855597be9 public boolean onGround; public boolean horizontalCollision; public boolean verticalCollision; -@@ -1092,6 +1093,13 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -1134,6 +1135,13 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess // Paper end - detailed watchdog information public void move(MoverType movementType, Vec3 movement) { + // Leaves start - skip entity move if movement is zero -+ if (top.leavesmc.leaves.LeavesConfig.skipEntityMoveIfMovementIsZero) { ++ if (org.leavesmc.leaves.LeavesConfig.skipEntityMoveIfMovementIsZero) { + if (!this.boundingBoxChanged && movement.equals(Vec3.ZERO)) { + return; + } @@ -31,7 +31,7 @@ index 63e5a05d2dab763ee7ed9517f5a2807ddff7645b..6f215fdd907526472c6deec855597be9 final Vec3 originalMovement = movement; // Paper - Expose pre-collision velocity // Paper start - detailed watchdog information io.papermc.paper.util.TickThread.ensureTickThread("Cannot move an entity off-main"); -@@ -4127,6 +4135,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -4178,6 +4186,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess } public final void setBoundingBox(AABB boundingBox) { diff --git a/patches/server/0097-Skip-cloning-advancement-criteria.patch b/patches/server/0096-Skip-cloning-advancement-criteria.patch similarity index 83% rename from patches/server/0097-Skip-cloning-advancement-criteria.patch rename to patches/server/0096-Skip-cloning-advancement-criteria.patch index 665e79c6..f60dba6a 100644 --- a/patches/server/0097-Skip-cloning-advancement-criteria.patch +++ b/patches/server/0096-Skip-cloning-advancement-criteria.patch @@ -6,15 +6,15 @@ Subject: [PATCH] Skip cloning advancement criteria This patch is Powered by Gale(https://github.com/GaleMC/Gale) diff --git a/src/main/java/net/minecraft/advancements/Advancement.java b/src/main/java/net/minecraft/advancements/Advancement.java -index 366ce8120b0cc7136d2756070d710ec65ae7f44d..15644df3e3cc35d0061679340e82acc04042e2ca 100644 +index 6d04be3a75df1f847389b985c9b1c0330c9e2415..23a3575befe8282c5f1be7601645c4c6108776b3 100644 --- a/src/main/java/net/minecraft/advancements/Advancement.java +++ b/src/main/java/net/minecraft/advancements/Advancement.java -@@ -62,7 +62,7 @@ public record Advancement( +@@ -60,7 +60,7 @@ public record Advancement( AdvancementRequirements requirements, boolean sendsTelemetryEvent ) { - this(parent, display, rewards, Map.copyOf(criteria), requirements, sendsTelemetryEvent, display.map(Advancement::decorateName)); -+ this(parent, display, rewards, !top.leavesmc.leaves.LeavesConfig.skipCloningAdvancementCriteria ? Map.copyOf(criteria) : criteria, requirements, sendsTelemetryEvent, display.map(Advancement::decorateName)); // Leaves - skip cloning advancement criteria ++ this(parent, display, rewards, !org.leavesmc.leaves.LeavesConfig.skipCloningAdvancementCriteria ? Map.copyOf(criteria) : criteria, requirements, sendsTelemetryEvent, display.map(Advancement::decorateName)); // Leaves - skip cloning advancement criteria } private static DataResult validate(Advancement advancement) { diff --git a/patches/server/0098-Skip-negligible-planar-movement-multiplication.patch b/patches/server/0097-Skip-negligible-planar-movement-multiplication.patch similarity index 83% rename from patches/server/0098-Skip-negligible-planar-movement-multiplication.patch rename to patches/server/0097-Skip-negligible-planar-movement-multiplication.patch index 41599f36..072a1fe9 100644 --- a/patches/server/0098-Skip-negligible-planar-movement-multiplication.patch +++ b/patches/server/0097-Skip-negligible-planar-movement-multiplication.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Skip negligible planar movement multiplication This patch is Powered by Gale(https://github.com/GaleMC/Gale) diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 6f215fdd907526472c6deec855597be967e6242a..82970b3108a437eea27b3a2f0ec22a86c64a465c 100644 +index 912d444c478ce57814462e5b84e34b2e56293274..5e0fcc4e6d6afe034c44f7fcb528eab81cd0e3cd 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -1264,9 +1264,16 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -1306,9 +1306,16 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess } this.tryCheckInsideBlocks(); @@ -18,10 +18,10 @@ index 6f215fdd907526472c6deec855597be967e6242a..82970b3108a437eea27b3a2f0ec22a86 - this.setDeltaMovement(this.getDeltaMovement().multiply((double) f, 1.0D, (double) f)); + // Leaves start - skip negligible planar movement multiplication + Vec3 oldDeltaMovement = this.getDeltaMovement(); -+ if (!top.leavesmc.leaves.LeavesConfig.skipNegligiblePlanarMovementMultiplication || ++ if (!org.leavesmc.leaves.LeavesConfig.skipNegligiblePlanarMovementMultiplication || + (oldDeltaMovement.x < -1e-6 || oldDeltaMovement.x > 1e-6 || oldDeltaMovement.z < -1e-6 || oldDeltaMovement.z > 1e-6)) { + float f = this.getBlockSpeedFactor(); -+ if (!top.leavesmc.leaves.LeavesConfig.skipNegligiblePlanarMovementMultiplication || (f < 1 - 1e-6 || f > 1 + 1e-6)) { ++ if (!org.leavesmc.leaves.LeavesConfig.skipNegligiblePlanarMovementMultiplication || (f < 1 - 1e-6 || f > 1 + 1e-6)) { + this.setDeltaMovement(this.getDeltaMovement().multiply((double) f, 1.0D, (double) f)); + } + } diff --git a/patches/server/0099-Fix-villagers-dont-release-memory.patch b/patches/server/0098-Fix-villagers-dont-release-memory.patch similarity index 85% rename from patches/server/0099-Fix-villagers-dont-release-memory.patch rename to patches/server/0098-Fix-villagers-dont-release-memory.patch index 57e64eaa..fd6c10e0 100644 --- a/patches/server/0099-Fix-villagers-dont-release-memory.patch +++ b/patches/server/0098-Fix-villagers-dont-release-memory.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Fix villagers dont release memory 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 24044795d8e0f1fb15a4f2f5401f44897092f2a3..3d770c2b47b796b628a1452e7bb2392c7e371ac0 100644 +index a7930f9875aa4aca997caaead46ecdc21e5e11d7..6cac189cf6e0bef2f0ea8c0dbadb0f417171a05e 100644 --- a/src/main/java/net/minecraft/world/entity/npc/Villager.java +++ b/src/main/java/net/minecraft/world/entity/npc/Villager.java -@@ -1077,4 +1077,20 @@ public class Villager extends AbstractVillager implements ReputationEventHandler +@@ -1069,4 +1069,20 @@ public class Villager extends AbstractVillager implements ReputationEventHandler return optional.isPresent() ? worldTime - (Long) optional.get() < 24000L : false; } @@ -17,7 +17,7 @@ index 24044795d8e0f1fb15a4f2f5401f44897092f2a3..3d770c2b47b796b628a1452e7bb2392c + @Nullable + @Override + public Entity changeDimension(ServerLevel destination) { -+ if (top.leavesmc.leaves.LeavesConfig.villagersDontReleaseMemoryFix) { ++ if (org.leavesmc.leaves.LeavesConfig.villagersDontReleaseMemoryFix) { + this.releaseAllPois(); + this.getBrain().eraseMemory(MemoryModuleType.HOME); + this.getBrain().eraseMemory(MemoryModuleType.JOB_SITE); diff --git a/patches/server/0100-Avoid-anvil-too-expensive.patch b/patches/server/0099-Avoid-anvil-too-expensive.patch similarity index 81% rename from patches/server/0100-Avoid-anvil-too-expensive.patch rename to patches/server/0099-Avoid-anvil-too-expensive.patch index b3dd6a2f..5e7a3657 100644 --- a/patches/server/0100-Avoid-anvil-too-expensive.patch +++ b/patches/server/0099-Avoid-anvil-too-expensive.patch @@ -5,15 +5,15 @@ Subject: [PATCH] Avoid anvil too expensive diff --git a/src/main/java/net/minecraft/world/inventory/AnvilMenu.java b/src/main/java/net/minecraft/world/inventory/AnvilMenu.java -index cab3e0ba471c93764b5949ad68a0f2cce4d00099..8c30f88b8c3d3e1823bfabd5dfa60592848ec8f0 100644 +index 2bd91b48eaa06f85a5b9b1ae052c70e966ae8e4c..d49b2539476b2ae2fc09f1bad0e6a7222e35cf45 100644 --- a/src/main/java/net/minecraft/world/inventory/AnvilMenu.java +++ b/src/main/java/net/minecraft/world/inventory/AnvilMenu.java -@@ -293,7 +293,7 @@ public class AnvilMenu extends ItemCombinerMenu { +@@ -280,7 +280,7 @@ public class AnvilMenu extends ItemCombinerMenu { this.cost.set(this.maximumRepairCost - 1); // CraftBukkit } - if (this.cost.get() >= this.maximumRepairCost && !this.player.getAbilities().instabuild) { // CraftBukkit -+ if (this.cost.get() >= this.maximumRepairCost && (!top.leavesmc.leaves.LeavesConfig.avoidAnvilTooExpensive || this.cost.get() == DEFAULT_DENIED_COST) && !this.player.getAbilities().instabuild) { // CraftBukkit // Leaves - avoid anvil too expensive ++ if (this.cost.get() >= this.maximumRepairCost && (!org.leavesmc.leaves.LeavesConfig.avoidAnvilTooExpensive || this.cost.get() == DEFAULT_DENIED_COST) && !this.player.getAbilities().instabuild) { // CraftBukkit // Leaves - avoid anvil too expensive itemstack1 = ItemStack.EMPTY; } diff --git a/patches/server/0100-Bow-infinity-fix.patch b/patches/server/0100-Bow-infinity-fix.patch new file mode 100644 index 00000000..34b509d0 --- /dev/null +++ b/patches/server/0100-Bow-infinity-fix.patch @@ -0,0 +1,20 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: violetc <58360096+s-yh-china@users.noreply.github.com> +Date: Mon, 24 Jul 2023 15:54:18 +0800 +Subject: [PATCH] Bow infinity fix + + +diff --git a/src/main/java/net/minecraft/world/item/BowItem.java b/src/main/java/net/minecraft/world/item/BowItem.java +index 5ca843df5b4caa668953e5e36a9b20fabeb35046..a1675610ad5114d29f71d385a00330eb0744be5c 100644 +--- a/src/main/java/net/minecraft/world/item/BowItem.java ++++ b/src/main/java/net/minecraft/world/item/BowItem.java +@@ -80,7 +80,8 @@ public class BowItem extends ProjectileWeaponItem { + @Override + public InteractionResultHolder use(Level world, Player user, InteractionHand hand) { + ItemStack itemStack = user.getItemInHand(hand); +- boolean bl = !user.getProjectile(itemStack).isEmpty(); ++ boolean bl = !user.getProjectile(itemStack).isEmpty() ++ || (org.leavesmc.leaves.LeavesConfig.bowInfinityFix && net.minecraft.world.item.enchantment.EnchantmentHelper.getItemEnchantmentLevel(net.minecraft.world.item.enchantment.Enchantments.INFINITY, itemStack) > 0); + if (!user.hasInfiniteMaterials() && !bl) { + return InteractionResultHolder.fail(itemStack); + } else { diff --git a/patches/server/0101-Bow-infinity-fix.patch b/patches/server/0101-Bow-infinity-fix.patch deleted file mode 100644 index e63ffcf6..00000000 --- a/patches/server/0101-Bow-infinity-fix.patch +++ /dev/null @@ -1,19 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: violetc <58360096+s-yh-china@users.noreply.github.com> -Date: Mon, 24 Jul 2023 15:54:18 +0800 -Subject: [PATCH] Bow infinity fix - - -diff --git a/src/main/java/net/minecraft/world/item/BowItem.java b/src/main/java/net/minecraft/world/item/BowItem.java -index 08d597db1a5345a343777a01427655e6bf2c926b..d4127e4b437960670d5c91179a726b433659b317 100644 ---- a/src/main/java/net/minecraft/world/item/BowItem.java -+++ b/src/main/java/net/minecraft/world/item/BowItem.java -@@ -130,7 +130,7 @@ public class BowItem extends ProjectileWeaponItem implements Vanishable { - @Override - public InteractionResultHolder use(Level world, Player user, InteractionHand hand) { - ItemStack itemstack = user.getItemInHand(hand); -- boolean flag = !user.getProjectile(itemstack).isEmpty(); -+ boolean flag = !user.getProjectile(itemstack).isEmpty() || (top.leavesmc.leaves.LeavesConfig.bowInfinityFix && EnchantmentHelper.getItemEnchantmentLevel(Enchantments.INFINITY_ARROWS, itemstack) > 0); - - if (!user.getAbilities().instabuild && !flag) { - return InteractionResultHolder.fail(itemstack); diff --git a/patches/server/0102-Zero-tick-plants.patch b/patches/server/0101-Zero-tick-plants.patch similarity index 75% rename from patches/server/0102-Zero-tick-plants.patch rename to patches/server/0101-Zero-tick-plants.patch index 20233b56..82e12831 100644 --- a/patches/server/0102-Zero-tick-plants.patch +++ b/patches/server/0101-Zero-tick-plants.patch @@ -5,15 +5,15 @@ Subject: [PATCH] Zero tick plants diff --git a/src/main/java/net/minecraft/world/level/block/BambooStalkBlock.java b/src/main/java/net/minecraft/world/level/block/BambooStalkBlock.java -index e8dc4ea90d74036dacb0785fcb9125df192a4c22..80284b01b7dc08659b4daf631ba820a4fc12411b 100644 +index e2951dd077441fe9cda461a2d3ef0c0671308316..a53d00991a02edf7e68faa1632d17f10136ccaf2 100644 --- a/src/main/java/net/minecraft/world/level/block/BambooStalkBlock.java +++ b/src/main/java/net/minecraft/world/level/block/BambooStalkBlock.java @@ -122,8 +122,11 @@ public class BambooStalkBlock extends Block implements BonemealableBlock { - public void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) { + protected void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) { if (!state.canSurvive(world, pos)) { world.destroyBlock(pos, true); + // Leaves start - zero tick plants -+ } else if (top.leavesmc.leaves.LeavesConfig.zeroTickPlants) { ++ } else if (org.leavesmc.leaves.LeavesConfig.zeroTickPlants) { + this.randomTick(state, world, pos, random); + // Leaves end - zero tick plants } @@ -22,15 +22,15 @@ index e8dc4ea90d74036dacb0785fcb9125df192a4c22..80284b01b7dc08659b4daf631ba820a4 @Override diff --git a/src/main/java/net/minecraft/world/level/block/CactusBlock.java b/src/main/java/net/minecraft/world/level/block/CactusBlock.java -index ba4aaf850af36a84517c70581e141157c4f15b99..46ea78ae8f78d70dd4d2b5d51749757e40b31a7d 100644 +index ff4dda48116a2969704b355ff96407ba869b466e..8e544483b7556c9c54a8f5e9f691d4079e79db3c 100644 --- a/src/main/java/net/minecraft/world/level/block/CactusBlock.java +++ b/src/main/java/net/minecraft/world/level/block/CactusBlock.java @@ -46,8 +46,11 @@ public class CactusBlock extends Block { - public void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) { + protected void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) { if (!state.canSurvive(world, pos)) { world.destroyBlock(pos, true); + // Leaves start - zero tick plants -+ } else if (top.leavesmc.leaves.LeavesConfig.zeroTickPlants) { ++ } else if (org.leavesmc.leaves.LeavesConfig.zeroTickPlants) { + this.randomTick(state, world, pos, random); + // Leaves end - zero tick plants } @@ -39,15 +39,15 @@ index ba4aaf850af36a84517c70581e141157c4f15b99..46ea78ae8f78d70dd4d2b5d51749757e @Override diff --git a/src/main/java/net/minecraft/world/level/block/ChorusFlowerBlock.java b/src/main/java/net/minecraft/world/level/block/ChorusFlowerBlock.java -index 0ab1bbd7c8dc8e45f754434357898d8fc990a021..107a3df31a77ff7d13e18691dc2c96024456a0d6 100644 +index 6709cb6b657a8612781c2fe4dd76ee38f329c5ba..43978e5aee045577d3fb1e51a2b225c91f3d6c20 100644 --- a/src/main/java/net/minecraft/world/level/block/ChorusFlowerBlock.java +++ b/src/main/java/net/minecraft/world/level/block/ChorusFlowerBlock.java @@ -51,8 +51,11 @@ public class ChorusFlowerBlock extends Block { - public void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) { + protected void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) { if (!state.canSurvive(world, pos)) { world.destroyBlock(pos, true); + // Leaves start - zero tick plants -+ } else if (top.leavesmc.leaves.LeavesConfig.zeroTickPlants) { ++ } else if (org.leavesmc.leaves.LeavesConfig.zeroTickPlants) { + this.randomTick(state, world, pos, random); + // Leaves end - zero tick plants } @@ -56,7 +56,7 @@ index 0ab1bbd7c8dc8e45f754434357898d8fc990a021..107a3df31a77ff7d13e18691dc2c9602 @Override diff --git a/src/main/java/net/minecraft/world/level/block/GrowingPlantHeadBlock.java b/src/main/java/net/minecraft/world/level/block/GrowingPlantHeadBlock.java -index 30300ef3ec839dfa944c992ab50db4d3859bb02e..0012973aafb19413d228119271c57cb620007292 100644 +index cf05da1c86e3018db11dc079bf50317b6639e5cc..9c3599e5193bae23cca6f492be5e70fe1276e807 100644 --- a/src/main/java/net/minecraft/world/level/block/GrowingPlantHeadBlock.java +++ b/src/main/java/net/minecraft/world/level/block/GrowingPlantHeadBlock.java @@ -142,4 +142,15 @@ public abstract class GrowingPlantHeadBlock extends GrowingPlantBlock implements @@ -69,22 +69,22 @@ index 30300ef3ec839dfa944c992ab50db4d3859bb02e..0012973aafb19413d228119271c57cb6 + public void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) { + if (!state.canSurvive(world, pos)) { + world.destroyBlock(pos, true); -+ } else if (top.leavesmc.leaves.LeavesConfig.zeroTickPlants) { ++ } else if (org.leavesmc.leaves.LeavesConfig.zeroTickPlants) { + this.randomTick(state, world, pos, random); + } + } + // Leaves end - zero tick plants } diff --git a/src/main/java/net/minecraft/world/level/block/SugarCaneBlock.java b/src/main/java/net/minecraft/world/level/block/SugarCaneBlock.java -index 04957d461d0e968d443737068aaeec1d0bce78b2..5fabb71d01aadfddd9ddd0db2f93d08a8ad7a900 100644 +index c48c622e92cedeaa46b929c7adfedec98dd5a3fb..5415285dbb597eb3f5e6ca4749dc45820b571808 100644 --- a/src/main/java/net/minecraft/world/level/block/SugarCaneBlock.java +++ b/src/main/java/net/minecraft/world/level/block/SugarCaneBlock.java @@ -46,8 +46,11 @@ public class SugarCaneBlock extends Block { - public void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) { + protected void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) { if (!state.canSurvive(world, pos)) { world.destroyBlock(pos, true); + // Leaves start - zero tick plants -+ } else if (top.leavesmc.leaves.LeavesConfig.zeroTickPlants) { ++ } else if (org.leavesmc.leaves.LeavesConfig.zeroTickPlants) { + this.randomTick(state, world, pos, random); + // Leaves end - zero tick plants } diff --git a/patches/server/0103-Leaves-update-command.patch b/patches/server/0102-Leaves-update-command.patch similarity index 90% rename from patches/server/0103-Leaves-update-command.patch rename to patches/server/0102-Leaves-update-command.patch index 5e8dfe7a..f09f924b 100644 --- a/patches/server/0103-Leaves-update-command.patch +++ b/patches/server/0102-Leaves-update-command.patch @@ -4,15 +4,15 @@ Date: Mon, 31 Jul 2023 17:42:25 +0800 Subject: [PATCH] Leaves update command -diff --git a/src/main/java/top/leavesmc/leaves/command/LeavesCommand.java b/src/main/java/top/leavesmc/leaves/command/LeavesCommand.java -index 9b6fb546a672fa5b27047fec638e42b2b5dbf533..abf5c05cd5b54b53a192cc452f0e12c43f1fa2fa 100644 ---- a/src/main/java/top/leavesmc/leaves/command/LeavesCommand.java -+++ b/src/main/java/top/leavesmc/leaves/command/LeavesCommand.java +diff --git a/src/main/java/org/leavesmc/leaves/command/LeavesCommand.java b/src/main/java/org/leavesmc/leaves/command/LeavesCommand.java +index b9e2bdb034dcd5119680ddea44a1eda11a0189b2..facd180da9b7025cf7ae192cbe91317ff4b70472 100644 +--- a/src/main/java/org/leavesmc/leaves/command/LeavesCommand.java ++++ b/src/main/java/org/leavesmc/leaves/command/LeavesCommand.java @@ -13,6 +13,7 @@ import org.bukkit.plugin.PluginManager; import org.checkerframework.checker.nullness.qual.Nullable; import org.jetbrains.annotations.NotNull; - import top.leavesmc.leaves.command.subcommands.ConfigCommand; -+import top.leavesmc.leaves.command.subcommands.UpdateCommand; + import org.leavesmc.leaves.command.subcommands.ConfigCommand; ++import org.leavesmc.leaves.command.subcommands.UpdateCommand; import java.util.ArrayList; import java.util.Arrays; @@ -24,18 +24,18 @@ index 9b6fb546a672fa5b27047fec638e42b2b5dbf533..abf5c05cd5b54b53a192cc452f0e12c4 return commands.entrySet().stream() .flatMap(entry -> entry.getKey().stream().map(s -> Map.entry(s, entry.getValue()))) -diff --git a/src/main/java/top/leavesmc/leaves/command/subcommands/UpdateCommand.java b/src/main/java/top/leavesmc/leaves/command/subcommands/UpdateCommand.java +diff --git a/src/main/java/org/leavesmc/leaves/command/subcommands/UpdateCommand.java b/src/main/java/org/leavesmc/leaves/command/subcommands/UpdateCommand.java new file mode 100644 -index 0000000000000000000000000000000000000000..293117a6c54fdce70d69b93fe80ce0216f9b3ea2 +index 0000000000000000000000000000000000000000..7f94df607e8ffd48ab2cb7c90d520c2b4a906cdc --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/command/subcommands/UpdateCommand.java ++++ b/src/main/java/org/leavesmc/leaves/command/subcommands/UpdateCommand.java @@ -0,0 +1,21 @@ -+package top.leavesmc.leaves.command.subcommands; ++package org.leavesmc.leaves.command.subcommands; + +import org.bukkit.ChatColor; +import org.bukkit.command.CommandSender; -+import top.leavesmc.leaves.command.LeavesSubcommand; -+import top.leavesmc.leaves.util.LeavesUpdateHelper; ++import org.leavesmc.leaves.command.LeavesSubcommand; ++import org.leavesmc.leaves.util.LeavesUpdateHelper; + +public class UpdateCommand implements LeavesSubcommand { + @@ -51,13 +51,13 @@ index 0000000000000000000000000000000000000000..293117a6c54fdce70d69b93fe80ce021 + return false; + } +} -diff --git a/src/main/java/top/leavesmc/leaves/util/LeavesUpdateHelper.java b/src/main/java/top/leavesmc/leaves/util/LeavesUpdateHelper.java +diff --git a/src/main/java/org/leavesmc/leaves/util/LeavesUpdateHelper.java b/src/main/java/org/leavesmc/leaves/util/LeavesUpdateHelper.java new file mode 100644 -index 0000000000000000000000000000000000000000..8ed3d15ebea4d8cfa134f331bd49d38fb2219b9a +index 0000000000000000000000000000000000000000..06ca57f0cb319a254ca1511e60f05e5ca151beea --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/util/LeavesUpdateHelper.java ++++ b/src/main/java/org/leavesmc/leaves/util/LeavesUpdateHelper.java @@ -0,0 +1,240 @@ -+package top.leavesmc.leaves.util; ++package org.leavesmc.leaves.util; + +import com.google.common.base.Charsets; +import com.google.gson.Gson; @@ -68,7 +68,7 @@ index 0000000000000000000000000000000000000000..8ed3d15ebea4d8cfa134f331bd49d38f +import net.minecraft.Util; +import org.bukkit.Bukkit; +import org.jetbrains.annotations.NotNull; -+import top.leavesmc.leaves.LeavesLogger; ++import org.leavesmc.leaves.LeavesLogger; + +import java.io.BufferedReader; +import java.io.BufferedWriter; diff --git a/patches/server/0104-Force-peaceful-mode-switch.patch b/patches/server/0103-Force-peaceful-mode-switch.patch similarity index 86% rename from patches/server/0104-Force-peaceful-mode-switch.patch rename to patches/server/0103-Force-peaceful-mode-switch.patch index 3fb5664c..5fbbaa92 100644 --- a/patches/server/0104-Force-peaceful-mode-switch.patch +++ b/patches/server/0103-Force-peaceful-mode-switch.patch @@ -5,15 +5,15 @@ Subject: [PATCH] Force peaceful mode switch diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index a3db45d411772d71ba46632633e935f2251bcfda..5c136b06599ddab0d42b9a8f63828748952433de 100644 +index db41ee04b5dd3e162830342e4b1f2b457ffb7fed..c402a51a0951ad775cd7829f442edb8cf779d5ee 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -@@ -77,6 +77,12 @@ public class ServerChunkCache extends ChunkSource { +@@ -75,6 +75,12 @@ public class ServerChunkCache extends ChunkSource { private final LevelChunk[] lastLoadedChunks = new LevelChunk[4 * 4]; // Paper end + // Leaves start - peaceful mode switch -+ public int peacefulModeSwitchTick = top.leavesmc.leaves.LeavesConfig.forcePeacefulMode; ++ public int peacefulModeSwitchTick = org.leavesmc.leaves.LeavesConfig.forcePeacefulMode; + public int peacefulModeSwitchCount = -1; + private final List> peacefulModeSwitchEntityTypes = List.of(net.minecraft.world.entity.boss.wither.WitherBoss.class, net.minecraft.world.entity.monster.Shulker.class, net.minecraft.world.entity.monster.warden.Warden.class); + // Leaves end - peaceful mode switch @@ -21,7 +21,7 @@ index a3db45d411772d71ba46632633e935f2251bcfda..5c136b06599ddab0d42b9a8f63828748 public ServerChunkCache(ServerLevel world, LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, StructureTemplateManager structureTemplateManager, Executor workerExecutor, ChunkGenerator chunkGenerator, int viewDistance, int simulationDistance, boolean dsync, ChunkProgressListener worldGenerationProgressListener, ChunkStatusUpdateListener chunkStatusChangeListener, Supplier persistentStateManagerFactory) { this.level = world; this.mainThreadProcessor = new ServerChunkCache.MainThreadExecutor(world); -@@ -501,7 +507,21 @@ public class ServerChunkCache extends ChunkSource { +@@ -500,7 +506,21 @@ public class ServerChunkCache extends ChunkSource { } // Leaves end - reset ice & snow tick random gameprofilerfiller.push("filteringLoadedChunks"); @@ -44,7 +44,7 @@ index a3db45d411772d71ba46632633e935f2251bcfda..5c136b06599ddab0d42b9a8f63828748 // Paper - optimise chunk tick iteration -@@ -589,10 +609,20 @@ public class ServerChunkCache extends ChunkSource { +@@ -588,10 +608,20 @@ public class ServerChunkCache extends ChunkSource { } Util.shuffle(shuffled, this.level.random); chunkIterator = shuffled.iterator(); @@ -68,7 +68,7 @@ index a3db45d411772d71ba46632633e935f2251bcfda..5c136b06599ddab0d42b9a8f63828748 LevelChunk chunk1 = chunkIterator.next(); // Paper end - optimise chunk tick iteration ChunkPos chunkcoordintpair = chunk1.getPos(); -@@ -623,7 +653,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -622,7 +652,7 @@ public class ServerChunkCache extends ChunkSource { // Paper end - optimise chunk tick iteration chunk1.incrementInhabitedTime(j); if (spawn && flag && (this.spawnEnemies || this.spawnFriendlies) && this.level.getWorldBorder().isWithinBounds(chunkcoordintpair)) { // Spigot // Paper - optimise chunk tick iteration @@ -78,10 +78,10 @@ index a3db45d411772d71ba46632633e935f2251bcfda..5c136b06599ddab0d42b9a8f63828748 if (true || this.level.shouldTickBlocksAt(chunkcoordintpair.toLong())) { // Paper - optimise chunk tick iteration diff --git a/src/main/java/net/minecraft/world/level/NaturalSpawner.java b/src/main/java/net/minecraft/world/level/NaturalSpawner.java -index 3e10668ca548472238bb4bb0a80a89f169a71496..aaea6e5701e23c5023bb990712bde7af23288ab1 100644 +index 083a8a7dd99e447904dbac161dd3a1de663d6011..27f064812fd7b8f3feedc9966c9dfc78bfdcc85f 100644 --- a/src/main/java/net/minecraft/world/level/NaturalSpawner.java +++ b/src/main/java/net/minecraft/world/level/NaturalSpawner.java -@@ -133,6 +133,12 @@ public final class NaturalSpawner { +@@ -128,6 +128,12 @@ public final class NaturalSpawner { } public static void spawnForChunk(ServerLevel world, LevelChunk chunk, NaturalSpawner.SpawnState info, boolean spawnAnimals, boolean spawnMonsters, boolean rareSpawn) { @@ -94,7 +94,7 @@ index 3e10668ca548472238bb4bb0a80a89f169a71496..aaea6e5701e23c5023bb990712bde7af world.getProfiler().push("spawner"); MobCategory[] aenumcreaturetype = NaturalSpawner.SPAWNING_CATEGORIES; int i = aenumcreaturetype.length; -@@ -141,6 +147,11 @@ public final class NaturalSpawner { +@@ -136,6 +142,11 @@ public final class NaturalSpawner { for (int j = 0; j < i; ++j) { MobCategory enumcreaturetype = aenumcreaturetype[j]; @@ -107,10 +107,10 @@ index 3e10668ca548472238bb4bb0a80a89f169a71496..aaea6e5701e23c5023bb990712bde7af boolean spawnThisTick = true; int limit = enumcreaturetype.getMaxInstancesPerChunk(); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index 00357d78182b3ff87e3d9a45705b072af56739c8..f30320f4e45d5afacb31339cf7c54a55573ad43f 100644 +index f2b20ed5063a293f0b464548f590d652170cd1d8..ab4510eb9e5eaca46e3278c73e208757292a9f90 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -@@ -2450,6 +2450,18 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -2458,6 +2458,18 @@ public class CraftWorld extends CraftRegionAccessor implements World { return CraftFeatureFlag.getFromNMS(this.getHandle().enabledFeatures()).stream().map(FeatureFlag.class::cast).collect(Collectors.toUnmodifiableSet()); } @@ -129,16 +129,16 @@ index 00357d78182b3ff87e3d9a45705b072af56739c8..f30320f4e45d5afacb31339cf7c54a55 public void storeBukkitValues(CompoundTag c) { if (!this.persistentDataContainer.isEmpty()) { c.put("BukkitValues", this.persistentDataContainer.toTagCompound()); -diff --git a/src/main/java/top/leavesmc/leaves/command/LeavesCommand.java b/src/main/java/top/leavesmc/leaves/command/LeavesCommand.java -index abf5c05cd5b54b53a192cc452f0e12c43f1fa2fa..5efdb9b5138738da7cfc075ce0be531d2608577e 100644 ---- a/src/main/java/top/leavesmc/leaves/command/LeavesCommand.java -+++ b/src/main/java/top/leavesmc/leaves/command/LeavesCommand.java +diff --git a/src/main/java/org/leavesmc/leaves/command/LeavesCommand.java b/src/main/java/org/leavesmc/leaves/command/LeavesCommand.java +index facd180da9b7025cf7ae192cbe91317ff4b70472..2d871fafff90e2dbc8c4141f92cdb1544ccdce43 100644 +--- a/src/main/java/org/leavesmc/leaves/command/LeavesCommand.java ++++ b/src/main/java/org/leavesmc/leaves/command/LeavesCommand.java @@ -13,6 +13,7 @@ import org.bukkit.plugin.PluginManager; import org.checkerframework.checker.nullness.qual.Nullable; import org.jetbrains.annotations.NotNull; - import top.leavesmc.leaves.command.subcommands.ConfigCommand; -+import top.leavesmc.leaves.command.subcommands.PeacefulModeSwitchCommand; - import top.leavesmc.leaves.command.subcommands.UpdateCommand; + import org.leavesmc.leaves.command.subcommands.ConfigCommand; ++import org.leavesmc.leaves.command.subcommands.PeacefulModeSwitchCommand; + import org.leavesmc.leaves.command.subcommands.UpdateCommand; import java.util.ArrayList; @@ -35,6 +36,7 @@ public final class LeavesCommand extends Command { @@ -149,13 +149,13 @@ index abf5c05cd5b54b53a192cc452f0e12c43f1fa2fa..5efdb9b5138738da7cfc075ce0be531d return commands.entrySet().stream() .flatMap(entry -> entry.getKey().stream().map(s -> Map.entry(s, entry.getValue()))) -diff --git a/src/main/java/top/leavesmc/leaves/command/subcommands/PeacefulModeSwitchCommand.java b/src/main/java/top/leavesmc/leaves/command/subcommands/PeacefulModeSwitchCommand.java +diff --git a/src/main/java/org/leavesmc/leaves/command/subcommands/PeacefulModeSwitchCommand.java b/src/main/java/org/leavesmc/leaves/command/subcommands/PeacefulModeSwitchCommand.java new file mode 100644 -index 0000000000000000000000000000000000000000..417689ab712ce21ee05fa05ffec35b9ff163e324 +index 0000000000000000000000000000000000000000..4c7895c94f7adaf0a7fb7c31327786b14768632e --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/command/subcommands/PeacefulModeSwitchCommand.java ++++ b/src/main/java/org/leavesmc/leaves/command/subcommands/PeacefulModeSwitchCommand.java @@ -0,0 +1,87 @@ -+package top.leavesmc.leaves.command.subcommands; ++package org.leavesmc.leaves.command.subcommands; + +import io.papermc.paper.command.CommandUtil; +import net.kyori.adventure.text.Component; @@ -169,7 +169,7 @@ index 0000000000000000000000000000000000000000..417689ab712ce21ee05fa05ffec35b9f +import org.bukkit.command.CommandSender; +import org.bukkit.craftbukkit.CraftWorld; +import org.bukkit.entity.Player; -+import top.leavesmc.leaves.command.LeavesSubcommand; ++import org.leavesmc.leaves.command.LeavesSubcommand; + +import java.util.ArrayList; +import java.util.Collections; diff --git a/patches/server/0105-Add-Leaves-Auto-Update.patch b/patches/server/0104-Add-Leaves-Auto-Update.patch similarity index 89% rename from patches/server/0105-Add-Leaves-Auto-Update.patch rename to patches/server/0104-Add-Leaves-Auto-Update.patch index f2964832..47f0dadf 100644 --- a/patches/server/0105-Add-Leaves-Auto-Update.patch +++ b/patches/server/0104-Add-Leaves-Auto-Update.patch @@ -4,10 +4,10 @@ Date: Sun, 6 Aug 2023 09:57:53 +0800 Subject: [PATCH] Add Leaves Auto Update -diff --git a/src/main/java/top/leavesmc/leaves/util/LeavesUpdateHelper.java b/src/main/java/top/leavesmc/leaves/util/LeavesUpdateHelper.java -index 8ed3d15ebea4d8cfa134f331bd49d38fb2219b9a..e2fe17e6d536981bf4c2df40d55bf1f5ae83471b 100644 ---- a/src/main/java/top/leavesmc/leaves/util/LeavesUpdateHelper.java -+++ b/src/main/java/top/leavesmc/leaves/util/LeavesUpdateHelper.java +diff --git a/src/main/java/org/leavesmc/leaves/util/LeavesUpdateHelper.java b/src/main/java/org/leavesmc/leaves/util/LeavesUpdateHelper.java +index 06ca57f0cb319a254ca1511e60f05e5ca151beea..061869a93704e9605378468af8343c64fa009580 100644 +--- a/src/main/java/org/leavesmc/leaves/util/LeavesUpdateHelper.java ++++ b/src/main/java/org/leavesmc/leaves/util/LeavesUpdateHelper.java @@ -7,8 +7,11 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonSyntaxException; @@ -16,8 +16,8 @@ index 8ed3d15ebea4d8cfa134f331bd49d38fb2219b9a..e2fe17e6d536981bf4c2df40d55bf1f5 import org.bukkit.Bukkit; +import org.checkerframework.checker.units.qual.C; import org.jetbrains.annotations.NotNull; -+import top.leavesmc.leaves.LeavesConfig; - import top.leavesmc.leaves.LeavesLogger; ++import org.leavesmc.leaves.LeavesConfig; + import org.leavesmc.leaves.LeavesLogger; import java.io.BufferedReader; @@ -26,6 +29,12 @@ import java.nio.channels.ReadableByteChannel; diff --git a/patches/server/0106-Replay-Mod-API.patch b/patches/server/0105-Replay-Mod-API.patch similarity index 83% rename from patches/server/0106-Replay-Mod-API.patch rename to patches/server/0105-Replay-Mod-API.patch index 470125aa..cb770865 100644 --- a/patches/server/0106-Replay-Mod-API.patch +++ b/patches/server/0105-Replay-Mod-API.patch @@ -5,27 +5,36 @@ Subject: [PATCH] Replay Mod API This patch is Powered by ReplayMod(https://github.com/ReplayMod) +diff --git a/.gitignore b/.gitignore +index 1ad93453221244f880855b510e888e759275b640..3811c0d849a3eb028ed1a6b7a2d4747f7f570448 100644 +--- a/.gitignore ++++ b/.gitignore +@@ -46,4 +46,3 @@ dependency-reduced-pom.xml + # vs code + /.vscode + /.factorypath +- diff --git a/src/main/java/net/minecraft/commands/arguments/EntityArgument.java b/src/main/java/net/minecraft/commands/arguments/EntityArgument.java -index 8d79cfa371546996ef65f94232c1d344e7c590ec..9c262c82d9ab24bdbbe03df8cee3d5d99e8f8868 100644 +index 7976885b902a6ce7d80f31e49448c99452eb9765..6bed90ec5effafbad4aaf82878fe24633891e4e5 100644 --- a/src/main/java/net/minecraft/commands/arguments/EntityArgument.java +++ b/src/main/java/net/minecraft/commands/arguments/EntityArgument.java -@@ -147,6 +147,7 @@ public class EntityArgument implements ArgumentType { +@@ -146,6 +146,7 @@ public class EntityArgument implements ArgumentType { if (icompletionprovider instanceof CommandSourceStack commandSourceStack && commandSourceStack.getEntity() instanceof ServerPlayer sourcePlayer) { collection = new java.util.ArrayList<>(); for (final ServerPlayer player : commandSourceStack.getServer().getPlayerList().getPlayers()) { -+ if (player instanceof top.leavesmc.leaves.replay.ServerPhotographer) continue; // Leaves - skip photographer ++ if (player instanceof org.leavesmc.leaves.replay.ServerPhotographer) continue; // Leaves - skip photographer if (sourcePlayer.getBukkitEntity().canSee(player.getBukkitEntity())) { collection.add(player.getGameProfile().getName()); } diff --git a/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java b/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java -index 676a1499747b071515479130875157263d3a8352..e5ef298dc1df9cc42b3d349939a966b77fc0d554 100644 +index 676a1499747b071515479130875157263d3a8352..af2f95487c3d044dc4462baf981c66cf0ee6a7cf 100644 --- a/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java +++ b/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java @@ -122,6 +122,7 @@ public class EntitySelector { return this.findPlayers(source); } else if (this.playerName != null) { ServerPlayer entityplayer = source.getServer().getPlayerList().getPlayerByName(this.playerName); -+ entityplayer = entityplayer instanceof top.leavesmc.leaves.replay.ServerPhotographer ? null : entityplayer; // Leaves - skip photographer ++ entityplayer = entityplayer instanceof org.leavesmc.leaves.replay.ServerPhotographer ? null : entityplayer; // Leaves - skip photographer return (List) (entityplayer == null ? Collections.emptyList() : Lists.newArrayList(new ServerPlayer[]{entityplayer})); } else if (this.entityUUID != null) { @@ -33,7 +42,7 @@ index 676a1499747b071515479130875157263d3a8352..e5ef298dc1df9cc42b3d349939a966b7 ServerLevel worldserver = (ServerLevel) iterator.next(); entity = worldserver.getEntity(this.entityUUID); -+ entity = entity instanceof top.leavesmc.leaves.replay.ServerPhotographer ? null : entity; // Leaves - skip photographer ++ entity = entity instanceof org.leavesmc.leaves.replay.ServerPhotographer ? null : entity; // Leaves - skip photographer } while (entity == null); return Lists.newArrayList(new Entity[]{entity}); @@ -42,7 +51,7 @@ index 676a1499747b071515479130875157263d3a8352..e5ef298dc1df9cc42b3d349939a966b7 if (this.currentEntity) { - return (List) (source.getEntity() != null && predicate.test(source.getEntity()) ? Lists.newArrayList(new Entity[]{source.getEntity()}) : Collections.emptyList()); -+ return (List) (source.getEntity() != null && !(source.getEntity() instanceof top.leavesmc.leaves.replay.ServerPhotographer) && predicate.test(source.getEntity()) ? Lists.newArrayList(new Entity[]{source.getEntity()}) : Collections.emptyList()); // Leaves - skip photographer ++ return (List) (source.getEntity() != null && !(source.getEntity() instanceof org.leavesmc.leaves.replay.ServerPhotographer) && predicate.test(source.getEntity()) ? Lists.newArrayList(new Entity[]{source.getEntity()}) : Collections.emptyList()); // Leaves - skip photographer } else { List list = Lists.newArrayList(); @@ -50,7 +59,7 @@ index 676a1499747b071515479130875157263d3a8352..e5ef298dc1df9cc42b3d349939a966b7 this.addEntities(list, worldserver1, vec3d, predicate); } } -+ list.removeIf(entity -> entity instanceof top.leavesmc.leaves.replay.ServerPhotographer); // Leaves - skip photographer ++ list.removeIf(entity -> entity instanceof org.leavesmc.leaves.replay.ServerPhotographer); // Leaves - skip photographer return this.sortAndLimit(vec3d, list); } @@ -58,11 +67,11 @@ index 676a1499747b071515479130875157263d3a8352..e5ef298dc1df9cc42b3d349939a966b7 if (this.playerName != null) { entityplayer = source.getServer().getPlayerList().getPlayerByName(this.playerName); -+ entityplayer = entityplayer instanceof top.leavesmc.leaves.replay.ServerPhotographer ? null : entityplayer; // Leaves - skip photographer ++ entityplayer = entityplayer instanceof org.leavesmc.leaves.replay.ServerPhotographer ? null : entityplayer; // Leaves - skip photographer return (List) (entityplayer == null ? Collections.emptyList() : Lists.newArrayList(new ServerPlayer[]{entityplayer})); } else if (this.entityUUID != null) { entityplayer = source.getServer().getPlayerList().getPlayer(this.entityUUID); -+ entityplayer = entityplayer instanceof top.leavesmc.leaves.replay.ServerPhotographer ? null : entityplayer; // Leaves - skip photographer ++ entityplayer = entityplayer instanceof org.leavesmc.leaves.replay.ServerPhotographer ? null : entityplayer; // Leaves - skip photographer return (List) (entityplayer == null ? Collections.emptyList() : Lists.newArrayList(new ServerPlayer[]{entityplayer})); } else { Vec3 vec3d = (Vec3) this.position.apply(source.getPosition()); @@ -71,7 +80,7 @@ index 676a1499747b071515479130875157263d3a8352..e5ef298dc1df9cc42b3d349939a966b7 ServerPlayer entityplayer1 = (ServerPlayer) entity; - if (predicate.test(entityplayer1)) { -+ if (predicate.test(entityplayer1) && !(entityplayer1 instanceof top.leavesmc.leaves.replay.ServerPhotographer)) { // Leaves - skip photographer ++ if (predicate.test(entityplayer1) && !(entityplayer1 instanceof org.leavesmc.leaves.replay.ServerPhotographer)) { // Leaves - skip photographer return Lists.newArrayList(new ServerPlayer[]{entityplayer1}); } } @@ -80,7 +89,7 @@ index 676a1499747b071515479130875157263d3a8352..e5ef298dc1df9cc42b3d349939a966b7 if (this.isWorldLimited()) { - object = source.getLevel().getPlayers(predicate, i); -+ object = source.getLevel().getPlayers((entityplayer3 -> !(entityplayer3 instanceof top.leavesmc.leaves.replay.ServerPhotographer) && predicate.test(entityplayer3)), i); // Leaves - skip photographer ++ object = source.getLevel().getPlayers((entityplayer3 -> !(entityplayer3 instanceof org.leavesmc.leaves.replay.ServerPhotographer) && predicate.test(entityplayer3)), i); // Leaves - skip photographer } else { object = Lists.newArrayList(); Iterator iterator = source.getServer().getPlayerList().getPlayers().iterator(); @@ -89,15 +98,15 @@ index 676a1499747b071515479130875157263d3a8352..e5ef298dc1df9cc42b3d349939a966b7 ServerPlayer entityplayer2 = (ServerPlayer) iterator.next(); - if (predicate.test(entityplayer2)) { -+ if (predicate.test(entityplayer2) && !(entityplayer2 instanceof top.leavesmc.leaves.replay.ServerPhotographer)) { // Leaves - skip photographer ++ if (predicate.test(entityplayer2) && !(entityplayer2 instanceof org.leavesmc.leaves.replay.ServerPhotographer)) { // Leaves - skip photographer ((List) object).add(entityplayer2); if (((List) object).size() >= i) { return (List) object; diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 791e6680db77d3ec464168e5225d3ab0844b5e84..7fd45603c33730e3cb8d3aa1180ecd30f253e0f5 100644 +index 21b659382656f01d7576cd0481c831166f7f3229..5c03702896a837425dfa13fdd5db1056f9267a88 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -1606,7 +1606,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop !playerList.isOp(player.getGameProfile())) .map(player -> player.getGameProfile().getName()), -diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 2730718b162c20110145798dbb0eaad0b139e99b..7f8b5195ac50f153411eb6713c6a861864cc8886 100644 ---- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -299,7 +299,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl - super(server, connection, clientData, player); // CraftBukkit - this.chunkSender = new PlayerChunkSender(connection.isMemoryConnection()); - // Leaves start - fakeplayer -- if (player instanceof top.leavesmc.leaves.bot.ServerBot) { -+ if (player instanceof top.leavesmc.leaves.bot.ServerBot || player instanceof top.leavesmc.leaves.replay.ServerPhotographer) { // Leaves - and photographer - connection.setListenerForce(this); - } else { - connection.setListener(this); diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index 139129f0110dc656bc729ce795f012ec087641cf..dc140b2003a997c13f7bdc8f5c707f98f4d6ff17 100644 +index c4aac957906ff3bf28b29e58e30decc608562e6a..b2b7932073bd2f083dff9462418e1a1c9853ebb6 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java -@@ -124,6 +124,7 @@ import org.bukkit.event.player.PlayerSpawnChangeEvent; - import top.leavesmc.leaves.bot.ServerBot; - import top.leavesmc.leaves.util.ReturnPortalManager; // Leaves - return portal fix - import top.leavesmc.leaves.util.ArrayConstants; -+import top.leavesmc.leaves.replay.ServerPhotographer; +@@ -126,6 +126,7 @@ import org.bukkit.event.player.PlayerSpawnChangeEvent; + // CraftBukkit end + + import org.leavesmc.leaves.bot.ServerBot; ++import org.leavesmc.leaves.replay.ServerPhotographer; public abstract class PlayerList { -@@ -156,6 +157,7 @@ public abstract class PlayerList { - private boolean allowCheatsForAllPlayers; +@@ -158,6 +159,7 @@ public abstract class PlayerList { + private boolean allowCommandsForAllPlayers; private static final boolean ALLOW_LOGOUTIVATOR = false; private int sendAllPlayerInfoIn; + public final List realPlayers = new java.util.concurrent.CopyOnWriteArrayList(); // Leaves - replay api // CraftBukkit start private CraftServer cserver; -@@ -182,6 +184,120 @@ public abstract class PlayerList { +@@ -184,6 +186,120 @@ public abstract class PlayerList { } abstract public void loadAndSaveFiles(); // Paper - fix converting txt to json file; moved from DedicatedPlayerList constructor @@ -183,13 +179,13 @@ index 139129f0110dc656bc729ce795f012ec087641cf..dc140b2003a997c13f7bdc8f5c707f98 + LevelData worlddata = worldserver1.getLevelData(); + + player.loadGameTypes(null); -+ ServerGamePacketListenerImpl playerconnection = new ServerGamePacketListenerImpl(this.server, connection, player, CommonListenerCookie.createInitial(player.gameProfile)); ++ ServerGamePacketListenerImpl playerconnection = new ServerGamePacketListenerImpl(this.server, connection, player, CommonListenerCookie.createInitial(player.gameProfile, false)); + GameRules gamerules = worldserver1.getGameRules(); + boolean flag = gamerules.getBoolean(GameRules.RULE_DO_IMMEDIATE_RESPAWN); + boolean flag1 = gamerules.getBoolean(GameRules.RULE_REDUCEDDEBUGINFO); + boolean flag2 = gamerules.getBoolean(GameRules.RULE_LIMITED_CRAFTING); + -+ playerconnection.send(new ClientboundLoginPacket(player.getId(), worlddata.isHardcore(), this.server.levelKeys(), this.getMaxPlayers(), worldserver1.getWorld().getSendViewDistance(), worldserver1.getWorld().getSimulationDistance(), flag1, !flag, flag2, player.createCommonSpawnInfo(worldserver1))); // Paper - replace old player chunk management ++ playerconnection.send(new ClientboundLoginPacket(player.getId(), worlddata.isHardcore(), this.server.levelKeys(), this.getMaxPlayers(), worldserver1.getWorld().getSendViewDistance(), worldserver1.getWorld().getSimulationDistance(), flag1, !flag, flag2, player.createCommonSpawnInfo(worldserver1), this.server.enforceSecureProfile())); // Paper - replace old player chunk management + player.getBukkitEntity().sendSupportedChannels(); // CraftBukkit + playerconnection.send(new ClientboundChangeDifficultyPacket(worlddata.getDifficulty(), worlddata.isDifficultyLocked())); + playerconnection.send(new ClientboundPlayerAbilitiesPacket(player.getAbilities())); @@ -223,10 +219,10 @@ index 139129f0110dc656bc729ce795f012ec087641cf..dc140b2003a997c13f7bdc8f5c707f98 + return; + } + -+ top.leavesmc.leaves.protocol.core.LeavesProtocolManager.handlePlayerJoin(player); // Leaves - protocol ++ // org.leavesmc.leaves.protocol.core.LeavesProtocolManager.handlePlayerJoin(player); // Leaves - protocol + + // Leaves start - bot support -+ if (top.leavesmc.leaves.LeavesConfig.fakeplayerSupport) { ++ if (org.leavesmc.leaves.LeavesConfig.fakeplayerSupport) { + ServerBot bot = ServerBot.getBot(player.getScoreboardName().toLowerCase(java.util.Locale.ROOT)); + if (bot != null) { + bot.die(bot.damageSources().fellOutOfWorld()); // Leaves - remove bot with the same name @@ -269,7 +265,7 @@ index 139129f0110dc656bc729ce795f012ec087641cf..dc140b2003a997c13f7bdc8f5c707f98 + Iterator iterator = player.getActiveEffects().iterator(); + while (iterator.hasNext()) { + MobEffectInstance mobeffect = (MobEffectInstance) iterator.next(); -+ playerconnection.send(new ClientboundUpdateMobEffectPacket(player.getId(), mobeffect)); ++ playerconnection.send(new ClientboundUpdateMobEffectPacket(player.getId(), mobeffect, false)); + } + + if (player.isDeadOrDying()) { @@ -286,7 +282,7 @@ index 139129f0110dc656bc729ce795f012ec087641cf..dc140b2003a997c13f7bdc8f5c707f98 public void placeNewPlayer(Connection connection, ServerPlayer player, CommonListenerCookie clientData) { player.isRealPlayer = true; // Paper player.loginTime = System.currentTimeMillis(); // Paper - Replace OfflinePlayer#getLastPlayed -@@ -328,6 +444,7 @@ public abstract class PlayerList { +@@ -330,6 +446,7 @@ public abstract class PlayerList { // entityplayer.connection.send(ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(this.players)); // CraftBukkit - replaced with loop below this.players.add(player); @@ -294,7 +290,7 @@ index 139129f0110dc656bc729ce795f012ec087641cf..dc140b2003a997c13f7bdc8f5c707f98 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 -@@ -399,6 +516,12 @@ public abstract class PlayerList { +@@ -401,6 +518,12 @@ public abstract class PlayerList { continue; } @@ -307,7 +303,7 @@ index 139129f0110dc656bc729ce795f012ec087641cf..dc140b2003a997c13f7bdc8f5c707f98 onlinePlayers.add(entityplayer1); // Paper - Use single player info update packet on join } // Paper start - Use single player info update packet on join -@@ -613,6 +736,43 @@ public abstract class PlayerList { +@@ -611,6 +734,43 @@ public abstract class PlayerList { } @@ -351,7 +347,7 @@ index 139129f0110dc656bc729ce795f012ec087641cf..dc140b2003a997c13f7bdc8f5c707f98 public net.kyori.adventure.text.Component remove(ServerPlayer entityplayer) { // CraftBukkit - return string // Paper - return Component // Paper start - Fix kick event leave message not being sent return this.remove(entityplayer, net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW, io.papermc.paper.configuration.GlobalConfiguration.get().messages.useDisplayNameInQuitMessage ? entityplayer.getBukkitEntity().displayName() : io.papermc.paper.adventure.PaperAdventure.asAdventure(entityplayer.getDisplayName()))); -@@ -681,6 +841,7 @@ public abstract class PlayerList { +@@ -679,6 +839,7 @@ public abstract class PlayerList { entityplayer.retireScheduler(); // Paper - Folia schedulers entityplayer.getAdvancements().stopListening(); this.players.remove(entityplayer); @@ -359,7 +355,7 @@ index 139129f0110dc656bc729ce795f012ec087641cf..dc140b2003a997c13f7bdc8f5c707f98 this.playersByName.remove(entityplayer.getScoreboardName().toLowerCase(java.util.Locale.ROOT)); // Spigot this.server.getCustomBossEvents().onPlayerDisconnect(entityplayer); UUID uuid = entityplayer.getUUID(); -@@ -774,7 +935,7 @@ public abstract class PlayerList { +@@ -773,7 +934,7 @@ public abstract class PlayerList { event.disallow(PlayerLoginEvent.Result.KICK_BANNED, io.papermc.paper.adventure.PaperAdventure.asAdventure(ichatmutablecomponent)); // Paper - Adventure } else { // return this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(gameprofile) ? IChatBaseComponent.translatable("multiplayer.disconnect.server_full") : null; @@ -369,26 +365,18 @@ index 139129f0110dc656bc729ce795f012ec087641cf..dc140b2003a997c13f7bdc8f5c707f98 } } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 79c10c26e9a27b120070b408e261a26bb66a5082..70b4f5dc96e285184bd3e676397c6bddd193db37 100644 +index 87bb3ecfbc1fc48a0c276261ea438ba43f8e9e50..405a04f2711e26e22d7dd091745b5b5a01d724d9 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -262,6 +262,7 @@ import org.yaml.snakeyaml.error.MarkedYAMLException; - - import net.md_5.bungee.api.chat.BaseComponent; // Spigot - import top.leavesmc.leaves.entity.CraftBotManager; -+import top.leavesmc.leaves.entity.CraftPhotographerManager; - - import javax.annotation.Nullable; // Paper - import javax.annotation.Nonnull; // Paper -@@ -309,6 +310,7 @@ public final class CraftServer implements Server { +@@ -306,6 +306,7 @@ public final class CraftServer implements Server { private final io.papermc.paper.logging.SysoutCatcher sysoutCatcher = new io.papermc.paper.logging.SysoutCatcher(); // Paper - private final CraftPotionBrewer potionBrewer = new CraftPotionBrewer(); // Paper - Custom Potion Mixes - private final CraftBotManager botManager = new CraftBotManager(); -+ private final CraftPhotographerManager photographerManager = new CraftPhotographerManager(); + private final io.papermc.paper.potion.PaperPotionBrewer potionBrewer; // Paper - Custom Potion Mixes + private final org.leavesmc.leaves.entity.CraftBotManager botManager = new org.leavesmc.leaves.entity.CraftBotManager(); // Leaves ++ private final org.leavesmc.leaves.entity.CraftPhotographerManager photographerManager = new org.leavesmc.leaves.entity.CraftPhotographerManager(); // Leaves // Paper start - Folia region threading API private final io.papermc.paper.threadedregions.scheduler.FallbackRegionScheduler regionizedScheduler = new io.papermc.paper.threadedregions.scheduler.FallbackRegionScheduler(); -@@ -390,7 +392,7 @@ public final class CraftServer implements Server { +@@ -388,7 +389,7 @@ public final class CraftServer implements Server { public CraftServer(DedicatedServer console, PlayerList playerList) { this.console = console; this.playerList = (DedicatedPlayerList) playerList; @@ -397,28 +385,28 @@ index 79c10c26e9a27b120070b408e261a26bb66a5082..70b4f5dc96e285184bd3e676397c6bdd @Override public CraftPlayer apply(ServerPlayer player) { return player.getBukkitEntity(); -@@ -3279,4 +3281,11 @@ public final class CraftServer implements Server { +@@ -3283,4 +3284,11 @@ public final class CraftServer implements Server { return botManager; } // Leaves end - Bot API + + // Leaves start - replay mod api + @Override -+ public CraftPhotographerManager getPhotographerManager() { ++ public org.leavesmc.leaves.entity.CraftPhotographerManager getPhotographerManager() { + return photographerManager; + } + // Leaves end - replay mod api } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java -index 12f8ed45dc280a9ad7e975b1922cc9309c3d53b8..2254ab17bc087c2a54a15588b908c55efa01522c 100644 +index ff4563be301d237bb2f431e424687891e95b2b4f..22f29b760bc569f4ca38617e147c699689a1ddf1 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java -@@ -59,6 +59,8 @@ import top.leavesmc.leaves.bot.ServerBot; - import top.leavesmc.leaves.entity.CraftBot; +@@ -59,6 +59,8 @@ import org.leavesmc.leaves.bot.ServerBot; + import org.leavesmc.leaves.entity.CraftBot; import net.md_5.bungee.api.chat.BaseComponent; // Spigot -+import top.leavesmc.leaves.entity.CraftPhotographer; -+import top.leavesmc.leaves.replay.ServerPhotographer; ++import org.leavesmc.leaves.entity.CraftPhotographer; ++import org.leavesmc.leaves.replay.ServerPhotographer; public abstract class CraftEntity implements org.bukkit.entity.Entity { private static PermissibleBase perm; @@ -431,25 +419,25 @@ index 12f8ed45dc280a9ad7e975b1922cc9309c3d53b8..2254ab17bc087c2a54a15588b908c55e // Special case complex part, since there is no extra entity type for them if (entity instanceof EnderDragonPart complexPart) { diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 44f4665db613c558078df5bb49106e4ca5679dfe..be198fa712ced7b61de16bdbc1f13acd2306cb22 100644 +index 561a7a8e96e2d91bbb87fe6230e94b5f38073d27..25a5ce110c0515f5a0ee5f287a7f3dd029a8f29f 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -@@ -2138,7 +2138,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -2223,7 +2223,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public boolean canSee(Player player) { - return this.canSee((org.bukkit.entity.Entity) player); -+ return !(player instanceof top.leavesmc.leaves.entity.Photographer) && this.canSee((org.bukkit.entity.Entity) player); // Leaves - skip photographer ++ return !(player instanceof org.leavesmc.leaves.entity.Photographer) && this.canSee((org.bukkit.entity.Entity) player); // Leaves - skip photographer } @Override -diff --git a/src/main/java/top/leavesmc/leaves/entity/CraftPhotographer.java b/src/main/java/top/leavesmc/leaves/entity/CraftPhotographer.java +diff --git a/src/main/java/org/leavesmc/leaves/entity/CraftPhotographer.java b/src/main/java/org/leavesmc/leaves/entity/CraftPhotographer.java new file mode 100644 -index 0000000000000000000000000000000000000000..4f58b6623a6b5c726d718ced6ab106af3e665e35 +index 0000000000000000000000000000000000000000..fed2005cb711d0d15d5c87e5f0f7939c7a6a8ffa --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/entity/CraftPhotographer.java ++++ b/src/main/java/org/leavesmc/leaves/entity/CraftPhotographer.java @@ -0,0 +1,73 @@ -+package top.leavesmc.leaves.entity; ++package org.leavesmc.leaves.entity; + +import net.minecraft.server.level.ServerPlayer; +import org.bukkit.craftbukkit.CraftServer; @@ -457,7 +445,7 @@ index 0000000000000000000000000000000000000000..4f58b6623a6b5c726d718ced6ab106af +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; -+import top.leavesmc.leaves.replay.ServerPhotographer; ++import org.leavesmc.leaves.replay.ServerPhotographer; + +import java.io.File; + @@ -522,23 +510,23 @@ index 0000000000000000000000000000000000000000..4f58b6623a6b5c726d718ced6ab106af + return "CraftPhotographer{" + "name=" + getName() + '}'; + } +} -diff --git a/src/main/java/top/leavesmc/leaves/entity/CraftPhotographerManager.java b/src/main/java/top/leavesmc/leaves/entity/CraftPhotographerManager.java +diff --git a/src/main/java/org/leavesmc/leaves/entity/CraftPhotographerManager.java b/src/main/java/org/leavesmc/leaves/entity/CraftPhotographerManager.java new file mode 100644 -index 0000000000000000000000000000000000000000..56b41cb3401ea597b48ec98098fe31f4dfb4933d +index 0000000000000000000000000000000000000000..202e1694123ddfdf716b25d4eaef88d00ed2e3c7 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/entity/CraftPhotographerManager.java ++++ b/src/main/java/org/leavesmc/leaves/entity/CraftPhotographerManager.java @@ -0,0 +1,84 @@ -+package top.leavesmc.leaves.entity; ++package org.leavesmc.leaves.entity; + +import com.google.common.collect.Lists; +import org.bukkit.Location; +import org.bukkit.util.Consumer; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; -+import top.leavesmc.leaves.bot.ServerBot; -+import top.leavesmc.leaves.replay.BukkitRecorderOption; -+import top.leavesmc.leaves.replay.RecorderOption; -+import top.leavesmc.leaves.replay.ServerPhotographer; ++import org.leavesmc.leaves.bot.ServerBot; ++import org.leavesmc.leaves.replay.BukkitRecorderOption; ++import org.leavesmc.leaves.replay.RecorderOption; ++import org.leavesmc.leaves.replay.ServerPhotographer; + +import java.util.Collection; +import java.util.Collections; @@ -612,13 +600,13 @@ index 0000000000000000000000000000000000000000..56b41cb3401ea597b48ec98098fe31f4 + return photographerViews; + } +} -diff --git a/src/main/java/top/leavesmc/leaves/replay/DigestOutputStream.java b/src/main/java/top/leavesmc/leaves/replay/DigestOutputStream.java +diff --git a/src/main/java/org/leavesmc/leaves/replay/DigestOutputStream.java b/src/main/java/org/leavesmc/leaves/replay/DigestOutputStream.java new file mode 100644 -index 0000000000000000000000000000000000000000..92a6478b337c4371e61b7e7878b242619398ecdd +index 0000000000000000000000000000000000000000..e67ff063b7f50b4bfdaaaeb88f225eb768d89623 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/replay/DigestOutputStream.java ++++ b/src/main/java/org/leavesmc/leaves/replay/DigestOutputStream.java @@ -0,0 +1,46 @@ -+package top.leavesmc.leaves.replay; ++package org.leavesmc.leaves.replay; + +import org.jetbrains.annotations.NotNull; + @@ -664,13 +652,13 @@ index 0000000000000000000000000000000000000000..92a6478b337c4371e61b7e7878b24261 + out.write(b, off, len); + } +} -diff --git a/src/main/java/top/leavesmc/leaves/replay/RecordMetaData.java b/src/main/java/top/leavesmc/leaves/replay/RecordMetaData.java +diff --git a/src/main/java/org/leavesmc/leaves/replay/RecordMetaData.java b/src/main/java/org/leavesmc/leaves/replay/RecordMetaData.java new file mode 100644 -index 0000000000000000000000000000000000000000..46a86cfce4aa859b8de7c126c22f64a999a4fe7a +index 0000000000000000000000000000000000000000..0e8cd7e878ec1294d6cb830a004eeefd8b82c415 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/replay/RecordMetaData.java ++++ b/src/main/java/org/leavesmc/leaves/replay/RecordMetaData.java @@ -0,0 +1,23 @@ -+package top.leavesmc.leaves.replay; ++package org.leavesmc.leaves.replay; + +import java.util.HashSet; +import java.util.Set; @@ -693,19 +681,22 @@ index 0000000000000000000000000000000000000000..46a86cfce4aa859b8de7c126c22f64a9 + + public Set players = new HashSet<>(); +} -diff --git a/src/main/java/top/leavesmc/leaves/replay/Recorder.java b/src/main/java/top/leavesmc/leaves/replay/Recorder.java +diff --git a/src/main/java/org/leavesmc/leaves/replay/Recorder.java b/src/main/java/org/leavesmc/leaves/replay/Recorder.java new file mode 100644 -index 0000000000000000000000000000000000000000..7626e7b1171fcf829673a5fb3c07b3d9e5de48bf +index 0000000000000000000000000000000000000000..94bda07ec3eafb902023801a4f10e294a12d4cf1 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/replay/Recorder.java -@@ -0,0 +1,264 @@ -+package top.leavesmc.leaves.replay; ++++ b/src/main/java/org/leavesmc/leaves/replay/Recorder.java +@@ -0,0 +1,289 @@ ++package org.leavesmc.leaves.replay; + ++import com.mojang.serialization.DynamicOps; +import io.netty.channel.local.LocalChannel; +import net.minecraft.SharedConstants; +import net.minecraft.core.LayeredRegistryAccess; +import net.minecraft.core.RegistryAccess; +import net.minecraft.core.RegistrySynchronization; ++import net.minecraft.nbt.NbtOps; ++import net.minecraft.nbt.Tag; +import net.minecraft.network.Connection; +import net.minecraft.network.ConnectionProtocol; +import net.minecraft.network.PacketSendListener; @@ -713,10 +704,12 @@ index 0000000000000000000000000000000000000000..7626e7b1171fcf829673a5fb3c07b3d9 +import net.minecraft.network.protocol.PacketFlow; +import net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket; +import net.minecraft.network.protocol.common.ClientboundDisconnectPacket; ++import net.minecraft.network.protocol.common.ClientboundResourcePackPushPacket; +import net.minecraft.network.protocol.common.ClientboundUpdateTagsPacket; +import net.minecraft.network.protocol.common.custom.BrandPayload; +import net.minecraft.network.protocol.configuration.ClientboundFinishConfigurationPacket; +import net.minecraft.network.protocol.configuration.ClientboundRegistryDataPacket; ++import net.minecraft.network.protocol.configuration.ClientboundSelectKnownPacks; +import net.minecraft.network.protocol.configuration.ClientboundUpdateEnabledFeaturesPacket; +import net.minecraft.network.protocol.game.ClientboundAddEntityPacket; +import net.minecraft.network.protocol.game.ClientboundBundlePacket; @@ -727,15 +720,20 @@ index 0000000000000000000000000000000000000000..7626e7b1171fcf829673a5fb3c07b3d9 +import net.minecraft.network.protocol.login.ClientboundGameProfilePacket; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.RegistryLayer; ++import net.minecraft.server.network.config.ServerResourcePackConfigurationTask; ++import net.minecraft.server.packs.repository.KnownPack; +import net.minecraft.tags.TagNetworkSerialization; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.flag.FeatureFlags; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; -+import top.leavesmc.leaves.LeavesLogger; ++import org.leavesmc.leaves.LeavesLogger; + +import java.io.File; +import java.io.IOException; ++import java.util.List; ++import java.util.Optional; ++import java.util.Set; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionException; +import java.util.concurrent.ExecutorService; @@ -785,7 +783,7 @@ index 0000000000000000000000000000000000000000..7626e7b1171fcf829673a5fb3c07b3d9 + metaData.mcversion = SharedConstants.getCurrentVersion().getName(); + + // TODO start event -+ savePacket(new ClientboundGameProfilePacket(photographer.getGameProfile()), ConnectionProtocol.LOGIN); ++ savePacket(new ClientboundGameProfilePacket(photographer.getGameProfile(), true), ConnectionProtocol.LOGIN); + startConfiguration(); + + if (recorderOption.forceWeather != null) { @@ -797,12 +795,27 @@ index 0000000000000000000000000000000000000000..7626e7b1171fcf829673a5fb3c07b3d9 + state = ConnectionProtocol.CONFIGURATION; + MinecraftServer server = MinecraftServer.getServer(); + savePacket(new ClientboundCustomPayloadPacket(new BrandPayload(server.getServerModName())), ConnectionProtocol.CONFIGURATION); -+ LayeredRegistryAccess layeredregistryaccess = server.registries(); + + savePacket(new ClientboundUpdateEnabledFeaturesPacket(FeatureFlags.REGISTRY.toNames(server.getWorldData().enabledFeatures())), ConnectionProtocol.CONFIGURATION); -+ savePacket(new ClientboundRegistryDataPacket((new RegistryAccess.ImmutableRegistryAccess(RegistrySynchronization.networkedRegistries(layeredregistryaccess))).freeze()), ConnectionProtocol.CONFIGURATION); ++ ++ List knownPackslist = server.getResourceManager().listPacks().flatMap((iresourcepack) -> iresourcepack.location().knownPackInfo().stream()).toList(); ++ LayeredRegistryAccess layeredregistryaccess = server.registries(); ++ ++ savePacket(new ClientboundSelectKnownPacks(knownPackslist)); ++ DynamicOps dynamicOps = layeredregistryaccess.compositeAccess().createSerializationContext(NbtOps.INSTANCE); ++ RegistrySynchronization.packRegistries( ++ dynamicOps, ++ layeredregistryaccess.getAccessFrom(RegistryLayer.WORLDGEN), ++ Set.copyOf(knownPackslist), ++ (key, entries) -> savePacket(new ClientboundRegistryDataPacket(key, entries), ConnectionProtocol.CONFIGURATION) ++ ); + savePacket(new ClientboundUpdateTagsPacket(TagNetworkSerialization.serializeTagsToNetwork(layeredregistryaccess)), ConnectionProtocol.CONFIGURATION); -+ savePacket(new ClientboundFinishConfigurationPacket(), ConnectionProtocol.CONFIGURATION); ++ ++ server.getServerResourcePack().ifPresent((info) -> { ++ savePacket(new ClientboundResourcePackPushPacket(info.id(), info.url(), info.hash(), info.isRequired(), Optional.ofNullable(info.prompt())), ConnectionProtocol.CONFIGURATION); ++ }); ++ ++ savePacket(ClientboundFinishConfigurationPacket.INSTANCE, ConnectionProtocol.CONFIGURATION); + state = ConnectionProtocol.PLAY; + } + @@ -963,13 +976,13 @@ index 0000000000000000000000000000000000000000..7626e7b1171fcf829673a5fb3c07b3d9 + } + } +} -diff --git a/src/main/java/top/leavesmc/leaves/replay/RecorderOption.java b/src/main/java/top/leavesmc/leaves/replay/RecorderOption.java +diff --git a/src/main/java/org/leavesmc/leaves/replay/RecorderOption.java b/src/main/java/org/leavesmc/leaves/replay/RecorderOption.java new file mode 100644 -index 0000000000000000000000000000000000000000..06e7166336d621e1a8edb4a2ad88e2cb8a52abb1 +index 0000000000000000000000000000000000000000..8978fe0c7ed092334618e27892f940ee8c302fc7 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/replay/RecorderOption.java ++++ b/src/main/java/org/leavesmc/leaves/replay/RecorderOption.java @@ -0,0 +1,57 @@ -+package top.leavesmc.leaves.replay; ++package org.leavesmc.leaves.replay; + +import net.minecraft.network.protocol.Packet; +import net.minecraft.network.protocol.game.ClientboundGameEventPacket; @@ -1026,13 +1039,13 @@ index 0000000000000000000000000000000000000000..06e7166336d621e1a8edb4a2ad88e2cb + } + } +} -diff --git a/src/main/java/top/leavesmc/leaves/replay/ReplayFile.java b/src/main/java/top/leavesmc/leaves/replay/ReplayFile.java +diff --git a/src/main/java/org/leavesmc/leaves/replay/ReplayFile.java b/src/main/java/org/leavesmc/leaves/replay/ReplayFile.java new file mode 100644 -index 0000000000000000000000000000000000000000..8cb0f7e2c9f6b7455541c5e06acca0e1ceb60a11 +index 0000000000000000000000000000000000000000..5076b552816d7eae3a1c89fff488de63414eb5ee --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/replay/ReplayFile.java -@@ -0,0 +1,178 @@ -+package top.leavesmc.leaves.replay; ++++ b/src/main/java/org/leavesmc/leaves/replay/ReplayFile.java +@@ -0,0 +1,199 @@ ++package org.leavesmc.leaves.replay; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; @@ -1041,10 +1054,19 @@ index 0000000000000000000000000000000000000000..8cb0f7e2c9f6b7455541c5e06acca0e1 +import net.minecraft.SharedConstants; +import net.minecraft.network.ConnectionProtocol; +import net.minecraft.network.FriendlyByteBuf; ++import net.minecraft.network.ProtocolInfo; ++import net.minecraft.network.RegistryFriendlyByteBuf; ++import net.minecraft.network.codec.StreamCodec; +import net.minecraft.network.protocol.Packet; +import net.minecraft.network.protocol.PacketFlow; ++import net.minecraft.network.protocol.configuration.ConfigurationProtocols; ++import net.minecraft.network.protocol.game.GameProtocols; ++import net.minecraft.network.protocol.handshake.HandshakeProtocols; ++import net.minecraft.network.protocol.login.LoginProtocols; ++import net.minecraft.network.protocol.status.StatusProtocols; ++import net.minecraft.server.MinecraftServer; +import org.jetbrains.annotations.NotNull; -+import top.leavesmc.leaves.util.UUIDSerializer; ++import org.leavesmc.leaves.util.UUIDSerializer; + +import java.io.BufferedOutputStream; +import java.io.DataOutputStream; @@ -1059,6 +1081,7 @@ index 0000000000000000000000000000000000000000..8cb0f7e2c9f6b7455541c5e06acca0e1 +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.util.List; ++import java.util.Map; +import java.util.UUID; +import java.util.zip.CRC32; +import java.util.zip.ZipEntry; @@ -1081,6 +1104,8 @@ index 0000000000000000000000000000000000000000..8cb0f7e2c9f6b7455541c5e06acca0e1 + private final File markerFile; + private final File metaFile; + ++ private final Map> protocols; ++ + public ReplayFile(@NotNull File name) throws IOException { + this.tmpDir = new File(name.getParentFile(), name.getName() + ".tmp"); + if (tmpDir.exists()) { @@ -1094,18 +1119,27 @@ index 0000000000000000000000000000000000000000..8cb0f7e2c9f6b7455541c5e06acca0e1 + } + + File packetFile = new File(tmpDir, RECORDING_FILE); -+ metaFile = new File(tmpDir, META_FILE); -+ markerFile = new File(tmpDir, MARKER_FILE); ++ this.metaFile = new File(tmpDir, META_FILE); ++ this.markerFile = new File(tmpDir, MARKER_FILE); + -+ packetStream = new DataOutputStream(new DigestOutputStream(new BufferedOutputStream(new FileOutputStream(packetFile)), crc32)); ++ this.packetStream = new DataOutputStream(new DigestOutputStream(new BufferedOutputStream(new FileOutputStream(packetFile)), crc32)); ++ ++ this.protocols = Map.of( ++ ConnectionProtocol.STATUS, StatusProtocols.CLIENTBOUND, ++ ConnectionProtocol.LOGIN, LoginProtocols.CLIENTBOUND, ++ ConnectionProtocol.CONFIGURATION, ConfigurationProtocols.CLIENTBOUND, ++ ConnectionProtocol.PLAY, GameProtocols.CLIENTBOUND.bind(RegistryFriendlyByteBuf.decorator(MinecraftServer.getServer().registryAccess())) ++ ); + } + -+ private byte @NotNull [] getPacketBytes(Packet packet, ConnectionProtocol state) { -+ int packetID = state.codec(PacketFlow.CLIENTBOUND).packetId(packet); ++ private byte @NotNull [] getPacketBytes(Packet packet, ConnectionProtocol state) { // TODO: Fix this ++ ProtocolInfo protocol = this.protocols.get(state); ++ if (protocol == null) { ++ throw new IllegalArgumentException("Unknown protocol state " + state); ++ } ++ + ByteBuf buf = Unpooled.buffer(); -+ FriendlyByteBuf packetBuf = new FriendlyByteBuf(buf); -+ packetBuf.writeVarInt(packetID); -+ packet.write(packetBuf); ++ protocol.codec().encode(buf, packet); + + buf.readerIndex(0); + byte[] ret = new byte[buf.readableBytes()]; @@ -1210,13 +1244,13 @@ index 0000000000000000000000000000000000000000..8cb0f7e2c9f6b7455541c5e06acca0e1 + return dir.delete(); + } +} -diff --git a/src/main/java/top/leavesmc/leaves/replay/ReplayMarker.java b/src/main/java/top/leavesmc/leaves/replay/ReplayMarker.java +diff --git a/src/main/java/org/leavesmc/leaves/replay/ReplayMarker.java b/src/main/java/org/leavesmc/leaves/replay/ReplayMarker.java new file mode 100644 -index 0000000000000000000000000000000000000000..852f2098d93d4437fe79af06e454d8494b6decf1 +index 0000000000000000000000000000000000000000..1568f6928d5d4f38ca1919c6de6ec9bb9deb20b2 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/replay/ReplayMarker.java ++++ b/src/main/java/org/leavesmc/leaves/replay/ReplayMarker.java @@ -0,0 +1,43 @@ -+package top.leavesmc.leaves.replay; ++package org.leavesmc.leaves.replay; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; @@ -1259,13 +1293,13 @@ index 0000000000000000000000000000000000000000..852f2098d93d4437fe79af06e454d849 + } + } +} -diff --git a/src/main/java/top/leavesmc/leaves/replay/ServerPhotographer.java b/src/main/java/top/leavesmc/leaves/replay/ServerPhotographer.java +diff --git a/src/main/java/org/leavesmc/leaves/replay/ServerPhotographer.java b/src/main/java/org/leavesmc/leaves/replay/ServerPhotographer.java new file mode 100644 -index 0000000000000000000000000000000000000000..7818db1ca51fd61c96a74bec3d31a0c1d5efe4cc +index 0000000000000000000000000000000000000000..99d00b6acd2302e06f70f75786e8928610592261 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/replay/ServerPhotographer.java ++++ b/src/main/java/org/leavesmc/leaves/replay/ServerPhotographer.java @@ -0,0 +1,216 @@ -+package top.leavesmc.leaves.replay; ++package org.leavesmc.leaves.replay; + +import com.mojang.authlib.GameProfile; +import net.minecraft.server.MinecraftServer; @@ -1279,10 +1313,10 @@ index 0000000000000000000000000000000000000000..7818db1ca51fd61c96a74bec3d31a0c1 +import org.bukkit.Location; +import org.bukkit.craftbukkit.CraftWorld; +import org.jetbrains.annotations.NotNull; -+import top.leavesmc.leaves.LeavesLogger; -+import top.leavesmc.leaves.bot.BotStatsCounter; -+import top.leavesmc.leaves.entity.CraftPhotographer; -+import top.leavesmc.leaves.entity.Photographer; ++import org.leavesmc.leaves.LeavesLogger; ++import org.leavesmc.leaves.bot.BotStatsCounter; ++import org.leavesmc.leaves.entity.CraftPhotographer; ++import org.leavesmc.leaves.entity.Photographer; + +import java.io.File; +import java.io.IOException; @@ -1291,7 +1325,7 @@ index 0000000000000000000000000000000000000000..7818db1ca51fd61c96a74bec3d31a0c1 +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CopyOnWriteArrayList; + -+import static top.leavesmc.leaves.bot.ServerBot.isCreateLegal; ++import static org.leavesmc.leaves.bot.ServerBot.isCreateLegal; + +public class ServerPhotographer extends ServerPlayer { + @@ -1481,13 +1515,13 @@ index 0000000000000000000000000000000000000000..7818db1ca51fd61c96a74bec3d31a0c1 + } + } +} -diff --git a/src/main/java/top/leavesmc/leaves/replay/ServerPhotographerGameMode.java b/src/main/java/top/leavesmc/leaves/replay/ServerPhotographerGameMode.java +diff --git a/src/main/java/org/leavesmc/leaves/replay/ServerPhotographerGameMode.java b/src/main/java/org/leavesmc/leaves/replay/ServerPhotographerGameMode.java new file mode 100644 -index 0000000000000000000000000000000000000000..8a1cd9b1fe9823d5a9f578ced54ec25e75d44208 +index 0000000000000000000000000000000000000000..c612215b0f1e8c3fae641e7a23c7cf7d165eca87 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/replay/ServerPhotographerGameMode.java ++++ b/src/main/java/org/leavesmc/leaves/replay/ServerPhotographerGameMode.java @@ -0,0 +1,35 @@ -+package top.leavesmc.leaves.replay; ++package org.leavesmc.leaves.replay; + +import net.kyori.adventure.text.Component; +import net.minecraft.server.level.ServerPlayerGameMode; @@ -1522,13 +1556,13 @@ index 0000000000000000000000000000000000000000..8a1cd9b1fe9823d5a9f578ced54ec25e + public void tick() { + } +} -diff --git a/src/main/java/top/leavesmc/leaves/util/UUIDSerializer.java b/src/main/java/top/leavesmc/leaves/util/UUIDSerializer.java +diff --git a/src/main/java/org/leavesmc/leaves/util/UUIDSerializer.java b/src/main/java/org/leavesmc/leaves/util/UUIDSerializer.java new file mode 100644 -index 0000000000000000000000000000000000000000..1329a725a2bd03d3ef6d7131d8bc77f20bf2e566 +index 0000000000000000000000000000000000000000..b0834f4b569b3e28ec7e026b3ff4236219498011 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/util/UUIDSerializer.java ++++ b/src/main/java/org/leavesmc/leaves/util/UUIDSerializer.java @@ -0,0 +1,17 @@ -+package top.leavesmc.leaves.util; ++package org.leavesmc.leaves.util; + +import com.google.gson.JsonElement; +import com.google.gson.JsonPrimitive; diff --git a/patches/server/0107-Fix-vehicle-teleport-by-end-gateway.patch b/patches/server/0106-Fix-vehicle-teleport-by-end-gateway.patch similarity index 88% rename from patches/server/0107-Fix-vehicle-teleport-by-end-gateway.patch rename to patches/server/0106-Fix-vehicle-teleport-by-end-gateway.patch index 09839212..fa42cfb7 100644 --- a/patches/server/0107-Fix-vehicle-teleport-by-end-gateway.patch +++ b/patches/server/0106-Fix-vehicle-teleport-by-end-gateway.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Fix vehicle teleport by end gateway 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 88c9097368f7a842e1d31c460330aa3d267676ef..7b626bc319eeebff6f0165db0eb0fd6c70d8cc36 100644 +index 4af071ff2d0a29ad9315e1076436f70f848c89b8..8809755d0e3e6199e2db6c061e53375d17753b70 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 -@@ -221,7 +221,7 @@ public class TheEndGatewayBlockEntity extends TheEndPortalBlockEntity { +@@ -215,7 +215,7 @@ public class TheEndGatewayBlockEntity extends TheEndPortalBlockEntity { entity1.setPortalCooldown(); ((ServerPlayer) entity1).connection.teleport(teleEvent.getTo()); diff --git a/patches/server/0108-Leaves-I18n.patch b/patches/server/0107-Leaves-I18n.patch similarity index 99% rename from patches/server/0108-Leaves-I18n.patch rename to patches/server/0107-Leaves-I18n.patch index 3b2cd2eb..ed0ef16a 100644 --- a/patches/server/0108-Leaves-I18n.patch +++ b/patches/server/0107-Leaves-I18n.patch @@ -51,14 +51,14 @@ index a9bca1d10553f1406f7dbce3f7c40378b6abdc10..aa7f4f738c637ffc3d50f2bdb5ee61ff Builder builder = ImmutableMap.builder(); BiConsumer biConsumer = builder::put; diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -index 6725bbf2d966ae900e9b5efa619875c386bb9526..5ddeae61955be0e212db8467804aa42a88f61f04 100644 +index f240a9d90ec469a99d3d8b82cfa3fcb5d0e78057..7148b5c8f4b63649ef8f89963b6bd591fd1a97bf 100644 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -@@ -222,6 +222,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -234,6 +234,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface - top.leavesmc.leaves.LeavesConfig.init((java.io.File) options.valueOf("leaves-settings")); // Leaves - Server Config + org.leavesmc.leaves.LeavesConfig.init((java.io.File) options.valueOf("leaves-settings")); // Leaves - Server Config System.setProperty("spark.serverconfigs.extra", "leaves.yml"); // Leaves - spark config -+ net.minecraft.locale.Language.loadI18N(top.leavesmc.leaves.LeavesConfig.serverLang); // Leaves - i18n ++ net.minecraft.locale.Language.loadI18N(org.leavesmc.leaves.LeavesConfig.serverLang); // Leaves - i18n com.destroystokyo.paper.Metrics.PaperMetrics.startMetrics(); // Paper - start metrics // Leaves - down diff --git a/patches/server/0109-Fix-minecraft-hopper-not-work-without-player.patch b/patches/server/0108-Fix-minecraft-hopper-not-work-without-player.patch similarity index 84% rename from patches/server/0109-Fix-minecraft-hopper-not-work-without-player.patch rename to patches/server/0108-Fix-minecraft-hopper-not-work-without-player.patch index 08d2799d..33bd32ad 100644 --- a/patches/server/0109-Fix-minecraft-hopper-not-work-without-player.patch +++ b/patches/server/0108-Fix-minecraft-hopper-not-work-without-player.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Fix minecraft hopper not work without player 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 761142374f793a1cd4228936b21a68d7a0458894..97367882f7643b9abe221ccb907e220c05ab588c 100644 +index d7f8464bf3eed0e42a5fc7f14a5b243d171f8b5e..265022e4c56472c7d673eb7b03359b2d57ee507c 100644 --- a/src/main/java/net/minecraft/world/entity/vehicle/MinecartHopper.java +++ b/src/main/java/net/minecraft/world/entity/vehicle/MinecartHopper.java -@@ -86,6 +86,13 @@ public class MinecartHopper extends AbstractMinecartContainer implements Hopper +@@ -91,6 +91,13 @@ public class MinecartHopper extends AbstractMinecartContainer implements Hopper } } diff --git a/patches/server/0110-Wool-Hopper-Counter.patch b/patches/server/0109-Wool-Hopper-Counter.patch similarity index 83% rename from patches/server/0110-Wool-Hopper-Counter.patch rename to patches/server/0109-Wool-Hopper-Counter.patch index a8bfc59b..12134781 100644 --- a/patches/server/0110-Wool-Hopper-Counter.patch +++ b/patches/server/0109-Wool-Hopper-Counter.patch @@ -6,48 +6,71 @@ Subject: [PATCH] Wool Hopper Counter This patch is Powered by fabric-carpet(https://github.com/gnembon/fabric-carpet) diff --git a/src/main/java/net/minecraft/world/item/crafting/Ingredient.java b/src/main/java/net/minecraft/world/item/crafting/Ingredient.java -index 7c29750e534eae4266bf7a63c50e3827401d6569..ab9a8c428975d016fbfa210b3a8cb5310cf3def2 100644 +index e314f36951e9ac15c57137e24fce8c410373130a..dd232d9e86c5bf03cfb4597d3291a172d8c17741 100644 --- a/src/main/java/net/minecraft/world/item/crafting/Ingredient.java +++ b/src/main/java/net/minecraft/world/item/crafting/Ingredient.java -@@ -30,7 +30,7 @@ import net.minecraft.world.level.ItemLike; - public final class Ingredient implements Predicate { - - public static final Ingredient EMPTY = new Ingredient(Stream.empty()); +@@ -35,7 +35,7 @@ public final class Ingredient implements Predicate { + }, (recipeitemstack) -> { + return Arrays.asList(recipeitemstack.getItems()); + }); - private final Ingredient.Value[] values; + public final Ingredient.Value[] values; // Leaves - private -> public @Nullable public ItemStack[] itemStacks; @Nullable +diff --git a/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java b/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java +index a31326e24cb68472c81cd781c5e3041772712862..f0422a70ef79c837405284fd42a74af6c57959de 100644 +--- a/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java ++++ b/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java +@@ -45,7 +45,7 @@ public class RecipeManager extends SimpleJsonResourceReloadListener { + private static final Logger LOGGER = LogUtils.getLogger(); + private final HolderLookup.Provider registries; + public Multimap, RecipeHolder> byType = ImmutableMultimap.of(); +- private Map> byName = ImmutableMap.of(); ++ public Map> byName = ImmutableMap.of(); // Leaves - hopper counter + private boolean hasErrors; + + public RecipeManager(HolderLookup.Provider registryLookup) { 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 006e990d57c7ad1081f63402ef85a3ba856fe329..5e01a9b3ef4574280475bef5d7b06635766f756d 100644 +index b08b7ffbcfbc6a12d74cadf878fd069f7a1345cb..741ab2ffc8e4f40f43e24fed3b6d55580a3fdaca 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 -@@ -445,6 +445,13 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -202,7 +202,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen + + final int fullState = getFullState(blockEntity); // Paper - Perf: Optimize Hoppers + if (fullState != HOPPER_EMPTY) { // Paper - Perf: Optimize Hoppers +- flag = HopperBlockEntity.ejectItems(world, pos, blockEntity); ++ flag = HopperBlockEntity.ejectItems(world, pos, blockEntity); // Leaves - hopper counter + } + + if (fullState != HOPPER_IS_FULL || flag) { // Paper - Perf: Optimize Hoppers +@@ -432,7 +432,14 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen + private static final java.util.function.BiPredicate IS_EMPTY_TEST = (itemstack, i) -> itemstack.isEmpty(); // Paper end - Perf: Optimize Hoppers - private static boolean ejectItems(Level world, BlockPos blockposition, BlockState iblockdata, Container iinventory, HopperBlockEntity hopper) { // CraftBukkit -+ // Leaves start - hopper counter -+ if (top.leavesmc.leaves.util.HopperCounter.isEnabled()) { -+ if (woolHopperCounter(world, blockposition, iblockdata, iinventory, hopper)) { ++ // Leaves start - hopper counter + private static boolean ejectItems(Level world, BlockPos pos, HopperBlockEntity blockEntity) { ++ if (org.leavesmc.leaves.util.HopperCounter.isEnabled()) { ++ if (woolHopperCounter(world, pos, world.getBlockState(pos), (Container) blockEntity, blockEntity)) { + return true; + } + } + // Leaves end - hopper counter - Container iinventory1 = HopperBlockEntity.getAttachedContainer(world, blockposition, iblockdata); + Container iinventory = HopperBlockEntity.getAttachedContainer(world, pos, blockEntity); - if (iinventory1 == null) { -@@ -502,6 +509,23 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen + if (iinventory == null) { +@@ -491,6 +498,23 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen } } + // Leaves start - hopper counter + private static boolean woolHopperCounter(Level level, BlockPos blockPos, BlockState state, Container container, HopperBlockEntity hopper) { -+ net.minecraft.world.item.DyeColor woolColor = top.leavesmc.leaves.util.WoolUtils.getWoolColorAtPosition(level, blockPos.relative(state.getValue(HopperBlock.FACING))); ++ net.minecraft.world.item.DyeColor woolColor = org.leavesmc.leaves.util.WoolUtils.getWoolColorAtPosition(level, blockPos.relative(state.getValue(HopperBlock.FACING))); + if (woolColor != null) { + for (int i = 0; i < container.getContainerSize(); ++i) { + if (!container.getItem(i).isEmpty()) { + ItemStack itemstack = container.getItem(i); -+ top.leavesmc.leaves.util.HopperCounter.getCounter(woolColor).add(level.getServer(), itemstack); ++ org.leavesmc.leaves.util.HopperCounter.getCounter(woolColor).add(level.getServer(), itemstack); + container.setItem(i, ItemStack.EMPTY); + } + } @@ -57,20 +80,20 @@ index 006e990d57c7ad1081f63402ef85a3ba856fe329..5e01a9b3ef4574280475bef5d7b06635 + } + // Leaves end - hopper counter + - private static IntStream getSlots(Container inventory, Direction side) { - return inventory instanceof WorldlyContainer ? IntStream.of(((WorldlyContainer) inventory).getSlotsForFace(side)) : IntStream.range(0, inventory.getContainerSize()); - } -diff --git a/src/main/java/top/leavesmc/leaves/command/LeavesCommand.java b/src/main/java/top/leavesmc/leaves/command/LeavesCommand.java -index 5efdb9b5138738da7cfc075ce0be531d2608577e..9fc807312bd61158f996abb8424ec0c0005d2d42 100644 ---- a/src/main/java/top/leavesmc/leaves/command/LeavesCommand.java -+++ b/src/main/java/top/leavesmc/leaves/command/LeavesCommand.java + private static int[] getSlots(Container inventory, Direction side) { + if (inventory instanceof WorldlyContainer iworldinventory) { + return iworldinventory.getSlotsForFace(side); +diff --git a/src/main/java/org/leavesmc/leaves/command/LeavesCommand.java b/src/main/java/org/leavesmc/leaves/command/LeavesCommand.java +index 2d871fafff90e2dbc8c4141f92cdb1544ccdce43..31473e5a257276d1feb37e98cf52477cd9523712 100644 +--- a/src/main/java/org/leavesmc/leaves/command/LeavesCommand.java ++++ b/src/main/java/org/leavesmc/leaves/command/LeavesCommand.java @@ -13,6 +13,7 @@ import org.bukkit.plugin.PluginManager; import org.checkerframework.checker.nullness.qual.Nullable; import org.jetbrains.annotations.NotNull; - import top.leavesmc.leaves.command.subcommands.ConfigCommand; -+import top.leavesmc.leaves.command.subcommands.CounterCommand; - import top.leavesmc.leaves.command.subcommands.PeacefulModeSwitchCommand; - import top.leavesmc.leaves.command.subcommands.UpdateCommand; + import org.leavesmc.leaves.command.subcommands.ConfigCommand; ++import org.leavesmc.leaves.command.subcommands.CounterCommand; + import org.leavesmc.leaves.command.subcommands.PeacefulModeSwitchCommand; + import org.leavesmc.leaves.command.subcommands.UpdateCommand; @@ -37,6 +38,7 @@ public final class LeavesCommand extends Command { commands.put(Set.of("config"), new ConfigCommand()); @@ -80,13 +103,13 @@ index 5efdb9b5138738da7cfc075ce0be531d2608577e..9fc807312bd61158f996abb8424ec0c0 return commands.entrySet().stream() .flatMap(entry -> entry.getKey().stream().map(s -> Map.entry(s, entry.getValue()))) -diff --git a/src/main/java/top/leavesmc/leaves/command/subcommands/CounterCommand.java b/src/main/java/top/leavesmc/leaves/command/subcommands/CounterCommand.java +diff --git a/src/main/java/org/leavesmc/leaves/command/subcommands/CounterCommand.java b/src/main/java/org/leavesmc/leaves/command/subcommands/CounterCommand.java new file mode 100644 -index 0000000000000000000000000000000000000000..24eecf862f3f5fab678813de7de8d3ba7af467fb +index 0000000000000000000000000000000000000000..358780d37600220d132ae8e2e6c594fc71af4e40 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/command/subcommands/CounterCommand.java ++++ b/src/main/java/org/leavesmc/leaves/command/subcommands/CounterCommand.java @@ -0,0 +1,121 @@ -+package top.leavesmc.leaves.command.subcommands; ++package org.leavesmc.leaves.command.subcommands; + +import io.papermc.paper.command.CommandUtil; +import net.kyori.adventure.text.Component; @@ -97,9 +120,9 @@ index 0000000000000000000000000000000000000000..24eecf862f3f5fab678813de7de8d3ba +import net.minecraft.world.item.DyeColor; +import org.bukkit.command.CommandSender; +import org.jetbrains.annotations.NotNull; -+import top.leavesmc.leaves.LeavesConfig; -+import top.leavesmc.leaves.command.LeavesSubcommand; -+import top.leavesmc.leaves.util.HopperCounter; ++import org.leavesmc.leaves.LeavesConfig; ++import org.leavesmc.leaves.command.LeavesSubcommand; ++import org.leavesmc.leaves.util.HopperCounter; + +import java.util.ArrayList; +import java.util.Arrays; @@ -207,13 +230,13 @@ index 0000000000000000000000000000000000000000..24eecf862f3f5fab678813de7de8d3ba + return LeavesConfig.hopperCounter; + } +} -diff --git a/src/main/java/top/leavesmc/leaves/util/HopperCounter.java b/src/main/java/top/leavesmc/leaves/util/HopperCounter.java +diff --git a/src/main/java/org/leavesmc/leaves/util/HopperCounter.java b/src/main/java/org/leavesmc/leaves/util/HopperCounter.java new file mode 100644 -index 0000000000000000000000000000000000000000..3b173b175fe3412ac9f87fb1d520777182125348 +index 0000000000000000000000000000000000000000..1551feb2e2787ccf15dbe6a027e7fff21f762c7a --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/util/HopperCounter.java ++++ b/src/main/java/org/leavesmc/leaves/util/HopperCounter.java @@ -0,0 +1,334 @@ -+package top.leavesmc.leaves.util; ++package org.leavesmc.leaves.util; + +import it.unimi.dsi.fastutil.objects.Object2LongLinkedOpenHashMap; +import it.unimi.dsi.fastutil.objects.Object2LongMap; @@ -394,7 +417,7 @@ index 0000000000000000000000000000000000000000..3b173b175fe3412ac9f87fb1d5207771 + entry(Items.POISONOUS_POTATO, Blocks.SLIME_BLOCK), + entry(Items.SPIDER_EYE, Blocks.NETHERRACK), + entry(Items.GUNPOWDER, Blocks.GRAY_WOOL), -+ entry(Items.SCUTE, Blocks.LIME_WOOL), ++ entry(Items.TURTLE_SCUTE, Blocks.LIME_WOOL), + entry(Items.FEATHER, Blocks.WHITE_WOOL), + entry(Items.FLINT, Blocks.BLACK_WOOL), + entry(Items.LEATHER, Blocks.SPRUCE_PLANKS), @@ -492,7 +515,7 @@ index 0000000000000000000000000000000000000000..3b173b175fe3412ac9f87fb1d5207771 + } + + public static List> getAllMatching(@NotNull RecipeManager manager, RecipeType type, ResourceLocation output, final RegistryAccess registryAccess) { -+ Map> typeRecipes = manager.recipes.get(type); ++ Map> typeRecipes = manager.byName; // Leaves - hopper counter + if (typeRecipes == null) { + return Collections.emptyList(); + } @@ -547,13 +570,13 @@ index 0000000000000000000000000000000000000000..3b173b175fe3412ac9f87fb1d5207771 + return enabled; + } +} -diff --git a/src/main/java/top/leavesmc/leaves/util/WoolUtils.java b/src/main/java/top/leavesmc/leaves/util/WoolUtils.java +diff --git a/src/main/java/org/leavesmc/leaves/util/WoolUtils.java b/src/main/java/org/leavesmc/leaves/util/WoolUtils.java new file mode 100644 -index 0000000000000000000000000000000000000000..a314af297795f6a6ac83b161e39c0c2c7ee58fb2 +index 0000000000000000000000000000000000000000..a4cd63179a15e5f172c43a2da963e23d7d71fc28 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/util/WoolUtils.java ++++ b/src/main/java/org/leavesmc/leaves/util/WoolUtils.java @@ -0,0 +1,38 @@ -+package top.leavesmc.leaves.util; ++package org.leavesmc.leaves.util; + +import net.minecraft.core.BlockPos; +import net.minecraft.world.item.DyeColor; diff --git a/patches/server/0111-RNG-Fishing.patch b/patches/server/0110-RNG-Fishing.patch similarity index 83% rename from patches/server/0111-RNG-Fishing.patch rename to patches/server/0110-RNG-Fishing.patch index 058af30b..2a1a0acb 100644 --- a/patches/server/0111-RNG-Fishing.patch +++ b/patches/server/0110-RNG-Fishing.patch @@ -5,23 +5,23 @@ Subject: [PATCH] RNG Fishing 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 c4e09998ed133e74dcf488869d82d9154a18d3de..d0ce318d8be176e95888a26641bb092d2e7adddc 100644 +index f959f1819181b867dfabd19005e730069dffda4d..85d041981641acb2487325f8f874f65ddfb61e67 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java +++ b/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java -@@ -505,7 +505,7 @@ public class FishingHook extends Projectile { +@@ -506,7 +506,7 @@ public class FishingHook extends Projectile { } else if (this.nibble > 0) { LootParams lootparams = (new LootParams.Builder((ServerLevel) this.level())).withParameter(LootContextParams.ORIGIN, this.position()).withParameter(LootContextParams.TOOL, usedItem).withParameter(LootContextParams.THIS_ENTITY, this).withLuck((float) this.luck + entityhuman.getLuck()).create(LootContextParamSets.FISHING); - LootTable loottable = this.level().getServer().getLootData().getLootTable(BuiltInLootTables.FISHING); + LootTable loottable = this.level().getServer().reloadableRegistries().getLootTable(BuiltInLootTables.FISHING); - List list = loottable.getRandomItems(lootparams); -+ List list = top.leavesmc.leaves.LeavesConfig.rngFishing ? loottable.getRandomItems(lootparams, this.random) : loottable.getRandomItems(lootparams); // Leaves - world random ++ List list = org.leavesmc.leaves.LeavesConfig.rngFishing ? loottable.getRandomItems(lootparams, this.random) : loottable.getRandomItems(lootparams); // Leaves - world random CriteriaTriggers.FISHING_ROD_HOOKED.trigger((ServerPlayer) entityhuman, usedItem, this, list); Iterator iterator = list.iterator(); diff --git a/src/main/java/net/minecraft/world/level/storage/loot/LootContext.java b/src/main/java/net/minecraft/world/level/storage/loot/LootContext.java -index d042b04108c3fe244caa6b9fc293c83ac7200a57..58d27f27dc3b60ba7d4e14f86431890481275cdd 100644 +index 4a1a37040a328281ce748486b7f4150b7b0a3b01..849bde24d9a0f64ea9a64d9cd94de979befd1261 100644 --- a/src/main/java/net/minecraft/world/level/storage/loot/LootContext.java +++ b/src/main/java/net/minecraft/world/level/storage/loot/LootContext.java -@@ -95,6 +95,13 @@ public class LootContext { +@@ -96,6 +96,13 @@ public class LootContext { this.params = parameters; } @@ -36,10 +36,10 @@ index d042b04108c3fe244caa6b9fc293c83ac7200a57..58d27f27dc3b60ba7d4e14f864318904 if (seed != 0L) { this.random = RandomSource.create(seed); diff --git a/src/main/java/net/minecraft/world/level/storage/loot/LootTable.java b/src/main/java/net/minecraft/world/level/storage/loot/LootTable.java -index 05af6fa0585406c4922d2eb174f7e53f4269acd6..3fcbb53f1244adc46e1bdf681f72598b10fb6fb1 100644 +index 6db7a023dd802706935c384df0b0aa430a6e29aa..1199c741a14eaa9f002ee756a3ffb35d22ec26df 100644 --- a/src/main/java/net/minecraft/world/level/storage/loot/LootTable.java +++ b/src/main/java/net/minecraft/world/level/storage/loot/LootTable.java -@@ -132,6 +132,12 @@ public class LootTable { +@@ -136,6 +136,12 @@ public class LootTable { return this.getRandomItems((new LootContext.Builder(parameters)).create(this.randomSequence)); } diff --git a/patches/server/0112-Leaves-Reload-Command.patch b/patches/server/0111-Leaves-Reload-Command.patch similarity index 59% rename from patches/server/0112-Leaves-Reload-Command.patch rename to patches/server/0111-Leaves-Reload-Command.patch index 42e41fea..61d441a5 100644 --- a/patches/server/0112-Leaves-Reload-Command.patch +++ b/patches/server/0111-Leaves-Reload-Command.patch @@ -4,16 +4,16 @@ Date: Tue, 5 Sep 2023 00:07:10 +0800 Subject: [PATCH] Leaves Reload Command -diff --git a/src/main/java/top/leavesmc/leaves/command/LeavesCommand.java b/src/main/java/top/leavesmc/leaves/command/LeavesCommand.java -index 9fc807312bd61158f996abb8424ec0c0005d2d42..3d7b012d51fc2774cde688fcde01800a511c6bf2 100644 ---- a/src/main/java/top/leavesmc/leaves/command/LeavesCommand.java -+++ b/src/main/java/top/leavesmc/leaves/command/LeavesCommand.java +diff --git a/src/main/java/org/leavesmc/leaves/command/LeavesCommand.java b/src/main/java/org/leavesmc/leaves/command/LeavesCommand.java +index 31473e5a257276d1feb37e98cf52477cd9523712..0f958ccafda1490f1acfc8089c47f6b7de7d4722 100644 +--- a/src/main/java/org/leavesmc/leaves/command/LeavesCommand.java ++++ b/src/main/java/org/leavesmc/leaves/command/LeavesCommand.java @@ -15,6 +15,7 @@ import org.jetbrains.annotations.NotNull; - import top.leavesmc.leaves.command.subcommands.ConfigCommand; - import top.leavesmc.leaves.command.subcommands.CounterCommand; - import top.leavesmc.leaves.command.subcommands.PeacefulModeSwitchCommand; -+import top.leavesmc.leaves.command.subcommands.ReloadCommand; - import top.leavesmc.leaves.command.subcommands.UpdateCommand; + import org.leavesmc.leaves.command.subcommands.ConfigCommand; + import org.leavesmc.leaves.command.subcommands.CounterCommand; + import org.leavesmc.leaves.command.subcommands.PeacefulModeSwitchCommand; ++import org.leavesmc.leaves.command.subcommands.ReloadCommand; + import org.leavesmc.leaves.command.subcommands.UpdateCommand; import java.util.ArrayList; @@ -39,6 +40,7 @@ public final class LeavesCommand extends Command { @@ -24,19 +24,19 @@ index 9fc807312bd61158f996abb8424ec0c0005d2d42..3d7b012d51fc2774cde688fcde01800a return commands.entrySet().stream() .flatMap(entry -> entry.getKey().stream().map(s -> Map.entry(s, entry.getValue()))) -diff --git a/src/main/java/top/leavesmc/leaves/command/subcommands/ReloadCommand.java b/src/main/java/top/leavesmc/leaves/command/subcommands/ReloadCommand.java +diff --git a/src/main/java/org/leavesmc/leaves/command/subcommands/ReloadCommand.java b/src/main/java/org/leavesmc/leaves/command/subcommands/ReloadCommand.java new file mode 100644 -index 0000000000000000000000000000000000000000..ecf0b1a6d59e662a02458bbc50c7a3f5388cce5f +index 0000000000000000000000000000000000000000..749718287eb5364001176927248a4094afaf8750 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/command/subcommands/ReloadCommand.java ++++ b/src/main/java/org/leavesmc/leaves/command/subcommands/ReloadCommand.java @@ -0,0 +1,22 @@ -+package top.leavesmc.leaves.command.subcommands; ++package org.leavesmc.leaves.command.subcommands; + +import net.minecraft.server.MinecraftServer; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; -+import top.leavesmc.leaves.LeavesConfig; -+import top.leavesmc.leaves.command.LeavesSubcommand; ++import org.leavesmc.leaves.LeavesConfig; ++import org.leavesmc.leaves.command.LeavesSubcommand; + +import java.io.File; + diff --git a/patches/server/0113-Spider-jockeys-drop-gapples.patch b/patches/server/0112-Spider-jockeys-drop-gapples.patch similarity index 78% rename from patches/server/0113-Spider-jockeys-drop-gapples.patch rename to patches/server/0112-Spider-jockeys-drop-gapples.patch index 0a848acf..cf9c7dda 100644 --- a/patches/server/0113-Spider-jockeys-drop-gapples.patch +++ b/patches/server/0112-Spider-jockeys-drop-gapples.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Spider jockeys drop gapples diff --git a/src/main/java/net/minecraft/world/entity/monster/Spider.java b/src/main/java/net/minecraft/world/entity/monster/Spider.java -index 7618364e5373fe17cfe45a5a4ee9ab25e591581c..38dfa8b2018c43208b11006fe396c9d53f9cc5a5 100644 +index fa0316e9d2a4cf213982994dc8bf310299cca984..27c37f3152fe2317ae5dcee154267274c82aaa7c 100644 --- a/src/main/java/net/minecraft/world/entity/monster/Spider.java +++ b/src/main/java/net/minecraft/world/entity/monster/Spider.java -@@ -154,6 +154,18 @@ public class Spider extends Monster { +@@ -145,6 +145,18 @@ public class Spider extends Monster { this.entityData.set(Spider.DATA_FLAGS_ID, b0); } @@ -16,8 +16,8 @@ index 7618364e5373fe17cfe45a5a4ee9ab25e591581c..38dfa8b2018c43208b11006fe396c9d5 + @Override + protected void dropFromLootTable(DamageSource damageSource, boolean causedByPlayer) { + super.dropFromLootTable(damageSource, causedByPlayer); -+ if (top.leavesmc.leaves.LeavesConfig.spiderJockeysDropGapples > 0.0D) { -+ if (this.hasPassenger(entity -> entity.getType() == EntityType.SKELETON) && this.random.nextDouble() < top.leavesmc.leaves.LeavesConfig.spiderJockeysDropGapples) { ++ if (org.leavesmc.leaves.LeavesConfig.spiderJockeysDropGapples > 0.0D) { ++ if (this.hasPassenger(entity -> entity.getType() == EntityType.SKELETON) && this.random.nextDouble() < org.leavesmc.leaves.LeavesConfig.spiderJockeysDropGapples) { + this.spawnAtLocation(new net.minecraft.world.item.ItemStack(net.minecraft.world.item.Items.ENCHANTED_GOLDEN_APPLE)); + } + } @@ -26,4 +26,4 @@ index 7618364e5373fe17cfe45a5a4ee9ab25e591581c..38dfa8b2018c43208b11006fe396c9d5 + @Nullable @Override - public SpawnGroupData finalizeSpawn(ServerLevelAccessor world, DifficultyInstance difficulty, MobSpawnType spawnReason, @Nullable SpawnGroupData entityData, @Nullable CompoundTag entityNbt) { + public SpawnGroupData finalizeSpawn(ServerLevelAccessor world, DifficultyInstance difficulty, MobSpawnType spawnReason, @Nullable SpawnGroupData entityData) { diff --git a/patches/server/0114-Force-Void-Trade.patch b/patches/server/0113-Force-Void-Trade.patch similarity index 78% rename from patches/server/0114-Force-Void-Trade.patch rename to patches/server/0113-Force-Void-Trade.patch index 2b594460..44d5f890 100644 --- a/patches/server/0114-Force-Void-Trade.patch +++ b/patches/server/0113-Force-Void-Trade.patch @@ -4,11 +4,20 @@ Date: Thu, 14 Sep 2023 20:23:03 +0800 Subject: [PATCH] Force Void Trade +diff --git a/.gitignore b/.gitignore +index 3811c0d849a3eb028ed1a6b7a2d4747f7f570448..1ad93453221244f880855b510e888e759275b640 100644 +--- a/.gitignore ++++ b/.gitignore +@@ -46,3 +46,4 @@ dependency-reduced-pom.xml + # vs code + /.vscode + /.factorypath ++ diff --git a/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java b/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java -index fd1648546542f146ba7b866873f105ed1427ef7d..1ecbb7cb0f608e11ce84d7082bd4d3018a2bdfd5 100644 +index d323cf157f2a910916baa9ce3f7e5bc81648c47d..308638bb5dc12ac11eb7a44d05647403184f38d6 100644 --- a/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java +++ b/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java -@@ -59,6 +59,7 @@ public abstract class AbstractVillager extends AgeableMob implements InventoryCa +@@ -66,6 +66,7 @@ public abstract class AbstractVillager extends AgeableMob implements InventoryCa @Nullable protected MerchantOffers offers; private final SimpleContainer inventory = new SimpleContainer(8, (org.bukkit.craftbukkit.entity.CraftAbstractVillager) this.getBukkitEntity()); // CraftBukkit add argument @@ -16,7 +25,7 @@ index fd1648546542f146ba7b866873f105ed1427ef7d..1ecbb7cb0f608e11ce84d7082bd4d301 public AbstractVillager(EntityType type, Level world) { super(type, world); -@@ -150,7 +151,13 @@ public abstract class AbstractVillager extends AgeableMob implements InventoryCa +@@ -143,7 +144,13 @@ public abstract class AbstractVillager extends AgeableMob implements InventoryCa @Override public void processTrade(MerchantOffer recipe, @Nullable io.papermc.paper.event.player.PlayerPurchaseEvent event) { // The MerchantRecipe passed in here is the one set by the PlayerPurchaseEvent if (event == null || event.willIncreaseTradeUses()) { @@ -31,7 +40,7 @@ index fd1648546542f146ba7b866873f105ed1427ef7d..1ecbb7cb0f608e11ce84d7082bd4d301 } if (event == null || event.isRewardingExp()) { this.rewardTradeXp(recipe); -@@ -162,7 +169,7 @@ public abstract class AbstractVillager extends AgeableMob implements InventoryCa +@@ -155,7 +162,7 @@ public abstract class AbstractVillager extends AgeableMob implements InventoryCa @Override public void notifyTrade(MerchantOffer offer) { // offer.increaseUses(); // Paper - Add PlayerTradeEvent and PlayerPurchaseEvent @@ -40,16 +49,16 @@ index fd1648546542f146ba7b866873f105ed1427ef7d..1ecbb7cb0f608e11ce84d7082bd4d301 // this.rewardTradeXp(offer); // Paper - Add PlayerTradeEvent and PlayerPurchaseEvent if (this.tradingPlayer instanceof ServerPlayer) { CriteriaTriggers.TRADE.trigger((ServerPlayer) this.tradingPlayer, this, offer.getResult()); -@@ -180,7 +187,7 @@ public abstract class AbstractVillager extends AgeableMob implements InventoryCa +@@ -173,7 +180,7 @@ public abstract class AbstractVillager extends AgeableMob implements InventoryCa @Override public void notifyTradeUpdated(ItemStack stack) { if (!this.level().isClientSide && this.ambientSoundTime > -this.getAmbientSoundInterval() + 20) { - this.ambientSoundTime = -this.getAmbientSoundInterval(); + if (!voidTrade) this.ambientSoundTime = -this.getAmbientSoundInterval(); // Leaves - force void trade - this.playSound(this.getTradeUpdatedSound(!stack.isEmpty()), this.getSoundVolume(), this.getVoicePitch()); + this.makeSound(this.getTradeUpdatedSound(!stack.isEmpty())); } -@@ -229,6 +236,12 @@ public abstract class AbstractVillager extends AgeableMob implements InventoryCa +@@ -228,6 +235,12 @@ public abstract class AbstractVillager extends AgeableMob implements InventoryCa } protected void stopTrading() { @@ -62,7 +71,7 @@ index fd1648546542f146ba7b866873f105ed1427ef7d..1ecbb7cb0f608e11ce84d7082bd4d301 this.setTradingPlayer((Player) null); } -@@ -308,4 +321,10 @@ public abstract class AbstractVillager extends AgeableMob implements InventoryCa +@@ -307,4 +320,10 @@ public abstract class AbstractVillager extends AgeableMob implements InventoryCa public boolean isClientSide() { return this.level().isClientSide; } @@ -74,7 +83,7 @@ index fd1648546542f146ba7b866873f105ed1427ef7d..1ecbb7cb0f608e11ce84d7082bd4d301 + // Leaves end - force void trade } 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 3d770c2b47b796b628a1452e7bb2392c7e371ac0..3e54994e883ee71099daefcf87a9af64bb17fc92 100644 +index 6cac189cf6e0bef2f0ea8c0dbadb0f417171a05e..45be97d79377f028264e7828e929d37893ebdfb5 100644 --- a/src/main/java/net/minecraft/world/entity/npc/Villager.java +++ b/src/main/java/net/minecraft/world/entity/npc/Villager.java @@ -348,6 +348,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler @@ -85,7 +94,7 @@ index 3d770c2b47b796b628a1452e7bb2392c7e371ac0..3e54994e883ee71099daefcf87a9af64 this.updateSpecialPrices(customer); this.setTradingPlayer(customer); this.openTradingScreen(customer, this.getDisplayName(), this.getVillagerData().getLevel()); -@@ -650,8 +651,12 @@ public class Villager extends AbstractVillager implements ReputationEventHandler +@@ -643,8 +644,12 @@ public class Villager extends AbstractVillager implements ReputationEventHandler protected void rewardTradeXp(MerchantOffer offer) { int i = 3 + this.random.nextInt(4); @@ -101,7 +110,7 @@ index 3d770c2b47b796b628a1452e7bb2392c7e371ac0..3e54994e883ee71099daefcf87a9af64 this.updateMerchantTimer = 40; this.increaseProfessionLevelOnUpdate = true; diff --git a/src/main/java/net/minecraft/world/entity/npc/WanderingTrader.java b/src/main/java/net/minecraft/world/entity/npc/WanderingTrader.java -index 8d1cc1a644415be251f469ab1cb2ebc09fe5c3eb..57e24718fc04283b47067fc2c4cb1956d256a722 100644 +index 0854e9b7ee2e6b23b6c1ee6a324a5a253c9d4679..43d2785ee82467f0ce6c60b29d8f6f33fe65acc4 100644 --- a/src/main/java/net/minecraft/world/entity/npc/WanderingTrader.java +++ b/src/main/java/net/minecraft/world/entity/npc/WanderingTrader.java @@ -121,6 +121,7 @@ public class WanderingTrader extends net.minecraft.world.entity.npc.AbstractVill @@ -113,10 +122,10 @@ index 8d1cc1a644415be251f469ab1cb2ebc09fe5c3eb..57e24718fc04283b47067fc2c4cb1956 this.openTradingScreen(player, this.getDisplayName(), 1); } diff --git a/src/main/java/net/minecraft/world/inventory/MerchantMenu.java b/src/main/java/net/minecraft/world/inventory/MerchantMenu.java -index 9c17c14de888ef3fbf4139cbad3889ece1d74aa1..39855fc8858f48ea3db00fc35b2b22e66643fdf9 100644 +index 2992e86f5f83431e230162380b33721df785ba91..7ec2ef906433d7e0164ce0e5ec62fef602ba6b37 100644 --- a/src/main/java/net/minecraft/world/inventory/MerchantMenu.java +++ b/src/main/java/net/minecraft/world/inventory/MerchantMenu.java -@@ -26,7 +26,7 @@ public class MerchantMenu extends AbstractContainerMenu { +@@ -27,7 +27,7 @@ public class MerchantMenu extends AbstractContainerMenu { private static final int SELLSLOT2_X = 162; private static final int BUYSLOT_X = 220; private static final int ROW_Y = 37; @@ -126,10 +135,10 @@ index 9c17c14de888ef3fbf4139cbad3889ece1d74aa1..39855fc8858f48ea3db00fc35b2b22e6 private int merchantLevel; private boolean showProgressBar; diff --git a/src/main/java/net/minecraft/world/item/trading/MerchantOffer.java b/src/main/java/net/minecraft/world/item/trading/MerchantOffer.java -index 02feea12c998f37098b72becf6bfaf6b27d155de..b0ac4dcb539c3286a0c79ce7322f8cb8a2237d75 100644 +index 0efc8d997b34302c3e0a5d7ec73a11a940dbeefe..d246c9932f3f98972124089306d6ed740bb9a31b 100644 --- a/src/main/java/net/minecraft/world/item/trading/MerchantOffer.java +++ b/src/main/java/net/minecraft/world/item/trading/MerchantOffer.java -@@ -20,6 +20,7 @@ public class MerchantOffer { +@@ -51,6 +51,7 @@ public class MerchantOffer { public float priceMultiplier; public int xp; public boolean ignoreDiscounts; // Paper - Add ignore discounts API @@ -137,31 +146,15 @@ index 02feea12c998f37098b72becf6bfaf6b27d155de..b0ac4dcb539c3286a0c79ce7322f8cb8 // CraftBukkit start private CraftMerchantRecipe bukkitHandle; -@@ -73,6 +74,7 @@ public class MerchantOffer { - this.specialPriceDiff = nbt.getInt("specialPrice"); - this.demand = nbt.getInt("demand"); - this.ignoreDiscounts = nbt.getBoolean("Paper.IgnoreDiscounts"); // Paper - Add ignore discounts API -+ this.voidTradeUses = 0; // Leaves - force void trade - } - - public MerchantOffer(ItemStack buyItem, ItemStack sellItem, int maxUses, int merchantExperience, float priceMultiplier) { -@@ -107,6 +109,7 @@ public class MerchantOffer { - this.xp = merchantExperience; +@@ -77,6 +78,7 @@ public class MerchantOffer { this.priceMultiplier = priceMultiplier; - this.demand = demandBonus; + this.xp = merchantExperience; + this.ignoreDiscounts = ignoreDiscounts; // Paper + this.voidTradeUses = 0; // Leaves - force void trade } - private MerchantOffer(MerchantOffer offer) { -@@ -122,6 +125,7 @@ public class MerchantOffer { - this.demand = offer.demand; - this.priceMultiplier = offer.priceMultiplier; - this.xp = offer.xp; -+ this.voidTradeUses = 0; // Leaves - force void trade - } - - public ItemStack getBaseCostA() { -@@ -172,6 +176,16 @@ public class MerchantOffer { + public MerchantOffer(ItemCost buyItem, ItemStack sellItem, int maxUses, int merchantExperience, float priceMultiplier) { +@@ -154,6 +156,16 @@ public class MerchantOffer { ++this.uses; } @@ -178,7 +171,7 @@ index 02feea12c998f37098b72becf6bfaf6b27d155de..b0ac4dcb539c3286a0c79ce7322f8cb8 public int getDemand() { return this.demand; } -@@ -201,7 +215,7 @@ public class MerchantOffer { +@@ -183,7 +195,7 @@ public class MerchantOffer { } public boolean isOutOfStock() { @@ -188,15 +181,15 @@ index 02feea12c998f37098b72becf6bfaf6b27d155de..b0ac4dcb539c3286a0c79ce7322f8cb8 public void setToOutOfStock() { 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 7b626bc319eeebff6f0165db0eb0fd6c70d8cc36..e9069275d038e7b5a15c4f85dae6dbc4851ba374 100644 +index 8809755d0e3e6199e2db6c061e53375d17753b70..bd748c1b6d174b14aa4b5cba14578cc5c118b912 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 -@@ -219,6 +219,16 @@ public class TheEndGatewayBlockEntity extends TheEndPortalBlockEntity { +@@ -213,6 +213,16 @@ public class TheEndGatewayBlockEntity extends TheEndPortalBlockEntity { return; } + // Leaves start - force void trade -+ if (top.leavesmc.leaves.LeavesConfig.forceVoidTrade) { ++ if (org.leavesmc.leaves.LeavesConfig.forceVoidTrade) { + if (((ServerPlayer) entity1).containerMenu instanceof net.minecraft.world.inventory.MerchantMenu merchantMenu) { + if (merchantMenu.trader instanceof net.minecraft.world.entity.npc.AbstractVillager villager) { + villager.setVoidTrade(); diff --git a/patches/server/0114-Placeholder-for-Servux-Protocol.patch b/patches/server/0114-Placeholder-for-Servux-Protocol.patch new file mode 100644 index 00000000..1ffcc17d --- /dev/null +++ b/patches/server/0114-Placeholder-for-Servux-Protocol.patch @@ -0,0 +1,15 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: MC_XiaoHei +Date: Thu, 9 May 2024 22:46:34 +0800 +Subject: [PATCH] Placeholder for Servux-Protocol + + +diff --git a/.gitignore b/.gitignore +index 1ad93453221244f880855b510e888e759275b640..3811c0d849a3eb028ed1a6b7a2d4747f7f570448 100644 +--- a/.gitignore ++++ b/.gitignore +@@ -46,4 +46,3 @@ dependency-reduced-pom.xml + # vs code + /.vscode + /.factorypath +- diff --git a/patches/server/0116-Villager-infinite-discounts.patch b/patches/server/0115-Villager-infinite-discounts.patch similarity index 75% rename from patches/server/0116-Villager-infinite-discounts.patch rename to patches/server/0115-Villager-infinite-discounts.patch index b325ac65..01fc16e8 100644 --- a/patches/server/0116-Villager-infinite-discounts.patch +++ b/patches/server/0115-Villager-infinite-discounts.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Villager infinite discounts diff --git a/src/main/java/net/minecraft/world/entity/ai/gossip/GossipType.java b/src/main/java/net/minecraft/world/entity/ai/gossip/GossipType.java -index 8c942c21dc3aebcd2fc89b5bde92c73a95bdc3e3..55b4386fc57286548161f9ee91e19e22e35ba3c9 100644 +index 90bdbd686560bc2987af6524bf32b0c51ef98887..8444f233b68f056fe6ef9f7f6c40e69aa8222ab7 100644 --- a/src/main/java/net/minecraft/world/entity/ai/gossip/GossipType.java +++ b/src/main/java/net/minecraft/world/entity/ai/gossip/GossipType.java @@ -15,9 +15,9 @@ public enum GossipType implements StringRepresentable { @@ -19,14 +19,14 @@ index 8c942c21dc3aebcd2fc89b5bde92c73a95bdc3e3..55b4386fc57286548161f9ee91e19e22 + public int decayPerTransfer; // Leaves - not final public static final Codec CODEC = StringRepresentable.fromEnum(GossipType::values); - private GossipType(String key, int multiplier, int maxReputation, int decay, int shareDecrement) { -diff --git a/src/main/java/top/leavesmc/leaves/util/VillagerInfiniteDiscountHelper.java b/src/main/java/top/leavesmc/leaves/util/VillagerInfiniteDiscountHelper.java + private GossipType(final String key, final int multiplier, final int maxReputation, final int decay, final int shareDecrement) { +diff --git a/src/main/java/org/leavesmc/leaves/util/VillagerInfiniteDiscountHelper.java b/src/main/java/org/leavesmc/leaves/util/VillagerInfiniteDiscountHelper.java new file mode 100644 -index 0000000000000000000000000000000000000000..a5063fdcc8b5bf009994bf4134a56390141e69c2 +index 0000000000000000000000000000000000000000..83a6ef92a097b9c8c29299db1d01ad56eeb87441 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/util/VillagerInfiniteDiscountHelper.java ++++ b/src/main/java/org/leavesmc/leaves/util/VillagerInfiniteDiscountHelper.java @@ -0,0 +1,18 @@ -+package top.leavesmc.leaves.util; ++package org.leavesmc.leaves.util; + +import net.minecraft.world.entity.ai.gossip.GossipType; + diff --git a/patches/server/0117-CCE-update-suppression.patch b/patches/server/0116-CCE-update-suppression.patch similarity index 76% rename from patches/server/0117-CCE-update-suppression.patch rename to patches/server/0116-CCE-update-suppression.patch index 69470653..4e147755 100644 --- a/patches/server/0117-CCE-update-suppression.patch +++ b/patches/server/0116-CCE-update-suppression.patch @@ -5,27 +5,27 @@ Subject: [PATCH] CCE update suppression diff --git a/src/main/java/net/minecraft/world/level/block/ShulkerBoxBlock.java b/src/main/java/net/minecraft/world/level/block/ShulkerBoxBlock.java -index fb7cffcf77a89202cb87b347bea518cc89987afd..95376a06e850e14f3cd131a776f264a1dab592ee 100644 +index aeb0577abcc0790edaece34939a6756424610dbc..254ae2f75ab25b3b1c2349b593122c3e09c9b981 100644 --- a/src/main/java/net/minecraft/world/level/block/ShulkerBoxBlock.java +++ b/src/main/java/net/minecraft/world/level/block/ShulkerBoxBlock.java -@@ -254,17 +254,21 @@ public class ShulkerBoxBlock extends BaseEntityBlock { +@@ -231,17 +231,21 @@ public class ShulkerBoxBlock extends BaseEntityBlock { @Override - public int getAnalogOutputSignal(BlockState state, Level world, BlockPos pos) { + protected int getAnalogOutputSignal(BlockState state, Level world, BlockPos pos) { - // Leaves start - fix update suppression crash + // Leaves start - fix update suppression crash - and cce fix - if (top.leavesmc.leaves.LeavesConfig.updateSuppressionCrashFix) { + if (org.leavesmc.leaves.LeavesConfig.updateSuppressionCrashFix) { try { - return AbstractContainerMenu.getRedstoneSignalFromBlockEntity(world.getBlockEntity(pos)); -+ return top.leavesmc.leaves.LeavesConfig.cceUpdateSuppression ? ++ return org.leavesmc.leaves.LeavesConfig.cceUpdateSuppression ? + AbstractContainerMenu.getRedstoneSignalFromContainer((net.minecraft.world.Container) world.getBlockEntity(pos)) : + AbstractContainerMenu.getRedstoneSignalFromBlockEntity(world.getBlockEntity(pos)); } catch (ClassCastException ex) { - throw new top.leavesmc.leaves.util.UpdateSuppressionException(null, pos); + throw new org.leavesmc.leaves.util.UpdateSuppressionException(null, pos); } } else { - return AbstractContainerMenu.getRedstoneSignalFromBlockEntity(world.getBlockEntity(pos)); -+ return top.leavesmc.leaves.LeavesConfig.cceUpdateSuppression ? ++ return org.leavesmc.leaves.LeavesConfig.cceUpdateSuppression ? + AbstractContainerMenu.getRedstoneSignalFromContainer((net.minecraft.world.Container) world.getBlockEntity(pos)) : + AbstractContainerMenu.getRedstoneSignalFromBlockEntity(world.getBlockEntity(pos)); } diff --git a/patches/server/0118-Disable-offline-warn-if-use-proxy.patch b/patches/server/0117-Disable-offline-warn-if-use-proxy.patch similarity index 89% rename from patches/server/0118-Disable-offline-warn-if-use-proxy.patch rename to patches/server/0117-Disable-offline-warn-if-use-proxy.patch index 5cf2a652..4896d509 100644 --- a/patches/server/0118-Disable-offline-warn-if-use-proxy.patch +++ b/patches/server/0117-Disable-offline-warn-if-use-proxy.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Disable offline warn if use proxy diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -index 5ddeae61955be0e212db8467804aa42a88f61f04..142d2f21f171d45180a89946f0e3ece2101258be 100644 +index 7148b5c8f4b63649ef8f89963b6bd591fd1a97bf..5a2bd2543dee0c307d2702395fc676c4f44bf59d 100644 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -@@ -284,7 +284,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -296,7 +296,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 diff --git a/patches/server/0119-Disable-moved-wrongly-threshold.patch b/patches/server/0118-Disable-moved-wrongly-threshold.patch similarity index 87% rename from patches/server/0119-Disable-moved-wrongly-threshold.patch rename to patches/server/0118-Disable-moved-wrongly-threshold.patch index d22a01e9..c32bbb25 100644 --- a/patches/server/0119-Disable-moved-wrongly-threshold.patch +++ b/patches/server/0118-Disable-moved-wrongly-threshold.patch @@ -5,42 +5,42 @@ Subject: [PATCH] Disable moved wrongly threshold diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index cb1b08063abf7cf2c1b44922b2d9f50ccf0effa7..f29dd46b7a4c20df21fbcbbb5b5c4bb5440700fd 100644 +index ca22905fa9948f85dcace5098ffd9807d338c93c..c39fbba316f97fa1e069360344c2d636bf08fade 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -555,7 +555,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -566,7 +566,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl } // Paper end - Prevent moving into unloaded chunks - if (d10 - d9 > Math.max(100.0D, Math.pow((double) (org.spigotmc.SpigotConfig.movedTooQuicklyMultiplier * (float) i * speed), 2)) && !this.isSingleplayerOwner()) { -+ if (!top.leavesmc.leaves.LeavesConfig.disableMovedWronglyThreshold && d10 - d9 > Math.max(100.0D, Math.pow((double) (org.spigotmc.SpigotConfig.movedTooQuicklyMultiplier * (float) i * speed), 2)) && !this.isSingleplayerOwner()) { // Leaves - disable can ++ if (!org.leavesmc.leaves.LeavesConfig.disableMovedWronglyThreshold && d10 - d9 > Math.max(100.0D, Math.pow((double) (org.spigotmc.SpigotConfig.movedTooQuicklyMultiplier * (float) i * speed), 2)) && !this.isSingleplayerOwner()) { // Leaves - disable can // CraftBukkit end ServerGamePacketListenerImpl.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", new Object[]{entity.getName().getString(), this.player.getName().getString(), d6, d7, d8}); this.send(new ClientboundMoveVehiclePacket(entity)); -@@ -591,7 +591,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -602,7 +602,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl d10 = d6 * d6 + d7 * d7 + d8 * d8; boolean flag2 = false; - if (d10 > org.spigotmc.SpigotConfig.movedWronglyThreshold) { // Spigot -+ if (!top.leavesmc.leaves.LeavesConfig.disableMovedWronglyThreshold && d10 > org.spigotmc.SpigotConfig.movedWronglyThreshold) { // Spigot // Leaves - disable can ++ if (!org.leavesmc.leaves.LeavesConfig.disableMovedWronglyThreshold && d10 > org.spigotmc.SpigotConfig.movedWronglyThreshold) { // Spigot // Leaves - disable can flag2 = true; // Paper - diff on change, this should be moved wrongly ServerGamePacketListenerImpl.LOGGER.warn("{} (vehicle of {}) moved wrongly! {}", new Object[]{entity.getName().getString(), this.player.getName().getString(), Math.sqrt(d10)}); } -@@ -1437,7 +1437,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -1417,7 +1417,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl io.papermc.paper.event.player.PlayerFailMoveEvent event = fireFailMove(io.papermc.paper.event.player.PlayerFailMoveEvent.FailReason.MOVED_TOO_QUICKLY, toX, toY, toZ, toYaw, toPitch, true); if (!event.isAllowed()) { - if (event.getLogWarning()) -+ if (!top.leavesmc.leaves.LeavesConfig.disableMovedWronglyThreshold && event.getLogWarning()) // Leaves - disable can ++ if (!org.leavesmc.leaves.LeavesConfig.disableMovedWronglyThreshold && event.getLogWarning()) // Leaves - disable can ServerGamePacketListenerImpl.LOGGER.warn("{} moved too quickly! {},{},{}", new Object[]{this.player.getName().getString(), d6, d7, d8}); this.teleport(this.player.getX(), this.player.getY(), this.player.getZ(), this.player.getYRot(), this.player.getXRot()); return; -@@ -1507,7 +1507,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -1487,7 +1487,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl d10 = d6 * d6 + d7 * d7 + d8 * d8; boolean movedWrongly = false; // Paper - Add fail move event; rename - if (!this.player.isChangingDimension() && d10 > org.spigotmc.SpigotConfig.movedWronglyThreshold && !this.player.isSleeping() && !this.player.gameMode.isCreative() && this.player.gameMode.getGameModeForPlayer() != GameType.SPECTATOR) { // Spigot -+ if (!top.leavesmc.leaves.LeavesConfig.disableMovedWronglyThreshold && !this.player.isChangingDimension() && d10 > org.spigotmc.SpigotConfig.movedWronglyThreshold && !this.player.isSleeping() && !this.player.gameMode.isCreative() && this.player.gameMode.getGameModeForPlayer() != GameType.SPECTATOR) { // Spigot // Leaves - disable can ++ if (!org.leavesmc.leaves.LeavesConfig.disableMovedWronglyThreshold && !this.player.isChangingDimension() && d10 > org.spigotmc.SpigotConfig.movedWronglyThreshold && !this.player.isSleeping() && !this.player.gameMode.isCreative() && this.player.gameMode.getGameModeForPlayer() != GameType.SPECTATOR) { // Spigot // Leaves - disable can // Paper start - Add fail move event io.papermc.paper.event.player.PlayerFailMoveEvent event = fireFailMove(io.papermc.paper.event.player.PlayerFailMoveEvent.FailReason.MOVED_WRONGLY, toX, toY, toZ, toYaw, toPitch, true); diff --git a/patches/server/0120-Armor-stand-cant-kill-by-mob-projectile.patch b/patches/server/0119-Armor-stand-cant-kill-by-mob-projectile.patch similarity index 84% rename from patches/server/0120-Armor-stand-cant-kill-by-mob-projectile.patch rename to patches/server/0119-Armor-stand-cant-kill-by-mob-projectile.patch index c7530289..718d3dc0 100644 --- a/patches/server/0120-Armor-stand-cant-kill-by-mob-projectile.patch +++ b/patches/server/0119-Armor-stand-cant-kill-by-mob-projectile.patch @@ -5,15 +5,15 @@ Subject: [PATCH] Armor stand cant kill by mob projectile diff --git a/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java b/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java -index 575ef3806fc89b7492f5d6b6500e37c775dfaad8..9720d9d0b0c732147f7e0004896cbaa35318d24d 100644 +index 32fd9c3d79bb9e9e75b03750696425089e503dcb..4b04753093dd6c9140f68966120f80e52608936f 100644 --- a/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java +++ b/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java -@@ -519,6 +519,14 @@ public class ArmorStand extends LivingEntity { +@@ -525,6 +525,14 @@ public class ArmorStand extends LivingEntity { boolean flag = source.is(DamageTypeTags.CAN_BREAK_ARMOR_STAND); boolean flag1 = source.is(DamageTypeTags.ALWAYS_KILLS_ARMOR_STANDS); + // Leaves start - Armor stand cant kill by mob projectile -+ if (top.leavesmc.leaves.LeavesConfig.armorStandCantKillByMobProjectile) { ++ if (org.leavesmc.leaves.LeavesConfig.armorStandCantKillByMobProjectile) { + if (!flag && !(source.getDirectEntity() instanceof net.minecraft.world.entity.projectile.AbstractArrow)) { + return false; + } diff --git a/patches/server/0121-Make-Item-tick-vanilla.patch b/patches/server/0120-Make-Item-tick-vanilla.patch similarity index 83% rename from patches/server/0121-Make-Item-tick-vanilla.patch rename to patches/server/0120-Make-Item-tick-vanilla.patch index c3f21525..29e79049 100644 --- a/patches/server/0121-Make-Item-tick-vanilla.patch +++ b/patches/server/0120-Make-Item-tick-vanilla.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Make Item tick vanilla 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 ffa9fe429ed773db25a5e1020283b12597a69070..feb3fb984f6e6ed70992a038649249a9d3a9c938 100644 +index 1bb762349c868e6a68b46366710dbbee60466eaf..7ebe3c96254ea94855a80b9ffab6bffdc0dac808 100644 --- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java -@@ -252,6 +252,9 @@ public class ItemEntity extends Entity implements TraceableEntity { +@@ -258,6 +258,9 @@ public class ItemEntity extends Entity implements TraceableEntity { // Spigot start - copied from above @Override public void inactiveTick() { @@ -18,7 +18,7 @@ index ffa9fe429ed773db25a5e1020283b12597a69070..feb3fb984f6e6ed70992a038649249a9 // CraftBukkit start - Use wall time for pickup and despawn timers int elapsedTicks = MinecraftServer.currentTick - this.lastTick; if (this.pickupDelay != 32767) this.pickupDelay -= elapsedTicks; -@@ -269,6 +272,8 @@ public class ItemEntity extends Entity implements TraceableEntity { +@@ -275,6 +278,8 @@ public class ItemEntity extends Entity implements TraceableEntity { // CraftBukkit end this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause } diff --git a/patches/server/0122-Copper-Bulb-1-gt-delay.patch b/patches/server/0121-Copper-Bulb-1-gt-delay.patch similarity index 78% rename from patches/server/0122-Copper-Bulb-1-gt-delay.patch rename to patches/server/0121-Copper-Bulb-1-gt-delay.patch index c76c0f27..a1630015 100644 --- a/patches/server/0122-Copper-Bulb-1-gt-delay.patch +++ b/patches/server/0121-Copper-Bulb-1-gt-delay.patch @@ -5,16 +5,16 @@ Subject: [PATCH] Copper Bulb 1 gt delay diff --git a/src/main/java/net/minecraft/world/level/block/CopperBulbBlock.java b/src/main/java/net/minecraft/world/level/block/CopperBulbBlock.java -index 3ce239c7833e1d23f5345b6af2cd3b1269828a6f..4b20a9812852c98da7199b1c9f1c21aa19681148 100644 +index b4250059a9068124b76268913f675babac379670..e6cfa8c1ce45c5e4b647ac6faceb838961e69dad 100644 --- a/src/main/java/net/minecraft/world/level/block/CopperBulbBlock.java +++ b/src/main/java/net/minecraft/world/level/block/CopperBulbBlock.java @@ -30,14 +30,26 @@ public class CopperBulbBlock extends Block { @Override - public void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) { + protected void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) { if (oldState.getBlock() != state.getBlock() && world instanceof ServerLevel serverLevel) { - this.checkAndFlip(state, serverLevel, pos); + // Leaves start - copper bulb 1 gt delay -+ if (!top.leavesmc.leaves.LeavesConfig.copperBulb1gt) { ++ if (!org.leavesmc.leaves.LeavesConfig.copperBulb1gt) { + this.checkAndFlip(state, serverLevel, pos); + } else { + world.scheduleTick(pos, this, 1); @@ -24,11 +24,11 @@ index 3ce239c7833e1d23f5345b6af2cd3b1269828a6f..4b20a9812852c98da7199b1c9f1c21aa } @Override - public void neighborChanged(BlockState state, Level world, BlockPos pos, Block sourceBlock, BlockPos sourcePos, boolean notify) { + protected void neighborChanged(BlockState state, Level world, BlockPos pos, Block sourceBlock, BlockPos sourcePos, boolean notify) { if (world instanceof ServerLevel serverLevel) { - this.checkAndFlip(state, serverLevel, pos); + // Leaves start - copper bulb 1 gt -+ if (!top.leavesmc.leaves.LeavesConfig.copperBulb1gt) { ++ if (!org.leavesmc.leaves.LeavesConfig.copperBulb1gt) { + this.checkAndFlip(state, serverLevel, pos); + } else { + world.scheduleTick(pos, this, 1); @@ -44,7 +44,7 @@ index 3ce239c7833e1d23f5345b6af2cd3b1269828a6f..4b20a9812852c98da7199b1c9f1c21aa + // Leaves start - copper bulb 1 gt delay + @Override + public void tick(BlockState state, ServerLevel world, BlockPos pos, net.minecraft.util.RandomSource random) { -+ if (top.leavesmc.leaves.LeavesConfig.copperBulb1gt) { ++ if (org.leavesmc.leaves.LeavesConfig.copperBulb1gt) { + checkAndFlip(state, world, pos); + } + } diff --git a/patches/server/0122-Crafter-1-gt-delay.patch b/patches/server/0122-Crafter-1-gt-delay.patch new file mode 100644 index 00000000..555b48c2 --- /dev/null +++ b/patches/server/0122-Crafter-1-gt-delay.patch @@ -0,0 +1,28 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: violetc <58360096+s-yh-china@users.noreply.github.com> +Date: Tue, 12 Dec 2023 14:15:54 +0800 +Subject: [PATCH] Crafter 1 gt delay + + +diff --git a/src/main/java/net/minecraft/world/level/block/CrafterBlock.java b/src/main/java/net/minecraft/world/level/block/CrafterBlock.java +index 4d315bd1df9f4647814500135195375166c578b3..69f7c2e4a41c73c99f3c9bf7a2923339d77e7f37 100644 +--- a/src/main/java/net/minecraft/world/level/block/CrafterBlock.java ++++ b/src/main/java/net/minecraft/world/level/block/CrafterBlock.java +@@ -80,7 +80,7 @@ public class CrafterBlock extends BaseEntityBlock { + boolean bl2 = state.getValue(TRIGGERED); + BlockEntity blockEntity = world.getBlockEntity(pos); + if (bl && !bl2) { +- world.scheduleTick(pos, this, 4); ++ world.scheduleTick(pos, this, !org.leavesmc.leaves.LeavesConfig.crafter1gt ? 4 : 1); // Leaves - crafter 1 gt delay + world.setBlock(pos, state.setValue(TRIGGERED, Boolean.valueOf(true)), 2); + this.setBlockEntityTriggered(blockEntity, true); + } else if (!bl && bl2) { +@@ -130,7 +130,7 @@ public class CrafterBlock extends BaseEntityBlock { + @Override + public void setPlacedBy(Level world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack itemStack) { + if (state.getValue(TRIGGERED)) { +- world.scheduleTick(pos, this, 4); ++ world.scheduleTick(pos, this, !org.leavesmc.leaves.LeavesConfig.crafter1gt ? 4 : 1); // Leaves - crafter 1 gt delay + } + } + diff --git a/patches/server/0123-Crafter-1-gt-delay.patch b/patches/server/0123-Crafter-1-gt-delay.patch deleted file mode 100644 index cba3f79e..00000000 --- a/patches/server/0123-Crafter-1-gt-delay.patch +++ /dev/null @@ -1,45 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: violetc <58360096+s-yh-china@users.noreply.github.com> -Date: Tue, 12 Dec 2023 14:15:54 +0800 -Subject: [PATCH] Crafter 1 gt delay - - -diff --git a/src/main/java/net/minecraft/world/level/block/CrafterBlock.java b/src/main/java/net/minecraft/world/level/block/CrafterBlock.java -index 00b8cf2261a8b26cd05647ab1e2591e556915d8b..41f620637788cb449afcf6aca49adc5b11aedad3 100644 ---- a/src/main/java/net/minecraft/world/level/block/CrafterBlock.java -+++ b/src/main/java/net/minecraft/world/level/block/CrafterBlock.java -@@ -76,7 +76,7 @@ public class CrafterBlock extends BaseEntityBlock { - boolean bl2 = state.getValue(TRIGGERED); - BlockEntity blockEntity = world.getBlockEntity(pos); - if (bl && !bl2) { -- world.scheduleTick(pos, this, 4); -+ world.scheduleTick(pos, this, !top.leavesmc.leaves.LeavesConfig.crafter1gt ? 4 : 1); // Leaves - crafter 1 gt delay - world.setBlock(pos, state.setValue(TRIGGERED, Boolean.valueOf(true)), 2); - this.setBlockEntityTriggered(blockEntity, true); - } else if (!bl && bl2) { -@@ -130,7 +130,7 @@ public class CrafterBlock extends BaseEntityBlock { - } - - if (state.getValue(TRIGGERED)) { -- world.scheduleTick(pos, this, 4); -+ world.scheduleTick(pos, this, !top.leavesmc.leaves.LeavesConfig.crafter1gt ? 4 : 1); // Leaves - crafter 1 gt delay - } - } - -@@ -156,13 +156,13 @@ public class CrafterBlock extends BaseEntityBlock { - - protected void dispenseFrom(BlockState state, ServerLevel world, BlockPos pos) { - if (world.getBlockEntity(pos) instanceof CrafterBlockEntity crafterBlockEntity) { -- Optional optional = getPotentialResults(world, crafterBlockEntity); -- if (optional.isEmpty()) { -+ Optional optional1 = getPotentialResults(world, crafterBlockEntity); -+ if (optional1.isEmpty()) { - world.levelEvent(1050, pos, 0); - } else { - crafterBlockEntity.setCraftingTicksRemaining(6); - world.setBlock(pos, state.setValue(CRAFTING, Boolean.valueOf(true)), 2); -- CraftingRecipe craftingRecipe = optional.get(); -+ CraftingRecipe craftingRecipe = optional1.get(); - ItemStack itemStack = craftingRecipe.assemble(crafterBlockEntity, world.registryAccess()); - itemStack.onCraftedBySystem(world); - this.dispenseItem(world, pos, crafterBlockEntity, itemStack, state); diff --git a/patches/server/0124-Linear-region-file-format.patch b/patches/server/0123-Linear-region-file-format.patch similarity index 75% rename from patches/server/0124-Linear-region-file-format.patch rename to patches/server/0123-Linear-region-file-format.patch index b85dfe3e..9e177b46 100644 --- a/patches/server/0124-Linear-region-file-format.patch +++ b/patches/server/0123-Linear-region-file-format.patch @@ -5,11 +5,20 @@ Subject: [PATCH] Linear region file format This patch is Powered by LinearPurpur(https://github.com/StupidCraft/LinearPurpur) +diff --git a/.gitignore b/.gitignore +index 3811c0d849a3eb028ed1a6b7a2d4747f7f570448..1ad93453221244f880855b510e888e759275b640 100644 +--- a/.gitignore ++++ b/.gitignore +@@ -46,3 +46,4 @@ dependency-reduced-pom.xml + # vs code + /.vscode + /.factorypath ++ diff --git a/build.gradle.kts b/build.gradle.kts -index 77d6f5eeeb9918a70e0003e97671778303c33ce9..f3f70a48d758ccbbf1210681c24f0b3a838fb66b 100644 +index 28baa9a192a6fd83563b57a411e9bc905ba6b7e1..de18503a98afca9a271f81bb24cb489d902cfe39 100644 --- a/build.gradle.kts +++ b/build.gradle.kts -@@ -36,6 +36,10 @@ dependencies { +@@ -30,6 +30,10 @@ dependencies { alsoShade(log4jPlugins.output) implementation("io.netty:netty-codec-haproxy:4.1.97.Final") // Paper - Add support for proxy protocol // Paper end @@ -17,14 +26,11 @@ index 77d6f5eeeb9918a70e0003e97671778303c33ce9..f3f70a48d758ccbbf1210681c24f0b3a + implementation("com.github.luben:zstd-jni:1.5.5-11") + implementation("org.lz4:lz4-java:1.8.0") + // Leaves end - Linear format - implementation("org.apache.logging.log4j:log4j-iostreams:2.19.0") // Paper - remove exclusion + implementation("org.apache.logging.log4j:log4j-iostreams:2.22.1") // Paper - remove exclusion implementation("org.ow2.asm:asm-commons:9.7") implementation("org.spongepowered:configurate-yaml:4.2.0-SNAPSHOT") // Paper - config files -diff --git a/src/main/java/com/destroystokyo/paper/io/PaperFileIOThread.java b/src/main/java/com/destroystokyo/paper/io/PaperFileIOThread.java -new file mode 100644 -index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/main/java/io/papermc/paper/chunk/system/io/RegionFileIOThread.java b/src/main/java/io/papermc/paper/chunk/system/io/RegionFileIOThread.java -index 2934f0cf0ef09c84739312b00186c2ef0019a165..ad909f888c8eb6fa8d4ebeeebdc538aee749346d 100644 +index 2934f0cf0ef09c84739312b00186c2ef0019a165..f1833e1d4de1c03f81ac5263ae97e911e2a63393 100644 --- a/src/main/java/io/papermc/paper/chunk/system/io/RegionFileIOThread.java +++ b/src/main/java/io/papermc/paper/chunk/system/io/RegionFileIOThread.java @@ -816,7 +816,7 @@ public final class RegionFileIOThread extends PrioritisedQueueExecutorThread { @@ -32,7 +38,7 @@ index 2934f0cf0ef09c84739312b00186c2ef0019a165..ad909f888c8eb6fa8d4ebeeebdc538ae final ChunkPos chunkPos = new ChunkPos(chunkX, chunkZ); if (intendingToBlock) { - return taskController.computeForRegionFile(chunkX, chunkZ, true, (final RegionFile file) -> { -+ return taskController.computeForRegionFile(chunkX, chunkZ, true, (final top.leavesmc.leaves.region.AbstractRegionFile file) -> { // Leaves ++ return taskController.computeForRegionFile(chunkX, chunkZ, true, (final org.leavesmc.leaves.region.AbstractRegionFile file) -> { // Leaves if (file == null) { // null if no regionfile exists return Boolean.FALSE; } @@ -41,7 +47,7 @@ index 2934f0cf0ef09c84739312b00186c2ef0019a165..ad909f888c8eb6fa8d4ebeeebdc538ae } // else: it either exists or is not known, fall back to checking the loaded region file - return taskController.computeForRegionFileIfLoaded(chunkX, chunkZ, (final RegionFile file) -> { -+ return taskController.computeForRegionFileIfLoaded(chunkX, chunkZ, (final top.leavesmc.leaves.region.AbstractRegionFile file) -> { // Leaves ++ return taskController.computeForRegionFileIfLoaded(chunkX, chunkZ, (final org.leavesmc.leaves.region.AbstractRegionFile file) -> { // Leaves if (file == null) { // null if not loaded // not sure at this point, let the I/O thread figure it out return Boolean.TRUE; @@ -50,10 +56,10 @@ index 2934f0cf0ef09c84739312b00186c2ef0019a165..ad909f888c8eb6fa8d4ebeeebdc538ae } - public T computeForRegionFile(final int chunkX, final int chunkZ, final boolean existingOnly, final Function function) { -+ public T computeForRegionFile(final int chunkX, final int chunkZ, final boolean existingOnly, final Function function) { // Leaves ++ public T computeForRegionFile(final int chunkX, final int chunkZ, final boolean existingOnly, final Function function) { // Leaves final RegionFileStorage cache = this.getCache(); - final RegionFile regionFile; -+ final top.leavesmc.leaves.region.AbstractRegionFile regionFile; // Leaves ++ final org.leavesmc.leaves.region.AbstractRegionFile regionFile; // Leaves synchronized (cache) { try { regionFile = cache.getRegionFile(new ChunkPos(chunkX, chunkZ), existingOnly, true); @@ -68,10 +74,10 @@ index 2934f0cf0ef09c84739312b00186c2ef0019a165..ad909f888c8eb6fa8d4ebeeebdc538ae } - public T computeForRegionFileIfLoaded(final int chunkX, final int chunkZ, final Function function) { -+ public T computeForRegionFileIfLoaded(final int chunkX, final int chunkZ, final Function function) { // Leaves ++ public T computeForRegionFileIfLoaded(final int chunkX, final int chunkZ, final Function function) { // Leaves final RegionFileStorage cache = this.getCache(); - final RegionFile regionFile; -+ final top.leavesmc.leaves.region.AbstractRegionFile regionFile; // Leaves ++ final org.leavesmc.leaves.region.AbstractRegionFile regionFile; // Leaves synchronized (cache) { regionFile = cache.getRegionFileIfLoaded(new ChunkPos(chunkX, chunkZ)); @@ -91,88 +97,76 @@ index 2934f0cf0ef09c84739312b00186c2ef0019a165..ad909f888c8eb6fa8d4ebeeebdc538ae } } diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java -index 86207dd0f1f666588535d03f5576fbe4e2267eeb..3b58923acdf8f2b3663c9cd321f1638d448c5da0 100644 +index 7dcdc9b40c594234d87bef3e75a68ddaa58506a3..6bbccbc2e114bf31a0ca3341437b7d5f466f858e 100644 --- a/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java -@@ -854,13 +854,13 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -885,13 +885,13 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider } public ChunkStatus getChunkStatusOnDiskIfCached(ChunkPos chunkPos) { - net.minecraft.world.level.chunk.storage.RegionFile regionFile = regionFileCache.getRegionFileIfLoaded(chunkPos); -+ top.leavesmc.leaves.region.AbstractRegionFile regionFile = regionFileCache.getRegionFileIfLoaded(chunkPos); // Leaves ++ org.leavesmc.leaves.region.AbstractRegionFile regionFile = regionFileCache.getRegionFileIfLoaded(chunkPos); // Leaves return regionFile == null ? null : regionFile.getStatusIfCached(chunkPos.x, chunkPos.z); } public ChunkStatus getChunkStatusOnDisk(ChunkPos chunkPos) throws IOException { - net.minecraft.world.level.chunk.storage.RegionFile regionFile = regionFileCache.getRegionFile(chunkPos, true); -+ top.leavesmc.leaves.region.AbstractRegionFile regionFile = regionFileCache.getRegionFile(chunkPos, true); // Leaves ++ org.leavesmc.leaves.region.AbstractRegionFile regionFile = regionFileCache.getRegionFile(chunkPos, true); // Leaves if (regionFile == null || !regionFileCache.chunkExists(chunkPos)) { return null; -@@ -878,7 +878,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -909,7 +909,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider } public void updateChunkStatusOnDisk(ChunkPos chunkPos, @Nullable CompoundTag compound) throws IOException { - net.minecraft.world.level.chunk.storage.RegionFile regionFile = regionFileCache.getRegionFile(chunkPos, false); -+ top.leavesmc.leaves.region.AbstractRegionFile regionFile = regionFileCache.getRegionFile(chunkPos, false); // Leaves ++ org.leavesmc.leaves.region.AbstractRegionFile regionFile = regionFileCache.getRegionFile(chunkPos, false); // Leaves regionFile.setStatus(chunkPos.x, chunkPos.z, ChunkSerializer.getStatus(compound)); } diff --git a/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java b/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java -index 77dd632a266f4abed30b87b7909d77857c01e316..68416a42ff257d3ba4881496262cfa3b6ca2755a 100644 +index 3e582c49069f2a820ba3baac03917493877d9875..c9f7e0e819dceffa01bffdc522e778d35481426e 100644 --- a/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java +++ b/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java -@@ -61,7 +61,7 @@ public class WorldUpgrader { - private volatile int skipped; - private final Reference2FloatMap> progressMap = Reference2FloatMaps.synchronize(new Reference2FloatOpenHashMap()); - private volatile Component status = Component.translatable("optimizeWorld.stage.counting"); +@@ -76,7 +76,7 @@ public class WorldUpgrader { + volatile int skipped; + final Reference2FloatMap> progressMap = Reference2FloatMaps.synchronize(new Reference2FloatOpenHashMap()); + volatile Component status = Component.translatable("optimizeWorld.stage.counting"); - public static final Pattern REGEX = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\.mca$"); -+ public static Pattern REGEX = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\.(linear | mca)$"); // Leaves - private final DimensionDataStorage overworldDataStorage; ++ public static final Pattern REGEX = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\.(linear | mca)$"); // Leaves + final DimensionDataStorage overworldDataStorage; - public WorldUpgrader(LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, Registry dimensionOptionsRegistry, boolean eraseCache) { -@@ -241,7 +241,7 @@ public class WorldUpgrader { - File file = this.levelStorage.getDimensionPath(world).toFile(); - File file1 = new File(file, "region"); - File[] afile = file1.listFiles((file2, s) -> { -- return s.endsWith(".mca"); -+ return s.endsWith(".mca") || s.endsWith(".linear"); // Leaves - }); + public WorldUpgrader(LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, RegistryAccess dynamicRegistryManager, boolean eraseCache, boolean recreateRegionFiles) { +@@ -406,7 +406,7 @@ public class WorldUpgrader { - if (afile == null) { -@@ -260,7 +260,10 @@ public class WorldUpgrader { - int l = Integer.parseInt(matcher.group(2)) << 5; + private static List getAllChunkPositions(RegionStorageInfo key, Path regionDirectory) { + File[] afile = regionDirectory.toFile().listFiles((file, s) -> { +- return s.endsWith(".mca"); ++ return s.endsWith(".mca") || s.endsWith(".linear"); // Leaves + }); - try { -- RegionFile regionfile = new RegionFile(file2.toPath(), file1.toPath(), true); -+ // Leaves start -+ int linearCompression = top.leavesmc.leaves.LeavesConfig.linearCompressionLevel; -+ top.leavesmc.leaves.region.AbstractRegionFile regionfile = top.leavesmc.leaves.region.AbstractRegionFileFactory.getAbstractRegionFile(linearCompression, file2.toPath(), file1.toPath(), true); -+ // Leaves end - - try { - for (int i1 = 0; i1 < 32; ++i1) { + if (afile == null) { 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 6cf83502a954cce9c562ec036bfeddb477d38b73..d43c41d377dd04d0babb99170203e2f5bb831204 100644 +index 1362a47943cf1a51a185a15094b1f74c94bf40ef..5dc0631ee8122f1a8473b6b1cf890cb567400e09 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 -@@ -26,7 +26,7 @@ import net.minecraft.nbt.NbtIo; // Paper +@@ -28,7 +28,7 @@ import net.minecraft.nbt.NbtIo; // Paper import net.minecraft.world.level.ChunkPos; import org.slf4j.Logger; -public class RegionFile implements AutoCloseable { -+public class RegionFile implements AutoCloseable, top.leavesmc.leaves.region.AbstractRegionFile { // Leaves ++public class RegionFile implements AutoCloseable, org.leavesmc.leaves.region.AbstractRegionFile { // Leaves private static final Logger LOGGER = LogUtils.getLogger(); private static final int SECTOR_BYTES = 4096; -@@ -50,6 +50,16 @@ public class RegionFile implements AutoCloseable { - public final java.util.concurrent.locks.ReentrantLock fileLock = new java.util.concurrent.locks.ReentrantLock(); // Paper - public final Path regionFile; // Paper +@@ -60,6 +60,16 @@ public class RegionFile implements AutoCloseable { + return sectors + (sign >>> 63); + } + // Leaves start - Abstract getters + public Path getRegionFile() { -+ return this.regionFile; ++ return this.path; + } + + public java.util.concurrent.locks.ReentrantLock getFileLock() { @@ -180,10 +174,10 @@ index 6cf83502a954cce9c562ec036bfeddb477d38b73..d43c41d377dd04d0babb99170203e2f5 + } + // Leaves end + - // Paper start - Attempt to recalculate regionfile header if it is corrupt - private static long roundToSectors(long bytes) { - long sectors = bytes >>> 12; // 4096 = 2^12 -@@ -128,7 +138,7 @@ public class RegionFile implements AutoCloseable { + private static final CompoundTag OVERSIZED_COMPOUND = new CompoundTag(); + + private CompoundTag attemptRead(long sector, int chunkDataLength, long fileLength) throws IOException { +@@ -130,7 +140,7 @@ public class RegionFile implements AutoCloseable { } // note: only call for CHUNK regionfiles @@ -192,7 +186,7 @@ index 6cf83502a954cce9c562ec036bfeddb477d38b73..d43c41d377dd04d0babb99170203e2f5 if (!this.canRecalcHeader) { return false; } -@@ -955,10 +965,10 @@ public class RegionFile implements AutoCloseable { +@@ -972,10 +982,10 @@ public class RegionFile implements AutoCloseable { private static int getChunkIndex(int x, int z) { return (x & 31) + (z & 31) * 32; } @@ -205,8 +199,8 @@ index 6cf83502a954cce9c562ec036bfeddb477d38b73..d43c41d377dd04d0babb99170203e2f5 final int offset = getChunkIndex(x, z); boolean previous = this.oversized[offset] == 1; this.oversized[offset] = (byte) (oversized ? 1 : 0); -@@ -997,7 +1007,7 @@ public class RegionFile implements AutoCloseable { - return this.regionFile.getParent().resolve(this.regionFile.getFileName().toString().replaceAll("\\.mca$", "") + "_oversized_" + x + "_" + z + ".nbt"); +@@ -1014,7 +1024,7 @@ public class RegionFile implements AutoCloseable { + return this.path.getParent().resolve(this.path.getFileName().toString().replaceAll("\\.mca$", "") + "_oversized_" + x + "_" + z + ".nbt"); } - synchronized CompoundTag getOversizedData(int x, int z) throws IOException { @@ -215,38 +209,37 @@ index 6cf83502a954cce9c562ec036bfeddb477d38b73..d43c41d377dd04d0babb99170203e2f5 try (DataInputStream out = new DataInputStream(new java.io.BufferedInputStream(new InflaterInputStream(Files.newInputStream(file))))) { return NbtIo.read((java.io.DataInput) out); 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 fe312b1aef579cb4bf81bdd967cf72ff880d7505..756c69066ad5336c8faffd22dd48f2ec94271200 100644 +index f6e3b745fc417354380d4a969f83aee430bad785..67c344a8e6d9a32e0d574112e5f766f7d8e0c779 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 -@@ -21,9 +21,14 @@ public class RegionFileStorage implements AutoCloseable { +@@ -21,11 +21,15 @@ public class RegionFileStorage implements AutoCloseable { public static final String ANVIL_EXTENSION = ".mca"; private static final int MAX_CACHE_SIZE = 256; - public final Long2ObjectLinkedOpenHashMap regionCache = new Long2ObjectLinkedOpenHashMap(); -+ public final Long2ObjectLinkedOpenHashMap regionCache = new Long2ObjectLinkedOpenHashMap(); // Leaves ++ public final Long2ObjectLinkedOpenHashMap regionCache = new Long2ObjectLinkedOpenHashMap(); // Leaves + private final RegionStorageInfo info; private final Path folder; private final boolean sync; -+ // Leaves start - region format -+ public final top.leavesmc.leaves.region.RegionFileFormat format; -+ public final int linearCompression; -+ public final boolean linearCrashOnBrokenSymlink; -+ // Leaves end private final boolean isChunkData; // Paper ++ // Leaves start - region format ++ public final org.leavesmc.leaves.region.RegionFileFormat format; ++ public final int linearCompression; ++ // Leaves end // Paper start - cache regionfile does not exist state -@@ -60,6 +65,11 @@ public class RegionFileStorage implements AutoCloseable { - this(directory, dsync, false); - } - RegionFileStorage(Path directory, boolean dsync, boolean isChunkData) { -+ // Leaves start -+ this.format = top.leavesmc.leaves.LeavesConfig.regionFormatName; -+ this.linearCompression = top.leavesmc.leaves.LeavesConfig.linearCompressionLevel; -+ this.linearCrashOnBrokenSymlink = top.leavesmc.leaves.LeavesConfig.linearCrashOnBrokenSymlink; -+ // Leaves end - this.isChunkData = isChunkData; - // Paper end - add isChunkData param + static final int MAX_NON_EXISTING_CACHE = 1024 * 64; +@@ -66,13 +70,17 @@ public class RegionFileStorage implements AutoCloseable { this.folder = directory; -@@ -70,7 +80,7 @@ public class RegionFileStorage implements AutoCloseable { + this.sync = dsync; + this.info = storageKey; ++ // Leaves start ++ this.format = org.leavesmc.leaves.LeavesConfig.regionFormatName; ++ this.linearCompression = org.leavesmc.leaves.LeavesConfig.linearCompressionLevel; ++ // Leaves end + } + + // Paper start @Nullable public static ChunkPos getRegionFileCoordinates(Path file) { String fileName = file.getFileName().toString(); @@ -255,52 +248,32 @@ index fe312b1aef579cb4bf81bdd967cf72ff880d7505..756c69066ad5336c8faffd22dd48f2ec return null; } -@@ -90,29 +100,49 @@ public class RegionFileStorage implements AutoCloseable { +@@ -92,29 +100,29 @@ public class RegionFileStorage implements AutoCloseable { } } - public synchronized RegionFile getRegionFileIfLoaded(ChunkPos chunkcoordintpair) { -+ public synchronized top.leavesmc.leaves.region.AbstractRegionFile getRegionFileIfLoaded(ChunkPos chunkcoordintpair) { // Leaves ++ public synchronized org.leavesmc.leaves.region.AbstractRegionFile getRegionFileIfLoaded(ChunkPos chunkcoordintpair) { // Leaves return this.regionCache.getAndMoveToFirst(ChunkPos.asLong(chunkcoordintpair.getRegionX(), chunkcoordintpair.getRegionZ())); } public synchronized boolean chunkExists(ChunkPos pos) throws IOException { - RegionFile regionfile = getRegionFile(pos, true); -+ top.leavesmc.leaves.region.AbstractRegionFile regionfile = getRegionFile(pos, true); // Leaves ++ org.leavesmc.leaves.region.AbstractRegionFile regionfile = getRegionFile(pos, true); // Leaves return regionfile != null ? regionfile.hasChunk(pos) : false; } - public synchronized RegionFile getRegionFile(ChunkPos chunkcoordintpair, boolean existingOnly) throws IOException { // CraftBukkit -+ // Leaves start -+ private void guardAgainstBrokenSymlinks(Path path) throws IOException { -+ if (!linearCrashOnBrokenSymlink) { -+ return; -+ } -+ if (this.format != top.leavesmc.leaves.region.RegionFileFormat.LINEAR) { -+ return; -+ } -+ if (!java.nio.file.Files.isSymbolicLink(path)) { -+ return; -+ } -+ Path link = java.nio.file.Files.readSymbolicLink(path); -+ if (!java.nio.file.Files.exists(link) || !java.nio.file.Files.isReadable(link)) { -+ top.leavesmc.leaves.LeavesLogger.LOGGER.log(java.util.logging.Level.SEVERE, "Linear region file {} is a broken symbolic link, crashing to prevent data loss", path); -+ net.minecraft.server.MinecraftServer.getServer().halt(false); -+ throw new IOException("Linear region file " + path + " is a broken symbolic link, crashing to prevent data loss"); -+ } -+ } -+ // Leaves end -+ -+ public synchronized top.leavesmc.leaves.region.AbstractRegionFile getRegionFile(ChunkPos chunkcoordintpair, boolean existingOnly) throws IOException { // CraftBukkit // Leaves ++ public synchronized org.leavesmc.leaves.region.AbstractRegionFile getRegionFile(ChunkPos chunkcoordintpair, boolean existingOnly) throws IOException { // CraftBukkit // Leaves return this.getRegionFile(chunkcoordintpair, existingOnly, false); } - public synchronized RegionFile getRegionFile(ChunkPos chunkcoordintpair, boolean existingOnly, boolean lock) throws IOException { -+ public synchronized top.leavesmc.leaves.region.AbstractRegionFile getRegionFile(ChunkPos chunkcoordintpair, boolean existingOnly, boolean lock) throws IOException { // Leaves ++ public synchronized org.leavesmc.leaves.region.AbstractRegionFile getRegionFile(ChunkPos chunkcoordintpair, boolean existingOnly, boolean lock) throws IOException { // Leaves // Paper end long i = ChunkPos.asLong(chunkcoordintpair.getRegionX(), chunkcoordintpair.getRegionZ()); final long regionPos = i; // Paper - OBFHELPER - RegionFile regionfile = (RegionFile) this.regionCache.getAndMoveToFirst(i); -+ top.leavesmc.leaves.region.AbstractRegionFile regionfile = this.regionCache.getAndMoveToFirst(i); // Leaves ++ org.leavesmc.leaves.region.AbstractRegionFile regionfile = this.regionCache.getAndMoveToFirst(i); // Leaves if (regionfile != null) { // Paper start @@ -311,7 +284,7 @@ index fe312b1aef579cb4bf81bdd967cf72ff880d7505..756c69066ad5336c8faffd22dd48f2ec } // Paper end return regionfile; -@@ -123,28 +153,46 @@ public class RegionFileStorage implements AutoCloseable { +@@ -125,28 +133,40 @@ public class RegionFileStorage implements AutoCloseable { } // Paper end - cache regionfile does not exist state if (this.regionCache.size() >= io.papermc.paper.configuration.GlobalConfiguration.get().misc.regionFileCacheSize) { // Paper - Sanitise RegionFileCache and make configurable @@ -331,32 +304,25 @@ index fe312b1aef579cb4bf81bdd967cf72ff880d7505..756c69066ad5336c8faffd22dd48f2ec + if (existingOnly) { + Path anvil = path.resolve("r." + j + "." + chunkcoordintpair.getRegionZ() + ".mca"); + Path linear = path.resolve("r." + j + "." + chunkcoordintpair.getRegionZ() + ".linear"); -+ guardAgainstBrokenSymlinks(linear); -+ if (java.nio.file.Files.exists(anvil)) { -+ path1 = anvil; -+ } else if (java.nio.file.Files.exists(linear)) { -+ path1 = linear; -+ } else { -+ this.markNonExisting(regionPos); -+ return null; ++ path1 = java.nio.file.Files.exists(linear) ? linear : java.nio.file.Files.exists(anvil) ? anvil : null; ++ if (path1 == null) { ++ markNonExisting(regionPos); ++ return null; // CraftBukkit + } -+ // Leaves end } else { -+ // Leaves start - Polyglot + String extension = switch (this.format) { + case LINEAR -> "linear"; + default -> "mca"; + }; + path1 = path.resolve("r." + j + "." + chunkcoordintpair.getRegionZ() + "." + extension); -+ // Leaves end -+ guardAgainstBrokenSymlinks(path1); // Leaves - Crash on broken symlink ++ // Leaves end - Polyglot this.createRegionFile(regionPos); } // Paper end - cache regionfile does not exist state FileUtil.createDirectoriesSafe(this.folder); // Paper - only create directory if not existing only - moved from above -- RegionFile regionfile1 = new RegionFile(path1, this.folder, this.sync, this.isChunkData); // Paper - allow for chunk regionfiles to regen header -- -+ top.leavesmc.leaves.region.AbstractRegionFile regionfile1 = top.leavesmc.leaves.region.AbstractRegionFileFactory.getAbstractRegionFile(this.linearCompression, path1, this.folder, this.sync, this.isChunkData); // Paper - allow for chunk regionfiles to regen header // Leaves +- RegionFile regionfile1 = new RegionFile(this.info, path1, this.folder, this.sync, this.isChunkData); // Paper - allow for chunk regionfiles to regen header ++ org.leavesmc.leaves.region.AbstractRegionFile regionfile1 = org.leavesmc.leaves.region.AbstractRegionFileFactory.getAbstractRegionFile(this.linearCompression, this.info, path1, this.folder, this.sync, this.isChunkData); // Paper - allow for chunk regionfiles to regen header // Leaves + this.regionCache.putAndMoveToFirst(i, regionfile1); // Paper start if (lock) { @@ -366,21 +332,21 @@ index fe312b1aef579cb4bf81bdd967cf72ff880d7505..756c69066ad5336c8faffd22dd48f2ec } // Paper end return regionfile1; -@@ -156,7 +204,7 @@ public class RegionFileStorage implements AutoCloseable { +@@ -158,7 +178,7 @@ public class RegionFileStorage implements AutoCloseable { 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."); } - private static CompoundTag readOversizedChunk(RegionFile regionfile, ChunkPos chunkCoordinate) throws IOException { -+ private static CompoundTag readOversizedChunk(top.leavesmc.leaves.region.AbstractRegionFile regionfile, ChunkPos chunkCoordinate) throws IOException { // Leaves ++ private static CompoundTag readOversizedChunk(org.leavesmc.leaves.region.AbstractRegionFile regionfile, ChunkPos chunkCoordinate) throws IOException { // Leaves synchronized (regionfile) { try (DataInputStream datainputstream = regionfile.getChunkDataInputStream(chunkCoordinate)) { CompoundTag oversizedData = regionfile.getOversizedData(chunkCoordinate.x, chunkCoordinate.z); -@@ -191,14 +239,14 @@ public class RegionFileStorage implements AutoCloseable { +@@ -193,14 +213,14 @@ public class RegionFileStorage implements AutoCloseable { @Nullable public CompoundTag read(ChunkPos pos) throws IOException { // CraftBukkit start - SPIGOT-5680: There's no good reason to preemptively create files on read, save that for writing - RegionFile regionfile = this.getRegionFile(pos, true, true); // Paper -+ top.leavesmc.leaves.region.AbstractRegionFile regionfile = this.getRegionFile(pos, true, true); // Paper // Leaves ++ org.leavesmc.leaves.region.AbstractRegionFile regionfile = this.getRegionFile(pos, true, true); // Paper // Leaves if (regionfile == null) { return null; } @@ -388,36 +354,36 @@ index fe312b1aef579cb4bf81bdd967cf72ff880d7505..756c69066ad5336c8faffd22dd48f2ec return this.read(pos, regionfile); } - public CompoundTag read(ChunkPos pos, RegionFile regionfile) throws IOException { -+ public CompoundTag read(ChunkPos pos, top.leavesmc.leaves.region.AbstractRegionFile regionfile) throws IOException { // Leaves ++ public CompoundTag read(ChunkPos pos, org.leavesmc.leaves.region.AbstractRegionFile regionfile) throws IOException { // Leaves // We add the regionfile parameter to avoid the potential deadlock (on fileLock) if we went back to obtain a regionfile // if we decide to re-read // Paper end -@@ -208,7 +256,7 @@ public class RegionFileStorage implements AutoCloseable { +@@ -210,7 +230,7 @@ public class RegionFileStorage implements AutoCloseable { // Paper start if (regionfile.isOversized(pos.x, pos.z)) { -- printOversizedLog("Loading Oversized Chunk!", regionfile.regionFile, pos.x, pos.z); +- printOversizedLog("Loading Oversized Chunk!", regionfile.getPath(), pos.x, pos.z); + printOversizedLog("Loading Oversized Chunk!", regionfile.getRegionFile(), pos.x, pos.z); // Leaves return readOversizedChunk(regionfile, pos); } // Paper end -@@ -222,12 +270,12 @@ public class RegionFileStorage implements AutoCloseable { +@@ -224,12 +244,12 @@ public class RegionFileStorage implements AutoCloseable { if (this.isChunkData) { ChunkPos chunkPos = ChunkSerializer.getChunkCoordinate(nbttagcompound); if (!chunkPos.equals(pos)) { -- net.minecraft.server.MinecraftServer.LOGGER.error("Attempting to read chunk data at " + pos + " but got chunk data for " + chunkPos + " instead! Attempting regionfile recalculation for regionfile " + regionfile.regionFile.toAbsolutePath()); +- net.minecraft.server.MinecraftServer.LOGGER.error("Attempting to read chunk data at " + pos + " but got chunk data for " + chunkPos + " instead! Attempting regionfile recalculation for regionfile " + regionfile.getPath().toAbsolutePath()); + net.minecraft.server.MinecraftServer.LOGGER.error("Attempting to read chunk data at " + pos + " but got chunk data for " + chunkPos + " instead! Attempting regionfile recalculation for regionfile " + regionfile.getRegionFile().toAbsolutePath()); // Leaves if (regionfile.recalculateHeader()) { - regionfile.fileLock.lock(); // otherwise we will unlock twice and only lock once. + regionfile.getFileLock().lock(); // otherwise we will unlock twice and only lock once. // Leaves return this.read(pos, regionfile); } -- net.minecraft.server.MinecraftServer.LOGGER.error("Can't recalculate regionfile header, regenerating chunk " + pos + " for " + regionfile.regionFile.toAbsolutePath()); +- net.minecraft.server.MinecraftServer.LOGGER.error("Can't recalculate regionfile header, regenerating chunk " + pos + " for " + regionfile.getPath().toAbsolutePath()); + net.minecraft.server.MinecraftServer.LOGGER.error("Can't recalculate regionfile header, regenerating chunk " + pos + " for " + regionfile.getRegionFile().toAbsolutePath()); // Leaves return null; } } -@@ -261,13 +309,13 @@ public class RegionFileStorage implements AutoCloseable { +@@ -263,13 +283,13 @@ public class RegionFileStorage implements AutoCloseable { return nbttagcompound; } finally { // Paper start @@ -429,20 +395,20 @@ index fe312b1aef579cb4bf81bdd967cf72ff880d7505..756c69066ad5336c8faffd22dd48f2ec public void scanChunk(ChunkPos chunkPos, StreamTagVisitor scanner) throws IOException { // CraftBukkit start - SPIGOT-5680: There's no good reason to preemptively create files on read, save that for writing - RegionFile regionfile = this.getRegionFile(chunkPos, true); -+ top.leavesmc.leaves.region.AbstractRegionFile regionfile = this.getRegionFile(chunkPos, true); // Leaves ++ org.leavesmc.leaves.region.AbstractRegionFile regionfile = this.getRegionFile(chunkPos, true); // Leaves if (regionfile == null) { return; } -@@ -298,7 +346,7 @@ public class RegionFileStorage implements AutoCloseable { +@@ -300,7 +320,7 @@ public class RegionFileStorage implements AutoCloseable { protected void write(ChunkPos pos, @Nullable CompoundTag nbt) throws IOException { // Paper start - rewrite chunk system - RegionFile regionfile = this.getRegionFile(pos, nbt == null, true); // CraftBukkit -+ top.leavesmc.leaves.region.AbstractRegionFile regionfile = this.getRegionFile(pos, nbt == null, true); // CraftBukkit // Paper // Paper start - rewrite chunk system // Leaves ++ org.leavesmc.leaves.region.AbstractRegionFile regionfile = this.getRegionFile(pos, nbt == null, true); // CraftBukkit // Paper // Paper start - rewrite chunk system // Leaves if (nbt == null && regionfile == null) { return; } -@@ -313,8 +361,33 @@ public class RegionFileStorage implements AutoCloseable { +@@ -315,8 +335,33 @@ public class RegionFileStorage implements AutoCloseable { if (nbt == null) { regionfile.clear(pos); } else { @@ -450,9 +416,9 @@ index fe312b1aef579cb4bf81bdd967cf72ff880d7505..756c69066ad5336c8faffd22dd48f2ec + // Leaves start - auto convert anvil to linear + DataOutputStream dataoutputstream; + -+ if(regionfile instanceof RegionFile && top.leavesmc.leaves.LeavesConfig.regionFormatName == top.leavesmc.leaves.region.RegionFileFormat.LINEAR && top.leavesmc.leaves.LeavesConfig.autoConvertAnvilToLinear) { ++ if(regionfile instanceof RegionFile && org.leavesmc.leaves.LeavesConfig.regionFormatName == org.leavesmc.leaves.region.RegionFileFormat.LINEAR && org.leavesmc.leaves.LeavesConfig.autoConvertAnvilToLinear) { + Path linearFilePath = Path.of(regionfile.getRegionFile().toString().replaceAll(".mca", ".linear")); -+ try (top.leavesmc.leaves.region.LinearRegionFile linearRegionFile = new top.leavesmc.leaves.region.LinearRegionFile(linearFilePath, top.leavesmc.leaves.LeavesConfig.linearCompressionLevel)) { ++ try (org.leavesmc.leaves.region.LinearRegionFile linearRegionFile = new org.leavesmc.leaves.region.LinearRegionFile(linearFilePath, org.leavesmc.leaves.LeavesConfig.linearCompressionLevel)) { + DataInputStream regionDataInputStream = regionfile.getChunkDataInputStream(pos); + if (regionDataInputStream == null) { + continue; @@ -477,7 +443,7 @@ index fe312b1aef579cb4bf81bdd967cf72ff880d7505..756c69066ad5336c8faffd22dd48f2ec try { NbtIo.write(nbt, (DataOutput) dataoutputstream); regionfile.setStatus(pos.x, pos.z, ChunkSerializer.getStatus(nbt)); // Paper - Cache chunk status -@@ -353,7 +426,7 @@ public class RegionFileStorage implements AutoCloseable { +@@ -355,7 +400,7 @@ public class RegionFileStorage implements AutoCloseable { // Paper end - Chunk save reattempt // Paper start - rewrite chunk system } finally { @@ -486,48 +452,48 @@ index fe312b1aef579cb4bf81bdd967cf72ff880d7505..756c69066ad5336c8faffd22dd48f2ec } // Paper end - rewrite chunk system } -@@ -363,7 +436,7 @@ public class RegionFileStorage implements AutoCloseable { +@@ -365,7 +410,7 @@ public class RegionFileStorage implements AutoCloseable { ObjectIterator objectiterator = this.regionCache.values().iterator(); while (objectiterator.hasNext()) { - RegionFile regionfile = (RegionFile) objectiterator.next(); -+ top.leavesmc.leaves.region.AbstractRegionFile regionfile = (top.leavesmc.leaves.region.AbstractRegionFile) objectiterator.next(); // Leaves ++ org.leavesmc.leaves.region.AbstractRegionFile regionfile = (org.leavesmc.leaves.region.AbstractRegionFile) objectiterator.next(); // Leaves try { regionfile.close(); -@@ -379,7 +452,7 @@ public class RegionFileStorage implements AutoCloseable { +@@ -381,7 +426,7 @@ public class RegionFileStorage implements AutoCloseable { ObjectIterator objectiterator = this.regionCache.values().iterator(); while (objectiterator.hasNext()) { - RegionFile regionfile = (RegionFile) objectiterator.next(); -+ top.leavesmc.leaves.region.AbstractRegionFile regionfile = (top.leavesmc.leaves.region.AbstractRegionFile) objectiterator.next(); // Leaves ++ org.leavesmc.leaves.region.AbstractRegionFile regionfile = (org.leavesmc.leaves.region.AbstractRegionFile) objectiterator.next(); // Leaves regionfile.flush(); } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index 88ab671678da7617d8e22176d64b69101e7f4a33..946d1c4457337b98a8d8cb865c7474cf7874ac36 100644 +index ab4510eb9e5eaca46e3278c73e208757292a9f90..c5a89cfe1eae92c624565a0e4185c6969f2708c6 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -@@ -574,7 +574,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -584,7 +584,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { world.getChunk(x, z); // make sure we're at ticket level 32 or lower return true; } - net.minecraft.world.level.chunk.storage.RegionFile file; -+ top.leavesmc.leaves.region.AbstractRegionFile file; // Leaves ++ org.leavesmc.leaves.region.AbstractRegionFile file; // Leaves try { file = world.getChunkSource().chunkMap.regionFileCache.getRegionFile(chunkPos, false); } catch (java.io.IOException ex) { -diff --git a/src/main/java/top/leavesmc/leaves/region/AbstractRegionFile.java b/src/main/java/top/leavesmc/leaves/region/AbstractRegionFile.java +diff --git a/src/main/java/org/leavesmc/leaves/region/AbstractRegionFile.java b/src/main/java/org/leavesmc/leaves/region/AbstractRegionFile.java new file mode 100644 -index 0000000000000000000000000000000000000000..835b6d3726eda2573f616463d744cb5f6233e01c +index 0000000000000000000000000000000000000000..2116a2e7e10e64aad1373171c6efde65de6ca198 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/region/AbstractRegionFile.java ++++ b/src/main/java/org/leavesmc/leaves/region/AbstractRegionFile.java @@ -0,0 +1,45 @@ -+package top.leavesmc.leaves.region; ++package org.leavesmc.leaves.region; + +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.level.ChunkPos; -+import net.minecraft.world.level.chunk.ChunkStatus; ++import net.minecraft.world.level.chunk.status.ChunkStatus; + +import java.io.DataInputStream; +import java.io.DataOutputStream; @@ -568,49 +534,50 @@ index 0000000000000000000000000000000000000000..835b6d3726eda2573f616463d744cb5f + Path getRegionFile(); +} + -diff --git a/src/main/java/top/leavesmc/leaves/region/AbstractRegionFileFactory.java b/src/main/java/top/leavesmc/leaves/region/AbstractRegionFileFactory.java +diff --git a/src/main/java/org/leavesmc/leaves/region/AbstractRegionFileFactory.java b/src/main/java/org/leavesmc/leaves/region/AbstractRegionFileFactory.java new file mode 100644 -index 0000000000000000000000000000000000000000..980744f9b620a19fede7a6c7ce341bf5275a9b6a +index 0000000000000000000000000000000000000000..8050b23fd624d2462200b621a6d711b144b2b46b --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/region/AbstractRegionFileFactory.java -@@ -0,0 +1,30 @@ -+package top.leavesmc.leaves.region; ++++ b/src/main/java/org/leavesmc/leaves/region/AbstractRegionFileFactory.java +@@ -0,0 +1,31 @@ ++package org.leavesmc.leaves.region; + +import net.minecraft.world.level.chunk.storage.RegionFile; +import net.minecraft.world.level.chunk.storage.RegionFileVersion; ++import net.minecraft.world.level.chunk.storage.RegionStorageInfo; + +import java.io.IOException; +import java.nio.file.Path; + +public class AbstractRegionFileFactory { + -+ public static AbstractRegionFile getAbstractRegionFile(int linearCompression, Path file, Path directory, boolean dsync) throws IOException { -+ return getAbstractRegionFile(linearCompression, file, directory, RegionFileVersion.VERSION_DEFLATE, dsync); ++ public static AbstractRegionFile getAbstractRegionFile(int linearCompression, RegionStorageInfo storageKey, Path file, Path directory, boolean dsync) throws IOException { ++ return getAbstractRegionFile(linearCompression, storageKey, file, directory, RegionFileVersion.VERSION_DEFLATE, dsync); + } + -+ public static AbstractRegionFile getAbstractRegionFile(int linearCompression, Path file, Path directory, boolean dsync, boolean canRecalcHeader) throws IOException { -+ return getAbstractRegionFile(linearCompression, file, directory, RegionFileVersion.VERSION_DEFLATE, dsync, canRecalcHeader); ++ public static AbstractRegionFile getAbstractRegionFile(int linearCompression, RegionStorageInfo storageKey, Path file, Path directory, boolean dsync, boolean canRecalcHeader) throws IOException { ++ return getAbstractRegionFile(linearCompression, storageKey, file, directory, RegionFileVersion.VERSION_DEFLATE, dsync, canRecalcHeader); + } + -+ public static AbstractRegionFile getAbstractRegionFile(int linearCompression, Path file, Path directory, RegionFileVersion outputChunkStreamVersion, boolean dsync) throws IOException { -+ return getAbstractRegionFile(linearCompression, file, directory, outputChunkStreamVersion, dsync, false); ++ public static AbstractRegionFile getAbstractRegionFile(int linearCompression, RegionStorageInfo storageKey, Path file, Path directory, RegionFileVersion outputChunkStreamVersion, boolean dsync) throws IOException { ++ return getAbstractRegionFile(linearCompression, storageKey, file, directory, outputChunkStreamVersion, dsync, false); + } + -+ public static AbstractRegionFile getAbstractRegionFile(int linearCompression, Path file, Path directory, RegionFileVersion outputChunkStreamVersion, boolean dsync, boolean canRecalcHeader) throws IOException { ++ public static AbstractRegionFile getAbstractRegionFile(int linearCompression, RegionStorageInfo storageKey, Path file, Path directory, RegionFileVersion outputChunkStreamVersion, boolean dsync, boolean canRecalcHeader) throws IOException { + if (file.toString().endsWith(".linear")) { + return new LinearRegionFile(file, linearCompression); + } else { -+ return new RegionFile(file, directory, outputChunkStreamVersion, dsync, canRecalcHeader); ++ return new RegionFile(storageKey, file, directory, outputChunkStreamVersion, dsync, canRecalcHeader); + } + } +} -diff --git a/src/main/java/top/leavesmc/leaves/region/LinearRegionFile.java b/src/main/java/top/leavesmc/leaves/region/LinearRegionFile.java +diff --git a/src/main/java/org/leavesmc/leaves/region/LinearRegionFile.java b/src/main/java/org/leavesmc/leaves/region/LinearRegionFile.java new file mode 100644 -index 0000000000000000000000000000000000000000..072495e6c0c08a3239faab0fb6ebb28451039694 +index 0000000000000000000000000000000000000000..dd57eea25d8a52b298c49e47f06108cbf8150160 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/region/LinearRegionFile.java -@@ -0,0 +1,328 @@ -+package top.leavesmc.leaves.region; ++++ b/src/main/java/org/leavesmc/leaves/region/LinearRegionFile.java +@@ -0,0 +1,330 @@ ++package org.leavesmc.leaves.region; + +import com.github.luben.zstd.ZstdInputStream; +import com.github.luben.zstd.ZstdOutputStream; @@ -620,7 +587,7 @@ index 0000000000000000000000000000000000000000..072495e6c0c08a3239faab0fb6ebb284 +import net.jpountz.lz4.LZ4FastDecompressor; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.level.ChunkPos; -+import net.minecraft.world.level.chunk.ChunkStatus; ++import net.minecraft.world.level.chunk.status.ChunkStatus; +import org.slf4j.Logger; + +import javax.annotation.Nullable; @@ -673,7 +640,9 @@ index 0000000000000000000000000000000000000000..072495e6c0c08a3239faab0fb6ebb284 + + Arrays.fill(this.bufferUncompressedSize, 0); + -+ if (!regionFile.canRead()) return; ++ if (!regionFile.canRead()) { ++ return; ++ } + + try (FileInputStream fileStream = new FileInputStream(regionFile); + DataInputStream rawDataStream = new DataInputStream(fileStream)) { @@ -938,13 +907,13 @@ index 0000000000000000000000000000000000000000..072495e6c0c08a3239faab0fb6ebb284 + return false; + } +} -diff --git a/src/main/java/top/leavesmc/leaves/region/LinearRegionFileFlusher.java b/src/main/java/top/leavesmc/leaves/region/LinearRegionFileFlusher.java +diff --git a/src/main/java/org/leavesmc/leaves/region/LinearRegionFileFlusher.java b/src/main/java/org/leavesmc/leaves/region/LinearRegionFileFlusher.java new file mode 100644 -index 0000000000000000000000000000000000000000..fd8ec703b1be35ef3c29afd4abe2dfaf8bdc5c61 +index 0000000000000000000000000000000000000000..d452d704c54b211be6becd41d12862ba33553c1f --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/region/LinearRegionFileFlusher.java -@@ -0,0 +1,52 @@ -+package top.leavesmc.leaves.region; ++++ b/src/main/java/org/leavesmc/leaves/region/LinearRegionFileFlusher.java +@@ -0,0 +1,53 @@ ++package org.leavesmc.leaves.region; + +import com.google.common.util.concurrent.ThreadFactoryBuilder; + @@ -952,7 +921,8 @@ index 0000000000000000000000000000000000000000..fd8ec703b1be35ef3c29afd4abe2dfaf +import java.util.concurrent.*; + +import org.bukkit.Bukkit; -+import top.leavesmc.leaves.LeavesConfig; ++import org.leavesmc.leaves.LeavesConfig; ++import org.leavesmc.leaves.LeavesLogger; + +// Powered by LinearPurpur(https://github.com/StupidCraft/LinearPurpur) +public class LinearRegionFileFlusher { @@ -970,7 +940,7 @@ index 0000000000000000000000000000000000000000..fd8ec703b1be35ef3c29afd4abe2dfaf + ); + + public LinearRegionFileFlusher() { -+ Bukkit.getLogger().info("Using " + LeavesConfig.getLinearFlushThreads() + " threads for linear region flushing."); ++ LeavesLogger.LOGGER.info("Using " + LeavesConfig.getLinearFlushThreads() + " threads for linear region flushing."); + scheduler.scheduleAtFixedRate(this::pollAndFlush, 0L, LeavesConfig.linearFlushFrequency, TimeUnit.SECONDS); + } + @@ -996,13 +966,13 @@ index 0000000000000000000000000000000000000000..fd8ec703b1be35ef3c29afd4abe2dfaf + } +} + -diff --git a/src/main/java/top/leavesmc/leaves/region/RegionFileFormat.java b/src/main/java/top/leavesmc/leaves/region/RegionFileFormat.java +diff --git a/src/main/java/org/leavesmc/leaves/region/RegionFileFormat.java b/src/main/java/org/leavesmc/leaves/region/RegionFileFormat.java new file mode 100644 -index 0000000000000000000000000000000000000000..a9a8e79557fac57e29b64e7e55fc04b80ad11ae3 +index 0000000000000000000000000000000000000000..3651246acf3dd786eb6a85c7a846a248962cdd7f --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/region/RegionFileFormat.java ++++ b/src/main/java/org/leavesmc/leaves/region/RegionFileFormat.java @@ -0,0 +1,14 @@ -+package top.leavesmc.leaves.region; ++package org.leavesmc.leaves.region; + +public enum RegionFileFormat { + ANVIL, LINEAR, INVALID; diff --git a/patches/server/0125-Protection-stacking.patch b/patches/server/0124-Protection-stacking.patch similarity index 82% rename from patches/server/0125-Protection-stacking.patch rename to patches/server/0124-Protection-stacking.patch index dc685297..3a1d8fcd 100644 --- a/patches/server/0125-Protection-stacking.patch +++ b/patches/server/0124-Protection-stacking.patch @@ -5,15 +5,15 @@ Subject: [PATCH] Protection stacking diff --git a/src/main/java/net/minecraft/world/item/enchantment/ProtectionEnchantment.java b/src/main/java/net/minecraft/world/item/enchantment/ProtectionEnchantment.java -index 6a75ede277c2515214ce5181d177edd8e0006ab7..28451f664f39f23fe7102cfeef85e2962cca35b3 100644 +index 8f30cdd7f9f43e5a1d100f6c6d25fb54475289f1..d3942f1df56f8e265179ea81c7bafdc3dfe9e40a 100644 --- a/src/main/java/net/minecraft/world/item/enchantment/ProtectionEnchantment.java +++ b/src/main/java/net/minecraft/world/item/enchantment/ProtectionEnchantment.java -@@ -48,6 +48,11 @@ public class ProtectionEnchantment extends Enchantment { +@@ -32,6 +32,11 @@ public class ProtectionEnchantment extends Enchantment { @Override public boolean checkCompatibility(Enchantment other) { + // Leaves start - protection stacking -+ if (top.leavesmc.leaves.LeavesConfig.protectionStacking) { ++ if (org.leavesmc.leaves.LeavesConfig.protectionStacking) { + return super.checkCompatibility(other); + } + // Leaves end - protection stacking diff --git a/patches/server/0126-No-TNT-place-update.patch b/patches/server/0125-No-TNT-place-update.patch similarity index 78% rename from patches/server/0126-No-TNT-place-update.patch rename to patches/server/0125-No-TNT-place-update.patch index b6e1d045..5bd1a44e 100644 --- a/patches/server/0126-No-TNT-place-update.patch +++ b/patches/server/0125-No-TNT-place-update.patch @@ -5,15 +5,15 @@ Subject: [PATCH] No TNT place update diff --git a/src/main/java/net/minecraft/world/level/block/TntBlock.java b/src/main/java/net/minecraft/world/level/block/TntBlock.java -index 5fa5e8c838720eb1491aea73d462f4bc7d779956..b2835cabbe6235d6e7a99349bdd22a7244f2b38a 100644 +index a5e1813ba4fee55f469d5c4884124fccecd908d2..52af38f35b47e43fa328f66d969b7b5f6c2cc915 100644 --- a/src/main/java/net/minecraft/world/level/block/TntBlock.java +++ b/src/main/java/net/minecraft/world/level/block/TntBlock.java -@@ -48,7 +48,7 @@ public class TntBlock extends Block { +@@ -49,7 +49,7 @@ public class TntBlock extends Block { @Override - public void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) { + protected void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) { if (!oldState.is(state.getBlock())) { - if (world.hasNeighborSignal(pos) && CraftEventFactory.callTNTPrimeEvent(world, pos, PrimeCause.REDSTONE, null, null)) { // CraftBukkit - TNTPrimeEvent -+ if (!top.leavesmc.leaves.LeavesConfig.noTNTPlaceUpdate && world.hasNeighborSignal(pos) && CraftEventFactory.callTNTPrimeEvent(world, pos, PrimeCause.REDSTONE, null, null)) { // CraftBukkit - TNTPrimeEvent // Leaves - No tnt place update ++ if (!org.leavesmc.leaves.LeavesConfig.noTNTPlaceUpdate && world.hasNeighborSignal(pos) && CraftEventFactory.callTNTPrimeEvent(world, pos, PrimeCause.REDSTONE, null, null)) { // CraftBukkit - TNTPrimeEvent // Leaves - No tnt place update // Paper start - TNTPrimeEvent org.bukkit.block.Block tntBlock = org.bukkit.craftbukkit.block.CraftBlock.at(world, pos); if (!new com.destroystokyo.paper.event.block.TNTPrimeEvent(tntBlock, com.destroystokyo.paper.event.block.TNTPrimeEvent.PrimeReason.REDSTONE, null).callEvent()) { diff --git a/patches/server/0127-Placing-locked-hopper-no-longer-send-NC-updates.patch b/patches/server/0126-Placing-locked-hopper-no-longer-send-NC-updates.patch similarity index 90% rename from patches/server/0127-Placing-locked-hopper-no-longer-send-NC-updates.patch rename to patches/server/0126-Placing-locked-hopper-no-longer-send-NC-updates.patch index c11cd03d..63aca758 100644 --- a/patches/server/0127-Placing-locked-hopper-no-longer-send-NC-updates.patch +++ b/patches/server/0126-Placing-locked-hopper-no-longer-send-NC-updates.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Placing locked hopper no longer send NC updates diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index b219ff03ae82b9d94ba32304671428cf9987329a..5734c5d07df65cbb01c7d5c130a6fd3a078e22bc 100644 +index fdf56caa8756f065f892847898f2b2b9af18f5c6..4da9144e2b6e711587b4f202953928d8a48199f5 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -49,6 +49,7 @@ import net.minecraft.world.level.biome.BiomeManager; +@@ -54,6 +54,7 @@ import net.minecraft.world.level.biome.BiomeManager; import net.minecraft.world.level.block.BaseFireBlock; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; diff --git a/patches/server/0128-Renewable-deepslate.patch b/patches/server/0127-Renewable-deepslate.patch similarity index 83% rename from patches/server/0128-Renewable-deepslate.patch rename to patches/server/0127-Renewable-deepslate.patch index 3a39ee6d..3d7b3acc 100644 --- a/patches/server/0128-Renewable-deepslate.patch +++ b/patches/server/0127-Renewable-deepslate.patch @@ -5,20 +5,20 @@ Subject: [PATCH] Renewable deepslate diff --git a/src/main/java/net/minecraft/world/level/block/LiquidBlock.java b/src/main/java/net/minecraft/world/level/block/LiquidBlock.java -index 9b3dcf1a4d4cece92a629506d341f6bfe79d13d0..22a9567329eb54acef0bb12122c5da9b5ef24792 100644 +index 84623c632d8c2f0fa7ec939c711316d757117d23..bba79516a7e3765d6b04992dfae310eb30f889ce 100644 --- a/src/main/java/net/minecraft/world/level/block/LiquidBlock.java +++ b/src/main/java/net/minecraft/world/level/block/LiquidBlock.java -@@ -192,7 +192,7 @@ public class LiquidBlock extends Block implements BucketPickup { +@@ -190,7 +190,7 @@ public class LiquidBlock extends Block implements BucketPickup { BlockPos blockposition1 = pos.relative(enumdirection.getOpposite()); if (world.getFluidState(blockposition1).is(FluidTags.WATER)) { - Block block = world.getFluidState(pos).isSource() ? Blocks.OBSIDIAN : Blocks.COBBLESTONE; -+ Block block = world.getFluidState(pos).isSource() ? Blocks.OBSIDIAN : (top.leavesmc.leaves.LeavesConfig.renewableDeepslate && world.dimension() == Level.OVERWORLD && pos.getY() < 0 ? Blocks.COBBLED_DEEPSLATE : Blocks.COBBLESTONE); // Leaves - renewable deepslate ++ Block block = world.getFluidState(pos).isSource() ? Blocks.OBSIDIAN : (org.leavesmc.leaves.LeavesConfig.renewableDeepslate && world.dimension() == Level.OVERWORLD && pos.getY() < 0 ? Blocks.COBBLED_DEEPSLATE : Blocks.COBBLESTONE); // Leaves - renewable deepslate // CraftBukkit start if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, pos, block.defaultBlockState())) { diff --git a/src/main/java/net/minecraft/world/level/material/LavaFluid.java b/src/main/java/net/minecraft/world/level/material/LavaFluid.java -index 3bb4a9a1a6249e8ba2de237f801210e7f4fd5825..f9d386db467b608430b3abcfc609594db8a29b76 100644 +index 3bb4a9a1a6249e8ba2de237f801210e7f4fd5825..8f849cd7ee32a2180fc46d5ee618add72b07de72 100644 --- a/src/main/java/net/minecraft/world/level/material/LavaFluid.java +++ b/src/main/java/net/minecraft/world/level/material/LavaFluid.java @@ -211,7 +211,7 @@ public abstract class LavaFluid extends FlowingFluid { @@ -26,7 +26,7 @@ index 3bb4a9a1a6249e8ba2de237f801210e7f4fd5825..f9d386db467b608430b3abcfc609594d if (state.getBlock() instanceof LiquidBlock) { // CraftBukkit start - if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world.getMinecraftWorld(), pos, Blocks.STONE.defaultBlockState(), 3)) { -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world.getMinecraftWorld(), pos, top.leavesmc.leaves.LeavesConfig.renewableDeepslate && world.getMinecraftWorld().dimension() == Level.OVERWORLD && pos.getY() < 0 ? Blocks.DEEPSLATE.defaultBlockState() : Blocks.STONE.defaultBlockState(), 3)) { // Leaves - renewable deepslate ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world.getMinecraftWorld(), pos, org.leavesmc.leaves.LeavesConfig.renewableDeepslate && world.getMinecraftWorld().dimension() == Level.OVERWORLD && pos.getY() < 0 ? Blocks.DEEPSLATE.defaultBlockState() : Blocks.STONE.defaultBlockState(), 3)) { // Leaves - renewable deepslate return; } // CraftBukkit end diff --git a/patches/server/0129-Renewable-sponges.patch b/patches/server/0128-Renewable-sponges.patch similarity index 83% rename from patches/server/0129-Renewable-sponges.patch rename to patches/server/0128-Renewable-sponges.patch index 477cc13d..5d1094d2 100644 --- a/patches/server/0129-Renewable-sponges.patch +++ b/patches/server/0128-Renewable-sponges.patch @@ -5,21 +5,21 @@ Subject: [PATCH] Renewable sponges diff --git a/src/main/java/net/minecraft/world/entity/monster/Guardian.java b/src/main/java/net/minecraft/world/entity/monster/Guardian.java -index fd41ef66e2e12ec3a888bb376ef4363343914fcd..2719623d856ad33fa1164c566fddd8bd24dfc8bd 100644 +index 6c2e2fd5826a5f8070502e20d1d140c3d70bd0d3..661a589b8b2e624a24ae8b1405d1b116a9220844 100644 --- a/src/main/java/net/minecraft/world/entity/monster/Guardian.java +++ b/src/main/java/net/minecraft/world/entity/monster/Guardian.java -@@ -364,6 +364,30 @@ public class Guardian extends Monster { - return new Vector3f(0.0F, dimensions.height + 0.125F * scaleFactor, 0.0F); +@@ -345,6 +345,30 @@ public class Guardian extends Monster { + } + // Leaves start - renewable sponges + + @Override + public void thunderHit(net.minecraft.server.level.ServerLevel world, net.minecraft.world.entity.LightningBolt lightning) { -+ if (top.leavesmc.leaves.LeavesConfig.renewableSponges && !this.isRemoved() && !(this instanceof ElderGuardian)) { ++ if (org.leavesmc.leaves.LeavesConfig.renewableSponges && !this.isRemoved() && !(this instanceof ElderGuardian)) { + ElderGuardian elderGuardian = new ElderGuardian(EntityType.ELDER_GUARDIAN ,this.level()); + elderGuardian.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot()); -+ elderGuardian.finalizeSpawn(world ,this.level().getCurrentDifficultyAt(elderGuardian.blockPosition()), MobSpawnType.CONVERSION, null, null); ++ elderGuardian.finalizeSpawn(world ,this.level().getCurrentDifficultyAt(elderGuardian.blockPosition()), MobSpawnType.CONVERSION, null); + elderGuardian.setNoAi(this.isNoAi()); + + if (this.hasCustomName()) { diff --git a/patches/server/0130-Renewable-coral.patch b/patches/server/0129-Renewable-coral.patch similarity index 84% rename from patches/server/0130-Renewable-coral.patch rename to patches/server/0129-Renewable-coral.patch index 6d31c834..be0351d9 100644 --- a/patches/server/0130-Renewable-coral.patch +++ b/patches/server/0129-Renewable-coral.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Renewable coral diff --git a/src/main/java/net/minecraft/world/level/block/CoralFanBlock.java b/src/main/java/net/minecraft/world/level/block/CoralFanBlock.java -index c13e8bf5d6dbe9af6c7f391eeac976575f75301f..c2c8527fabd5bf683076792d3b86c8a8e4449fe9 100644 +index 7701683000132479d8c8eaa77ac3f93e41a960be..3bd4308bb2b8cce5091486f5fc57fbc7cb24b202 100644 --- a/src/main/java/net/minecraft/world/level/block/CoralFanBlock.java +++ b/src/main/java/net/minecraft/world/level/block/CoralFanBlock.java @@ -13,7 +13,7 @@ import net.minecraft.world.level.block.state.BlockState; @@ -13,7 +13,7 @@ index c13e8bf5d6dbe9af6c7f391eeac976575f75301f..c2c8527fabd5bf683076792d3b86c8a8 import net.minecraft.world.level.material.Fluids; -public class CoralFanBlock extends BaseCoralFanBlock { -+public class CoralFanBlock extends BaseCoralFanBlock implements top.leavesmc.leaves.util.FertilizableCoral { // Leaves - renewable coral ++public class CoralFanBlock extends BaseCoralFanBlock implements org.leavesmc.leaves.util.FertilizableCoral { // Leaves - renewable coral public static final MapCodec CODEC = RecordCodecBuilder.mapCodec((instance) -> { return instance.group(CoralBlock.DEAD_CORAL_FIELD.forGetter((blockcoralfan) -> { @@ -25,12 +25,12 @@ index c13e8bf5d6dbe9af6c7f391eeac976575f75301f..c2c8527fabd5bf683076792d3b86c8a8 + // Leaves start - renewable coral + @Override + public boolean isEnabled() { -+ return top.leavesmc.leaves.LeavesConfig.renewableCoral == top.leavesmc.leaves.LeavesConfig.RenewableCoralType.EXPANDED; ++ return org.leavesmc.leaves.LeavesConfig.renewableCoral == org.leavesmc.leaves.LeavesConfig.RenewableCoralType.EXPANDED; + } + // Leaves end - renewable coral } diff --git a/src/main/java/net/minecraft/world/level/block/CoralPlantBlock.java b/src/main/java/net/minecraft/world/level/block/CoralPlantBlock.java -index b461508e9efcea07acc621507b4c27ce45307714..1473aa6fee5342398edb9e2ac57301ff9962a0fe 100644 +index 4c4aa2a63be84ff614a3dc0db2864266755545a2..208685f28509f92483f1efc89302e7a9ce6838c6 100644 --- a/src/main/java/net/minecraft/world/level/block/CoralPlantBlock.java +++ b/src/main/java/net/minecraft/world/level/block/CoralPlantBlock.java @@ -16,7 +16,7 @@ import net.minecraft.world.level.material.Fluids; @@ -38,28 +38,28 @@ index b461508e9efcea07acc621507b4c27ce45307714..1473aa6fee5342398edb9e2ac57301ff import net.minecraft.world.phys.shapes.VoxelShape; -public class CoralPlantBlock extends BaseCoralPlantTypeBlock { -+public class CoralPlantBlock extends BaseCoralPlantTypeBlock implements top.leavesmc.leaves.util.FertilizableCoral { // Leaves - renewable coral ++public class CoralPlantBlock extends BaseCoralPlantTypeBlock implements org.leavesmc.leaves.util.FertilizableCoral { // Leaves - renewable coral public static final MapCodec CODEC = RecordCodecBuilder.mapCodec((instance) -> { return instance.group(CoralBlock.DEAD_CORAL_FIELD.forGetter((blockcoralplant) -> { @@ -73,4 +73,12 @@ public class CoralPlantBlock extends BaseCoralPlantTypeBlock { - public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) { + protected VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) { return CoralPlantBlock.SHAPE; } + + // Leaves start - renewable coral + @Override + public boolean isEnabled() { -+ return top.leavesmc.leaves.LeavesConfig.renewableCoral == top.leavesmc.leaves.LeavesConfig.RenewableCoralType.EXPANDED -+ || top.leavesmc.leaves.LeavesConfig.renewableCoral == top.leavesmc.leaves.LeavesConfig.RenewableCoralType.TRUE; ++ return org.leavesmc.leaves.LeavesConfig.renewableCoral == org.leavesmc.leaves.LeavesConfig.RenewableCoralType.EXPANDED ++ || org.leavesmc.leaves.LeavesConfig.renewableCoral == org.leavesmc.leaves.LeavesConfig.RenewableCoralType.TRUE; + } + // Leaves end - renewable coral } diff --git a/src/main/java/net/minecraft/world/level/levelgen/feature/CoralFeature.java b/src/main/java/net/minecraft/world/level/levelgen/feature/CoralFeature.java -index 64c20f4dce1c93d6835ced2235532df77451216b..e83feb12522e77d3664b7c917118f7ef52bd7431 100644 +index 7bc5ff8eb1174834dcc27363af4a5cef19017b3d..e2fc5f9c5cc4ce6b5c1a0d0c43b753c1ca87bf72 100644 --- a/src/main/java/net/minecraft/world/level/levelgen/feature/CoralFeature.java +++ b/src/main/java/net/minecraft/world/level/levelgen/feature/CoralFeature.java -@@ -34,6 +34,12 @@ public abstract class CoralFeature extends Feature { +@@ -31,6 +31,12 @@ public abstract class CoralFeature extends Feature { return !optional.isEmpty() && this.placeFeature(worldGenLevel, randomSource, blockPos, optional.get().defaultBlockState()); } @@ -72,13 +72,13 @@ index 64c20f4dce1c93d6835ced2235532df77451216b..e83feb12522e77d3664b7c917118f7ef protected abstract boolean placeFeature(LevelAccessor world, RandomSource random, BlockPos pos, BlockState state); protected boolean placeCoralBlock(LevelAccessor world, RandomSource random, BlockPos pos, BlockState state) { -diff --git a/src/main/java/top/leavesmc/leaves/util/FertilizableCoral.java b/src/main/java/top/leavesmc/leaves/util/FertilizableCoral.java +diff --git a/src/main/java/org/leavesmc/leaves/util/FertilizableCoral.java b/src/main/java/org/leavesmc/leaves/util/FertilizableCoral.java new file mode 100644 -index 0000000000000000000000000000000000000000..575fdfd268626e89111c04a81a133d69c8adf931 +index 0000000000000000000000000000000000000000..d7110e2def699626939f6fdeb0e8c614e51346d2 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/util/FertilizableCoral.java ++++ b/src/main/java/org/leavesmc/leaves/util/FertilizableCoral.java @@ -0,0 +1,72 @@ -+package top.leavesmc.leaves.util; ++package org.leavesmc.leaves.util; + +import net.minecraft.core.BlockPos; +import net.minecraft.core.Holder; diff --git a/patches/server/0131-Fast-resume.patch b/patches/server/0130-Fast-resume.patch similarity index 90% rename from patches/server/0131-Fast-resume.patch rename to patches/server/0130-Fast-resume.patch index 6f287491..59e7adcb 100644 --- a/patches/server/0131-Fast-resume.patch +++ b/patches/server/0130-Fast-resume.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Fast resume diff --git a/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkHolderManager.java b/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkHolderManager.java -index c2eb3e8b019dbc0543a2308d7e88e324aa265cfe..22ffaeb54f618ccc8170d037eeaa4e25e798fc59 100644 +index b133b977bc7d452b5032809f84f8ac2ff96ae5bb..be8280d421a483b354f88d60117002181abe570b 100644 --- a/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkHolderManager.java +++ b/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkHolderManager.java @@ -566,6 +566,56 @@ public final class ChunkHolderManager { @@ -66,32 +66,32 @@ index c2eb3e8b019dbc0543a2308d7e88e324aa265cfe..22ffaeb54f618ccc8170d037eeaa4e25 return this.removeTicketAtLevel(type, CoordinateUtils.getChunkKey(chunkPos), level, identifier); } diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 9478d8da5d7c7c594d5629aba3042b5ef141da04..7d1cd7b98e44e0b6c0d1f29df25ad45c0946548d 100644 +index 5c03702896a837425dfa13fdd5db1056f9267a88..1fb5d965f33828067e44253bd50e4baeb09bfb0d 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -663,6 +663,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop -Date: Fri, 5 Apr 2024 12:32:17 +0800 -Subject: [PATCH] Fix next steps - - -diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index c4146a74a2a1a13bd09b04b8d6303cc932c400bf..c4a7839845919f5bcc513e845bd666fe0f24d6be 100644 ---- a/src/main/java/net/minecraft/server/MinecraftServer.java -+++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -1160,7 +1160,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { -+ if (top.leavesmc.leaves.LeavesConfig.pcaSyncProtocol) { -+ top.leavesmc.leaves.protocol.PcaSyncProtocol.syncEntityToClient(this); ++ if (org.leavesmc.leaves.LeavesConfig.pcaSyncProtocol) { ++ org.leavesmc.leaves.protocol.PcaSyncProtocol.syncEntityToClient(this); + } + }); + } @@ -52,8 +52,8 @@ index 756d0434472921992c9d84597d7c9c824e93614c..efb69fdb0095c3d730f2a4608f15bf47 - public void setChanged() {} + public void setChanged() { + // Leaves start - pca -+ if (top.leavesmc.leaves.LeavesConfig.pcaSyncProtocol) { -+ top.leavesmc.leaves.protocol.PcaSyncProtocol.syncEntityToClient(this); ++ if (org.leavesmc.leaves.LeavesConfig.pcaSyncProtocol) { ++ org.leavesmc.leaves.protocol.PcaSyncProtocol.syncEntityToClient(this); + } + // Leaves end - pca + } @@ -72,8 +72,8 @@ index 89d06253b00604114e543ebbe12a9993ae95dc41..cb0cb894df65e6d4d65b369955a7d7d7 + @Override + public void setChanged() { + super.setChanged(); -+ if (top.leavesmc.leaves.LeavesConfig.pcaSyncProtocol) { -+ top.leavesmc.leaves.protocol.PcaSyncProtocol.syncBlockEntityToClient(this); ++ if (org.leavesmc.leaves.LeavesConfig.pcaSyncProtocol) { ++ org.leavesmc.leaves.protocol.PcaSyncProtocol.syncBlockEntityToClient(this); + } + } + // Leaves end - pca @@ -93,8 +93,8 @@ index 416aa989ebb18a8741cc9d605a1180ab830f6643..213bc3c11ff4ed9bc761e8153aa669d1 + @Override + public void setChanged() { + super.setChanged(); -+ if (top.leavesmc.leaves.LeavesConfig.pcaSyncProtocol) { -+ top.leavesmc.leaves.protocol.PcaSyncProtocol.syncBlockEntityToClient(this); ++ if (org.leavesmc.leaves.LeavesConfig.pcaSyncProtocol) { ++ org.leavesmc.leaves.protocol.PcaSyncProtocol.syncBlockEntityToClient(this); + } + } + // Leaves end - pca @@ -119,8 +119,8 @@ index d445ed0895293dd45c36226051f5809be8587ebe..160df5cedf5d04c8a8d5d5375a898edc } + // Leaves start - pca -+ if (top.leavesmc.leaves.LeavesConfig.pcaSyncProtocol) { -+ top.leavesmc.leaves.protocol.PcaSyncProtocol.syncBlockEntityToClient(this); ++ if (org.leavesmc.leaves.LeavesConfig.pcaSyncProtocol) { ++ org.leavesmc.leaves.protocol.PcaSyncProtocol.syncBlockEntityToClient(this); + } + // Leaves end - pca return list; @@ -131,8 +131,8 @@ index d445ed0895293dd45c36226051f5809be8587ebe..160df5cedf5d04c8a8d5d5375a898edc } + // Leaves start - pca -+ if (top.leavesmc.leaves.LeavesConfig.pcaSyncProtocol) { -+ top.leavesmc.leaves.protocol.PcaSyncProtocol.syncBlockEntityToClient(this); ++ if (org.leavesmc.leaves.LeavesConfig.pcaSyncProtocol) { ++ org.leavesmc.leaves.protocol.PcaSyncProtocol.syncBlockEntityToClient(this); + } + // Leaves end - pca + @@ -144,8 +144,8 @@ index d445ed0895293dd45c36226051f5809be8587ebe..160df5cedf5d04c8a8d5d5375a898edc flag = true; iterator.remove(); + // Leaves start - pca -+ if (top.leavesmc.leaves.LeavesConfig.pcaSyncProtocol) { -+ top.leavesmc.leaves.protocol.PcaSyncProtocol.syncBlockEntityToClient(Objects.requireNonNull(world.getBlockEntity(pos))); ++ if (org.leavesmc.leaves.LeavesConfig.pcaSyncProtocol) { ++ org.leavesmc.leaves.protocol.PcaSyncProtocol.syncBlockEntityToClient(Objects.requireNonNull(world.getBlockEntity(pos))); + } + // Leaves end - pca // CraftBukkit start @@ -156,8 +156,8 @@ index d445ed0895293dd45c36226051f5809be8587ebe..160df5cedf5d04c8a8d5d5375a898edc } // CraftBukkit end + // Leaves start - pca -+ if (top.leavesmc.leaves.LeavesConfig.pcaSyncProtocol) { -+ top.leavesmc.leaves.protocol.PcaSyncProtocol.syncBlockEntityToClient(this); ++ if (org.leavesmc.leaves.LeavesConfig.pcaSyncProtocol) { ++ org.leavesmc.leaves.protocol.PcaSyncProtocol.syncBlockEntityToClient(this); + } + // Leaves end - pca } @@ -175,8 +175,8 @@ index 9bb542ce3a8c52e1688bb1f66fc916dd23a5fd10..7356c6e03e4823a87a9918ef164b9438 + @Override + public void setChanged() { + super.setChanged(); -+ if (top.leavesmc.leaves.LeavesConfig.pcaSyncProtocol) { -+ top.leavesmc.leaves.protocol.PcaSyncProtocol.syncBlockEntityToClient(this); ++ if (org.leavesmc.leaves.LeavesConfig.pcaSyncProtocol) { ++ org.leavesmc.leaves.protocol.PcaSyncProtocol.syncBlockEntityToClient(this); + } + } + // Leaves end - pca @@ -196,8 +196,8 @@ index 9b1243d96e0694c62fc9e82e9be540bce0d2b3ad..13e778bd47792deb571a5294bcf86cec + @Override + public void setChanged() { + super.setChanged(); -+ if (top.leavesmc.leaves.LeavesConfig.pcaSyncProtocol) { -+ top.leavesmc.leaves.protocol.PcaSyncProtocol.syncBlockEntityToClient(this); ++ if (org.leavesmc.leaves.LeavesConfig.pcaSyncProtocol) { ++ org.leavesmc.leaves.protocol.PcaSyncProtocol.syncBlockEntityToClient(this); + } + } + // Leaves end - pca @@ -217,8 +217,8 @@ index 9b2c162c362fcf6093a3bf6da715ae8f18176c82..84b877a712a883b868b139d29da7e09c + @Override + public void setChanged() { + super.setChanged(); -+ if (top.leavesmc.leaves.LeavesConfig.pcaSyncProtocol) { -+ top.leavesmc.leaves.protocol.PcaSyncProtocol.syncBlockEntityToClient(this); ++ if (org.leavesmc.leaves.LeavesConfig.pcaSyncProtocol) { ++ org.leavesmc.leaves.protocol.PcaSyncProtocol.syncBlockEntityToClient(this); + } + } + // Leaves end - pca @@ -238,8 +238,8 @@ index 881379681c39230a00b3a1f11cd87498984396c7..e01eb2025458cf311348c58a15308540 + @Override + public void setChanged() { + super.setChanged(); -+ if (top.leavesmc.leaves.LeavesConfig.pcaSyncProtocol) { -+ top.leavesmc.leaves.protocol.PcaSyncProtocol.syncBlockEntityToClient(this); ++ if (org.leavesmc.leaves.LeavesConfig.pcaSyncProtocol) { ++ org.leavesmc.leaves.protocol.PcaSyncProtocol.syncBlockEntityToClient(this); + } + } + // Leaves end - pca @@ -259,8 +259,8 @@ index cdb739df2a285032d25d84f4464f202a7a3fa578..cffc280655851e18439c9dfcb01ff69a + @Override + public void setChanged() { + super.setChanged(); -+ if (top.leavesmc.leaves.LeavesConfig.pcaSyncProtocol) { -+ top.leavesmc.leaves.protocol.PcaSyncProtocol.syncBlockEntityToClient(this); ++ if (org.leavesmc.leaves.LeavesConfig.pcaSyncProtocol) { ++ org.leavesmc.leaves.protocol.PcaSyncProtocol.syncBlockEntityToClient(this); + } + } + // Leaves end - pca @@ -273,8 +273,8 @@ index cdb739df2a285032d25d84f4464f202a7a3fa578..cffc280655851e18439c9dfcb01ff69a blockEntity.setCooldown(world.spigotConfig.hopperTransfer); // Spigot setChanged(world, pos, state); + // Leaves start - pca -+ if (top.leavesmc.leaves.LeavesConfig.pcaSyncProtocol) { -+ top.leavesmc.leaves.protocol.PcaSyncProtocol.syncBlockEntityToClient(blockEntity); ++ if (org.leavesmc.leaves.LeavesConfig.pcaSyncProtocol) { ++ org.leavesmc.leaves.protocol.PcaSyncProtocol.syncBlockEntityToClient(blockEntity); + } + // Leaves end - pca return true; @@ -292,8 +292,8 @@ index 1fa22445a4ecc8c08dbcf0cc6bd39dc5003604c4..5c311270a39f6b4996c8b58822d24556 + @Override + public void setChanged() { + super.setChanged(); -+ if (top.leavesmc.leaves.LeavesConfig.pcaSyncProtocol) { -+ top.leavesmc.leaves.protocol.PcaSyncProtocol.syncBlockEntityToClient(this); ++ if (org.leavesmc.leaves.LeavesConfig.pcaSyncProtocol) { ++ org.leavesmc.leaves.protocol.PcaSyncProtocol.syncBlockEntityToClient(this); + } + } + // Leaves end - pca @@ -301,13 +301,13 @@ index 1fa22445a4ecc8c08dbcf0cc6bd39dc5003604c4..5c311270a39f6b4996c8b58822d24556 @Override public int[] getSlotsForFace(Direction side) { return ShulkerBoxBlockEntity.SLOTS; -diff --git a/src/main/java/top/leavesmc/leaves/protocol/PcaSyncProtocol.java b/src/main/java/top/leavesmc/leaves/protocol/PcaSyncProtocol.java +diff --git a/src/main/java/org/leavesmc/leaves/protocol/PcaSyncProtocol.java b/src/main/java/org/leavesmc/leaves/protocol/PcaSyncProtocol.java new file mode 100644 index 0000000000000000000000000000000000000000..f4a7aed61511ad9557c8cc4779229b3bf79159dd --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/protocol/PcaSyncProtocol.java ++++ b/src/main/java/org/leavesmc/leaves/protocol/PcaSyncProtocol.java @@ -0,0 +1,389 @@ -+package top.leavesmc.leaves.protocol; ++package org.leavesmc.leaves.protocol; + +import net.minecraft.core.BlockPos; +import net.minecraft.nbt.CompoundTag; @@ -330,12 +330,12 @@ index 0000000000000000000000000000000000000000..f4a7aed61511ad9557c8cc4779229b3b +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; -+import top.leavesmc.leaves.LeavesConfig; -+import top.leavesmc.leaves.LeavesLogger; -+import top.leavesmc.leaves.bot.ServerBot; -+import top.leavesmc.leaves.protocol.core.LeavesProtocol; -+import top.leavesmc.leaves.protocol.core.ProtocolHandler; -+import top.leavesmc.leaves.protocol.core.ProtocolUtils; ++import org.leavesmc.leaves.LeavesConfig; ++import org.leavesmc.leaves.LeavesLogger; ++import org.leavesmc.leaves.bot.ServerBot; ++import org.leavesmc.leaves.protocol.core.LeavesProtocol; ++import org.leavesmc.leaves.protocol.core.ProtocolHandler; ++import org.leavesmc.leaves.protocol.core.ProtocolUtils; + +import java.util.HashMap; +import java.util.HashSet; @@ -343,7 +343,7 @@ index 0000000000000000000000000000000000000000..f4a7aed61511ad9557c8cc4779229b3b +import java.util.Set; +import java.util.concurrent.locks.ReentrantLock; + -+import static top.leavesmc.leaves.protocol.core.LeavesProtocolManager.EmptyPayload; ++import static org.leavesmc.leaves.protocol.core.LeavesProtocolManager.EmptyPayload; + +@LeavesProtocol(namespace = "pca") +public class PcaSyncProtocol { diff --git a/patches/server/0038-BBOR-Protocol.patch b/patches/unapplied/server/0038-BBOR-Protocol.patch similarity index 94% rename from patches/server/0038-BBOR-Protocol.patch rename to patches/unapplied/server/0038-BBOR-Protocol.patch index 3bde093a..d8f944ac 100644 --- a/patches/server/0038-BBOR-Protocol.patch +++ b/patches/unapplied/server/0038-BBOR-Protocol.patch @@ -12,7 +12,7 @@ index c1a50cedca731c08f793ba3eba4210bc26824e16..82751434c31fe8825f32921f498fd015 entityplayer.getRecipeBook().sendInitialRecipeBook(entityplayer); } -+ top.leavesmc.leaves.protocol.BBORProtocol.onDataPackReload(); // Leaves - bbor ++ org.leavesmc.leaves.protocol.BBORProtocol.onDataPackReload(); // Leaves - bbor } public boolean isAllowCheatsForAllPlayers() { @@ -26,19 +26,19 @@ index ae746ebde8ba2aded37bc1c9b3c4acdfd5f9def0..344ebb91a1cd4c74d398ded5edd8ef68 this.loaded = loadedToWorld; + // Leaves start - bbor + if (loaded) { -+ top.leavesmc.leaves.protocol.BBORProtocol.onChunkLoaded(this); ++ org.leavesmc.leaves.protocol.BBORProtocol.onChunkLoaded(this); + } + // Leaves end - bbor } public Level getLevel() { -diff --git a/src/main/java/top/leavesmc/leaves/protocol/BBORProtocol.java b/src/main/java/top/leavesmc/leaves/protocol/BBORProtocol.java +diff --git a/src/main/java/org/leavesmc/leaves/protocol/BBORProtocol.java b/src/main/java/org/leavesmc/leaves/protocol/BBORProtocol.java new file mode 100644 index 0000000000000000000000000000000000000000..4e1e099f6f480ae694405f0b1f98f429e2653d31 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/protocol/BBORProtocol.java ++++ b/src/main/java/org/leavesmc/leaves/protocol/BBORProtocol.java @@ -0,0 +1,227 @@ -+package top.leavesmc.leaves.protocol; ++package org.leavesmc.leaves.protocol; + +import net.minecraft.core.BlockPos; +import net.minecraft.core.Registry; @@ -55,10 +55,10 @@ index 0000000000000000000000000000000000000000..4e1e099f6f480ae694405f0b1f98f429 +import net.minecraft.world.level.levelgen.structure.StructureStart; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; -+import top.leavesmc.leaves.LeavesConfig; -+import top.leavesmc.leaves.protocol.core.LeavesProtocol; -+import top.leavesmc.leaves.protocol.core.ProtocolHandler; -+import top.leavesmc.leaves.protocol.core.ProtocolUtils; ++import org.leavesmc.leaves.LeavesConfig; ++import org.leavesmc.leaves.protocol.core.LeavesProtocol; ++import org.leavesmc.leaves.protocol.core.ProtocolHandler; ++import org.leavesmc.leaves.protocol.core.ProtocolUtils; + +import java.util.HashMap; +import java.util.HashSet; @@ -67,7 +67,7 @@ index 0000000000000000000000000000000000000000..4e1e099f6f480ae694405f0b1f98f429 +import java.util.concurrent.ConcurrentHashMap; +import java.util.stream.Collectors; + -+import static top.leavesmc.leaves.protocol.core.LeavesProtocolManager.EmptyPayload; ++import static org.leavesmc.leaves.protocol.core.LeavesProtocolManager.EmptyPayload; + +@LeavesProtocol(namespace = "bbor") +public class BBORProtocol { diff --git a/patches/server/0041-Jade-Protocol.patch b/patches/unapplied/server/0041-Jade-Protocol.patch similarity index 98% rename from patches/server/0041-Jade-Protocol.patch rename to patches/unapplied/server/0041-Jade-Protocol.patch index 9d551e4f..f0a7003c 100644 --- a/patches/server/0041-Jade-Protocol.patch +++ b/patches/unapplied/server/0041-Jade-Protocol.patch @@ -31,13 +31,13 @@ index d624c5ebbbe88c5fc2a4b8521f71ac00f05d58cf..bc9a9a177e15570ad29bac0080dc341f protected long nextMobSpawnsAt; protected int totalMobsSpawned; protected Optional nextSpawnData; -diff --git a/src/main/java/top/leavesmc/leaves/protocol/JadeProtocol.java b/src/main/java/top/leavesmc/leaves/protocol/JadeProtocol.java +diff --git a/src/main/java/org/leavesmc/leaves/protocol/JadeProtocol.java b/src/main/java/org/leavesmc/leaves/protocol/JadeProtocol.java new file mode 100644 index 0000000000000000000000000000000000000000..9b99e7a19f260081c90cdb98f71cc295b5869575 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/protocol/JadeProtocol.java ++++ b/src/main/java/org/leavesmc/leaves/protocol/JadeProtocol.java @@ -0,0 +1,910 @@ -+package top.leavesmc.leaves.protocol; ++package org.leavesmc.leaves.protocol; + +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; @@ -113,10 +113,10 @@ index 0000000000000000000000000000000000000000..9b99e7a19f260081c90cdb98f71cc295 +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; -+import top.leavesmc.leaves.LeavesConfig; -+import top.leavesmc.leaves.protocol.core.LeavesProtocol; -+import top.leavesmc.leaves.protocol.core.ProtocolHandler; -+import top.leavesmc.leaves.protocol.core.ProtocolUtils; ++import org.leavesmc.leaves.LeavesConfig; ++import org.leavesmc.leaves.protocol.core.LeavesProtocol; ++import org.leavesmc.leaves.protocol.core.ProtocolHandler; ++import org.leavesmc.leaves.protocol.core.ProtocolUtils; + +import java.util.Collection; +import java.util.List; diff --git a/patches/server/0056-Syncmatica-Protocol.patch b/patches/unapplied/server/0056-Syncmatica-Protocol.patch similarity index 90% rename from patches/server/0056-Syncmatica-Protocol.patch rename to patches/unapplied/server/0056-Syncmatica-Protocol.patch index 57973103..20b4ba69 100644 --- a/patches/server/0056-Syncmatica-Protocol.patch +++ b/patches/unapplied/server/0056-Syncmatica-Protocol.patch @@ -13,7 +13,7 @@ index 98b0cee150e9e27e6bafc7c2afc9d5008ca8ef82..2d388dcafc02a04348a1c07d970b7a8b Objects.requireNonNull(server); this.signedMessageDecoder = SignedMessageChain.Decoder.unsigned(uuid, server::enforceSecureProfile); this.chatMessageChain = new FutureChain(server.chatExecutor); // CraftBukkit - async chat -+ this.exchangeTarget = new top.leavesmc.leaves.protocol.syncmatica.exchange.ExchangeTarget(this); // Leaves - Syncmatica Protocol ++ this.exchangeTarget = new org.leavesmc.leaves.protocol.syncmatica.exchange.ExchangeTarget(this); // Leaves - Syncmatica Protocol } // CraftBukkit start - add fields @@ -21,18 +21,18 @@ index 98b0cee150e9e27e6bafc7c2afc9d5008ca8ef82..2d388dcafc02a04348a1c07d970b7a8b private boolean justTeleported = false; // CraftBukkit end -+ public final top.leavesmc.leaves.protocol.syncmatica.exchange.ExchangeTarget exchangeTarget; // Leaves - Syncmatica Protocol ++ public final org.leavesmc.leaves.protocol.syncmatica.exchange.ExchangeTarget exchangeTarget; // Leaves - Syncmatica Protocol + @Override public void tick() { if (this.ackBlockChangesUpTo > -1) { -diff --git a/src/main/java/top/leavesmc/leaves/protocol/syncmatica/CommunicationManager.java b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/CommunicationManager.java +diff --git a/src/main/java/org/leavesmc/leaves/protocol/syncmatica/CommunicationManager.java b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/CommunicationManager.java new file mode 100644 index 0000000000000000000000000000000000000000..4c2aa74795b0883f280eaa721a83ea6891ffdab2 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/CommunicationManager.java ++++ b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/CommunicationManager.java @@ -0,0 +1,391 @@ -+package top.leavesmc.leaves.protocol.syncmatica; ++package org.leavesmc.leaves.protocol.syncmatica; + +import com.mojang.authlib.GameProfile; +import io.netty.buffer.Unpooled; @@ -46,15 +46,15 @@ index 0000000000000000000000000000000000000000..4c2aa74795b0883f280eaa721a83ea68 +import net.minecraft.world.level.block.Mirror; +import net.minecraft.world.level.block.Rotation; +import org.jetbrains.annotations.NotNull; -+import top.leavesmc.leaves.protocol.core.LeavesProtocol; -+import top.leavesmc.leaves.protocol.core.LeavesProtocolManager; -+import top.leavesmc.leaves.protocol.core.ProtocolHandler; -+import top.leavesmc.leaves.protocol.syncmatica.exchange.DownloadExchange; -+import top.leavesmc.leaves.protocol.syncmatica.exchange.Exchange; -+import top.leavesmc.leaves.protocol.syncmatica.exchange.ExchangeTarget; -+import top.leavesmc.leaves.protocol.syncmatica.exchange.ModifyExchangeServer; -+import top.leavesmc.leaves.protocol.syncmatica.exchange.UploadExchange; -+import top.leavesmc.leaves.protocol.syncmatica.exchange.VersionHandshakeServer; ++import org.leavesmc.leaves.protocol.core.LeavesProtocol; ++import org.leavesmc.leaves.protocol.core.LeavesProtocolManager; ++import org.leavesmc.leaves.protocol.core.ProtocolHandler; ++import org.leavesmc.leaves.protocol.syncmatica.exchange.DownloadExchange; ++import org.leavesmc.leaves.protocol.syncmatica.exchange.Exchange; ++import org.leavesmc.leaves.protocol.syncmatica.exchange.ExchangeTarget; ++import org.leavesmc.leaves.protocol.syncmatica.exchange.ModifyExchangeServer; ++import org.leavesmc.leaves.protocol.syncmatica.exchange.UploadExchange; ++import org.leavesmc.leaves.protocol.syncmatica.exchange.VersionHandshakeServer; + +import java.io.File; +import java.io.FileNotFoundException; @@ -423,13 +423,13 @@ index 0000000000000000000000000000000000000000..4c2aa74795b0883f280eaa721a83ea68 + handleExchange(e); + } +} -diff --git a/src/main/java/top/leavesmc/leaves/protocol/syncmatica/Feature.java b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/Feature.java +diff --git a/src/main/java/org/leavesmc/leaves/protocol/syncmatica/Feature.java b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/Feature.java new file mode 100644 index 0000000000000000000000000000000000000000..1125755d7d78a118d1fe407e9ca554a89f4d9a9a --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/Feature.java ++++ b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/Feature.java @@ -0,0 +1,23 @@ -+package top.leavesmc.leaves.protocol.syncmatica; ++package org.leavesmc.leaves.protocol.syncmatica; + +import org.jetbrains.annotations.Nullable; + @@ -452,13 +452,13 @@ index 0000000000000000000000000000000000000000..1125755d7d78a118d1fe407e9ca554a8 + return null; + } +} -diff --git a/src/main/java/top/leavesmc/leaves/protocol/syncmatica/FeatureSet.java b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/FeatureSet.java +diff --git a/src/main/java/org/leavesmc/leaves/protocol/syncmatica/FeatureSet.java b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/FeatureSet.java new file mode 100644 index 0000000000000000000000000000000000000000..3d851913e2016fcd384b6a8b1e91753cb8ea91ef --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/FeatureSet.java ++++ b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/FeatureSet.java @@ -0,0 +1,67 @@ -+package top.leavesmc.leaves.protocol.syncmatica; ++package org.leavesmc.leaves.protocol.syncmatica; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; @@ -525,13 +525,13 @@ index 0000000000000000000000000000000000000000..3d851913e2016fcd384b6a8b1e91753c + versionFeatures.put("0.1", new FeatureSet(Collections.singletonList(Feature.CORE))); + } +} -diff --git a/src/main/java/top/leavesmc/leaves/protocol/syncmatica/FileStorage.java b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/FileStorage.java +diff --git a/src/main/java/org/leavesmc/leaves/protocol/syncmatica/FileStorage.java b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/FileStorage.java new file mode 100644 index 0000000000000000000000000000000000000000..5dccbce7287fe436de9436f35a7d1ffcfc5d74ab --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/FileStorage.java ++++ b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/FileStorage.java @@ -0,0 +1,80 @@ -+package top.leavesmc.leaves.protocol.syncmatica; ++package org.leavesmc.leaves.protocol.syncmatica; + +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; @@ -611,13 +611,13 @@ index 0000000000000000000000000000000000000000..5dccbce7287fe436de9436f35a7d1ffc + return new File(SyncmaticaProtocol.getLitematicFolder(), placement.getHash().toString() + ".litematic"); + } +} -diff --git a/src/main/java/top/leavesmc/leaves/protocol/syncmatica/LocalLitematicState.java b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/LocalLitematicState.java +diff --git a/src/main/java/org/leavesmc/leaves/protocol/syncmatica/LocalLitematicState.java b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/LocalLitematicState.java new file mode 100644 index 0000000000000000000000000000000000000000..82ffc8cbd1b488c8723693b685a91c2a4149fb47 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/LocalLitematicState.java ++++ b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/LocalLitematicState.java @@ -0,0 +1,24 @@ -+package top.leavesmc.leaves.protocol.syncmatica; ++package org.leavesmc.leaves.protocol.syncmatica; + +public enum LocalLitematicState { + NO_LOCAL_LITEMATIC(true, false), @@ -641,13 +641,13 @@ index 0000000000000000000000000000000000000000..82ffc8cbd1b488c8723693b685a91c2a + return fileReady; + } +} -diff --git a/src/main/java/top/leavesmc/leaves/protocol/syncmatica/MessageType.java b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/MessageType.java +diff --git a/src/main/java/org/leavesmc/leaves/protocol/syncmatica/MessageType.java b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/MessageType.java new file mode 100644 index 0000000000000000000000000000000000000000..04d785846be3670b741d90634f5f691899127835 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/MessageType.java ++++ b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/MessageType.java @@ -0,0 +1,8 @@ -+package top.leavesmc.leaves.protocol.syncmatica; ++package org.leavesmc.leaves.protocol.syncmatica; + +public enum MessageType { + SUCCESS, @@ -655,13 +655,13 @@ index 0000000000000000000000000000000000000000..04d785846be3670b741d90634f5f6918 + WARNING, + ERROR +} -diff --git a/src/main/java/top/leavesmc/leaves/protocol/syncmatica/PacketType.java b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/PacketType.java +diff --git a/src/main/java/org/leavesmc/leaves/protocol/syncmatica/PacketType.java b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/PacketType.java new file mode 100644 index 0000000000000000000000000000000000000000..8f3227d36da0a3055cc25e538437de58fd5730e3 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/PacketType.java ++++ b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/PacketType.java @@ -0,0 +1,30 @@ -+package top.leavesmc.leaves.protocol.syncmatica; ++package org.leavesmc.leaves.protocol.syncmatica; + +import net.minecraft.resources.ResourceLocation; + @@ -691,13 +691,13 @@ index 0000000000000000000000000000000000000000..8f3227d36da0a3055cc25e538437de58 + identifier = new ResourceLocation(SyncmaticaProtocol.PROTOCOL_ID, id); + } +} -diff --git a/src/main/java/top/leavesmc/leaves/protocol/syncmatica/PlayerIdentifier.java b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/PlayerIdentifier.java +diff --git a/src/main/java/org/leavesmc/leaves/protocol/syncmatica/PlayerIdentifier.java b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/PlayerIdentifier.java new file mode 100644 index 0000000000000000000000000000000000000000..f9ba2a41ab1e0d50bf85fd024b6d29e65b3a5cf7 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/PlayerIdentifier.java ++++ b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/PlayerIdentifier.java @@ -0,0 +1,37 @@ -+package top.leavesmc.leaves.protocol.syncmatica; ++package org.leavesmc.leaves.protocol.syncmatica; + +import com.google.gson.JsonObject; +import com.google.gson.JsonPrimitive; @@ -734,18 +734,18 @@ index 0000000000000000000000000000000000000000..f9ba2a41ab1e0d50bf85fd024b6d29e6 + return jsonObject; + } +} -diff --git a/src/main/java/top/leavesmc/leaves/protocol/syncmatica/PlayerIdentifierProvider.java b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/PlayerIdentifierProvider.java +diff --git a/src/main/java/org/leavesmc/leaves/protocol/syncmatica/PlayerIdentifierProvider.java b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/PlayerIdentifierProvider.java new file mode 100644 index 0000000000000000000000000000000000000000..f4fc3bac20359ecf17a25d7b8e8f34cfebcf4b24 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/PlayerIdentifierProvider.java ++++ b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/PlayerIdentifierProvider.java @@ -0,0 +1,46 @@ -+package top.leavesmc.leaves.protocol.syncmatica; ++package org.leavesmc.leaves.protocol.syncmatica; + +import com.google.gson.JsonObject; +import com.mojang.authlib.GameProfile; +import org.jetbrains.annotations.NotNull; -+import top.leavesmc.leaves.protocol.syncmatica.exchange.ExchangeTarget; ++import org.leavesmc.leaves.protocol.syncmatica.exchange.ExchangeTarget; + +import java.util.HashMap; +import java.util.Map; @@ -786,13 +786,13 @@ index 0000000000000000000000000000000000000000..f4fc3bac20359ecf17a25d7b8e8f34cf + ); + } +} -diff --git a/src/main/java/top/leavesmc/leaves/protocol/syncmatica/ServerPlacement.java b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/ServerPlacement.java +diff --git a/src/main/java/org/leavesmc/leaves/protocol/syncmatica/ServerPlacement.java b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/ServerPlacement.java new file mode 100644 index 0000000000000000000000000000000000000000..8c5bc7d6244d6ccd9a561030fff44ccdecc1ed5c --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/ServerPlacement.java ++++ b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/ServerPlacement.java @@ -0,0 +1,166 @@ -+package top.leavesmc.leaves.protocol.syncmatica; ++package org.leavesmc.leaves.protocol.syncmatica; + +import com.google.gson.JsonObject; +import com.google.gson.JsonPrimitive; @@ -958,13 +958,13 @@ index 0000000000000000000000000000000000000000..8c5bc7d6244d6ccd9a561030fff44ccd + return null; + } +} -diff --git a/src/main/java/top/leavesmc/leaves/protocol/syncmatica/ServerPosition.java b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/ServerPosition.java +diff --git a/src/main/java/org/leavesmc/leaves/protocol/syncmatica/ServerPosition.java b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/ServerPosition.java new file mode 100644 index 0000000000000000000000000000000000000000..3f6ee21ce72943e11f8d924321eb286652c5c533 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/ServerPosition.java ++++ b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/ServerPosition.java @@ -0,0 +1,51 @@ -+package top.leavesmc.leaves.protocol.syncmatica; ++package org.leavesmc.leaves.protocol.syncmatica; + +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; @@ -1015,13 +1015,13 @@ index 0000000000000000000000000000000000000000..3f6ee21ce72943e11f8d924321eb2866 + return null; + } +} -diff --git a/src/main/java/top/leavesmc/leaves/protocol/syncmatica/SubRegionData.java b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/SubRegionData.java +diff --git a/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SubRegionData.java b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SubRegionData.java new file mode 100644 index 0000000000000000000000000000000000000000..6903c26742f5e10aa75f52b7abd5273e7116600b --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/SubRegionData.java ++++ b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SubRegionData.java @@ -0,0 +1,90 @@ -+package top.leavesmc.leaves.protocol.syncmatica; ++package org.leavesmc.leaves.protocol.syncmatica; + +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; @@ -1111,13 +1111,13 @@ index 0000000000000000000000000000000000000000..6903c26742f5e10aa75f52b7abd5273e + return modificationData == null ? "[ERROR:null]" : modificationData.toString(); + } +} -diff --git a/src/main/java/top/leavesmc/leaves/protocol/syncmatica/SubRegionPlacementModification.java b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/SubRegionPlacementModification.java +diff --git a/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SubRegionPlacementModification.java b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SubRegionPlacementModification.java new file mode 100644 index 0000000000000000000000000000000000000000..0d67b562ed06f8de990c2f3d545e2839837f853d --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/SubRegionPlacementModification.java ++++ b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SubRegionPlacementModification.java @@ -0,0 +1,65 @@ -+package top.leavesmc.leaves.protocol.syncmatica; ++package org.leavesmc.leaves.protocol.syncmatica; + +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; @@ -1182,13 +1182,13 @@ index 0000000000000000000000000000000000000000..0d67b562ed06f8de990c2f3d545e2839 + return String.format("[name=%s, position=%s, rotation=%s, mirror=%s]", name, position, rotation, mirror); + } +} -diff --git a/src/main/java/top/leavesmc/leaves/protocol/syncmatica/SyncmaticManager.java b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/SyncmaticManager.java +diff --git a/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SyncmaticManager.java b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SyncmaticManager.java new file mode 100644 index 0000000000000000000000000000000000000000..9fbeef1ef528504276895faed4dba41ee0789e77 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/SyncmaticManager.java ++++ b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SyncmaticManager.java @@ -0,0 +1,108 @@ -+package top.leavesmc.leaves.protocol.syncmatica; ++package org.leavesmc.leaves.protocol.syncmatica; + +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; @@ -1296,16 +1296,16 @@ index 0000000000000000000000000000000000000000..9fbeef1ef528504276895faed4dba41e + } + } +} -diff --git a/src/main/java/top/leavesmc/leaves/protocol/syncmatica/SyncmaticaProtocol.java b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/SyncmaticaProtocol.java +diff --git a/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SyncmaticaProtocol.java b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SyncmaticaProtocol.java new file mode 100644 index 0000000000000000000000000000000000000000..2f44c35e199205ac2a9430c68a6ada3ef92d5d38 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/SyncmaticaProtocol.java ++++ b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SyncmaticaProtocol.java @@ -0,0 +1,123 @@ -+package top.leavesmc.leaves.protocol.syncmatica; ++package org.leavesmc.leaves.protocol.syncmatica; + +import org.jetbrains.annotations.NotNull; -+import top.leavesmc.leaves.LeavesConfig; ++import org.leavesmc.leaves.LeavesConfig; + +import java.io.File; +import java.io.IOException; @@ -1425,17 +1425,17 @@ index 0000000000000000000000000000000000000000..2f44c35e199205ac2a9430c68a6ada3e + return true; + } +} -diff --git a/src/main/java/top/leavesmc/leaves/protocol/syncmatica/exchange/AbstractExchange.java b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/exchange/AbstractExchange.java +diff --git a/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/AbstractExchange.java b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/AbstractExchange.java new file mode 100644 index 0000000000000000000000000000000000000000..625974f9ce0791b476336abafa6aa1af2f2ffbac --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/exchange/AbstractExchange.java ++++ b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/AbstractExchange.java @@ -0,0 +1,66 @@ -+package top.leavesmc.leaves.protocol.syncmatica.exchange; ++package org.leavesmc.leaves.protocol.syncmatica.exchange; + +import net.minecraft.network.FriendlyByteBuf; -+import top.leavesmc.leaves.protocol.syncmatica.CommunicationManager; -+import top.leavesmc.leaves.protocol.syncmatica.SyncmaticaProtocol; ++import org.leavesmc.leaves.protocol.syncmatica.CommunicationManager; ++import org.leavesmc.leaves.protocol.syncmatica.SyncmaticaProtocol; + +import java.util.UUID; + @@ -1497,22 +1497,22 @@ index 0000000000000000000000000000000000000000..625974f9ce0791b476336abafa6aa1af + return sourceId.equals(targetId); + } +} -diff --git a/src/main/java/top/leavesmc/leaves/protocol/syncmatica/exchange/DownloadExchange.java b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/exchange/DownloadExchange.java +diff --git a/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/DownloadExchange.java b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/DownloadExchange.java new file mode 100644 index 0000000000000000000000000000000000000000..7303769570656f36a3a76215e22020b1292007fb --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/exchange/DownloadExchange.java ++++ b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/DownloadExchange.java @@ -0,0 +1,125 @@ -+package top.leavesmc.leaves.protocol.syncmatica.exchange; ++package org.leavesmc.leaves.protocol.syncmatica.exchange; + +import io.netty.buffer.Unpooled; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.resources.ResourceLocation; +import org.jetbrains.annotations.NotNull; -+import top.leavesmc.leaves.protocol.syncmatica.MessageType; -+import top.leavesmc.leaves.protocol.syncmatica.PacketType; -+import top.leavesmc.leaves.protocol.syncmatica.ServerPlacement; -+import top.leavesmc.leaves.protocol.syncmatica.SyncmaticaProtocol; ++import org.leavesmc.leaves.protocol.syncmatica.MessageType; ++import org.leavesmc.leaves.protocol.syncmatica.PacketType; ++import org.leavesmc.leaves.protocol.syncmatica.ServerPlacement; ++import org.leavesmc.leaves.protocol.syncmatica.SyncmaticaProtocol; + +import java.io.File; +import java.io.FileOutputStream; @@ -1628,13 +1628,13 @@ index 0000000000000000000000000000000000000000..7303769570656f36a3a76215e22020b1 + return toDownload; + } +} -diff --git a/src/main/java/top/leavesmc/leaves/protocol/syncmatica/exchange/Exchange.java b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/exchange/Exchange.java +diff --git a/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/Exchange.java b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/Exchange.java new file mode 100644 index 0000000000000000000000000000000000000000..26482e63b7c24c80bdc111cea51b8d7b8052d64e --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/exchange/Exchange.java ++++ b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/Exchange.java @@ -0,0 +1,20 @@ -+package top.leavesmc.leaves.protocol.syncmatica.exchange; ++package org.leavesmc.leaves.protocol.syncmatica.exchange; + +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.resources.ResourceLocation; @@ -1654,19 +1654,19 @@ index 0000000000000000000000000000000000000000..26482e63b7c24c80bdc111cea51b8d7b + + void init(); +} -diff --git a/src/main/java/top/leavesmc/leaves/protocol/syncmatica/exchange/ExchangeTarget.java b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/exchange/ExchangeTarget.java +diff --git a/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/ExchangeTarget.java b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/ExchangeTarget.java new file mode 100644 index 0000000000000000000000000000000000000000..706680a3d7fae22f94cb86b8da2e306cfcf4cb1b --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/exchange/ExchangeTarget.java ++++ b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/ExchangeTarget.java @@ -0,0 +1,40 @@ -+package top.leavesmc.leaves.protocol.syncmatica.exchange; ++package org.leavesmc.leaves.protocol.syncmatica.exchange; + +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.network.ServerGamePacketListenerImpl; -+import top.leavesmc.leaves.protocol.core.ProtocolUtils; -+import top.leavesmc.leaves.protocol.syncmatica.FeatureSet; ++import org.leavesmc.leaves.protocol.core.ProtocolUtils; ++import org.leavesmc.leaves.protocol.syncmatica.FeatureSet; + +import java.util.ArrayList; +import java.util.Collection; @@ -1700,21 +1700,21 @@ index 0000000000000000000000000000000000000000..706680a3d7fae22f94cb86b8da2e306c + return ongoingExchanges; + } +} -diff --git a/src/main/java/top/leavesmc/leaves/protocol/syncmatica/exchange/FeatureExchange.java b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/exchange/FeatureExchange.java +diff --git a/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/FeatureExchange.java b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/FeatureExchange.java new file mode 100644 index 0000000000000000000000000000000000000000..f92739dbfa00de0e078834818dab79e34fc3d245 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/exchange/FeatureExchange.java ++++ b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/FeatureExchange.java @@ -0,0 +1,48 @@ -+package top.leavesmc.leaves.protocol.syncmatica.exchange; ++package org.leavesmc.leaves.protocol.syncmatica.exchange; + +import io.netty.buffer.Unpooled; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.resources.ResourceLocation; +import org.jetbrains.annotations.NotNull; -+import top.leavesmc.leaves.protocol.syncmatica.FeatureSet; -+import top.leavesmc.leaves.protocol.syncmatica.PacketType; -+import top.leavesmc.leaves.protocol.syncmatica.SyncmaticaProtocol; ++import org.leavesmc.leaves.protocol.syncmatica.FeatureSet; ++import org.leavesmc.leaves.protocol.syncmatica.PacketType; ++import org.leavesmc.leaves.protocol.syncmatica.SyncmaticaProtocol; + +public abstract class FeatureExchange extends AbstractExchange { + @@ -1754,22 +1754,22 @@ index 0000000000000000000000000000000000000000..f92739dbfa00de0e078834818dab79e3 + getPartner().sendPacket(PacketType.FEATURE.identifier, buf); + } +} -diff --git a/src/main/java/top/leavesmc/leaves/protocol/syncmatica/exchange/ModifyExchangeServer.java b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/exchange/ModifyExchangeServer.java +diff --git a/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/ModifyExchangeServer.java b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/ModifyExchangeServer.java new file mode 100644 index 0000000000000000000000000000000000000000..d87602fa78a8e599b71556f3dd103ff71ee83ae0 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/exchange/ModifyExchangeServer.java ++++ b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/ModifyExchangeServer.java @@ -0,0 +1,81 @@ -+package top.leavesmc.leaves.protocol.syncmatica.exchange; ++package org.leavesmc.leaves.protocol.syncmatica.exchange; + +import io.netty.buffer.Unpooled; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.resources.ResourceLocation; +import org.jetbrains.annotations.NotNull; -+import top.leavesmc.leaves.protocol.syncmatica.PacketType; -+import top.leavesmc.leaves.protocol.syncmatica.PlayerIdentifier; -+import top.leavesmc.leaves.protocol.syncmatica.ServerPlacement; -+import top.leavesmc.leaves.protocol.syncmatica.SyncmaticaProtocol; ++import org.leavesmc.leaves.protocol.syncmatica.PacketType; ++import org.leavesmc.leaves.protocol.syncmatica.PlayerIdentifier; ++import org.leavesmc.leaves.protocol.syncmatica.ServerPlacement; ++import org.leavesmc.leaves.protocol.syncmatica.SyncmaticaProtocol; + +import java.util.UUID; + @@ -1841,20 +1841,20 @@ index 0000000000000000000000000000000000000000..d87602fa78a8e599b71556f3dd103ff7 + } + } +} -diff --git a/src/main/java/top/leavesmc/leaves/protocol/syncmatica/exchange/UploadExchange.java b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/exchange/UploadExchange.java +diff --git a/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/UploadExchange.java b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/UploadExchange.java new file mode 100644 index 0000000000000000000000000000000000000000..9a1b37c69a3946b8f042a1118bf7dcf6ff0967ae --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/exchange/UploadExchange.java ++++ b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/UploadExchange.java @@ -0,0 +1,101 @@ -+package top.leavesmc.leaves.protocol.syncmatica.exchange; ++package org.leavesmc.leaves.protocol.syncmatica.exchange; + +import io.netty.buffer.Unpooled; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.resources.ResourceLocation; +import org.jetbrains.annotations.NotNull; -+import top.leavesmc.leaves.protocol.syncmatica.PacketType; -+import top.leavesmc.leaves.protocol.syncmatica.ServerPlacement; ++import org.leavesmc.leaves.protocol.syncmatica.PacketType; ++import org.leavesmc.leaves.protocol.syncmatica.ServerPlacement; + +import java.io.File; +import java.io.FileInputStream; @@ -1948,22 +1948,22 @@ index 0000000000000000000000000000000000000000..9a1b37c69a3946b8f042a1118bf7dcf6 + getPartner().sendPacket(PacketType.CANCEL_LITEMATIC.identifier, FriendlyByteBuf); + } +} -diff --git a/src/main/java/top/leavesmc/leaves/protocol/syncmatica/exchange/VersionHandshakeServer.java b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/exchange/VersionHandshakeServer.java +diff --git a/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/VersionHandshakeServer.java b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/VersionHandshakeServer.java new file mode 100644 index 0000000000000000000000000000000000000000..448d5e8423347c0154a146906617e32e18fbc30f --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/exchange/VersionHandshakeServer.java ++++ b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/VersionHandshakeServer.java @@ -0,0 +1,65 @@ -+package top.leavesmc.leaves.protocol.syncmatica.exchange; ++package org.leavesmc.leaves.protocol.syncmatica.exchange; + +import io.netty.buffer.Unpooled; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.resources.ResourceLocation; +import org.jetbrains.annotations.NotNull; -+import top.leavesmc.leaves.protocol.syncmatica.FeatureSet; -+import top.leavesmc.leaves.protocol.syncmatica.PacketType; -+import top.leavesmc.leaves.protocol.syncmatica.ServerPlacement; -+import top.leavesmc.leaves.protocol.syncmatica.SyncmaticaProtocol; ++import org.leavesmc.leaves.protocol.syncmatica.FeatureSet; ++import org.leavesmc.leaves.protocol.syncmatica.PacketType; ++import org.leavesmc.leaves.protocol.syncmatica.ServerPlacement; ++import org.leavesmc.leaves.protocol.syncmatica.SyncmaticaProtocol; + +import java.util.Collection; + diff --git a/patches/server/0063-Leaves-carpet-support.patch b/patches/unapplied/server/0063-Leaves-carpet-support.patch similarity index 89% rename from patches/server/0063-Leaves-carpet-support.patch rename to patches/unapplied/server/0063-Leaves-carpet-support.patch index 7c72e66a..cd348406 100644 --- a/patches/server/0063-Leaves-carpet-support.patch +++ b/patches/unapplied/server/0063-Leaves-carpet-support.patch @@ -4,13 +4,13 @@ Date: Tue, 27 Jun 2023 01:54:43 +0800 Subject: [PATCH] Leaves carpet support -diff --git a/src/main/java/top/leavesmc/leaves/protocol/CarpetServerProtocol.java b/src/main/java/top/leavesmc/leaves/protocol/CarpetServerProtocol.java +diff --git a/src/main/java/org/leavesmc/leaves/protocol/CarpetServerProtocol.java b/src/main/java/org/leavesmc/leaves/protocol/CarpetServerProtocol.java new file mode 100644 index 0000000000000000000000000000000000000000..e36ca7961b512568d60ed11f792f2bee58d27374 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/protocol/CarpetServerProtocol.java ++++ b/src/main/java/org/leavesmc/leaves/protocol/CarpetServerProtocol.java @@ -0,0 +1,113 @@ -+package top.leavesmc.leaves.protocol; ++package org.leavesmc.leaves.protocol; + +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.FriendlyByteBuf; @@ -19,11 +19,11 @@ index 0000000000000000000000000000000000000000..e36ca7961b512568d60ed11f792f2bee +import net.minecraft.server.level.ServerPlayer; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; -+import top.leavesmc.leaves.LeavesConfig; -+import top.leavesmc.leaves.LeavesLogger; -+import top.leavesmc.leaves.protocol.core.LeavesProtocol; -+import top.leavesmc.leaves.protocol.core.ProtocolHandler; -+import top.leavesmc.leaves.protocol.core.ProtocolUtils; ++import org.leavesmc.leaves.LeavesConfig; ++import org.leavesmc.leaves.LeavesLogger; ++import org.leavesmc.leaves.protocol.core.LeavesProtocol; ++import org.leavesmc.leaves.protocol.core.ProtocolHandler; ++import org.leavesmc.leaves.protocol.core.ProtocolUtils; + +import java.util.HashMap; +import java.util.Locale; diff --git a/patches/server/0075-Bladeren-Protocol.patch b/patches/unapplied/server/0075-Bladeren-Protocol.patch similarity index 92% rename from patches/server/0075-Bladeren-Protocol.patch rename to patches/unapplied/server/0075-Bladeren-Protocol.patch index 3247c115..c4f810b5 100644 --- a/patches/server/0075-Bladeren-Protocol.patch +++ b/patches/unapplied/server/0075-Bladeren-Protocol.patch @@ -4,13 +4,13 @@ Date: Fri, 7 Jul 2023 16:50:06 +0800 Subject: [PATCH] Bladeren Protocol -diff --git a/src/main/java/top/leavesmc/leaves/protocol/bladeren/BladerenProtocol.java b/src/main/java/top/leavesmc/leaves/protocol/bladeren/BladerenProtocol.java +diff --git a/src/main/java/org/leavesmc/leaves/protocol/bladeren/BladerenProtocol.java b/src/main/java/org/leavesmc/leaves/protocol/bladeren/BladerenProtocol.java new file mode 100644 index 0000000000000000000000000000000000000000..a91011c7a2c56646053bb9d158ff0c265c658c00 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/protocol/bladeren/BladerenProtocol.java ++++ b/src/main/java/org/leavesmc/leaves/protocol/bladeren/BladerenProtocol.java @@ -0,0 +1,145 @@ -+package top.leavesmc.leaves.protocol.bladeren; ++package org.leavesmc.leaves.protocol.bladeren; + +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.FriendlyByteBuf; @@ -19,10 +19,10 @@ index 0000000000000000000000000000000000000000..a91011c7a2c56646053bb9d158ff0c26 +import net.minecraft.server.level.ServerPlayer; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; -+import top.leavesmc.leaves.LeavesConfig; -+import top.leavesmc.leaves.protocol.core.LeavesProtocol; -+import top.leavesmc.leaves.protocol.core.ProtocolHandler; -+import top.leavesmc.leaves.protocol.core.ProtocolUtils; ++import org.leavesmc.leaves.LeavesConfig; ++import org.leavesmc.leaves.protocol.core.LeavesProtocol; ++import org.leavesmc.leaves.protocol.core.ProtocolHandler; ++import org.leavesmc.leaves.protocol.core.ProtocolUtils; + +import java.util.HashMap; +import java.util.Map; diff --git a/patches/server/0076-Bladeren-mspt-sync-protocol.patch b/patches/unapplied/server/0076-Bladeren-mspt-sync-protocol.patch similarity index 85% rename from patches/server/0076-Bladeren-mspt-sync-protocol.patch rename to patches/unapplied/server/0076-Bladeren-mspt-sync-protocol.patch index 169d34e3..a2765c8e 100644 --- a/patches/server/0076-Bladeren-mspt-sync-protocol.patch +++ b/patches/unapplied/server/0076-Bladeren-mspt-sync-protocol.patch @@ -4,23 +4,23 @@ Date: Mon, 3 Jul 2023 22:12:16 +0800 Subject: [PATCH] Bladeren mspt sync protocol -diff --git a/src/main/java/top/leavesmc/leaves/protocol/bladeren/MsptSyncProtocol.java b/src/main/java/top/leavesmc/leaves/protocol/bladeren/MsptSyncProtocol.java +diff --git a/src/main/java/org/leavesmc/leaves/protocol/bladeren/MsptSyncProtocol.java b/src/main/java/org/leavesmc/leaves/protocol/bladeren/MsptSyncProtocol.java new file mode 100644 index 0000000000000000000000000000000000000000..cf909f22f0860e6f56a86510dfcbd949a4c1fc32 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/protocol/bladeren/MsptSyncProtocol.java ++++ b/src/main/java/org/leavesmc/leaves/protocol/bladeren/MsptSyncProtocol.java @@ -0,0 +1,73 @@ -+package top.leavesmc.leaves.protocol.bladeren; ++package org.leavesmc.leaves.protocol.bladeren; + +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.level.ServerPlayer; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; -+import top.leavesmc.leaves.LeavesConfig; -+import top.leavesmc.leaves.protocol.core.LeavesProtocol; -+import top.leavesmc.leaves.protocol.core.ProtocolHandler; -+import top.leavesmc.leaves.protocol.core.ProtocolUtils; ++import org.leavesmc.leaves.LeavesConfig; ++import org.leavesmc.leaves.protocol.core.LeavesProtocol; ++import org.leavesmc.leaves.protocol.core.ProtocolHandler; ++import org.leavesmc.leaves.protocol.core.ProtocolUtils; + +import java.util.ArrayList; +import java.util.Arrays; diff --git a/patches/server/0115-Servux-Protocol.patch b/patches/unapplied/server/0115-Servux-Protocol.patch similarity index 93% rename from patches/server/0115-Servux-Protocol.patch rename to patches/unapplied/server/0115-Servux-Protocol.patch index c8c40f52..0d19cabf 100644 --- a/patches/server/0115-Servux-Protocol.patch +++ b/patches/unapplied/server/0115-Servux-Protocol.patch @@ -11,18 +11,18 @@ index 46230b09fc176665ba1d29ab3233c3b956a07710..abef121b9882c17a200e9f0186ee1263 @@ -934,6 +934,7 @@ public class LevelChunk extends ChunkAccess { // Leaves start - bbor if (loaded) { - top.leavesmc.leaves.protocol.BBORProtocol.onChunkLoaded(this); -+ top.leavesmc.leaves.protocol.ServuxProtocol.onChunkLoaded(this); // and servux + org.leavesmc.leaves.protocol.BBORProtocol.onChunkLoaded(this); ++ org.leavesmc.leaves.protocol.ServuxProtocol.onChunkLoaded(this); // and servux } // Leaves end - bbor } -diff --git a/src/main/java/top/leavesmc/leaves/protocol/ServuxProtocol.java b/src/main/java/top/leavesmc/leaves/protocol/ServuxProtocol.java +diff --git a/src/main/java/org/leavesmc/leaves/protocol/ServuxProtocol.java b/src/main/java/org/leavesmc/leaves/protocol/ServuxProtocol.java new file mode 100644 index 0000000000000000000000000000000000000000..f6fa9368f66de0f23d5387b38c0cff35658d3d59 --- /dev/null -+++ b/src/main/java/top/leavesmc/leaves/protocol/ServuxProtocol.java ++++ b/src/main/java/org/leavesmc/leaves/protocol/ServuxProtocol.java @@ -0,0 +1,175 @@ -+package top.leavesmc.leaves.protocol; ++package org.leavesmc.leaves.protocol; + +import io.netty.buffer.Unpooled; +import net.minecraft.core.Registry; @@ -40,10 +40,10 @@ index 0000000000000000000000000000000000000000..f6fa9368f66de0f23d5387b38c0cff35 +import net.minecraft.world.level.levelgen.structure.pieces.StructurePieceSerializationContext; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; -+import top.leavesmc.leaves.LeavesConfig; -+import top.leavesmc.leaves.protocol.core.LeavesProtocol; -+import top.leavesmc.leaves.protocol.core.ProtocolHandler; -+import top.leavesmc.leaves.protocol.core.ProtocolUtils; ++import org.leavesmc.leaves.LeavesConfig; ++import org.leavesmc.leaves.protocol.core.LeavesProtocol; ++import org.leavesmc.leaves.protocol.core.ProtocolHandler; ++import org.leavesmc.leaves.protocol.core.ProtocolUtils; + +import java.util.ArrayList; +import java.util.HashMap; diff --git a/patches/server/0137-Bytebuf-API.patch b/patches/unapplied/server/0137-Bytebuf-API.patch similarity index 100% rename from patches/server/0137-Bytebuf-API.patch rename to patches/unapplied/server/0137-Bytebuf-API.patch diff --git a/scripts/GetBuildNumber.sh b/scripts/GetBuildNumber.sh new file mode 100644 index 00000000..2ce59e5f --- /dev/null +++ b/scripts/GetBuildNumber.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +prop() { + grep "${1}" gradle.properties | cut -d'=' -f2 | sed 's/\r//' +} + +latest_build=$(curl -s https://api.leavesmc.org/v2/projects/leaves/versions/$(prop mcVersion)/latestGroupBuildId) + +if [[ $latest_build =~ ^[0-9]+$ ]]; then + echo "BUILD_NUMBER=$((latest_build + 1))" >> $GITHUB_ENV +else + echo "Error: Received non-integer value from API: $latest_build" + exit 1 +fi diff --git a/scripts/GetReleaseInfo.sh b/scripts/GetReleaseInfo.sh index 490ec09b..672dd153 100644 --- a/scripts/GetReleaseInfo.sh +++ b/scripts/GetReleaseInfo.sh @@ -1,3 +1,7 @@ +sha256() { + sha256sum $1 | awk '{print $1}' +} + sha1() { sha1sum $1 | awk '{print $1}' } @@ -52,6 +56,7 @@ echo "| File | $jarName |" >> $releaseinfo echo "| ---- | ---- |" >> $releaseinfo echo "| MD5 | `md5 $jarName` |" >> $releaseinfo echo "| SHA1 | `sha1 $jarName` |" >> $releaseinfo +echo "| SHA256 | `sha256 $jarName` |" >> $releaseinfo echo -n "{\"content\":\"Leaves New Release\",\"embeds\":[{\"title\":\"$leavesid\",\"url\":\"https://github.com/LeavesMC/Leaves/releases/tag/$tagid\",\"fields\":[{\"name\":\"Changelog\",\"value\":\"" >> $discordmes echo -n $(git log --oneline --pretty='> [%h] %s\\n' -$number) >> $discordmes diff --git a/settings.gradle.kts b/settings.gradle.kts index cca46d70..147f2fb4 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -5,6 +5,10 @@ pluginManagement { } } +plugins { + id("org.gradle.toolchains.foojay-resolver-convention") version("0.8.0") +} + rootProject.name = "Leaves" include("leaves-api", "leaves-server", "paper-api-generator")